mirror of
https://github.com/stablyai/orca.git
synced 2026-10-24 08:03:58 +00:00
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.
This commit is contained in:
@@ -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<typeof TerminalForegroundGroup>()),
|
||||
readTerminalProcessRows: vi.fn(async (): Promise<ProcessTableRow[] | null> => {
|
||||
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'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user