2025-04-18 17:44:24 -07:00
|
|
|
|
/**
|
|
|
|
|
|
* @license
|
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
|
import type React from 'react';
|
2025-04-15 21:41:08 -07:00
|
|
|
|
import { Box, Text } from 'ink';
|
2025-08-07 16:11:35 -07:00
|
|
|
|
import { theme } from '../semantic-colors.js';
|
2025-08-07 11:16:47 -07:00
|
|
|
|
import { shortenPath, tildeifyPath } from '@google/gemini-cli-core';
|
2025-05-22 10:36:44 -07:00
|
|
|
|
import { ConsoleSummaryDisplay } from './ConsoleSummaryDisplay.js';
|
2025-05-30 22:18:01 +00:00
|
|
|
|
import process from 'node:process';
|
2025-10-01 14:50:33 -07:00
|
|
|
|
import path from 'node:path';
|
2025-07-11 13:43:57 -07:00
|
|
|
|
import Gradient from 'ink-gradient';
|
2025-05-30 22:18:01 +00:00
|
|
|
|
import { MemoryUsageDisplay } from './MemoryUsageDisplay.js';
|
2025-08-07 11:16:47 -07:00
|
|
|
|
import { ContextUsageDisplay } from './ContextUsageDisplay.js';
|
2025-07-30 17:43:11 -07:00
|
|
|
|
import { DebugProfiler } from './DebugProfiler.js';
|
2025-10-01 14:50:33 -07:00
|
|
|
|
|
2025-08-07 15:55:53 -07:00
|
|
|
|
import { useTerminalSize } from '../hooks/useTerminalSize.js';
|
2025-10-01 14:50:33 -07:00
|
|
|
|
import { isNarrowWidth } from '../utils/isNarrowWidth.js';
|
2025-08-07 15:55:53 -07:00
|
|
|
|
|
2025-09-26 21:27:00 -04:00
|
|
|
|
import { useUIState } from '../contexts/UIStateContext.js';
|
|
|
|
|
|
import { useConfig } from '../contexts/ConfigContext.js';
|
|
|
|
|
|
import { useSettings } from '../contexts/SettingsContext.js';
|
|
|
|
|
|
import { useVimMode } from '../contexts/VimModeContext.js';
|
|
|
|
|
|
|
|
|
|
|
|
export const Footer: React.FC = () => {
|
|
|
|
|
|
const uiState = useUIState();
|
|
|
|
|
|
const config = useConfig();
|
|
|
|
|
|
const settings = useSettings();
|
|
|
|
|
|
const { vimEnabled, vimMode } = useVimMode();
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
model,
|
|
|
|
|
|
targetDir,
|
|
|
|
|
|
debugMode,
|
|
|
|
|
|
branchName,
|
|
|
|
|
|
debugMessage,
|
|
|
|
|
|
corgiMode,
|
|
|
|
|
|
errorCount,
|
|
|
|
|
|
showErrorDetails,
|
|
|
|
|
|
promptTokenCount,
|
|
|
|
|
|
nightly,
|
|
|
|
|
|
isTrustedFolder,
|
|
|
|
|
|
} = {
|
|
|
|
|
|
model: config.getModel(),
|
|
|
|
|
|
targetDir: config.getTargetDir(),
|
|
|
|
|
|
debugMode: config.getDebugMode(),
|
|
|
|
|
|
branchName: uiState.branchName,
|
|
|
|
|
|
debugMessage: uiState.debugMessage,
|
|
|
|
|
|
corgiMode: uiState.corgiMode,
|
|
|
|
|
|
errorCount: uiState.errorCount,
|
|
|
|
|
|
showErrorDetails: uiState.showErrorDetails,
|
|
|
|
|
|
promptTokenCount: uiState.sessionStats.lastPromptTokenCount,
|
|
|
|
|
|
nightly: uiState.nightly,
|
|
|
|
|
|
isTrustedFolder: uiState.isTrustedFolder,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const showMemoryUsage =
|
|
|
|
|
|
config.getDebugMode() || settings.merged.ui?.showMemoryUsage || false;
|
|
|
|
|
|
const hideCWD = settings.merged.ui?.footer?.hideCWD || false;
|
|
|
|
|
|
const hideSandboxStatus =
|
|
|
|
|
|
settings.merged.ui?.footer?.hideSandboxStatus || false;
|
|
|
|
|
|
const hideModelInfo = settings.merged.ui?.footer?.hideModelInfo || false;
|
2025-04-15 21:41:08 -07:00
|
|
|
|
|
2025-08-07 15:55:53 -07:00
|
|
|
|
const { columns: terminalWidth } = useTerminalSize();
|
|
|
|
|
|
|
2025-10-01 14:50:33 -07:00
|
|
|
|
const isNarrow = isNarrowWidth(terminalWidth);
|
|
|
|
|
|
|
|
|
|
|
|
// Adjust path length based on terminal width
|
|
|
|
|
|
const pathLength = Math.max(20, Math.floor(terminalWidth * 0.4));
|
|
|
|
|
|
const displayPath = isNarrow
|
|
|
|
|
|
? path.basename(tildeifyPath(targetDir))
|
|
|
|
|
|
: shortenPath(tildeifyPath(targetDir), pathLength);
|
2025-06-15 11:15:53 -07:00
|
|
|
|
|
2025-09-11 20:16:09 -04:00
|
|
|
|
const justifyContent = hideCWD && hideModelInfo ? 'center' : 'space-between';
|
2025-09-26 21:27:00 -04:00
|
|
|
|
const displayVimMode = vimEnabled ? vimMode : undefined;
|
2025-09-11 20:16:09 -04:00
|
|
|
|
|
2025-08-07 15:55:53 -07:00
|
|
|
|
return (
|
2025-08-07 11:16:47 -07:00
|
|
|
|
<Box
|
2025-09-11 20:16:09 -04:00
|
|
|
|
justifyContent={justifyContent}
|
2025-08-07 15:55:53 -07:00
|
|
|
|
width="100%"
|
2025-10-01 14:50:33 -07:00
|
|
|
|
flexDirection={isNarrow ? 'column' : 'row'}
|
|
|
|
|
|
alignItems={isNarrow ? 'flex-start' : 'center'}
|
2025-08-07 11:16:47 -07:00
|
|
|
|
>
|
2025-09-26 21:27:00 -04:00
|
|
|
|
{(debugMode || displayVimMode || !hideCWD) && (
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<Box>
|
|
|
|
|
|
{debugMode && <DebugProfiler />}
|
2025-09-26 21:27:00 -04:00
|
|
|
|
{displayVimMode && (
|
|
|
|
|
|
<Text color={theme.text.secondary}>[{displayVimMode}] </Text>
|
|
|
|
|
|
)}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
{!hideCWD &&
|
|
|
|
|
|
(nightly ? (
|
|
|
|
|
|
<Gradient colors={theme.ui.gradient}>
|
|
|
|
|
|
<Text>
|
|
|
|
|
|
{displayPath}
|
|
|
|
|
|
{branchName && <Text> ({branchName}*)</Text>}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</Gradient>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Text color={theme.text.link}>
|
|
|
|
|
|
{displayPath}
|
|
|
|
|
|
{branchName && (
|
|
|
|
|
|
<Text color={theme.text.secondary}> ({branchName}*)</Text>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
))}
|
|
|
|
|
|
{debugMode && (
|
|
|
|
|
|
<Text color={theme.status.error}>
|
|
|
|
|
|
{' ' + (debugMessage || '--debug')}
|
2025-08-07 15:55:53 -07:00
|
|
|
|
</Text>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
)}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
2025-08-07 15:55:53 -07:00
|
|
|
|
|
2025-08-14 11:15:48 -07:00
|
|
|
|
{/* Middle Section: Centered Trust/Sandbox Info */}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
{!hideSandboxStatus && (
|
|
|
|
|
|
<Box
|
2025-10-01 14:50:33 -07:00
|
|
|
|
flexGrow={isNarrow || hideCWD || hideModelInfo ? 0 : 1}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
alignItems="center"
|
2025-10-01 14:50:33 -07:00
|
|
|
|
justifyContent={isNarrow || hideCWD ? 'flex-start' : 'center'}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
display="flex"
|
2025-10-01 14:50:33 -07:00
|
|
|
|
paddingX={isNarrow ? 0 : 1}
|
|
|
|
|
|
paddingTop={isNarrow ? 1 : 0}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
>
|
|
|
|
|
|
{isTrustedFolder === false ? (
|
|
|
|
|
|
<Text color={theme.status.warning}>untrusted</Text>
|
|
|
|
|
|
) : process.env['SANDBOX'] &&
|
|
|
|
|
|
process.env['SANDBOX'] !== 'sandbox-exec' ? (
|
|
|
|
|
|
<Text color="green">
|
|
|
|
|
|
{process.env['SANDBOX'].replace(/^gemini-(?:cli-)?/, '')}
|
2025-08-07 16:11:35 -07:00
|
|
|
|
</Text>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
) : process.env['SANDBOX'] === 'sandbox-exec' ? (
|
|
|
|
|
|
<Text color={theme.status.warning}>
|
|
|
|
|
|
macOS Seatbelt{' '}
|
|
|
|
|
|
<Text color={theme.text.secondary}>
|
|
|
|
|
|
({process.env['SEATBELT_PROFILE']})
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Text color={theme.status.error}>
|
2025-10-01 14:50:33 -07:00
|
|
|
|
no sandbox <Text color={theme.text.secondary}>(see /docs)</Text>
|
2025-09-02 10:35:43 -07:00
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* Right Section: Gemini Label and Console Summary */}
|
2025-10-01 14:50:33 -07:00
|
|
|
|
{(!hideModelInfo ||
|
|
|
|
|
|
showMemoryUsage ||
|
|
|
|
|
|
corgiMode ||
|
|
|
|
|
|
(!showErrorDetails && errorCount > 0)) && (
|
|
|
|
|
|
<Box alignItems="center" paddingTop={isNarrow ? 1 : 0}>
|
|
|
|
|
|
{!hideModelInfo && (
|
|
|
|
|
|
<Box alignItems="center">
|
|
|
|
|
|
<Text color={theme.text.accent}>
|
|
|
|
|
|
{isNarrow ? '' : ' '}
|
|
|
|
|
|
{model}{' '}
|
|
|
|
|
|
<ContextUsageDisplay
|
|
|
|
|
|
promptTokenCount={promptTokenCount}
|
|
|
|
|
|
model={model}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
{showMemoryUsage && <MemoryUsageDisplay />}
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<Box alignItems="center" paddingLeft={2}>
|
|
|
|
|
|
{corgiMode && (
|
|
|
|
|
|
<Text>
|
2025-10-01 14:50:33 -07:00
|
|
|
|
{!hideModelInfo && <Text color={theme.ui.comment}>| </Text>}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<Text color={theme.status.error}>▼</Text>
|
|
|
|
|
|
<Text color={theme.text.primary}>(´</Text>
|
|
|
|
|
|
<Text color={theme.status.error}>ᴥ</Text>
|
|
|
|
|
|
<Text color={theme.text.primary}>`)</Text>
|
|
|
|
|
|
<Text color={theme.status.error}>▼ </Text>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{!showErrorDetails && errorCount > 0 && (
|
|
|
|
|
|
<Box>
|
2025-10-01 14:50:33 -07:00
|
|
|
|
{!hideModelInfo && <Text color={theme.ui.comment}>| </Text>}
|
2025-09-11 20:16:09 -04:00
|
|
|
|
<ConsoleSummaryDisplay errorCount={errorCount} />
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Box>
|
2025-09-02 10:35:43 -07:00
|
|
|
|
</Box>
|
2025-09-11 20:16:09 -04:00
|
|
|
|
)}
|
2025-04-21 14:43:43 -07:00
|
|
|
|
</Box>
|
2025-08-07 15:55:53 -07:00
|
|
|
|
);
|
|
|
|
|
|
};
|