Skip to content

Wait for Codex's live composer before pasting linked issue drafts - #25779

Merged
nwparker merged 7 commits into
mainfrom
nwparker/smarter-codex-issue-paste-detection
Oct 6, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/smarter-codex-issue-paste-detection

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​238
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211 $\color{#cf222e}{\Huge{\mathbf{−}}}$​115 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​96

ELI5

When you launch Codex from a linked issue, Orca now waits until its input is ready before inserting the issue context. The draft stays editable, including when you start typing during startup.

What Changed

Previously, Orca treated Codex's first › as ready, although the fullscreen loading screen already paints that prompt. It could also paste blindly after a timeout. The shared detector now waits for the reserved live footer row and visible input cursor after a completed render frame; punctuation in multiline input cannot impersonate that footer. Codex timeouts show the existing manual-paste notice and stop delivery, so a later redraw cannot unexpectedly insert the draft.

Older inline Codex keeps its prompt detection. The terminal escape reader is reused from the OpenCode detector; terminal title payloads cannot impersonate painted input.

Why

The live composer is a stronger signal than a prompt glyph or a fixed delay. Codex 0.160.1 has no native draft-prefill flag, and its positional prompt submits immediately. This preserves editable issue context without adding polling or another process.

Linked Issue

Maintainer-requested fix; no pre-existing issue.

Visual Proof

The transcript tests compare the previous readiness point (prompt visible, footer absent) with the new point (live footer visible, completed frame). This screenshot pair shows those startup stages in a hidden Orca renderer running the final code; it does not claim to reproduce the intermittent previous input loss.

At the previous detector's readiness point, the prompt is present but the footer is absent. The new detector holds the issue draft while early typing remains visible:

Before the live composer footer

After the live footer appears, the multiline context is inserted exactly once and remains editable alongside the early note:

After the live composer footer and draft delivery

Multiline Linear context remains editable in a git worktree with a single-item custom footer:

Multiline editable worktree draft

Testing

  • Manually tested locally with Codex 0.160.1 on macOS through Playwright CDP in a hidden Orca window: folder and git workspaces, typing during provisional startup, multiline drafts, and a customized single-item footer.
  • Repeated the early-typing and multiline-draft flow with the final scanner, inspected before/after rendered screenshots, and confirmed the draft remains present exactly once after startup settles.
  • Automated regression tests added for recorded startup frames, split terminal chunks, title decoys, startup dialogs, terminal-mode exits, and all three renderer timeout delivery paths.
  • All 457 focused regression, transcript-privacy, serializer, and watcher tests pass on the rebased branch, along with pnpm tc, the changed-file code-quality gate, and pnpm run build:electron-vite. Full CI passed before merge, including all five unit-test jobs, all four SSH/end-to-end jobs, typecheck/static analysis, packaging, native smoke tests, persistence, and Linux compatibility checks.
  • Scanner microbenchmark on macOS arm64, replaying captured startups in 64-character chunks: approximately 0.05–0.07 ms of CPU work per startup, versus 0.002 ms previously. Scanning stops on delivery or timeout.
  • Windows/Linux and live SSH were not manually tested; mocked SSH delivery and shared runtime tests cover those delivery boundaries.

Review

Self-review checked success, timeout, disposal, duplicate delivery, legacy Codex, and OpenCode parsing. Addressed CodeRabbit's control-string finding: OSC, DCS, SOS, PM, and APC payloads are ignored, including long payloads split across individual characters. Fixed two edge cases: disposal must not release a timed-out launch's delivery claim, and moving above multiline input must not let its punctuation impersonate the footer. Regression tests cover both; the disposal test was confirmed to fail with its fix removed, and a fresh real Codex capture reproduced the multiline false positive before its fix. No blocking findings remain.

The detector reads execution-host terminal output through the existing transport; it adds no local execution fallback, RPC fields, or stream opcodes. Other agents retain their existing timeout fallback. There are no platform-specific paths, shortcuts, shell commands, or git-provider assumptions. Memory is bounded; no new polling, subprocesses, or network requests. The existing notice is reused, and recorded transcripts were scanned for private identifiers. Pullfrog reviews are currently paused by the repository's PULLFROG_PAUSED setting.

Agent skill upstream boundary

  • Not applicable; no skill installation or sharing changes.

Notes

Compared the new recordings against the base b58f8197dc36 serializer; the same cell-attribute differences occur in both builds, with no byte differences or new regressions. These recordings now participate in the existing serializer baseline checks.

Rebased onto current main. Also corrected one outdated file-explorer test assertion from the recently merged linked-directory reconciliation change: it now checks exactly two batch-wide cache scans (one index, one purge). The failure reproduced before this correction, and no file-explorer runtime code changes are included.

Context can append after text already typed; this does not provide native prefill or guarantee context comes first. An unrecognized future fullscreen layout can time out and require manual paste instead of a blind late write. Older paired hosts keep their own existing detector until updated; no wire change is required.

Checklist

  • This PR is small and focused
  • Explained the user-facing before/after, mechanism, and choice over alternatives
  • Attached rendered result screenshots and transcript-based readiness comparison
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, folder workspaces, and integration impact considered
  • Full CI passed before merge; local focused checks and hidden-renderer validation passed

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 60477073-d6ee-4081-bdbc-8a7d4f9e0597
📥 Commits

Reviewing files that changed from the base of the PR and between b98cdaf and f48b9e3.

📒 Files selected for processing (4)
  • src/main/daemon/serialize-grid-transcript-replay.test.ts
  • src/renderer/src/components/right-sidebar/file-explorer-watch-reconcile.test.ts
  • src/shared/codex-composer-ready-scanner.test.ts
  • src/shared/terminal-escape-scanner.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The change adds a shared terminal escape scanner and uses it to detect Codex composer readiness from terminal output. Captured Codex transcripts and tests cover readiness signals and chunked input. Codex draft-paste flows now stop on readiness timeout without sending the draft, while other agents retain the process-ownership fallback.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f48b9

Codex draft delivery no longer appears vulnerable to the previously reported control-string false-readiness path. The reviewed change is mergeable after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to b98cd

The change reduces unexpected draft delivery by waiting for the live composer and stopping on timeout. Remaining uncertainty concerns terminal-output ownership and reconnect behavior, rather than a demonstrated expansion of privileges.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The evidenced sensitive outcome is insertion of configured launch content into the selected terminal, with optional submission in existing helper callers. A producer controlling that terminal's output can influence readiness. The inspected change does not establish a new credential, cross-environment route or privilege grant; wider service or tenant exposure remains unproven.

Security Findings and Attack Paths

  • inferred — The parser suppresses OSC and DCS payloads but does not recognize SOS, PM or APC as non-painted strings. Their payload text can reach Codex prompt detection and satisfy legacy readiness when bracketed paste is enabled. This residual false-readiness mechanism is not established as a PR regression: the base raw-stream detector also accepted the same prompt glyph inside such payloads. A reachable attacker-controlled producer was not established.

Trust Boundaries and Controls

  • observed — Pane delivery claims are scoped to worktree, tab and launch token, and delivery checks that the session still owns the pane transport. Separately, the tab helper captures the first PTY and does not revalidate the tab mapping before sending. That selection mechanism is unchanged by this PR; whether reconnect can invalidate its ownership assumption remains unresolved.

Resilience and Maintainability Implications

  • observed — Codex pane timeout marks the launch settled and attempted, clears timers, and returns without process-inspection fallback. Later output exits on settled state, and attempted claims are not released during cleanup. The main-runtime wait also uses one-shot settlement, abort cleanup and handoff counters to reject stale asynchronous readiness checks.

Hardening Proposals

  • proposed — Consider suppressing SOS, PM and APC payloads alongside OSC and DCS, and making the final PTY ownership requirement explicit for tab-scoped delivery across reconnect. These address residual assumptions, not demonstrated security regressions introduced by this PR.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: waiting for Codex’s live composer before pasting linked issue drafts.
Description check ✅ Passed The description covers the user-facing change, rationale, linked-issue exception, visual proof, testing, review, compatibility considerations, and checklist. It provides enough detail to assess the ch…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21f5973f-b4b8-46ba-a4ce-1dd572d52d47
📥 Commits

Reviewing files that changed from the base of the PR and between b58f819 and 57375d6.

📒 Files selected for processing (16)
  • src/main/runtime/__fixtures__/codex-fullscreen-custom-footer.meta.json
  • src/main/runtime/__fixtures__/codex-fullscreen-custom-footer.txt
  • src/main/runtime/__fixtures__/codex-fullscreen-early-input.meta.json
  • src/main/runtime/__fixtures__/codex-fullscreen-early-input.txt
  • src/main/runtime/__fixtures__/codex-fullscreen-startup.meta.json
  • src/main/runtime/__fixtures__/codex-fullscreen-startup.txt
  • src/main/runtime/codex-startup-paste-transcripts.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection/pane-serializer-settle.ts
  • src/renderer/src/lib/agent-paste-draft.test.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/startup-draft-input-kind.test.ts
  • src/shared/codex-composer-ready-scanner.test.ts
  • src/shared/codex-composer-ready-scanner.ts
  • src/shared/draft-paste-ready-scanner.ts
  • src/shared/opencode-agent-row-scanner.ts
  • src/shared/terminal-escape-scanner.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

Comment thread src/shared/terminal-escape-scanner.ts Resolved
@nwparker
nwparker force-pushed the nwparker/smarter-codex-issue-paste-detection branch from b98cdaf to f48b9e3 Compare October 6, 2026 06:01
@nwparker
nwparker merged commit ac3a25c into main Oct 6, 2026
53 checks passed
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.

1 participant