From 193eeaddff3a56286f17e70a58e2d8b8b3598a0b Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Fri, 2 Oct 2026 07:57:46 -0700 Subject: [PATCH] test(orchestration): read a launch's foreground through the pane's own terminal #24257's read now takes the pane's root pid from the session inventory and one ps limited to its terminal, so the launch-observation tests fake those rows instead of the whole-machine scan the read no longer uses. --- .../orca-runtime-launch-turn-start.test.ts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/runtime/orca-runtime-launch-turn-start.test.ts b/src/main/runtime/orca-runtime-launch-turn-start.test.ts index 1bc22b36671..7f7a9267aef 100644 --- a/src/main/runtime/orca-runtime-launch-turn-start.test.ts +++ b/src/main/runtime/orca-runtime-launch-turn-start.test.ts @@ -3,6 +3,8 @@ import type { AgentStatusIpcPayload } from '../../shared/agent-status-types' import { AGENT_PROMPT_TEST_WORKTREE_PATH } from './agent-prompt-submission-runtime-test-fixture' import { OrcaRuntimeService } from './orca-runtime' import { makeStore } from './runtime-rpc-worktree-store-fixtures' +import type { ProcessTableRow } from '../../shared/process-table-snapshot' +import type * as TerminalForegroundGroup from './terminal-foreground-group' const { WORKTREE } = vi.hoisted(() => ({ WORKTREE: { @@ -14,6 +16,30 @@ const { WORKTREE } = vi.hoisted(() => ({ } })) +// What `ps` limited to the pane's terminal answers: a login-wrapped zsh whose terminal's foreground +// group is the shell itself, or the named process launched from it. The verdict stays the real one. +const paneForeground = vi.hoisted(() => { + const state: { command: string | null } = { command: null } + return state +}) +vi.mock('./terminal-foreground-group', async (importOriginal) => ({ + ...(await importOriginal()), + readTerminalProcessRows: vi.fn(async (): Promise => { + const command = paneForeground.command + if (command === null) { + return null + } + const group = command === 'zsh' ? 101 : 102 + return [ + { pid: 100, ppid: 1, pgid: 100, tpgid: group, stat: 'Ss', command: '/usr/bin/login -flpq u' }, + { pid: 101, ppid: 100, pgid: 101, tpgid: group, stat: 'S', command: '-zsh' }, + ...(command === 'zsh' + ? [] + : [{ pid: 102, ppid: 101, pgid: 102, tpgid: group, stat: 'S+', command }]) + ] + }) +})) + vi.mock('../git/worktree', () => ({ listWorktrees: vi.fn().mockResolvedValue([WORKTREE]), listWorktreesStrict: vi.fn().mockResolvedValue([WORKTREE]) @@ -33,8 +59,11 @@ async function launchedCodex( write: () => true, kill: () => true, getForegroundProcess: async () => null, - confirmForegroundProcess: async () => options.foreground?.() ?? null + listProcesses: async () => [ + { id: 'pty-launch', rootProcessId: 100, cwd: '/tmp/worktree-a', title: 'zsh' } + ] }) + paneForeground.command = options.foreground?.() ?? null const { handle } = await runtime.createTerminal(`path:${AGENT_PROMPT_TEST_WORKTREE_PATH}`, { launchAgent: 'codex' })