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)]) })