diff --git a/packages/cli/src/ui/components/Footer.tsx b/packages/cli/src/ui/components/Footer.tsx index e0ff8bb5f4..4d614b8ba3 100644 --- a/packages/cli/src/ui/components/Footer.tsx +++ b/packages/cli/src/ui/components/Footer.tsx @@ -24,6 +24,107 @@ import { useConfig } from '../contexts/ConfigContext.js'; import { useSettings } from '../contexts/SettingsContext.js'; import { useVimMode } from '../contexts/VimModeContext.js'; +interface CwdIndicatorProps { + targetDir: string; + terminalWidth: number; + debugMode?: boolean; + debugMessage?: string; + color?: string; +} + +const CwdIndicator: React.FC = ({ + targetDir, + terminalWidth, + debugMode, + debugMessage, + color = theme.text.primary, +}) => { + const pathLength = Math.max(20, Math.floor(terminalWidth * 0.25)); + const displayPath = shortenPath(tildeifyPath(targetDir), pathLength); + return ( + + {displayPath} + {debugMode && ( + + {' ' + (debugMessage || '--debug')} + + )} + + ); +}; + +interface BranchIndicatorProps { + branchName: string; +} + +const BranchIndicator: React.FC = ({ branchName }) => ( + ({branchName}*) +); + +interface SandboxIndicatorProps { + isTrustedFolder: boolean | undefined; + terminalWidth: number; + showDocsHint?: boolean; +} + +const SandboxIndicator: React.FC = ({ + isTrustedFolder, + terminalWidth, + showDocsHint = false, +}) => { + if (isTrustedFolder === false) { + return untrusted; + } + + const sandbox = process.env['SANDBOX']; + if (sandbox && sandbox !== 'sandbox-exec') { + return ( + {sandbox.replace(/^gemini-(?:cli-)?/, '')} + ); + } + + if (sandbox === 'sandbox-exec') { + return ( + + macOS Seatbelt{' '} + + ({process.env['SEATBELT_PROFILE']}) + + + ); + } + + return ( + + no sandbox + {showDocsHint && terminalWidth >= 100 && ( + (see /docs) + )} + + ); +}; + +const CorgiIndicator: React.FC = () => ( + + + + + `) + + +); + +interface ErrorIndicatorProps { + errorCount: number; +} + +const ErrorIndicator: React.FC = ({ errorCount }) => ( + + | + + +); + export const Footer: React.FC = () => { const uiState = useUIState(); const config = useConfig(); @@ -71,9 +172,6 @@ export const Footer: React.FC = () => { const hideContextPercentage = settings.merged.ui.footer.hideContextPercentage; - const pathLength = Math.max(20, Math.floor(terminalWidth * 0.25)); - const displayPath = shortenPath(tildeifyPath(targetDir), pathLength); - const justifyContent = hideCWD && hideModelInfo ? 'center' : 'space-between'; @@ -94,17 +192,20 @@ export const Footer: React.FC = () => { [{displayVimMode}] )} {!hideCWD && ( - - {displayPath} + + {branchName && ( - ({branchName}*) + <> + + + )} - - )} - {debugMode && ( - - {' ' + (debugMessage || '--debug')} - + )} )} @@ -117,28 +218,11 @@ export const Footer: React.FC = () => { justifyContent="center" display="flex" > - {isTrustedFolder === false ? ( - untrusted - ) : process.env['SANDBOX'] && - process.env['SANDBOX'] !== 'sandbox-exec' ? ( - - {process.env['SANDBOX'].replace(/^gemini-(?:cli-)?/, '')} - - ) : process.env['SANDBOX'] === 'sandbox-exec' ? ( - - macOS Seatbelt{' '} - - ({process.env['SEATBELT_PROFILE']}) - - - ) : ( - - no sandbox - {terminalWidth >= 100 && ( - (see /docs) - )} - - )} + )} @@ -181,20 +265,13 @@ export const Footer: React.FC = () => { {corgiMode && ( - - | - - - - `) - - + | + )} {!showErrorDetails && errorCount > 0 && ( - - | - + + )} @@ -231,50 +308,31 @@ export const Footer: React.FC = () => { for (const id of items) { switch (id) { case 'cwd': { - const pathLength = Math.max(20, Math.floor(terminalWidth * 0.25)); - const displayPath = shortenPath(tildeifyPath(targetDir), pathLength); addElement( id, - - {displayPath} - {debugMode && ( - - {' ' + (debugMessage || '--debug')} - - )} - , + , ); break; } case 'git-branch': { if (branchName) { - addElement( - id, - {branchName}*, - ); + addElement(id, ); } break; } case 'sandbox-status': { addElement( id, - isTrustedFolder === false ? ( - untrusted - ) : process.env['SANDBOX'] && - process.env['SANDBOX'] !== 'sandbox-exec' ? ( - - {process.env['SANDBOX'].replace(/^gemini-(?:cli-)?/, '')} - - ) : process.env['SANDBOX'] === 'sandbox-exec' ? ( - - macOS Seatbelt{' '} - - ({process.env['SEATBELT_PROFILE']}) - - - ) : ( - no sandbox - ), + , ); break; } @@ -362,22 +420,13 @@ export const Footer: React.FC = () => { } if (corgiMode) { - addElement( - 'corgi-transient', - - - - - `) - - , - ); + addElement('corgi-transient', ); } if (!showErrorDetails && errorCount > 0) { addElement( 'error-count-transient', - , + , ); }