Collapse Grok rotating working titles to stable label (#7863)

Grok Build's working OSC titles interpolate a rotating status or tool
phrase between the spinner and its name, causing tab and sidebar
titles to fluctuate rapidly. Collapse these working frames to a stable
"⠋ Grok" label, while leaving idle and session titles untouched.
This commit is contained in:
Jinjing
2026-07-08 18:57:07 -07:00
committed by GitHub
parent 29cbe2d8cb
commit 2af8fb886f
4 changed files with 84 additions and 1 deletions
+29
View File
@@ -390,6 +390,35 @@ describe('normalizeTerminalTitle', () => {
expect(normalizeTerminalTitle('bash')).toBe('bash')
})
it('collapses Grok rotating working titles to one stable label', () => {
// Grok interpolates a rotating status/tool phrase between the spinner and its
// name, so each frame is a distinct title; they must all fold to one label.
expect(normalizeTerminalTitle('⠋ - Waiting for response… - grok')).toBe('⠋ Grok')
expect(normalizeTerminalTitle('⠴ - Thinking - grok')).toBe('⠋ Grok')
expect(normalizeTerminalTitle('⠙ - Responding - grok')).toBe('⠋ Grok')
expect(normalizeTerminalTitle('⠦ - Sleep 2s then echo hello-from-grok… - grok')).toBe('⠋ Grok')
expect(
normalizeTerminalTitle('⠹ - Waiting for response… - Execute Shell Command sleep 2 - grok')
).toBe('⠋ Grok')
// Idempotent: re-normalizing our own collapsed label stays stable.
expect(normalizeTerminalTitle('⠋ Grok')).toBe('⠋ Grok')
})
it('leaves Grok idle and session titles unchanged', () => {
// No spinner → not a working frame; the meaningful final title still shows.
expect(normalizeTerminalTitle('grok')).toBe('grok')
expect(normalizeTerminalTitle('Fix the auth bug - grok')).toBe('Fix the auth bug - grok')
// Names "grok" mid-title but ends with another agent → not a Grok frame.
expect(normalizeTerminalTitle('⠋ debugging grok - claude')).toBe('⠋ debugging grok - claude')
// Claude/Codex task text ending in "grok" must not collapse — only the
// Grok Build identity suffix " - grok" is the rotating-frame signal.
expect(normalizeTerminalTitle('⠋ wire up grok')).toBe('⠋ wire up grok')
expect(normalizeTerminalTitle('⠋ Codex is thinking about grok')).toBe(
'⠋ Codex is thinking about grok'
)
expect(normalizeTerminalTitle('⠋ support for Grok')).toBe('⠋ support for Grok')
})
it('collapses Pi spinner and idle titles to stable labels', () => {
expect(normalizeTerminalTitle('⠋ π - my-project')).toBe('⠋ Pi')
expect(normalizeTerminalTitle('π - my-project')).toBe('Pi')
+28 -1
View File
@@ -1,5 +1,32 @@
import { describe, expect, it } from 'vitest'
import { resolveExplicitTerminalTitleAgentType } from './terminal-title-agent-type'
import {
isGrokRotatingWorkingTitle,
resolveExplicitTerminalTitleAgentType
} from './terminal-title-agent-type'
describe('isGrokRotatingWorkingTitle', () => {
it('matches Grok working frames regardless of the rotating middle text', () => {
expect(isGrokRotatingWorkingTitle('⠋ - Waiting for response… - grok')).toBe(true)
expect(isGrokRotatingWorkingTitle('⠴ - Thinking - grok')).toBe(true)
expect(isGrokRotatingWorkingTitle('⠦ - Sleep 2s then echo hello… - grok')).toBe(true)
// Collapsed/stable form must stay matched so re-normalization is idempotent.
expect(isGrokRotatingWorkingTitle('⠋ grok')).toBe(true)
expect(isGrokRotatingWorkingTitle('⠋ Grok')).toBe(true)
})
it('ignores non-working, non-Grok, and lookalike titles', () => {
expect(isGrokRotatingWorkingTitle('grok')).toBe(false) // idle bare name, no spinner
expect(isGrokRotatingWorkingTitle('Fix the auth bug - grok')).toBe(false) // session title, no spinner
expect(isGrokRotatingWorkingTitle('⠋ debugging grok - claude')).toBe(false) // trailing name is another agent
expect(isGrokRotatingWorkingTitle('⠋ ~/grok-scratch/ready')).toBe(false) // path fragment, not a trailing token
expect(isGrokRotatingWorkingTitle('⠋ grokking the plan')).toBe(false) // "grok" not a whole trailing token
expect(isGrokRotatingWorkingTitle('⠋ Codex')).toBe(false)
// Task text ending in "grok" is not the Grok Build identity suffix " - grok".
expect(isGrokRotatingWorkingTitle('⠋ wire up grok')).toBe(false)
expect(isGrokRotatingWorkingTitle('⠋ Codex is thinking about grok')).toBe(false)
expect(isGrokRotatingWorkingTitle('⠋ support for Grok')).toBe(false)
})
})
describe('resolveExplicitTerminalTitleAgentType', () => {
it('maps explicit product-name titles to their TuiAgent id', () => {
+18
View File
@@ -51,6 +51,24 @@ export function isPiTerminalTitle(title: string): boolean {
return isLegacyPiCompatibleTitle(title) && !containsBrailleSpinner(title)
}
// Why: Grok Build's working OSC titles interpolate a rotating status/tool phrase
// between the spinner and its name — "⠋ - Waiting for response… - grok",
// "⠴ - Thinking - grok", "⠦ - Sleep 2s… - grok" — so every frame is a distinct
// title that flips the tab and sidebar labels. Require the identity suffix
// " - grok" (not arbitrary task text ending in "grok") so Claude/Codex titles
// like "⠋ wire up grok" stay intact. Spinner marks working; no-spinner session
// titles ("Fix the auth bug - grok") pass through. The bare "spinner + grok"
// branch keeps our own collapsed label idempotent under re-normalization.
const GROK_FRAME_IDENTITY_SUFFIX_RE = / - grok\s*$/i
const GROK_COLLAPSED_WORKING_TITLE_RE = /^[\u2800-\u28FF]+\s+grok\s*$/i
export function isGrokRotatingWorkingTitle(title: string): boolean {
if (!containsBrailleSpinner(title)) {
return false
}
return GROK_FRAME_IDENTITY_SUFFIX_RE.test(title) || GROK_COLLAPSED_WORKING_TITLE_RE.test(title)
}
export function isPiAgentTitle(title: string): boolean {
return isLegacyPiCompatibleTitle(title)
}
+9
View File
@@ -10,6 +10,7 @@ import {
GEMINI_SILENT_WORKING,
GEMINI_WORKING,
isGeminiTerminalTitle,
isGrokRotatingWorkingTitle,
isPiAgentTitle
} from './terminal-title-agent-type'
import {
@@ -95,5 +96,13 @@ export function normalizeTerminalTitle(title: string): string {
}
}
// Why: Grok Build interpolates a rotating status/tool phrase between the
// spinner and its name, so its working frames change the title many times per
// turn. Collapse them to one stable label; idle/session titles carry no
// spinner and pass through, so the meaningful final title still shows.
if (isGrokRotatingWorkingTitle(title)) {
return '\u280b Grok'
}
return title
}