orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(terminal): filter focus reports after Codex history resume

Open OrcaWin opened this issue 4 months ago β€’ 1 comments

Summary

Prevents native Windows Codex history resumes from leaving literal [I, [[I, or [O focus-report fragments in the idle composer.

The existing Windows guard was armed by an agent done status. A session resumed from Agent Session History can open directly on a completed Codex composer with focus reporting enabled but no pane status row, so ESC[O / ESC[I could still reach ConPTY. This change recognizes the explicit Codex sidebar-resume startup metadata and arms the same guard until the resumed session starts working again.

Screenshots

No visual change.

Electron validation exercised the visible Agent Session History resume flow and a real focus handoff between the history search and resumed terminal. The completed Codex composer remained clean with focus reporting enabled and no agent-status row.

Testing

  • [ ] pnpm lint
  • [ ] pnpm typecheck
  • [ ] pnpm test
  • [ ] pnpm build
  • [x] Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional focused validation:

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts β€” 447 passed
  • pnpm run typecheck:web
  • pnpm exec oxlint src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • Electron CDP validation on native Windows ConPTY

AI Review Report

Reviewed the existing startup input ordering fix and the native Windows post-turn focus-report suppression path. The main risk was over-broadly suppressing legitimate focus events for normal shells, Cursor, WSL, SSH, or runtime-hosted terminals. The implementation is restricted to native Windows ConPTY, explicit sidebar resume requests, and Codex startup metadata with no authoritative initial status. Existing working-state transitions restore focus reports.

Cross-platform compatibility was explicitly checked. The change does not alter shortcuts, labels, paths, Git commands, shell selection, macOS/Linux behavior, SSH, WSL, or remote-runtime transport behavior. The full PTY connection test file includes the neighboring remote-safety and non-Codex focus-report coverage.

Security Audit

No new command execution, path handling, authentication, dependency, or IPC surface was introduced. The filter accepts only xterm's exact focus-in and focus-out control sequences and uses existing trusted startup telemetry. Ordinary keyboard input and terminal query replies remain unchanged.

Notes

The behavioral change is intentionally Windows ConPTY-specific. The pre-fix failure was reproduced deterministically at the PTY transport boundary; the visible corruption itself is timing-sensitive.

OrcaWin avatar Jul 18 '26 01:07 OrcaWin

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Windows ConPTY pane initialization now detects Codex sidebar resume sessions without an initial agent status and enables suppression of native focus-report escape sequences while idle. Tests verify that \x1b[O and \x1b[I are suppressed initially and that focus input is forwarded after the pane’s agent status changes to working. Additional coverage confirms forwarding remains enabled for Claude history resume and fresh Codex launch scenarios.

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 is concise and accurately summarizes the Windows Codex focus-report filtering change.
Description check βœ… Passed The description matches the template and includes summary, screenshots, testing, review, security, and notes.

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[bot] avatar Jul 18 '26 02:07 coderabbitai[bot]