From c07f7d00b2d8f8f25e87b52f602eb70b8d2a9cb1 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 20 Sep 2026 02:48:37 -0700 Subject: [PATCH] fix(antigravity): bind native hook screen evidence to runtime terminal --- .../server-ingest-antigravity-screen.test.ts | 20 +++++++++++++++++++ .../server-ingest-antigravity-screen.ts | 5 +++-- ...ravity-command-approval-transcript.test.ts | 1 - .../orca-runtime-visible-snapshot-preview.ts | 10 ++++++---- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/main/agent-hooks/server-ingest-antigravity-screen.test.ts b/src/main/agent-hooks/server-ingest-antigravity-screen.test.ts index 5df0be3091f..a2910d26e6e 100644 --- a/src/main/agent-hooks/server-ingest-antigravity-screen.test.ts +++ b/src/main/agent-hooks/server-ingest-antigravity-screen.test.ts @@ -124,3 +124,23 @@ describe('host-owned Antigravity screen permission', () => { expect(baseline(server).observation).toEqual(waiting.observation) }) }) + +it('accepts the runtime-attested binding absent from a native hook row', () => { + const server = new AgentHookServer() + server.ingestTerminalStatus({ + paneKey: PANE, + payload: { state: 'working', agentType: 'antigravity', prompt: 'print marker' } + }) + const row = baseline(server) + expect(row.terminalHandle).toBeUndefined() + expect(server.ingestAntigravityScreenPermission({ baseline: row, command: 'echo OK' })).toBe( + false + ) + expect( + server.ingestAntigravityScreenPermission({ + baseline: { ...row, terminalHandle: 'term-runtime' }, + command: 'echo OK' + }) + ).toBe(true) + expect(baseline(server)).toMatchObject({ state: 'waiting', terminalHandle: 'term-runtime' }) +}) diff --git a/src/main/agent-hooks/server/server-ingest-antigravity-screen.ts b/src/main/agent-hooks/server/server-ingest-antigravity-screen.ts index 8a595e3f191..2564234724f 100644 --- a/src/main/agent-hooks/server/server-ingest-antigravity-screen.ts +++ b/src/main/agent-hooks/server/server-ingest-antigravity-screen.ts @@ -24,7 +24,8 @@ export abstract class AgentHookServerIngestAntigravityScreen extends AgentHookSe previous.connectionId || previous.payload.agentType !== 'antigravity' || !baseline.terminalHandle || - previous.terminalHandle !== baseline.terminalHandle || + (previous.terminalHandle !== undefined && + previous.terminalHandle !== baseline.terminalHandle) || !expected || !current || current.authorityId !== expected.authorityId || @@ -62,7 +63,7 @@ export abstract class AgentHookServerIngestAntigravityScreen extends AgentHookSe tabId: previous.tabId, worktreeId: previous.worktreeId, connectionId: previous.connectionId, - terminalHandle: previous.terminalHandle, + terminalHandle: baseline.terminalHandle, providerSession: previous.providerSession, payload: { ...previous.payload, diff --git a/src/main/runtime/antigravity-command-approval-transcript.test.ts b/src/main/runtime/antigravity-command-approval-transcript.test.ts index bb107a45734..a88cb7882fe 100644 --- a/src/main/runtime/antigravity-command-approval-transcript.test.ts +++ b/src/main/runtime/antigravity-command-approval-transcript.test.ts @@ -60,7 +60,6 @@ it('publishes the captured permission and cancellation to the canonical hook sto } wiring.statusStore.ingestTerminalStatus({ paneKey, - terminalHandle: handle, payload: { state: 'working', agentType: 'antigravity', diff --git a/src/main/runtime/orca-runtime-visible-snapshot-preview.ts b/src/main/runtime/orca-runtime-visible-snapshot-preview.ts index 4a316377166..44385ba13a5 100644 --- a/src/main/runtime/orca-runtime-visible-snapshot-preview.ts +++ b/src/main/runtime/orca-runtime-visible-snapshot-preview.ts @@ -23,11 +23,13 @@ export class OrcaRuntimeWithVisibleSnapshotPreview extends OrcaRuntimeWithCaptur if (!pty?.connected || pty.connectionId || !pty.paneKey) { return null } - return ( - this.getAgentProviderSessionRowsForPaneFn?.(pty.paneKey)?.find( - (row) => row.providerSessionOnly !== true && row.agentType === 'antigravity' - ) ?? null + const terminalHandle = this.getAgentStatusTerminalHandleForPaneKey(pty.paneKey) + const row = this.getAgentProviderSessionRowsForPaneFn?.(pty.paneKey)?.find( + (candidate) => + candidate.providerSessionOnly !== true && candidate.agentType === 'antigravity' ) + // Native hooks identify the pane; the runtime owns its live terminal binding. + return row && terminalHandle ? { ...row, terminalHandle } : null }, readScreen: (ptyId) => this.readVisibleTerminalState(ptyId), isCurrent: (ptyId, screen) =>