fix(runtime): demote completed hook identity evidence

This commit is contained in:
Brennan Benson
2026-08-27 15:12:47 -07:00
parent 400cf16d22
commit f5bc8ff306
3 changed files with 23 additions and 7 deletions
@@ -61,7 +61,8 @@ async function createRuntimeWithHookRows(
rows: AgentStatusIpcPayload[]
): Promise<OrcaRuntimeService> {
const runtime = new OrcaRuntimeService(null, undefined, {
getAgentStatusSnapshot: () => rows
getAgentStatusSnapshot: () => rows,
getAgentProviderSessionRowsForPane: () => rows
})
const internals = runtime as unknown as {
resolveTerminalWorkspaceLaunchScope: (selector: string) => Promise<unknown>
@@ -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()])
+5 -1
View File
@@ -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),
@@ -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',