From aae223a28f1846ad6f124fc88fdf62c60228f63c Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 6 Aug 2026 17:33:44 -0700 Subject: [PATCH] test(agent-launch): consume the shared readiness budget instead of restating it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hardcoding 20000 in the runtime waiter test meant it would keep passing if OrcaRuntimeService stopped consuming draftPasteReadyBudgetMs — the exact drift this PR exists to prevent. The literal values stay pinned once, in the scanner test. --- .../runtime/startup-draft-paste-readiness.test.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/runtime/startup-draft-paste-readiness.test.ts b/src/main/runtime/startup-draft-paste-readiness.test.ts index 01dd2c66fa9..d1068af7a35 100644 --- a/src/main/runtime/startup-draft-paste-readiness.test.ts +++ b/src/main/runtime/startup-draft-paste-readiness.test.ts @@ -6,13 +6,18 @@ * scanner, the shared budget, and the fallback are all exercised. */ import { beforeEach, afterEach, describe, expect, it, vi, type Mock } from 'vitest' +import { draftPasteReadyBudgetMs } from '../../shared/draft-paste-ready-scanner' import { OrcaRuntimeService } from './orca-runtime' const DECSET_BRACKETED_PASTE = '\x1b[?2004h' const CODEX_COMPOSER_PROMPT_RENDER = '\x1b[1m›\x1b[0m Ask Codex to do anything' const PTY_ID = 'pty-1' const HANDLE = 'term-1' -const CODEX_MARKER_BUDGET_MS = 20000 +// Why: pull the budgets from the shared policy rather than restating them, so +// this fails if the runtime waiter ever stops consuming it. The literal values +// are pinned once, in draft-paste-ready-scanner.test.ts. +const CODEX_MARKER_BUDGET_MS = draftPasteReadyBudgetMs('codex-composer-prompt') +const QUIET_WINDOW_BUDGET_MS = draftPasteReadyBudgetMs('render-quiet-after-bracketed-paste') type RuntimeHost = { getLivePtyForHandle: (handle: string) => { pty: { ptyId: string } } | null @@ -80,13 +85,13 @@ describe('waitForStartupDraftReady', () => { await Promise.resolve() observer?.(DECSET_BRACKETED_PASTE) - // The old 8s budget would already have resolved (to null) here. - await vi.advanceTimersByTimeAsync(8000) + // The old markerless-length budget would already have resolved (to null) here. + await vi.advanceTimersByTimeAsync(QUIET_WINDOW_BUDGET_MS) expect(getForegroundProcess).not.toHaveBeenCalled() // Still inside the marker budget: a late glyph is the real ready proof, and // must win over the ownership fallback. - await vi.advanceTimersByTimeAsync(CODEX_MARKER_BUDGET_MS - 8000 - 1) + await vi.advanceTimersByTimeAsync(CODEX_MARKER_BUDGET_MS - QUIET_WINDOW_BUDGET_MS - 1) observer?.(CODEX_COMPOSER_PROMPT_RENDER) await expect(promise).resolves.toBe(PTY_ID) expect(getForegroundProcess).not.toHaveBeenCalled()