From f5bc8ff306bc477c47be1f422729f9581180ceb6 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 27 Aug 2026 15:12:47 -0700 Subject: [PATCH] fix(runtime): demote completed hook identity evidence --- ...ntime-hook-agent-status-projection.test.ts | 19 ++++++++++++++++++- src/main/runtime/orca-runtime.ts | 6 +++++- .../pane-agent-identity-inventory.test.ts | 5 ----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts b/src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts index 11b9fc97afd..f8171862728 100644 --- a/src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts +++ b/src/main/runtime/orca-runtime-hook-agent-status-projection.test.ts @@ -61,7 +61,8 @@ async function createRuntimeWithHookRows( rows: AgentStatusIpcPayload[] ): Promise { const runtime = new OrcaRuntimeService(null, undefined, { - getAgentStatusSnapshot: () => rows + getAgentStatusSnapshot: () => rows, + getAgentProviderSessionRowsForPane: () => rows }) const internals = runtime as unknown as { resolveTerminalWorkspaceLaunchScope: (selector: string) => Promise @@ -115,6 +116,22 @@ function lastOscTitleEpochMs(runtime: OrcaRuntimeService): number { } describe('headless hook agent-status projection (#11761)', () => { + it('ranks a completed hook below present launch evidence in terminal identity', async () => { + const runtime = await createRuntimeWithHookRows([ + hookRow({ + agentType: 'codex', + state: 'done', + prompt: '', + toolName: undefined, + interactivePrompt: undefined + }) + ]) + + expect((await runtime.listTerminals()).terminals).toEqual([ + expect.objectContaining({ agentIdentity: 'claude' }) + ]) + }) + it('carries the hook state, tool and interactivePrompt to paired clients', async () => { const agentStatus = await projectAgentStatus([hookRow()]) diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 645fb4a41fe..d19e3ec9c3b 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -33969,7 +33969,7 @@ export class OrcaRuntimeService { const hookAgent = isTuiAgent(hookRow?.agentType) ? hookRow.agentType : null const agentIdentity = resolvePublishedPaneAgentIdentity({ hookAgent, - hookIsLive: hookRow?.live != null, + hookIsLive: hookRow?.agentIsLive, launchAgent, foregroundAgent, title @@ -35227,6 +35227,7 @@ export class OrcaRuntimeService { providerSessionAgentType: string | null providerSessionReceivedAt: number | null agentType: string | null + agentIsLive: boolean live: HookLiveAgentRow | null } { let session: AgentStatusIpcPayload | null = null @@ -35267,6 +35268,9 @@ export class OrcaRuntimeService { providerSessionAgentType: session?.agentType ?? null, providerSessionReceivedAt: session?.receivedAt ?? null, agentType: agent?.agentType ?? null, + // A fresh completed row still projects its terminal `done` status, but it is + // past-tense identity evidence and must not outrank process or launch facts. + agentIsLive: agent != null && agent.state !== 'done', live: live ? { payload: pickParsedAgentStatusPayload(live), diff --git a/src/shared/pane-agent-identity-inventory.test.ts b/src/shared/pane-agent-identity-inventory.test.ts index 730c6b0ce05..c7ed23bb41a 100644 --- a/src/shared/pane-agent-identity-inventory.test.ts +++ b/src/shared/pane-agent-identity-inventory.test.ts @@ -123,11 +123,6 @@ const INVENTORY: readonly InventoryGroup[] = [ classification: 'evidence-producer', paths: [['src/renderer/src/hooks/ipc-events/agent-status-routing.ts', 2]] }, - { - helper: 'buildAgentNameRe', - classification: 'action-consumer', - paths: [['src/main/runtime/orchestration/groups.ts', 2]] - }, { helper: 'buildAgentNameRe', classification: 'parser-implementation',