fix(terminal): filter focus reports after Codex history resume
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 passedpnpm run typecheck:webpnpm 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.
π 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.
Comment @coderabbitai help to get the list of available commands.