feat(cli): consolidate shell inactivity and redirection monitoring (#17086)

This commit is contained in:
N. Taylor Mullen
2026-01-21 14:31:24 -08:00
committed by GitHub
parent a1233e7e5c
commit 1c9a57c3c2
17 changed files with 675 additions and 157 deletions
+34 -7
View File
@@ -5,7 +5,10 @@
*/
import { describe, it, expect, vi, afterEach } from 'vitest';
import { computeTerminalTitle } from './windowTitle.js';
import {
computeTerminalTitle,
type TerminalTitleOptions,
} from './windowTitle.js';
import { StreamingState } from '../ui/types.js';
describe('computeTerminalTitle', () => {
@@ -19,10 +22,11 @@ describe('computeTerminalTitle', () => {
args: {
streamingState: StreamingState.Idle,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: false,
useDynamicTitle: true,
},
} as TerminalTitleOptions,
expected: '◇ Ready (my-project)',
},
{
@@ -30,10 +34,11 @@ describe('computeTerminalTitle', () => {
args: {
streamingState: StreamingState.Responding,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: false,
},
} as TerminalTitleOptions,
expected: 'Gemini CLI (my-project)'.padEnd(80, ' '),
exact: true,
},
@@ -44,10 +49,11 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: 'Reading files',
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: false,
useDynamicTitle: true,
},
} as TerminalTitleOptions,
expected: '✦ Working… (my-project)',
},
{
@@ -57,10 +63,11 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: 'Short thought',
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: true,
},
} as TerminalTitleOptions,
expected: '✦ Short thought (my-project)',
},
{
@@ -70,10 +77,11 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: undefined,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: true,
},
} as TerminalTitleOptions,
expected: '✦ Working… (my-project)'.padEnd(80, ' '),
exact: true,
},
@@ -82,12 +90,25 @@ describe('computeTerminalTitle', () => {
args: {
streamingState: StreamingState.Idle,
isConfirming: true,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: false,
useDynamicTitle: true,
},
} as TerminalTitleOptions,
expected: '✋ Action Required (my-project)',
},
{
description: 'silent working state',
args: {
streamingState: StreamingState.Responding,
isConfirming: false,
isSilentWorking: true,
folderName: 'my-project',
showThoughts: false,
useDynamicTitle: true,
} as TerminalTitleOptions,
expected: '⏲ Working… (my-project)',
},
])('should return $description', ({ args, expected, exact }) => {
const title = computeTerminalTitle(args);
if (exact) {
@@ -104,6 +125,7 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: longThought,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: true,
@@ -120,6 +142,7 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: longThought,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: true,
@@ -135,6 +158,7 @@ describe('computeTerminalTitle', () => {
streamingState: StreamingState.Responding,
thoughtSubject: 'BadTitle\x00 With\x07Control\x1BChars',
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: true,
useDynamicTitle: true,
@@ -153,6 +177,7 @@ describe('computeTerminalTitle', () => {
const title = computeTerminalTitle({
streamingState: StreamingState.Idle,
isConfirming: false,
isSilentWorking: false,
folderName: 'my-project',
showThoughts: false,
useDynamicTitle: true,
@@ -185,6 +210,7 @@ describe('computeTerminalTitle', () => {
const title = computeTerminalTitle({
streamingState: StreamingState.Idle,
isConfirming: false,
isSilentWorking: false,
folderName,
showThoughts: false,
useDynamicTitle: true,
@@ -201,6 +227,7 @@ describe('computeTerminalTitle', () => {
const title = computeTerminalTitle({
streamingState: StreamingState.Responding,
isConfirming: false,
isSilentWorking: false,
folderName: longFolderName,
showThoughts: true,
useDynamicTitle: false,
+8
View File
@@ -10,6 +10,7 @@ export interface TerminalTitleOptions {
streamingState: StreamingState;
thoughtSubject?: string;
isConfirming: boolean;
isSilentWorking: boolean;
folderName: string;
showThoughts: boolean;
useDynamicTitle: boolean;
@@ -32,6 +33,7 @@ export function computeTerminalTitle({
streamingState,
thoughtSubject,
isConfirming,
isSilentWorking,
folderName,
showThoughts,
useDynamicTitle,
@@ -62,6 +64,12 @@ export function computeTerminalTitle({
const maxContextLen = MAX_LEN - base.length - 3;
const context = truncate(displayContext, maxContextLen);
title = `${base}${getSuffix(context)}`;
} else if (isSilentWorking) {
const base = '⏲ Working…';
// Max context length is 80 - base.length - 3 (for ' (' and ')')
const maxContextLen = MAX_LEN - base.length - 3;
const context = truncate(displayContext, maxContextLen);
title = `${base}${getSuffix(context)}`;
} else if (streamingState === StreamingState.Idle) {
const base = '◇ Ready';
// Max context length is 80 - base.length - 3 (for ' (' and ')')