Skip to content

fix(orchestration): wait for Codex composer render - #14575

Merged
Jinwoo-H merged 1 commit into
mainfrom
bug-strange-behavior-i-think-when-using-orchestr
Aug 14, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
bug-strange-behavior-i-think-when-using-orchestr

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

ELI5

Orca pasted orchestration tasks into Codex or Claude and then pressed Enter after a fixed delay. On a slow TUI—especially Windows ConPTY—the paste could still be rendering, so Enter was swallowed and the task sat in the composer until someone pressed Enter manually. This waits for the agent's rendered composer to settle before submitting.

What Changed

Why

input_accepted proved only that Orca wrote bytes to the PTY; it did not prove the TUI had accepted Enter as a submitted turn. The prior 500 ms delay (1.5 seconds on Windows) was an open-loop timing guess. Codex and Claude both emit ESC[?25h while rendering pasted composer content, so PTY-local render observation plus bounded quiescence provides a stronger readiness signal without polling, provider calls, or wire changes.

This is an older latent race in the prompt-injection seam, not a recent release regression. PR #14342 added the render gate for Claude after the Codex report was filed; Codex still used the fixed-delay path.

Linked Issue

Fixes #13821

Addresses #14347

Visual Proof

Before: #14347 reports the prompt visible but stranded until manual Enter. The failure is timing-dependent and was reported on Windows, so no synthetic local “before” screenshot is presented as equivalent evidence.

After — exact-build Codex worker receives and starts the injected task without manual Enter:

Codex orchestration task autostarts

After — the worker calls worker_done and the dispatch settles:

Codex orchestration worker settled

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Automated:

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/agent-prompt-injection.test.ts src/main/runtime/orca-runtime.test.ts src/main/runtime/rpc/methods/orchestration.test.ts src/main/runtime/orchestration/coordinator.test.ts
    • 4 files passed; 1,303 tests passed; 1 skipped.
  • pnpm run typecheck:node
  • pnpm run check:code-quality:changed
  • pnpm run check:max-lines-ratchet
  • pnpm run check:reliability-gates
  • git diff --check

Manual:

  • Ran real Codex orchestration on the exact final Electron dev build on macOS.
  • The task auto-submitted without manual Enter, returned the expected marker, called worker_done, and reached worker: succeeded / stage: settled.
  • Confirmed local Codex CLI 0.147.0 emits the post-paste show-cursor marker in raw PTY output.

Not tested:

  • Physical Windows/ConPTY. The deterministic slow-host test delays Codex's marker until 7.9 seconds and emits a final frame after the original deadline, but live Windows validation remains a gap.
  • Live SSH/paired-runtime providers. The gate runs on the PTY-owning runtime and changes no exchanged data or wire contract.

Review

  • Scope is limited to programmatic Codex/Claude prompt submission; normal terminal input and other agents are unchanged.
  • A CLI that never emits the marker still receives one Enter after the bounded fallback, but starts later than before.
  • A late marker can extend the total wait while output remains noisy; timers and the PTY listener are always bounded and disposed.
  • No submit retry was added, avoiding duplicate-turn risk.
  • No persistence, RPC, remote-wire, Git, provider, folder-workspace, or renderer contract changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after evidence attached, with the intermittent before-state limitation documented
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Focused tests, Node typecheck, changed-code quality, and reliability gates pass; CI will cover the full repository matrix

Author

  • X / Twitter: N/A

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The prompt-render gate now supports Claude and Codex terminals. Shared constants control render markers, quiet periods, and hard timeouts. Late render markers reset the settlement window without creating duplicate timers. Runtime tests cover staged redraws, authority callbacks, late Codex markers, and silent Claude fallback. Reliability records include updated assertions, macOS evidence, red-green results, and performance details.

Merge Risk: 🔵 Low · up to 4e850

The PR replaces a fixed submission delay with marker-based rendering and quiescence detection; terminals that do not forward the marker may consistently incur the 8-second fallback delay. The change is mergeable with explicit owner awareness and follow-up validation for Windows/ConPTY behavior.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: waiting for Codex composer rendering before submission.
Description check ✅ Passed The description covers the required sections, explains the change and rationale, documents testing, and records platform limitations.
Linked Issues check ✅ Passed The changes address issue #13821 by waiting for Claude and Codex rendering to settle before sending one automatic Enter.
Out of Scope Changes check ✅ Passed The configuration, runtime implementation, and tests remain focused on reliable Claude and Codex prompt submission.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

17639-17659: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the repeated clear-then-set timer pattern.

armQuietTimer and armHardTimer both clear an existing timer, then set a new one with a different constant and target. This duplication is small, but a shared helper would remove it and make future timer changes (for example, adding a third timer class) less error-prone.

♻️ Proposed helper to remove duplication
+    const rearm = (
+      current: NodeJS.Timeout | null,
+      delayMs: number
+    ): NodeJS.Timeout => {
+      if (current) {
+        clearTimeout(current)
+      }
+      return setTimeout(finish, delayMs)
+    }
     const armQuietTimer = (): void => {
-      if (quietTimer) {
-        clearTimeout(quietTimer)
-      }
-      quietTimer = setTimeout(finish, AGENT_PROMPT_RENDER_QUIET_MS)
+      quietTimer = rearm(quietTimer, AGENT_PROMPT_RENDER_QUIET_MS)
     }
     const armHardTimer = (): void => {
-      if (hardTimer) {
-        clearTimeout(hardTimer)
-      }
-      hardTimer = setTimeout(finish, AGENT_PROMPT_RENDER_TIMEOUT_MS)
+      hardTimer = rearm(hardTimer, AGENT_PROMPT_RENDER_TIMEOUT_MS)
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f250a117-d38d-4c1f-af12-84934eef01e0

📥 Commits

Reviewing files that changed from the base of the PR and between b3c4ba9 and 4e85003.

📒 Files selected for processing (3)
  • config/reliability-gates.jsonc
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts

@Jinwoo-H

Jinwoo-H commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Physical Windows validation completed on windows 2.

  • Candidate: exact PR SHA 4e850031ccd7ef03e50a997efd7bc4a0fb7685b6, built and served from a separate unpackaged runtime on the Windows host
  • Host path: native Windows / ConPTY (win32)
  • Codex: codex-cli 0.147.0
  • Result: 5/5 fresh Codex orchestration workers passed
    • 1 ordinary cold start
    • 3 simultaneous cold starts
    • 1 cold start while four 25-second CPU burners were active
  • Every valid run auto-submitted the full Orca dispatch preamble without a manual Enter, produced its unique WINDOWS_CODEX_GATE_PASS_n response, sent worker_done, and reached succeeded / settled.
  • In the CPU-stressed run, the transcript recorded the injected user turn at 19:49:30.019Z and the first assistant response at 19:49:33.880Z (~3.9s).

A deliberately isolated fresh Orca profile was also tried first; Codex correctly stopped at its auth/interactive prerequisite because that profile had no credentials. That attempt never reached prompt injection and is excluded from the 5/5 result. Re-running from the machine's normal authenticated orca-dev profile exercised the candidate code successfully.

This validates the user-visible post-paste/Enter behavior on physical Windows. It does not distinguish whether a particular run used the render marker or the bounded no-marker fallback because that path is not externally surfaced.

Cleanup completed: worker output was archived, worker terminals released, candidate runtimes stopped, temporary pairing environments removed, and the Windows test worktree deleted.

@Jinwoo-H
Jinwoo-H merged commit ff9bc0f into main Aug 14, 2026
45 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

worker-start --agent claude: injected prompt often left unsubmitted in TUI input box (input_accepted != submitted)

1 participant