From 9cb56ebc4cf324278efaa862bc8b7115a70e593b Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:31:07 -0800 Subject: [PATCH] test(e2e): wait for the shell-ready deadline after a startup exec (#39203) * test(e2e): wait for the shell-ready deadline after a startup exec Since #30978 the terminal host no longer probes for a prompt when a profile exec drops Orca's ready marker; it submits the startup command once at the 15 s shell-ready deadline. The oracle allowed only 8 s, so the headless serve case failed unless the exec barrier happened to run long. Wait until that deadline (measured from terminal creation) plus the recovery budget, and route the spec from the shell-ready barrier and shell startup sources. * ci(e2e): route the startup-exec oracle helper to its spec --- .../pr-e2e-gate-contract.test.mjs | 17 +++++++++++++++++ .../pr-feature-area-e2e-source-routes.mjs | 12 ++++++++++++ .../helpers/startup-exec-readiness-oracle.ts | 13 ++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs b/config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs index 659e55c2e1e..4571e0de4c8 100644 --- a/config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs +++ b/config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs @@ -175,6 +175,23 @@ describe('runtime host status E2E routing', () => { }) }) +describe('startup exec readiness E2E routing', () => { + const spec = 'tests/e2e/paired-startup-exec-readiness.spec.ts' + it.each([ + 'src/main/daemon/sessions/session-shell-ready-barrier.ts', + 'src/main/daemon/shell-readiness/post-ready-flush-gate.ts', + 'src/main/pty/shell-startup/shell-templates.ts', + 'tests/e2e/helpers/startup-exec-readiness-oracle.ts' + ])('routes %s', (path) => { + expect(selectPrE2eSpecs([path])).toContain(spec) + }) + it('does not route unit tests of those sources', () => { + expect( + selectPrE2eSpecs(['src/main/daemon/shell-readiness/testing/shell-ready.test.ts']) + ).not.toContain(spec) + }) +}) + describe('agent descendant kill E2E routing', () => { const spec = 'tests/e2e/agent-descendant-process-kill.spec.ts' it.each([ diff --git a/config/scripts/workflow/source-routing/pr-feature-area-e2e-source-routes.mjs b/config/scripts/workflow/source-routing/pr-feature-area-e2e-source-routes.mjs index 2865a03a2cf..d2f90259a48 100644 --- a/config/scripts/workflow/source-routing/pr-feature-area-e2e-source-routes.mjs +++ b/config/scripts/workflow/source-routing/pr-feature-area-e2e-source-routes.mjs @@ -155,5 +155,17 @@ export const PR_FEATURE_AREA_E2E_SOURCE_ROUTES = [ 'src/shared/remote-runtime/host-store/runtime-environment-store.ts', `${COMPONENTS}sidebar/workspace-card/identity/worktree-card-header-items.tsx` ] + ), + featureRoute( + 'feature.startup-exec-readiness', + ['paired-startup-exec-readiness'], + [ + 'src/main/daemon/sessions/session-shell-ready-barrier.ts', + 'src/main/daemon/shell-readiness/', + 'src/main/pty/shell-startup/shell-prompt-readiness-probe.ts', + 'src/main/pty/shell-startup/shell-startup-output-scanner.ts', + 'src/main/pty/shell-startup/shell-templates.ts', + 'tests/e2e/helpers/startup-exec-readiness-oracle.ts' + ] ) ] diff --git a/tests/e2e/helpers/startup-exec-readiness-oracle.ts b/tests/e2e/helpers/startup-exec-readiness-oracle.ts index b48f37cd753..e473610f490 100644 --- a/tests/e2e/helpers/startup-exec-readiness-oracle.ts +++ b/tests/e2e/helpers/startup-exec-readiness-oracle.ts @@ -13,8 +13,11 @@ import { readFreshTerminalInventory } from './terminal-inventory-observation' import { quotePosixShell } from '../../../src/shared/shell/launch/shell-argument-quoting' const RECOVERY_DEADLINE_MS = 8_000 +// The host's shell-ready deadline (SHELL_READY_TIMEOUT_MS): a profile exec drops the ready marker, so the command waits for it. +const SHELL_READY_DEADLINE_MS = 15_000 export type StartupExecTerminal = { + createdAtMs: number hostPtyId: string panePtyId: string parentTabId: string @@ -150,6 +153,7 @@ export async function createStartupExecTerminal( `printf '%s|%s\\n' "$$" "$(tty)" > ${quotePosixShell(ledgerPath)}`, markerCommand(startupMarker) ].join('; ') + const createdAtMs = Date.now() const created = await callStartupExecRuntime<{ tab: { parentTabId: string; terminal: string | null } }>(page, 'session.tabs.createTerminal', { @@ -191,6 +195,7 @@ export async function createStartupExecTerminal( shown.terminal.ptyId ) return { + createdAtMs, hostPtyId: shown.terminal.ptyId, panePtyId, parentTabId: created.tab.parentTabId, @@ -214,8 +219,14 @@ export async function expectStartupExecRecovery( created: StartupExecTerminal, runId: string ): Promise { + const shellReadyDeadlineRemainingMs = Math.max( + 0, + created.createdAtMs + SHELL_READY_DEADLINE_MS - Date.now() + ) await expect - .poll(() => readTerminal(page, created.terminal), { timeout: RECOVERY_DEADLINE_MS }) + .poll(() => readTerminal(page, created.terminal), { + timeout: shellReadyDeadlineRemainingMs + RECOVERY_DEADLINE_MS + }) .toMatchObject({ tail: expect.arrayContaining([expect.stringContaining(created.startupMarker)]) })