mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-17 17:41:24 -07:00
feat(cli): Add setting to show status(or Gemini 's thoughts) in terminal title and taskbar icon (#4386)
Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,8 @@ import { calculatePromptWidths } from './components/InputPrompt.js';
|
||||
import { useStdin, useStdout } from 'ink';
|
||||
import ansiEscapes from 'ansi-escapes';
|
||||
import * as fs from 'node:fs';
|
||||
import { basename } from 'node:path';
|
||||
import { computeWindowTitle } from '../utils/windowTitle.js';
|
||||
import { useTextBuffer } from './components/shared/text-buffer.js';
|
||||
import { useLogger } from './hooks/useLogger.js';
|
||||
import { useGeminiStream } from './hooks/useGeminiStream.js';
|
||||
@@ -196,6 +198,10 @@ export const AppContainer = (props: AppContainerProps) => {
|
||||
|
||||
// Layout measurements
|
||||
const mainControlsRef = useRef<DOMElement>(null);
|
||||
const originalTitleRef = useRef(
|
||||
computeWindowTitle(basename(config.getTargetDir())),
|
||||
);
|
||||
const lastTitleRef = useRef<string | null>(null);
|
||||
const staticExtraHeight = 3;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -976,6 +982,40 @@ Logging in with Google... Please restart Gemini CLI to continue.
|
||||
{ isActive: showIdeRestartPrompt },
|
||||
);
|
||||
|
||||
// Update terminal title with Gemini CLI status and thoughts
|
||||
useEffect(() => {
|
||||
// Respect both showStatusInTitle and hideWindowTitle settings
|
||||
if (
|
||||
!settings.merged.ui?.showStatusInTitle ||
|
||||
settings.merged.ui?.hideWindowTitle
|
||||
)
|
||||
return;
|
||||
|
||||
let title;
|
||||
if (streamingState === StreamingState.Idle) {
|
||||
title = originalTitleRef.current;
|
||||
} else {
|
||||
const statusText = thought?.subject?.replace(/[\r\n]+/g, ' ').substring(0, 80);
|
||||
title = statusText || originalTitleRef.current;
|
||||
}
|
||||
|
||||
// Pad the title to a fixed width to prevent taskbar icon resizing.
|
||||
const paddedTitle = title.padEnd(80, ' ');
|
||||
|
||||
// Only update the title if it's different from the last value we set
|
||||
if (lastTitleRef.current !== paddedTitle) {
|
||||
lastTitleRef.current = paddedTitle;
|
||||
stdout.write(`\x1b]2;${paddedTitle}\x07`);
|
||||
}
|
||||
// Note: We don't need to reset the window title on exit because Gemini CLI is already doing that elsewhere
|
||||
}, [
|
||||
streamingState,
|
||||
thought,
|
||||
settings.merged.ui?.showStatusInTitle,
|
||||
settings.merged.ui?.hideWindowTitle,
|
||||
stdout,
|
||||
]);
|
||||
|
||||
const filteredConsoleMessages = useMemo(() => {
|
||||
if (config.getDebugMode()) {
|
||||
return consoleMessages;
|
||||
|
||||
Reference in New Issue
Block a user