diff --git a/src/main/ipc/pty/delivery/attached-pty-size.ts b/src/main/ipc/pty/delivery/attached-pty-size.ts index 14816e28fa9..2277d3fa79a 100644 --- a/src/main/ipc/pty/delivery/attached-pty-size.ts +++ b/src/main/ipc/pty/delivery/attached-pty-size.ts @@ -24,6 +24,17 @@ export function shouldSeedPreAttachPtySize(args: { } /** Attach does not resize the PTY; prefer proven provider/cached geometry over the pane request. */ +function resolveAttachedPtySize(args: { + result: Pick + cachedBeforeAttach: PtyGrid | undefined +}): PtyGrid | undefined { + return ( + positiveGrid(args.result.attachedGrid?.cols, args.result.attachedGrid?.rows) ?? + positiveGrid(args.result.snapshotCols, args.result.snapshotRows) ?? + positiveGrid(args.cachedBeforeAttach?.cols, args.cachedBeforeAttach?.rows) + ) +} + export function resolveCommittedPtySize(args: { result: Pick requested: PtyGrid @@ -32,12 +43,7 @@ export function resolveCommittedPtySize(args: { if (args.result.isReattach !== true) { return args.requested } - return ( - positiveGrid(args.result.attachedGrid?.cols, args.result.attachedGrid?.rows) ?? - positiveGrid(args.result.snapshotCols, args.result.snapshotRows) ?? - positiveGrid(args.cachedBeforeAttach?.cols, args.cachedBeforeAttach?.rows) ?? - args.requested - ) + return resolveAttachedPtySize(args) ?? args.requested } type HeadlessReflow = ((ptyId: string, cols: number, rows: number) => void) | undefined @@ -70,3 +76,22 @@ export function commitAttachedPtySize(args: { reflowHeadlessTerminalToCommittedGrid({ ...args, committedSize }) return committedSize } + +/** A rendererless attach has no pane request, so commit only geometry the attach proved. */ +export function commitRuntimeAttachedPtySize( + result: PtySpawnResult, + reflowHeadlessTerminalToPtyGrid: HeadlessReflow +): void { + const committedSize = resolveAttachedPtySize({ + result, + cachedBeforeAttach: ptySizes.get(result.id) + }) + if (committedSize) { + ptySizes.set(result.id, committedSize) + reflowHeadlessTerminalToCommittedGrid({ + result, + committedSize, + reflowHeadlessTerminalToPtyGrid + }) + } +} diff --git a/src/main/ipc/pty/pty-ipc-provider-fixtures.ts b/src/main/ipc/pty/pty-ipc-provider-fixtures.ts index bf744f6187b..1b9b89c307b 100644 --- a/src/main/ipc/pty/pty-ipc-provider-fixtures.ts +++ b/src/main/ipc/pty/pty-ipc-provider-fixtures.ts @@ -257,6 +257,7 @@ export function createPtyIpcProviderFixtures(ctx: { mainWindow: unknown }) { createPreAllocatedTerminalHandle: vi.fn(() => 'term_recovered'), registerPreAllocatedHandleForPty: vi.fn(), registerPty: vi.fn(), + reflowHeadlessTerminalToPtyGrid: vi.fn(), ...runtimeOverrides } registerPtyHandlers(mainWindow as never, runtime as never) diff --git a/src/main/ipc/pty/runtime/attach-hermes-mailbox.test.ts b/src/main/ipc/pty/runtime/attach-hermes-mailbox.test.ts new file mode 100644 index 00000000000..aea598345a3 --- /dev/null +++ b/src/main/ipc/pty/runtime/attach-hermes-mailbox.test.ts @@ -0,0 +1,185 @@ +import '../../../runtime/rpc/unused-default-rpc-methods.test-fixture' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { settledWriteStub } from '../../../providers/settled-pty-write-stub' +import type { IPtyProvider } from '../../../providers/pty-provider-contract' +import { OrchestrationDb } from '../../../runtime/orchestration/db/orchestration-db' +import { createRootDispatch } from '../../../runtime/orchestration/db/root-dispatch-test-fixture' +import { + createRuntime, + PANE_KEY, + PTY_ID, + TERMINAL_HANDLE +} from '../../../runtime/orchestration/mailbox/terminal-pointer/orchestration-mailbox-notification-test-harness' +import { ptySizes } from '../delivery/visibility-state' +import { getLocalPtyProvider, setLocalPtyProvider } from '../provider/registry' +import { attachPtyFromRuntimeController, getSizeFromRuntimeController } from './operations' +import type { PtyRuntimeControllerDeps } from './controller-deps' + +const originalProvider = getLocalPtyProvider() + +afterEach(() => { + setLocalPtyProvider(originalProvider) + ptySizes.delete(PTY_ID) + vi.useRealTimers() +}) + +describe('mail to a Hermes terminal attached without a renderer', () => { + it.each([ + ['status', '─ ready │ grok 4.7 │ 150k tokens\r\n❯', true], + ['reply', '─ ready │ grok 4.7 │ 150k tokens\r\n❯', true], + ['draft', '─ ready │ grok 4.7 │ 150k tokens\r\n❯ unsent draft', false], + ['busy', '─ thinking │ grok 4.7 │ 150k tokens\r\n❯ Ctrl+C to interrupt…', false] + ] as const)( + 'handles %s mail after attach without submitting a draft or busy composer', + async (kind, screen, ready) => { + vi.useFakeTimers() + const db = new OrchestrationDb(':memory:') + try { + const { runtime } = createRuntime(db, { headless: true, launchAgent: 'hermes' }) + const write = vi.fn((_id: string, data: string) => { + if (data.includes('You have')) { + runtime.onPtyData( + PTY_ID, + '\x1b]1;✓ Run Orca dispatched worker …\x07\x1b]2;✓ Run Orca dispatched worker … · grok-4.7 · ~/workspace\x07', + Date.now() + ) + } + return true + }) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach reads only this provider's attach method. + const provider = { + attach: async () => ({ + id: PTY_ID, + isReattach: true, + snapshot: screen, + snapshotCols: 120, + snapshotRows: 40 + }) + } as unknown as IPtyProvider + setLocalPtyProvider(provider) + runtime.setPtyController({ + write, + writeWithSettlement: settledWriteStub(write), + kill: () => true, + getForegroundProcess: async () => 'hermes', + getSize: getSizeFromRuntimeController + }) + const run = db.createRun({ + objective: 'wake attached worker', + coordinatorHandle: 'term_coordinator', + coordinatorPaneKey: 'coordinator:leaf' + }) + const task = db.createTask({ spec: 'Wait for guidance', runId: run.id }) + const dispatch = createRootDispatch(db, task.id, TERMINAL_HANDLE, PANE_KEY) + const mailbox = `dispatch:${dispatch.id}` + const message = + kind === 'reply' + ? db.answerQuestion({ + messageId: db.createQuestion({ + runId: run.id, + dispatchId: dispatch.id, + askerHandle: TERMINAL_HANDLE, + question: 'Ready?' + }).message.id, + runId: run.id, + consumerGeneration: run.consumer_generation, + body: 'Continue' + }).message + : db.insertMessage({ + from: 'term_coordinator', + to: mailbox, + subject: 'Continue', + runId: run.id + }) + + // Only attach and restored output: no renderer spawn or resize populates the size cache. + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach needs runtime; its delivery callbacks are optional. + const deps = { runtime } as unknown as PtyRuntimeControllerDeps + expect(await attachPtyFromRuntimeController(deps, PTY_ID)).toBe(true) + expect(ptySizes.get(PTY_ID)).toEqual({ cols: 120, rows: 40 }) + await runtime.serializeMainTerminalBuffer(PTY_ID) + runtime.notifyMessageArrived(mailbox, 'status') + await vi.advanceTimersByTimeAsync(1000) + + if (ready) { + expect(write.mock.calls.map(([, data]) => data)).toEqual([ + expect.stringContaining('You have 1 orchestration message'), + '\r' + ]) + expect(db.getMessageById(message.id)?.delivered_at).toEqual(expect.any(String)) + } else { + expect(write).not.toHaveBeenCalled() + expect(db.getMessageById(message.id)?.delivered_at).toBeNull() + } + } finally { + db.close() + } + } + ) + + it('keeps a resize that lands while attach is in flight', async () => { + ptySizes.set(PTY_ID, { cols: 80, rows: 24 }) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach reads only this provider's attach method. + const provider = { + attach: async () => { + ptySizes.set(PTY_ID, { cols: 140, rows: 48 }) + return { + id: PTY_ID, + isReattach: true, + snapshot: '─ ready │ grok 4.7 │ 150k tokens\r\n❯', + snapshotCols: 120, + snapshotRows: 40 + } + } + } as unknown as IPtyProvider + setLocalPtyProvider(provider) + const db = new OrchestrationDb(':memory:') + try { + const { runtime } = createRuntime(db, { headless: true, launchAgent: 'hermes' }) + runtime.setPtyController({ + write: () => true, + kill: () => true, + getForegroundProcess: async () => 'hermes', + getSize: getSizeFromRuntimeController + }) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach needs only runtime; its delivery callbacks are optional. + const deps = { runtime } as unknown as PtyRuntimeControllerDeps + expect(await attachPtyFromRuntimeController(deps, PTY_ID)).toBe(true) + expect(ptySizes.get(PTY_ID)).toEqual({ cols: 140, rows: 48 }) + // The TUI repaints for the resize, and the screen rules can read that repaint. + runtime.onPtyData(PTY_ID, '\x1b[2J\x1b[H─ ready │ grok 4.7 │ 150k tokens\r\n❯', Date.now()) + await runtime.serializeMainTerminalBuffer(PTY_ID) + expect(runtime['readRuledScreen'](PTY_ID)?.lines).toEqual([ + '─ ready │ grok 4.7 │ 150k tokens', + '❯' + ]) + } finally { + db.close() + } + }) + + it('keeps a resize that returns to the pre-attach dimensions', async () => { + const before = { cols: 80, rows: 24 } + ptySizes.set(PTY_ID, before) + const restored = { cols: 80, rows: 24 } + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach reads only this provider's attach method. + const provider = { + attach: async () => { + ptySizes.set(PTY_ID, { cols: 140, rows: 48 }) + ptySizes.set(PTY_ID, restored) + return { + id: PTY_ID, + isReattach: true, + snapshot: '─ ready │ grok 4.7 │ 150k tokens\r\n❯', + snapshotCols: 140, + snapshotRows: 48 + } + } + } as unknown as IPtyProvider + setLocalPtyProvider(provider) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach needs only the optional delivery callbacks. + const deps = {} as unknown as PtyRuntimeControllerDeps + expect(await attachPtyFromRuntimeController(deps, PTY_ID)).toBe(true) + expect(ptySizes.get(PTY_ID)).toBe(restored) + }) +}) diff --git a/src/main/ipc/pty/runtime/attach-quiet-agent-mailbox.test.ts b/src/main/ipc/pty/runtime/attach-quiet-agent-mailbox.test.ts new file mode 100644 index 00000000000..3dab1eea59c --- /dev/null +++ b/src/main/ipc/pty/runtime/attach-quiet-agent-mailbox.test.ts @@ -0,0 +1,111 @@ +import '../../../runtime/rpc/unused-default-rpc-methods.test-fixture' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { settledWriteStub } from '../../../providers/settled-pty-write-stub' +import type { IPtyProvider } from '../../../providers/pty-provider-contract' +import { OrchestrationDb } from '../../../runtime/orchestration/db/orchestration-db' +import { createRootDispatch } from '../../../runtime/orchestration/db/root-dispatch-test-fixture' +import { + createRuntime, + PANE_KEY, + PTY_ID, + TERMINAL_HANDLE +} from '../../../runtime/orchestration/mailbox/terminal-pointer/orchestration-mailbox-notification-test-harness' +import { ptySizes } from '../delivery/visibility-state' +import { getLocalPtyProvider, setLocalPtyProvider } from '../provider/registry' +import { attachPtyFromRuntimeController, getSizeFromRuntimeController } from './operations' +import type { PtyRuntimeControllerDeps } from './controller-deps' + +const originalProvider = getLocalPtyProvider() + +afterEach(() => { + setLocalPtyProvider(originalProvider) + ptySizes.delete(PTY_ID) + vi.useRealTimers() +}) + +const HERMES_READY = + '\x1b]2;\u2713 Coordinate dispatched worker \u2026 \u00b7 gpt-6.1-sol \u00b7 ~/ws\x07' + + '\u2500 ready \u2502 gpt 6.1 sol \u2502 7k/500k \u2502 4m 45s\r\n\u276f' +const RULE = '\u2500'.repeat(40) +const CLINE_READY = `${RULE}\r\n\u276f What can I do for you?\r\n${RULE}\r\n\u25cb Plan \u25cf Act (Tab)` + +async function mailAfterQuietAttach( + agent: 'hermes' | 'cline', + snapshot: string, + afterAttach: (runtime: ReturnType['runtime']) => Promise +): Promise<{ writes: string[]; delivered: boolean }> { + vi.useFakeTimers() + const db = new OrchestrationDb(':memory:') + try { + const { runtime } = createRuntime(db, { headless: true, launchAgent: agent }) + const write = vi.fn((_id: string, _data: string) => true) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach reads only this provider's attach method. + const provider = { + attach: async () => ({ + id: PTY_ID, + isReattach: true, + snapshot, + snapshotCols: 120, + snapshotRows: 40 + }) + } as unknown as IPtyProvider + setLocalPtyProvider(provider) + runtime.setPtyController({ + write, + writeWithSettlement: settledWriteStub(write), + kill: () => true, + getForegroundProcess: async () => agent, + getSize: getSizeFromRuntimeController + }) + const run = db.createRun({ + objective: 'wake quiet worker', + coordinatorHandle: 'term_coordinator', + coordinatorPaneKey: 'coordinator:leaf' + }) + const task = db.createTask({ spec: 'Wait for guidance', runId: run.id }) + const dispatch = createRootDispatch(db, task.id, TERMINAL_HANDLE, PANE_KEY) + const mailbox = `dispatch:${dispatch.id}` + const message = db.insertMessage({ + from: 'term_coordinator', + to: mailbox, + subject: 'Continue', + runId: run.id + }) + // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: attach needs runtime; its delivery callbacks are optional. + const deps = { runtime } as unknown as PtyRuntimeControllerDeps + expect(await attachPtyFromRuntimeController(deps, PTY_ID)).toBe(true) + await runtime.serializeMainTerminalBuffer(PTY_ID) + await afterAttach(runtime) + runtime.notifyMessageArrived(mailbox, 'status') + await vi.advanceTimersByTimeAsync(60_000) + return { + writes: write.mock.calls.map(([, data]) => data), + delivered: typeof db.getMessageById(message.id)?.delivered_at === 'string' + } + } finally { + db.close() + } +} + +describe('mail to a quiet idle agent after a runtime restart', () => { + // Real Hermes 0.23 writes its OSC title only on a state change, so a worker idle before the + // restart sends no title after reattach; only its ready screen and seeded title are known. + it('types and submits the pointer to Hermes without a fresh title', async () => { + expect(await mailAfterQuietAttach('hermes', HERMES_READY, async () => {})).toEqual({ + writes: [expect.stringContaining('You have 1 orchestration message'), '\r'], + delivered: true + }) + }) + + // A quiet-gated ready rule must still settle once a redraw soon after attach has gone quiet. + it('submits to Cline once its ready screen is quiet after a redraw', async () => { + const result = await mailAfterQuietAttach('cline', CLINE_READY, async (runtime) => { + await vi.advanceTimersByTimeAsync(2_000) + runtime.onPtyData(PTY_ID, '\x1b[H', Date.now()) + }) + expect(result).toEqual({ + writes: [expect.stringContaining('You have 1 orchestration message'), '\r'], + delivered: true + }) + }) +}) diff --git a/src/main/ipc/pty/runtime/operations.ts b/src/main/ipc/pty/runtime/operations.ts index 3c8907d9218..2c8d627c2d8 100644 --- a/src/main/ipc/pty/runtime/operations.ts +++ b/src/main/ipc/pty/runtime/operations.ts @@ -5,9 +5,8 @@ import { LocalPtyProvider } from '../../../providers/local-pty/local-pty-provide import { ptyOwnership } from '../provider/ownership-state' import { isRendererViewShowingPty, ptySizes } from '../delivery/visibility-state' import { isHiddenRendererPty } from '../delivery/pty-hidden-delivery-gate' -import { seedTerminalRestoreRecordsFromSpawnResult } from '../pane/agent-session-owners' -import { seedHeadlessTerminalFromSpawnResult } from '../pane/terminal-spawn-restore' import { hideRuntimeOwnedRendererDelivery } from './spawn-hidden-delivery' +import { seedAttachedRuntimeTerminal } from './seed-attached-runtime-terminal' import { rendererSerializerReadiness } from '../pane/serializer-state' import { getProviderForPty, localProvider, resolvePtyExecutionHost } from '../provider/registry' import { inspectPtyProviderProcess } from '../../../providers/pty-process-inspection' @@ -138,6 +137,7 @@ export async function attachPtyFromRuntimeController( } try { const sequenceBeforeProviderAttach = deps.runtime?.getPtyOutputSequence?.(ptyId) ?? 0 + const sizeBeforeAttach = ptySizes.get(ptyId) const attachResult = await provider.attach(ptyId) if (attachResult?.providerSequence) { deps.runtime?.synchronizePtyOutputSequenceFromProvider?.( @@ -147,9 +147,7 @@ export async function attachPtyFromRuntimeController( ) } if (attachResult) { - // A restarted runtime has never seen this screen; an idle agent may print nothing after attach. - seedHeadlessTerminalFromSpawnResult(deps.runtime, attachResult, null) - seedTerminalRestoreRecordsFromSpawnResult(deps.runtime, attachResult) + seedAttachedRuntimeTerminal(deps.runtime, attachResult, sizeBeforeAttach) } deps.syncPtyBackgroundedDelivery?.(ptyId, 'main-attach') return true diff --git a/src/main/ipc/pty/runtime/seed-attached-runtime-terminal.ts b/src/main/ipc/pty/runtime/seed-attached-runtime-terminal.ts new file mode 100644 index 00000000000..e60f68e1f56 --- /dev/null +++ b/src/main/ipc/pty/runtime/seed-attached-runtime-terminal.ts @@ -0,0 +1,25 @@ +import type { PtySpawnResult } from '../../../providers/pty-provider-contract' +import type { OrcaRuntimeService } from '../../../runtime/orca-runtime' +import { commitRuntimeAttachedPtySize, type PtyGrid } from '../delivery/attached-pty-size' +import { ptySizes } from '../delivery/visibility-state' +import { seedTerminalRestoreRecordsFromSpawnResult } from '../pane/agent-session-owners' +import { seedHeadlessTerminalFromSpawnResult } from '../pane/terminal-spawn-restore' + +/** Commit the attached grid, then seed the screen a restarted runtime has never seen. */ +export function seedAttachedRuntimeTerminal( + runtime: OrcaRuntimeService | undefined, + result: PtySpawnResult, + sizeBeforeAttach: PtyGrid | undefined +): void { + const sizeNow = ptySizes.get(result.id) + // Identity, not dimensions: A→B→A publishes a new entry that still measures A. + const resizeLanded = sizeNow !== undefined && sizeNow !== sizeBeforeAttach + if (!resizeLanded) { + commitRuntimeAttachedPtySize(result, runtime?.reflowHeadlessTerminalToPtyGrid.bind(runtime)) + } + seedHeadlessTerminalFromSpawnResult(runtime, result, null) + seedTerminalRestoreRecordsFromSpawnResult(runtime, result) + if (resizeLanded && sizeNow) { + runtime?.resizeHeadlessTerminalToPtyGrid(result.id, sizeNow.cols, sizeNow.rows) + } +} diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.meta.json b/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.meta.json new file mode 100644 index 00000000000..5105234ddc1 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.meta.json @@ -0,0 +1,9 @@ +{ + "capturedAt": "2026-11-08T19:48:25.862Z", + "platform": "darwin", + "command": ["agy"], + "cols": 120, + "rows": 40, + "note": "agy 1.4.11, macOS, Google account, AGY_CLI_HIDE_ACCOUNT_INFO=1; one background task running, a second turn mid-way through a foreground command", + "exitCode": 0 +} diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.txt b/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.txt new file mode 100644 index 00000000000..f597c1b7b8d --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-busy-with-background-task.txt @@ -0,0 +1,591 @@ +[>q[?2026$p[?2027$p]7501;?]11;?[>4m[?1049h[?25l[?5W[?2004h[>4;2m[>5u[?u +▄▀▀▄ +▀▀▀▀▀▀ +▀▀▀▀▀▀▀▀ + ▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + + Welcome back! You are currently not signed in. + + ⣷ Signing in...[>4m[<1u[?1049l[>4;2m[>5u[?u[0 q  +▄▀▀▄ Antigravity CLI 1.5.3 +▀▀▀▀▀▀ ~/orca-lanes/pr37732/agyws +▀▀▀▀▀▀▀▀ +▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcuts [?25h[?25l Gemini 3.8 Flash (Low) +~/orca-lanes/pr37732/agyws + + + + + + +Gemini 3.8 Flash · low [?25h[?25l M + ┃ Meet Gemini 4 Argon + ┃ Google’s most capable frontier model is now available in Antigravity. Built for complex, multi-step agentic + ┃ workflows, and deep reasoning. If it's not currently available to you, please reach out to your administrator to + ┃ enable it. + ┃ Learn more: https://docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools-settings#configure-model- + ┃ availability + ┃ esc to dismiss +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25lS[?25h[?25ltart the shell command "sleep 3 + + G[?25h[?25l03" as a background task, do not wai[?25h[?25lt for it, and end your turn with the[?25h[?25l word + Started. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +Gemini 3.8 Flash · low [?25h[?25l + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25l M──────────────────────────────────────────────────────────── +> Start the shell command "sleep 303" as a background task, do not wait for it, and end your turn with the word + Started. +⣷ Generating... +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣯ + +[?25h[?25l ⣟ Gene + +[?25h[?25l ⡿ Generatin + +[?25h[?25l ⢿ Generating... + +[?25h[?25l ⣻ Generating... + +[?25h[?25l ⣽ + +[?25h[?25l ⣾ Genera + +[?25h[?25l ⣷ Generating. + +[?25h[?25l ⣯ Generating... + +[?25h[?25l ⣟ Generating... + +[?25h[?25l ⡿ G + +[?25h[?25l ⢿ Genera + +[?25h[?25l ⣻ Generating. + +[?25h[?25l ⣽ Generating... + +[?25h[?25l.. +└ Tip: Use /settings to configure your environment. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣾ + + +[?25h[?25l ⣷ Ge + + +[?25h[?25l  +○ Running (sleep 303) (ctrl+o to expand) +⣷ Running command... +└ Tip: Use /settings to configure your environment. + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25lunn + + +[?25h[?25l ⣯ + + +[?25h[?25l Runnin + + +[?25h[?25lunning  + + +[?25h[?25l ⣟ + + +[?25h[?25l ● +ning com + + +[?25h[?25lg comma + + +[?25h[?25l ⡿ + + +[?25h[?25lcommand. + + +[?25h[?25lmand... + + +[?25h[?25l ⢿ + + +[?25h[?25l nd.. + + +[?25h[?25l ⣻ Running command... + + +[?25h[?25l ○ +⣽ + + + + + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⣾ Runn + + +[?25h[?25l ⣷ Running c + + +[?25h[?25l ⣯ Running command + + +[?25h[?25l ⣟ Running command... + + +[?25h[?25l ⡿ Running command... + + +[?25h[?25l ⢿ R + + +[?25h[?25l ⣻ Runnin + + +[?25h[?25l ⣽ Running com + + +[?25h[?25l ⣾ Running command + + +[?25h[?25l ⣷ Running command... + + +[?25h[?25l ⣯ Running command... + + +[?25h[?25l ⣟ Ru + + +[?25h[?25l ⡿ Running + + +[?25h[?25l ⢿ Running comm + + +[?25h[?25l  + Started. +⢿ Running command... +└ Tip: Use /settings to configure your environment. + +> + + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⣻ Running command.. + + +[?25h[?25land... + + +[?25h[?25l ⣽ Running command.. + + +[?25h[?25l ⣾ Running command... + + +[?25h[?25l + + + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25lR[?25h[?25lun the shell command "sleep 40" + + + + G[?25h[?25l in the foreground and wait for it.[?25h[?25l + + + +? for shortcuts[?25h[?25lM +> Run the shell command "sleep 40" in the foreground and wait for it. +⣾ Loading... +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⣷ Loading... + +[?25h[?25l ⣯ Loading... + +[?25h[?25l ⣟ + +[?25h[?25l ⡿ Load + +[?25h[?25l ⢿ Loading.. + +[?25h[?25l ⣻ Loading... + +[?25h[?25l ⣽ Loading... + +[?25h[?25l ⣾ Loa + +[?25h[?25l ⣷ Loading. + +[?25h[?25l ⣯ Loading... + +[?25h[?25l ⣟ Loading... + +[?25h[?25l ⡿ Lo + +[?25h[?25l ⢿ Loading + +[?25h[?25l ⣻ Loading... + +[?25h[?25l ⣽ Loading... + +[?25h[?25l ⣾ L + +[?25h[?25l Loadin + +[?25h[?25l ⣷ + +[?25h[?25l ⣯ Loading... + +[?25h[?25l  +○ Running (sleep 40) (ctrl+o to expand) +⣯ Running command... + +> + + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25land... + +[?25h[?25l ⣟ Running command. + +[?25h[?25l ● +.. + +[?25h[?25l. + +[?25h[?25l ⡿ + +[?25h[?25l Ru + +[?25h[?25l ⢿ Ru + +[?25h[?25lnn + +[?25h[?25l Runnin + +[?25h[?25l ⣻ + +[?25h[?25l ○ +unning  + +[?25h[?25l ⣽ Running com + +[?25h[?25l ⣾ Running command. + +[?25h[?25l ⣷ Running command... + +[?25h[?25l ⣯ Running command... + +[?25h[?25l ⣟ Ru + +[?25h[?25l ⡿ Running  + +[?25h[?25l ⢿ Running comma + +[?25h[?25l ⣻ Running command... + +[?25h[?25l ⣽ Running command... + +[?25h[?25l ⣾ + +[?25h[?25l ⣷ Runn + +[?25h[?25l ⣯ Running c + +[?25h[?25l ⣟ Running comman + +[?25h[?25l ⡿ Running command... + +[?25h[?25l ⢿ Running command... + +[?25h[?25l ⣻ + +[?25h[?25l ⣽ Runni + +[?25h[?25l ⣾ Running co + +[?25h[?25l ⣷ Running command + +[?25h[?25l ⣯ Running command... + +[?25h[?25l ⣟ Running command... + +[?25h[?25l ⡿ R + +[?25h[?25l ⢿ Runnin + +[?25h[?25l ⣻ Running com + +[?25h[?25l ⣽ Running command. + +[?25h[?25l ⣾ Running command... + +[?25h[?25l ⣷ Running command... + +[?25h[?25l ⣯ Ru + +[?25h[?25l ⣟ Running + +[?25h[?25l ⡿ Running comm + +[?25h[?25l ⢿ Running command.. + +[?25h[?25l ⣻ Running command... + +[?25h[?25l ⣽ Running command... + +[?25h[?25l ⣾ Run + +[?25h[?25l ⣷ Running  + +[?25h[?25l ⣯ Running comma + +[?25h[?25l ⣟ Running command... + +[?25h[?25l ⡿ Running command... + +[?25h[?25l ⢿ + +[?25h[?25l ⣻ Runn + +[?25h[?25l ⣽ Running c + +[?25h[?25l ⣾ Running comman + +[?25h[?25l ⣷ Running command... + +[?25h[?25l ⣯ Running command... + +[?25h[?25l ⣟ + +[?25h[?25l ⡿ Runni + +[?25h[?25l ⢿ Running co + +[?25h[?25l ⣻ Running command + +[?25h[?25l ⣽ Running command... + +[?25h[?25l ⣾ Running command... + +[?25h[?25l ⣷ R + +[?25h[?25l ⣯ Runnin + +[?25h[?25l ⣟ Running com + +[?25h[?25l ⡿ Running command. + +[?25h[?25l ⢿ Running command... + +[?25h[?25l ⣻ Running command... + +[?25h[?25l ⣽ Ru + +[?25h[?25l ⣾ Running + +[?25h[?25l ⣷ Running comm + +[?25h[?25l ⣯ Running command.. + +[?25h[?25l ⣟ Running command... + +[?25h[?25l ⡿ Running command... + +[?25h[?25l ⢿ Run + +[?25h[?25l ⣻ Running  + +[?25h[?25l ⣽ Running comma + +[?25h[?25l ⣾ Running command... + +[?25h[?25l ⣷ Running command... + +[?25h[?25l ⣯ + +[?25h[?25l ⣟ Runn + +[?25h[?25l ⡿ Running c + +[?25h[?25l ⢿ Running comman + +[?25h[?25l ⣻ Running command... + +[?25h[?25l ⣽ Running command... + +[?25h[?25l ⣾ + +[?25h[?25l ⣷ Runni + +[?25h[?25l ⣯ Running co + +[?25h[?25l ⣟ Running command + +[?25h[?25l ⡿ Running command... + +[?25h[?25l ⢿ Running command... + +[?25h[?25l ⣻ R + +[?25h[?25l ⣽ Runnin + +[?25h[?25l ⣾ Running com + +[?25h[?25l ⣷ Running command. + +[?25h[?25l ⣯ Running command... + +[?25h[?25l ⣟ Running command... + +[?25h[?25l ⡿ Ru + +[?25h[?25l ⢿ Running + +[?25h[?25l ⣻ Running comm + +[?25h[?25l ⣽ Running command.. + +[?25h[?25l ⣾ Running command... + +[?25h[?25l ⣷ Running command... + +[?25h[?25l ⣯ Run + +[?25h[?25l ⣟ Running  + +[?25h[?25l ⡿ Running comma + +[?25h[?25l ⢿ Running command... + +[?25h[?25l ⣻ Running command... + +[?25h[?25l ⣽ +└ Tip: Use /context to see what files are in the conversation. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:48:13] sleep 40 running + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 2 task(s) · /tasks [?25h[?25l ⣾ Runn + + +[?25h[?25l ⣷ Running c + + +[?25h[?25l ⣯ Running comman + + +[?25h[?25l ⣟ Running command... + + +[?25h[?25l ⡿ Running command... + + +[?25h[?25l ⢿ + + +[?25h[?25l ⣻ Runni + + +[?25h[?25l ⣽ Running co + + +[?25h[?25l ⣾ Running command + + +[?25h[?25l ⣷ Running command... + + +[?25h[?25l ⣯ Running command... + + +[?25h[?25l ⣟ R + + +[?25h[?25l ⡿ Runnin + + +[?25h[?25l ⢿ Running com + + +[?25h[?25l ⣻ Running command. + + +[?25h[?25l  + The command +⣻ Running command... +└ Tip: Use /context to see what files are in the conversation. + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:48:13] sleep 40 running + ● [14:47:49] sleep 303 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 2 task(s) · /tasks [?25h[?25l ⣽ Running command... + + +[?25h[?25lsleep 40 +.. + + +[?25h[?25lhas been started (task ID: 8a42e + + + +[?25h[?25l ⣾ + + +[?25h[?25l0ec-4f52-4e1a-8d02-cdbfc + + + +[?25h[?25l0f46 + + + +[?25h[?25l ⣷ Ru + + +[?25h[?25l ⣯ Running + + +[?25h \ No newline at end of file diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.meta.json b/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.meta.json new file mode 100644 index 00000000000..2a2802e9bb2 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.meta.json @@ -0,0 +1,9 @@ +{ + "capturedAt": "2026-11-08T19:48:21.856Z", + "platform": "darwin", + "command": ["agy"], + "cols": 120, + "rows": 40, + "note": "agy 1.4.11, macOS, Google account, AGY_CLI_HIDE_ACCOUNT_INFO=1; one background task running, an unsent draft in the composer", + "exitCode": 0 +} diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.txt b/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.txt new file mode 100644 index 00000000000..bb564831339 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-draft-with-background-task.txt @@ -0,0 +1,244 @@ +[>q[?2026$p[?2027$p]11;?]7501;?[>4m[?1049h[?25l[?5W[?2004h[>4;2m[>5u[?u +▄▀▀▄ +▀▀▀▀▀▀ +▀▀▀▀▀▀▀▀ + ▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + + Welcome back! You are currently not signed in. + + ⣷ Signing in...[>4m[<1u[?1049l[>4;2m[>5u[?u[0 q  +▄▀▀▄ Antigravity CLI 1.5.3 +▀▀▀▀▀▀ ~/orca-lanes/pr37732/agyws +▀▀▀▀▀▀▀▀ +▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcuts [?25h[?25l Gemini 3.8 Flash (Low) +~/orca-lanes/pr37732/agyws + + + + + + +Gemini 3.8 Flash · low [?25h[?25l M + ┃ Meet Gemini 4 Argon + ┃ Google’s most capable frontier model is now available in Antigravity. Built for complex, multi-step agentic + ┃ workflows, and deep reasoning. If it's not currently available to you, please reach out to your administrator to + ┃ enable it. + ┃ Learn more: https://docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools-settings#configure-model- + ┃ availability + ┃ esc to dismiss +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25lS[?25h[?25ltart the shell command "sleep 304" + + G[?25h[?25l as a background task, do not wait f[?25h[?25lor it, and end your turn with the wo[?25h[?25lrd + Started. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +Gemini 3.8 Flash · low [?25h[?25l + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25l M──────────────────────────────────────────────────────────── +> Start the shell command "sleep 304" as a background task, do not wait for it, and end your turn with the word + Started. +⣷ Generating... +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣯ + +[?25h[?25l ⣟ Gene + +[?25h[?25l ⡿ Generatin + +[?25h[?25l ⢿ Generating... + +[?25h[?25l ⣻ Generating... + +[?25h[?25l ⣽ G + +[?25h[?25l ⣾ Genera + +[?25h[?25l ⣷ Generating. + +[?25h[?25l ⣯ Generating... + +[?25h[?25l ⣟ Generating... + +[?25h[?25l ⡿ G + +[?25h[?25l ⢿ Genera + +[?25h[?25l ⣻ Generating.. + +[?25h[?25l ⣽ Generating... + +[?25h[?25l. +└ Tip: Use /settings to configure your environment. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣾ + + +[?25h[?25l  +○ Running (sleep 304) (ctrl+o to expand) +⣾ Running command... +└ Tip: Use /settings to configure your environment. + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣷ + + +[?25h[?25l Ru + + +[?25h[?25lun + + +[?25h[?25l ⣯ Runn + + +[?25h[?25l Running + + +[?25h[?25l ⣟ Running c + + +[?25h[?25l ● +ing comm + + +[?25h[?25l ⡿ Running comman + + +[?25h[?25lommand.. + + +[?25h[?25l ⢿ Running command... + + +[?25h[?25l nd + + +[?25h[?25l ⣻ Running command... + + +[?25h[?25l ○ + + + +[?25h[?25l + + ● [14:47:49] sleep 304 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⣽ + + +[?25h[?25l ⣾ Runni + + +[?25h[?25l ⣷ Running co + + +[?25h[?25l ⣯ Running command + + +[?25h[?25l ⣟ Running command... + + +[?25h[?25l ⡿ Running command... + + +[?25h[?25l ⢿ R + + +[?25h[?25l ⣻ Runnin + + +[?25h[?25l ⣽ Running co + + +[?25h[?25l ng com + + +[?25h[?25l ⣾ Running command + + +[?25h[?25l ⣷ Running command... + + +[?25h[?25l ⣯ Running command... + + +[?25h[?25l ⣟ Ru + + +[?25h[?25l ⡿ Running + + +[?25h[?25l ⢿ Running comm + + +[?25h[?25l ⣻ Running command.. + + +[?25h[?25l ⣽ Running command... + + +[?25h[?25l ⣾ Running command... + + +[?25h[?25l Run + + +[?25h[?25l ⣷ Run + + +[?25h[?25l ⣯ Running + + +[?25h[?25l ⣟ Running comma + + +[?25h[?25l ⡿ Running command... + + +[?25h[?25l  + Started. +⡿ Running command... +└ Tip: Use /settings to configure your environment. + +> + + ● [14:47:49] sleep 304 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⢿ Running command... + + +[?25h[?25l ⣻ + + +[?25h[?25l + + + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:47:49] sleep 304 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25luns + + + + G[?25h[?25lent draft[?25h \ No newline at end of file diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.meta.json b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.meta.json new file mode 100644 index 00000000000..27c7349e716 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.meta.json @@ -0,0 +1,9 @@ +{ + "capturedAt": "2026-11-08T19:47:27.977Z", + "platform": "darwin", + "command": ["agy"], + "cols": 120, + "rows": 40, + "note": "agy 1.4.11, macOS, Google account, AGY_CLI_HIDE_ACCOUNT_INFO=1; one background task running, turn ended at the idle composer", + "exitCode": 0 +} diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.txt b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.txt new file mode 100644 index 00000000000..ef6ef551413 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-background-task.txt @@ -0,0 +1,173 @@ +[>q[?2026$p[?2027$p]11;?]7501;?[>4m[?1049h[?25l[?5W[?2004h[>4;2m[>1u[?u +▄▀▀▄ +▀▀▀▀▀▀ +▀▀▀▀▀▀▀▀ + ▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + + Welcome back! You are currently not signed in. + + ⣷ Signing in...[>4m[<1u[?1049l[>4;2m[>1u[?u[0 q  +▄▀▀▄ Antigravity CLI 1.4.11 +▀▀▀▀▀▀ ~/orca-lanes/pr37732/agyws +▀▀▀▀▀▀▀▀ +▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcuts [?25h[?25l Gemini 3.8 Flash (Low) +~/orca-lanes/pr37732/agyws + + + + + + +Gemini 3.8 Flash · low [?25h[?25l M + ┃ Meet Gemini 4 Argon + ┃ Google’s most capable frontier model is now available in Antigravity. Built for complex, multi-step agentic + ┃ workflows, and deep reasoning. If it's not currently available to you, please reach out to your administrator to + ┃ enable it. + ┃ Learn more: https://docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools-settings#configure-model- + ┃ availability + ┃ esc to dismiss +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25lS[?25h[?25ltart the shell command "sl + + G[?25h[?25leep 300" as a background task, do no[?25h[?25lt wait for it, and end your turn with[?25h[?25l the word + Started. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +Gemini 3.8 Flash · low [?25h[?25l + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25l M──────────────────────────────────────────────────────────── +> Start the shell command "sleep 300" as a background task, do not wait for it, and end your turn with the word + Started. +⣷ Generating... +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25len + +[?25h[?25l ⣯ Genera + +[?25h[?25l ⣟ Generating. + +[?25h[?25l ⡿ Generating... + +[?25h[?25l ⢿ Generating... + +[?25h[?25l ⣻ Ge + +[?25h[?25l ⣽ Generat + +[?25h[?25l ⣾ Generating.. + +[?25h[?25l ⣷ Generating... + +[?25h[?25l ⣯ Generating... + +[?25h[?25l ⣟ Gen + +[?25h[?25l ⡿ Generati + +[?25h[?25l ⢿ Generating... + +[?25h[?25l ⣻ Generating... + +[?25h[?25l ⣽ + +[?25h[?25l  +○ Running (sleep 300) (ctrl+o to expand) +⣽ Generating... + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l Running command... + +[?25h[?25l ⣾ Running command. + +[?25h[?25lmand.. + +[?25h[?25land... + +[?25h[?25l nd + +[?25h[?25l ⣷ Running command. + +[?25h[?25l.. + +[?25h[?25l. + +[?25h[?25l ⣯ + +[?25h[?25l ● + + +[?25h[?25l ⣟ Ru + +[?25h[?25lnn + +[?25h[?25l Runnin + +[?25h[?25l ⡿ Running + +[?25h[?25l ⢿ Running comm + +[?25h[?25l ○ + command + +[?25h[?25l + + ● [14:46:49] sleep 300 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⣻ Running command.. + +[?25h[?25l ⣽ Running command... + +[?25h[?25l ⣾ Running command... + +[?25h[?25l ⣷ Run + +[?25h[?25l ⣯ Running  + +[?25h[?25l ⣟ Running comma + +[?25h[?25l ⡿ Running command... + +[?25h[?25l ⢿ Running command... + +[?25h[?25l ⣻ + +[?25h[?25l ⣽ Runn + +[?25h[?25l ⣾ Running c + +[?25h[?25l ⣷ Running comman + +[?25h[?25l ⣯ Running command... + +[?25h[?25ld... + +[?25h[?25l  + Started +⣟ Running command... + +> + + ● [14:46:49] sleep 300 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l ⡿ + +[?25h[?25l  + + + + + +? for shortcuts[?25h \ No newline at end of file diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.meta.json b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.meta.json new file mode 100644 index 00000000000..4173a380ff2 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.meta.json @@ -0,0 +1,9 @@ +{ + "capturedAt": "2026-11-08T19:48:31.841Z", + "platform": "darwin", + "command": ["agy"], + "cols": 120, + "rows": 40, + "note": "agy 1.4.11, macOS, Google account, AGY_CLI_HIDE_ACCOUNT_INFO=1; two background tasks running, turn ended at the idle composer", + "exitCode": 0 +} diff --git a/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.txt b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.txt new file mode 100644 index 00000000000..02f5f4a0c45 --- /dev/null +++ b/src/main/runtime/__fixtures__/antigravity-1-4-11-ready-two-background-tasks.txt @@ -0,0 +1,232 @@ +[>q[?2026$p[?2027$p]11;?]7501;?[>4m[?1049h[?25l[?5W[?2004h[>4;2m[>5u[?u +▄▀▀▄ +▀▀▀▀▀▀ +▀▀▀▀▀▀▀▀ + ▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + + Welcome back! You are currently not signed in. + + ⣷ Signing in...[>4m[<1u[?1049l[>4;2m[>5u[?u[0 q  +▄▀▀▄ Antigravity CLI 1.5.3 +▀▀▀▀▀▀ ~/orca-lanes/pr37732/agyws +▀▀▀▀▀▀▀▀ +▄▀▀ ▀▀▄ + ▄▀▀ ▀▀▄ + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcuts [?25h[?25l Gemini 3.8 Flash (Low) +~/orca-lanes/pr37732/agyws + + + + + + +Gemini 3.8 Flash · low [?25h[?25l M + ┃ Meet Gemini 4 Argon + ┃ Google’s most capable frontier model is now available in Antigravity. Built for complex, multi-step agentic + ┃ workflows, and deep reasoning. If it's not currently available to you, please reach out to your administrator to + ┃ enable it. + ┃ Learn more: https://docs.cloud.google.com/gemini/enterprise/docs/ai-developer-tools-settings#configure-model- + ┃ availability + ┃ esc to dismiss +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25lS[?25h[?25ltart two background tasks, "slee + + G[?25h[?25lp 301" and "sleep 302", do not wait[?25h[?25lfor them, and end your turn with the[?25h[?25l word + Started. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +Gemini 3.8 Flash · low [?25h[?25l + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low [?25h[?25l M──────────────────────────────────────────────────────────── +> Start two background tasks, "sleep 301" and "sleep 302", do not wait for them, and end your turn with the word + Started. +⣷ Generating... +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣯ + +[?25h[?25l ⣟ Gene + +[?25h[?25l ⡿ Generatin + +[?25h[?25l ⢿ Generating... + +[?25h[?25l ⣻ Generating... + +[?25h[?25l ⣽ + +[?25h[?25l ⣾ Gener + +[?25h[?25l ⣷ Generating + +[?25h[?25l ⣯ Generating... + +[?25h[?25l ⣟ Generating... + +[?25h[?25l ⡿ G + +[?25h[?25l ⢿ Genera + +[?25h[?25lenerating +└ Tip: Use /settings to configure your environment. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣻ Generating. + + +[?25h[?25l ⣽ Generating... + + +[?25h[?25l  +● Running (sleep 301) (ctrl+o to expand) +⣽ Generating... +└ Tip: Use /settings to configure your environment. + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25l ⣾ + + +[?25h[?25l ○ + Gen + + +[?25h[?25l ⣷ + + +[?25h[?25lner + + +[?25h[?25lan (sleep 301) +○ Running (sleep 302) (ctrl+o to expand) +⣷ Running command... +└ Tip: Use /settings to configure your environment. +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low [?25h[?25lunn + + +[?25h[?25l ⣯ Runn + + +[?25h[?25lin + + +[?25h[?25l Running  + + +[?25h[?25l ⣟ + + +[?25h[?25lning co + + +[?25h[?25l ⡿ Running comman + + +[?25h[?25l ⢿ Running command... + + +[?25h[?25l ⣻ Running command... + + +[?25h[?25l ⣽ + + +[?25h[?25l + + ● [14:47:49] sleep 301 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 1 task(s) · /tasks [?25h[?25l Runn + + +[?25h[?25l ⣾ Runn + + +[?25h[?25l ⣷ Running c + + +[?25h[?25l ⣯ Running comman + + +[?25h[?25l ⣟ Running command... + + +[?25h[?25l ⡿ Running command... + + +[?25h[?25l + +50] sleep 302 + ● [14:47:49] sleep 301 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 2 task(s) · /tasks [?25h[?25l ⢿ R + + +[?25h[?25l ⣻ Runnin + + +[?25h[?25l ⣽ Running com + + +[?25h[?25l ⣾ Running command + + +[?25h[?25l ⣷ Running command... + + +[?25h[?25l ⣯ Running command... + + +[?25h[?25l ⣟ Ru + + +[?25h[?25l ⡿ Running + + +[?25h[?25l ⢿ Running comm + + +[?25h[?25l ⣻ Running command.. + + +[?25h[?25l ⣽ Running command... + + +[?25h[?25l  + Started. +⣽ Running command... +└ Tip: Use /settings to configure your environment. + +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:47:50] sleep 302 running + ● [14:47:49] sleep 301 running +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +esc to cancelGemini 3.8 Flash · low · 2 task(s) · /tasks [?25h[?25l ⣾ + + +[?25h[?25l + + + + + +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +> +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── + ● [14:47:50] sleep 302 running +49] sleep 301 +──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +? for shortcutsGemini 3.8 Flash · low · 2 task(s) · /tasks [?25h \ No newline at end of file diff --git a/src/main/runtime/agent-state-rules/antigravity-background-task-rules.test.ts b/src/main/runtime/agent-state-rules/antigravity-background-task-rules.test.ts new file mode 100644 index 00000000000..408195ec75e --- /dev/null +++ b/src/main/runtime/agent-state-rules/antigravity-background-task-rules.test.ts @@ -0,0 +1,32 @@ +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import { describe, expect, it } from 'vitest' +import { HeadlessEmulator } from '../../daemon/emulation/headless-emulator' +import { visibleNonBlankTerminalLines } from '../terminal/output/tail/terminal-tail-read' +import { evaluateAgentStateRules } from './agent-state-rules-engine' + +async function verdictFor(fixture: string) { + const emulator = new HeadlessEmulator({ cols: 120, rows: 40 }) + await emulator.write( + readFileSync(join(__dirname, '..', '__fixtures__', `${fixture}.txt`), 'utf8') + ) + const lines = visibleNonBlankTerminalLines(emulator.getVisibleLines()) + emulator.dispose() + return evaluateAgentStateRules('antigravity', { readScreenLines: () => lines }) +} + +describe('antigravity composer with background task rows', () => { + it.each([ + 'antigravity-1-4-11-ready-background-task', + 'antigravity-1-4-11-ready-two-background-tasks' + ])('reads %s as a strong idle composer', async (fixture) => { + expect(await verdictFor(fixture)).toMatchObject({ state: 'idle', strength: 'strong' }) + }) + + it.each([ + 'antigravity-1-4-11-busy-with-background-task', + 'antigravity-1-4-11-draft-with-background-task' + ])('holds %s', async (fixture) => { + expect(await verdictFor(fixture)).toMatchObject({ state: 'hold' }) + }) +}) diff --git a/src/main/runtime/agent-state-rules/antigravity.json b/src/main/runtime/agent-state-rules/antigravity.json index 39b055db75a..24e31b40fa6 100644 --- a/src/main/runtime/agent-state-rules/antigravity.json +++ b/src/main/runtime/agent-state-rules/antigravity.json @@ -26,6 +26,28 @@ }, "answer": { "state": "idle", "strength": "strong", "requiresQuiet": true } }, + { + "id": "composer_ready_background_tasks", + "why": "agy 1.4 lists running background tasks (`● [14:12:56] sleep 900 running`) under the composer, closed by another rule above the hint row, so the composer is no longer in the bottom four rows. The hint row still decides as in composer_ready: a turn's own foreground command is listed the same way, but the hint then reads `esc to cancel`. One task row is required so the rule cannot collapse onto composer_ready's rows; more than six tasks reads as not shown.", + "priority": 490, + "when": { + "region": "screen", + "rows": [ + { "regex": "^─{8,}$" }, + { "regex": "^>$|^>\\s+[a-z][a-z-]*\\s+mode:\\s", "ignoreCase": true }, + { "regex": "^─{8,}$" }, + { "optional": { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" } }, + { "optional": { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" } }, + { "optional": { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" } }, + { "optional": { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" } }, + { "optional": { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" } }, + { "regex": "^●\\s+\\[\\d{1,2}:\\d{2}:\\d{2}\\]\\s+\\S" }, + { "regex": "^─{8,}$" }, + { "regex": "^\\? for shortcuts", "ignoreCase": true } + ] + }, + "answer": { "state": "idle", "strength": "strong", "requiresQuiet": true } + }, { "id": "composer_ready_custom_status_line", "why": "A custom statusLine replaces the hint row, so `esc to cancel` never shows; agy 1.5.2 then marks a turn only with a braille spinner row above the composer. Status rows may not hold a rule run, a hint, or agy's own `[mode · ]model · effort` footer, which drops its hint while the composer holds a draft. Pickers between the composer and status rows break the run. A custom row shaped like that footer holds; a mode-shaped draft above a custom statusLine still reads idle.", diff --git a/src/main/runtime/terminal/output/headless-terminal-state.ts b/src/main/runtime/terminal/output/headless-terminal-state.ts index 51f41c159c3..6df5db366d7 100644 --- a/src/main/runtime/terminal/output/headless-terminal-state.ts +++ b/src/main/runtime/terminal/output/headless-terminal-state.ts @@ -221,6 +221,13 @@ export abstract class OrcaRuntimeWithCreatePtyHeadlessTerminalState extends Orca }) } + /** A resize the PTY took before this mirror existed: the TUI repaints for it, so unlike a reflow it leaves the grid readable. */ + resizeHeadlessTerminalToPtyGrid(ptyId: string, cols: number, rows: number): void { + if (cols > 0 && rows > 0) { + this.resizeHeadlessTerminal(ptyId, cols, rows) + } + } + /** Reflow to provider-proven size after early live bytes used default geometry; preserve renderer restore baselines because no pane was measured. */ reflowHeadlessTerminalToPtyGrid(ptyId: string, cols: number, rows: number): void { if (cols <= 0 || rows <= 0) { diff --git a/src/main/runtime/terminal/output/terminal-buffer-operations.ts b/src/main/runtime/terminal/output/terminal-buffer-operations.ts index 102523d2eff..a1260a785f3 100644 --- a/src/main/runtime/terminal/output/terminal-buffer-operations.ts +++ b/src/main/runtime/terminal/output/terminal-buffer-operations.ts @@ -15,8 +15,12 @@ import { import { hookLeadTurnState } from '../wait/tui-idle-hook-lane' import { agentHookServer } from '../../../agent-hooks/server/agent-hook-server' +import { restoreFromReattachedReadyScreen } from '../wait/reattached-ready-screen' +import type { RuledScreen } from '../wait/screen-input-veto' +import type { AgentStatus } from '../../../../shared/agent-status/title/agent-title-core' export abstract class OrcaRuntimeWithSerializeMainTerminalBuffer extends OrcaRuntimeWithNotifyRemoteTerminalViewPresenceChanged { + protected abstract readCaughtUpRuledScreen(ptyId: string): RuledScreen | null protected abstract serializePreferredRestoredTerminalBuffer( ptyId: string, opts?: { scrollbackRows?: number } @@ -246,7 +250,8 @@ export abstract class OrcaRuntimeWithSerializeMainTerminalBuffer extends OrcaRun /** A surviving process main never saw live still has its agent's last own report, which the hook * server restores across restarts. Nothing can type into the terminal while main is down, so the - * report is current as long as an agent, not a shell, still holds the process. */ + * report is current as long as an agent, not a shell, still holds the process. Without a report, + * a screen-ruled agent's own strong ready screen speaks for it: such agents may write no title at rest. */ restoreReattachedAgentStatus(ptyId: string): void { const pty = this.ptysById.get(ptyId) if (!pty?.connected || pty.lastAgentStatusObservedLive) { @@ -254,31 +259,44 @@ export abstract class OrcaRuntimeWithSerializeMainTerminalBuffer extends OrcaRun } const { incarnationId } = pty const generation = this.getPtyLifecycleGeneration(ptyId) + // A respawn, an exit or a live report since the reattach decides instead. + const isCurrent = (): boolean => + this.ptysById.get(ptyId) === pty && + pty.incarnationId === incarnationId && + this.getPtyLifecycleGeneration(ptyId) === generation && + pty.connected && + !pty.lastAgentStatusObservedLive const paneKeys = [...this.collectAgentStatusPaneKeysForPty(ptyId)] void Promise.all([ this.ptyForegroundAgent.identifyForeground(ptyId), + // Why: the ready-screen read needs the seeded snapshot applied. + this.headlessTerminals.get(ptyId)?.writeChain, ...paneKeys.map((paneKey) => agentHookServer.readRestoredAgentStatus(paneKey)) - ]).then(([agent, ...reports]) => { + ]).then(([agent, , ...reports]) => { const report = reports.find((candidate) => candidate !== null) const turn = agent && report ? hookLeadTurnState(report) : null - // A respawn, an exit or a live report since the reattach decides instead. - if ( - !turn || - this.ptysById.get(ptyId) !== pty || - pty.incarnationId !== incarnationId || - this.getPtyLifecycleGeneration(ptyId) !== generation || - !pty.connected || - pty.lastAgentStatusObservedLive - ) { + if (!isCurrent()) { return } - this.applyTrackedPtyTitle(ptyId, pty.lastOscTitle ?? '', pty.lastOscTitle ?? '', undefined, { - statusOnly: true, - status: turn === 'done' ? 'idle' : turn - }) + if (turn) { + this.applyReattachedAgentStatus(ptyId, turn === 'done' ? 'idle' : turn) + } else if (agent) { + restoreFromReattachedReadyScreen({ + agent, + readScreen: () => this.readCaughtUpRuledScreen(ptyId), + readOutputClockAt: () => this.readOutputClockAt(ptyId), + isCurrent, + applyIdle: () => this.applyReattachedAgentStatus(ptyId, 'idle') + }) + } }) } + private applyReattachedAgentStatus(ptyId: string, status: AgentStatus): void { + const title = this.ptysById.get(ptyId)?.lastOscTitle ?? '' + this.applyTrackedPtyTitle(ptyId, title, title, undefined, { statusOnly: true, status }) + } + protected readOutputClockAt(ptyId: string | null | undefined): number | null { const pty = ptyId ? this.ptysById.get(ptyId) : undefined return pty ? (pty.lastOutputAt ?? pty.outputObservedSince ?? null) : null diff --git a/src/main/runtime/terminal/output/terminal-title-observation.ts b/src/main/runtime/terminal/output/terminal-title-observation.ts index 9894093fe8b..6d0b0c76879 100644 --- a/src/main/runtime/terminal/output/terminal-title-observation.ts +++ b/src/main/runtime/terminal/output/terminal-title-observation.ts @@ -6,6 +6,7 @@ import { detectAgentStatusFromTitle } from '../../../../shared/agent-status/titl import { terminalTitleBlocksExplicitAgentStatus } from '../../workspaces/process-listing/runtime-worktree-status-projection' import type { ClaudeTerminalEvidence } from '../../../../shared/claude-terminal-interrupt' import { agentStatusTakesTypedInput } from '../../orchestration/mailbox/routing/mailbox-owner' +import { hermesNativeTitleStatus } from '../../../../shared/agent-status/title/providers/hermes-terminal-title' export abstract class OrcaRuntimeWithApplyTrackedPtyTitle extends OrcaRuntimeWithGetUnpersistedTrackedTitleForPty { protected abstract collectPaneKeysForPty(ptyId: string): Set @@ -54,6 +55,7 @@ export abstract class OrcaRuntimeWithApplyTrackedPtyTitle extends OrcaRuntimeWit protected classifyPtyTitleStatus(ptyId: string, rawTitle: string): AgentStatus | null { return ( this.ptyTitleTrackersByPtyId.get(ptyId)?.programActivity ?? + hermesNativeTitleStatus(rawTitle, this.getPaneTerminalAgent(ptyId)) ?? detectAgentStatusFromTitle(rawTitle) ) } diff --git a/src/main/runtime/terminal/wait/reattached-ready-screen.ts b/src/main/runtime/terminal/wait/reattached-ready-screen.ts new file mode 100644 index 00000000000..f4703af0706 --- /dev/null +++ b/src/main/runtime/terminal/wait/reattached-ready-screen.ts @@ -0,0 +1,71 @@ +import type { TerminalAgent } from '../../../../shared/agent-status/identity/terminal-agent' +import { isTuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent-config' +import { + evaluateAgentStateRules, + readsTrustedScreen +} from '../../agent-state-rules/agent-state-rules-engine' +import type { RuledScreen } from './screen-input-veto' +import { TUI_IDLE_QUIESCENCE_MS } from './terminal-idle-policy' + +/** Long enough for a renderer's resize repaint and a redraw-interrupted quiet window. */ +const RECHECK_WINDOW_MS = 60_000 + +type ReattachedReadyScreen = { kind: 'idle' } | { kind: 'recheck'; afterMs: number } | null + +/** Whether a reattached agent's own strong ready rule holds on its trusted grid. Only agents whose + * rules read that grid qualify; a grid not yet readable or a quiet window still owed asks for a + * recheck, and anything else (busy, draft, dialog, unknown screen) answers nothing. */ +function readReattachedReadyScreen( + agent: TerminalAgent | null, + screen: RuledScreen | null, + outputClockAt: number | null +): ReattachedReadyScreen { + if (!isTuiAgent(agent) || !readsTrustedScreen(agent)) { + return null + } + if (!screen) { + return { kind: 'recheck', afterMs: TUI_IDLE_QUIESCENCE_MS } + } + const verdict = evaluateAgentStateRules(agent, { readScreenLines: () => screen.lines }) + if (verdict?.state !== 'idle' || verdict.strength !== 'strong') { + return null + } + const quietRemainingMs = + outputClockAt === null + ? TUI_IDLE_QUIESCENCE_MS + : TUI_IDLE_QUIESCENCE_MS - (Date.now() - outputClockAt) + return !verdict.requiresQuiet || quietRemainingMs <= 0 + ? { kind: 'idle' } + : { kind: 'recheck', afterMs: quietRemainingMs + 50 } +} + +export type ReattachedReadyScreenRestore = { + agent: TerminalAgent + readScreen: () => RuledScreen | null + readOutputClockAt: () => number | null + /** False once a respawn, exit or live status decides instead. */ + isCurrent: () => boolean + applyIdle: () => void +} + +/** Give a reattached agent idle when its ready screen holds, rechecking within a bounded window. */ +export function restoreFromReattachedReadyScreen( + restore: ReattachedReadyScreenRestore, + recheckUntil = Date.now() + RECHECK_WINDOW_MS +): void { + const ready = readReattachedReadyScreen( + restore.agent, + restore.readScreen(), + restore.readOutputClockAt() + ) + if (ready?.kind === 'idle') { + restore.applyIdle() + } else if (ready?.kind === 'recheck' && Date.now() < recheckUntil) { + const recheck = (): void => { + if (restore.isCurrent()) { + restoreFromReattachedReadyScreen(restore, recheckUntil) + } + } + setTimeout(recheck, ready.afterMs).unref?.() + } +} diff --git a/src/shared/agent-status/title/providers/hermes-terminal-title.test.ts b/src/shared/agent-status/title/providers/hermes-terminal-title.test.ts new file mode 100644 index 00000000000..fcc3caab0fb --- /dev/null +++ b/src/shared/agent-status/title/providers/hermes-terminal-title.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from 'vitest' +import { hermesNativeTitleStatus } from './hermes-terminal-title' + +describe('Hermes native session title markers', () => { + it.each([ + ['hermes', '✓ Run Orca dispatched worker … · grok-4.7 · ~/workspace', 'idle'], + ['hermes', '⏳ Ready to deploy', 'working'], + ['hermes', '⚠ Finished the changes', 'permission'], + ['hermes', '⚠️ Waiting for approval', 'permission'], + ['hermes', 'user@host: ~/workspace', null], + ['hermes', '✓not a status marker', null], + ['codex', '✓ Run Orca dispatched worker …', null], + [null, '✓ Run Orca dispatched worker …', null] + ] as const)('classifies %s title %s as %s', (agent, title, expected) => { + expect(hermesNativeTitleStatus(title, agent)).toBe(expected) + }) +}) diff --git a/src/shared/agent-status/title/providers/hermes-terminal-title.ts b/src/shared/agent-status/title/providers/hermes-terminal-title.ts new file mode 100644 index 00000000000..039966ae4cb --- /dev/null +++ b/src/shared/agent-status/title/providers/hermes-terminal-title.ts @@ -0,0 +1,21 @@ +import type { AgentStatus } from '../agent-title-core' +import type { TerminalAgent } from '../../identity/terminal-agent' + +// Hermes TUI titles lead with ⚠ (approval or question), ⏳ (busy) or ✓ (idle), then the session name. +const HERMES_TITLE_MARKER_STATUS: Record = { + '\u2713': 'idle', + '\u23F3': 'working', + '\u26A0': 'permission' +} + +/** The markers are too generic to identify Hermes, so they count only in a Hermes pane. */ +export function hermesNativeTitleStatus( + title: string, + agent: TerminalAgent | null +): AgentStatus | null { + if (agent !== 'hermes') { + return null + } + const marker = title.match(/^(\u2713|\u23F3|\u26A0)\uFE0F?(?:\s|$)/u)?.[1] + return marker ? HERMES_TITLE_MARKER_STATUS[marker] : null +}