Repository navigation
fix(terminal): stop treating the Codex boot header as tui-idle readiness #18019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Tauri-EPO
wants to merge
2
commits into
stablyai:main
from
Tauri-EPO:Tauri-EPO/codex-ready-header-loading
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { afterEach, describe, expect, it, vi } from 'vitest' | ||
| 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' | ||
|
|
||
| vi.mock('../git/worktree', () => ({ | ||
| listWorktrees: vi.fn().mockResolvedValue([ | ||
| { | ||
| path: '/tmp/worktree-a', | ||
| head: 'abc', | ||
| branch: 'feature/codex-ready-header', | ||
| isBare: false, | ||
| isMainWorktree: false | ||
| } | ||
| ]), | ||
| listWorktreesStrict: vi.fn().mockResolvedValue([ | ||
| { | ||
| path: '/tmp/worktree-a', | ||
| head: 'abc', | ||
| branch: 'feature/codex-ready-header', | ||
| isBare: false, | ||
| isMainWorktree: false | ||
| } | ||
| ]) | ||
| })) | ||
|
|
||
| const PTY = 'pty-codex' | ||
| const BOOT_HEADER = ' >_ OpenAI Codex (v0.152.0)\n model: loading\n directory: loading\n' | ||
| const READY_HEADER = | ||
| ' >_ OpenAI Codex (v0.152.0)\n model: gpt-5.6-sol medium\n directory: /tmp/worktree-a\n' | ||
|
|
||
| async function createCodexTerminal(): Promise<{ runtime: OrcaRuntimeService; handle: string }> { | ||
| const runtime = new OrcaRuntimeService(makeStore() as never) | ||
| runtime.setPtyController({ | ||
| spawn: async () => ({ id: PTY }), | ||
| write: () => true, | ||
| kill: () => true, | ||
| getForegroundProcess: async () => null | ||
| }) | ||
| const terminal = await runtime.createTerminal(`path:${AGENT_PROMPT_TEST_WORKTREE_PATH}`, { | ||
| launchAgent: 'codex' | ||
| }) | ||
| return { runtime, handle: terminal.handle } | ||
| } | ||
|
|
||
| describe('tui-idle and the Codex boot header', () => { | ||
| afterEach(() => vi.useRealTimers()) | ||
|
|
||
| // Why: worker-start pastes as soon as tui-idle resolves; on this header Codex is still booting | ||
| // and the paste lands scrambled on the splash screen or parks unsubmitted. | ||
| it('does not treat a header still loading its model and directory as ready', async () => { | ||
| vi.useFakeTimers() | ||
| const { runtime, handle } = await createCodexTerminal() | ||
| runtime.onPtyData(PTY, BOOT_HEADER, Date.now()) | ||
|
|
||
| const wait = runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 1_000 }) | ||
| const rejected = expect(wait).rejects.toThrow('timeout') | ||
| await vi.advanceTimersByTimeAsync(3_000) | ||
|
|
||
| await rejected | ||
| }) | ||
|
|
||
| it('treats the header as ready once the model and directory are settled', async () => { | ||
| const { runtime, handle } = await createCodexTerminal() | ||
| runtime.onPtyData(PTY, BOOT_HEADER, Date.now()) | ||
| runtime.onPtyData(PTY, READY_HEADER, Date.now()) | ||
|
|
||
| await expect( | ||
| runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 1_000 }) | ||
| ).resolves.toMatchObject({ condition: 'tui-idle', status: 'running' }) | ||
| }) | ||
|
|
||
| it('does not treat a header whose values have not arrived yet as ready', async () => { | ||
| vi.useFakeTimers() | ||
| const { runtime, handle } = await createCodexTerminal() | ||
| runtime.onPtyData(PTY, ' >_ OpenAI Codex (v0.152.0)\n model:\n directory:\n', Date.now()) | ||
|
|
||
| const wait = runtime.waitForTerminal(handle, { condition: 'tui-idle', timeoutMs: 1_000 }) | ||
| const rejected = expect(wait).rejects.toThrow('timeout') | ||
| await vi.advanceTimersByTimeAsync(3_000) | ||
|
|
||
| await rejected | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.