Repository navigation
Conversation
A program that enabled DEC mode 2031 received two CSI ?997 reports for each Orca light/dark flip on a visible pane: xterm reported the palette write itself, then Orca's maybePushMode2031Flip reported the app mode. Orca now sends its report before writing the theme and mutes xterm's copy only for a write whose flip Orca just reported. Every other xterm report is unchanged, including a palette light/dark change that keeps the app mode and the case where Orca's report is gated off.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The change appears mergeable, but the mobile-owned PTY test should cover the real input path so a future duplicate report cannot pass unnoticed. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 9904d20b-31c0-41c6-8f42-87ccf6e691ee
📒 Files selected for processing (3)
src/renderer/src/components/terminal-pane/terminal-appearance-color-scheme.test.tssrc/renderer/src/components/terminal-pane/terminal-appearance.tssrc/renderer/src/components/terminal-pane/terminal-mode-2031-replies.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- One report per flip:
applyTerminalAppearancenow callsmaybePushMode2031Flipbefore theoptions.themewrite and, when it reported a flip, routes the write throughsetThemeWithoutXtermColorSchemeReport, which mutes xterm's privatecolorSchemeUpdatesflag only for that write and restores it infinally. - Reused gate: the report/
safeFitAndThenpredicate was hoisted into a singledesktopSizesPtyconst, so the two paths can no longer drift apart. - Narrowed manager type:
applyTerminalAppearancenow takes aPick<PaneManager, ...>of the four methods it actually uses, letting the new test pass a typed fake instead of a cast. - New xterm-backed test:
terminal-appearance-color-scheme.test.tsdrives a real xterm under happy-dom and pins exactCSI ?997reply sequences across six scenarios.
I read the complete diff, the full applyTerminalAppearance/maybePushMode2031Flip sources, the mobile-fit-overrides and hidden-subscription state machines, and the installed xterm dist. I verified the new test is real coverage rather than theatre: with the mute removed it fails 2/6 exactly as the PR describes. Related terminal-pane suites (79 tests), pnpm run tc:web, and pnpm run check:code-quality:changed all pass. The only residual risk is the dependency on xterm's private _core.coreService.decPrivateModes.colorSchemeUpdates, which the author documents and which the new test would flag on an xterm bump that moves the field.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…te grid Orca's mode-2031 report shared the PTY resize gate, so it was skipped under a remote-desktop-fit override too. There xterm reported the flip instead and Orca's last-reported mode stayed stale, so the next appearance change after the desktop took the grid back repeated it. The report now has its own gate that skips only a phone's mobile-fit. Constraint: a phone driving the PTY answers color-scheme queries for itself Rejected: gate on the mobile input lock | changes when a flip made during the lock is reported; separate PR Tested: terminal-appearance-color-scheme.test.ts fails on the old gate with two ?997;2n and passes here Tested: pnpm test src/renderer/src/components/terminal-pane, pnpm tc:web, check:code-quality:changed Not-tested: a real remote-desktop-fit session in the Electron app
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Report gate split from the resize gate:
applyTerminalAppearancenow derivesreportsColorScheme(connected && fitOverride?.mode !== 'mobile-fit') separately fromdesktopSizesPty(connected && !fitOverride), so a desktop parked at another desktop's grid reports the flip itself instead of staying silent. - Parked-grid repeat fixed: with
remote-desktop-fitnow reporting,paneLastThemeModeadvances, so the next appearance pass after this desktop regains the grid no longer re-sends the same flip. - Test extended: the parked-grid case re-applies after
desktop-fitand asserts the reply list stays[LIGHT], an assertion that fails against the previous gate.
I read the full diff, the new commit's delta, plus mobile-fit-overrides.ts, pty-input-forward.ts, and the installed-xterm reply path. Verified the report now fires on remote-desktop-fit while the resize stays suppressed, and that pnpm tc:web, both appearance suites (36 tests), and pnpm run check:code-quality:changed pass. The cross-instance duplicate (an owner desktop and a parked viewer both reporting the same PTY) is unchanged in count versus main and remains the separate, already-tracked concern #9156.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-appearance-color-scheme.test.ts (1)
163-169: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExercise the production input-forwarding boundary.
This handler duplicates the
isPtyLockedcheck instead of usingforwardPtyInput. The test can therefore pass if production forwarding stops dropping xterm's mode-2031 reply for a mobile-owned PTY. Route xterm'sonDataevent throughforwardPtyInputand assert that the production transport receives no reply.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 856c6583-1d7c-4e94-a7cb-fe148f19fb81
📒 Files selected for processing (2)
src/renderer/src/components/terminal-pane/terminal-appearance-color-scheme.test.tssrc/renderer/src/components/terminal-pane/terminal-appearance.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/renderer/src/components/terminal-pane/terminal-appearance-color-scheme.test.ts
- src/renderer/src/components/terminal-pane/terminal-appearance.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.
|
About the CodeRabbit nitpick on the mirrored lock check in |
|
Hi @nwparker, since you've worked on the mode 2031 handling (#13904): on a visible pane, xterm's own palette-based |
|
Thank you @kargnas for tracking this down so clearly. Your write-up here and in #25498 pinned the duplicate |

ELI5
Some terminal programs, such as Claude Code and Neovim, ask the terminal to tell them when it switches between light and dark mode, so they can switch their own colors. When you flipped Orca between light and dark, a terminal you were looking at told those programs twice. Sometimes the two messages even disagreed: one said "dark" and the other said "light". After this change, Orca sends one message per flip.
What Changed
Before: a program turns on these notifications by sending DEC private mode 2031 (
CSI ?2031h). In a visible terminal pane, one Orca light/dark flip then sent the program twoCSI ?997;Xnreports (1= dark,2= light):terminal.options.thememakes xterm's theme service fireonChangeColors, and while xterm's owncolorSchemeUpdatesflag is on, xterm replies with_reportColorScheme(). That report is based on how bright the new palette is, and xterm sends it on every palette write.maybePushMode2031Flip. That one follows the app's light/dark mode and goes out only when the mode actually flips. Orca already sends this report for hidden panes, where xterm never sees the program's?2031h.After: one report per flip, from Orca.
Mechanism:
applyTerminalAppearancenow callsmaybePushMode2031Flipbefore it writes the theme instead of after. The move changes nothing the program receives, because each theme write now produces at most one report (Orca's or xterm's), so there is no order between two reports left to change.mobile-fit). Before, it shared the PTY resize gate, which also skips a desktop whose pane is parked at another desktop's grid (remote-desktop-fit). That shared gate dates from feat(mobile): Expo companion app [beta] #1245, which put the report inside the resize block; the comment there covers only the resize. The resize gate itself is unchanged.setThemeWithoutXtermColorSchemeReport(interminal-mode-2031-replies.ts). It turns xterm'scolorSchemeUpdatesflag off only whileoptions.themeis written, then restores it in afinally. In every other case the theme is written exactly as before, and xterm reports as before._core.coreService.decPrivateModeswithinchecks instead of a type cast. If a future xterm moves that field, the helper does nothing and the old duplicate comes back; nothing else breaks.applyTerminalAppearancenow accepts aPick<PaneManager, ...>of the four methods it calls, so the new test can pass a typed fake instead of a cast. Existing callers are unchanged.Behavior changes a reviewer should know about:
remote-desktop-fit), a flip is now reported by Orca instead of by xterm. Before, Orca's record of the last reported mode stayed stale there, so after this desktop took the grid back, the next appearance change (a font size change, for example) sent the same flip a second time. CodeRabbit found this on an earlier revision of this PR.Why
xterm's report and Orca's report exist for different panes: xterm only sees programs in visible panes, and Orca covers hidden panes too. On a visible pane they overlap exactly when Orca reports a flip and also writes a new theme, so that is the only write this change mutes.
Alternatives considered:
vtExtensions.colorSchemeQuery: false. This stops xterm's report, but it also stops xterm from answeringCSI ?996nand from tracking?2031hat all. For hidden terminals,src/main/daemon/terminal-view-attribute-responder.tsanswers?996nthe same way a visible xterm does. Turning xterm's answer off would make visible and hidden terminals answer differently.Linked Issue
Fixes #25498
Two issues are related, but this PR does not fix either one: #10913, where hidden main-window tabs get no report after a system appearance change, and #9156, where the host and a paired desktop both answer the same query.
Visual Proof
N/A. This change is not visible. It removes one duplicate control sequence sent to the program, and the terminal's colors change exactly as before. No attachments are included.
Testing
The new
terminal-appearance-color-scheme.test.tsruns a real xterm.jsTerminal(under happy-dom) throughapplyTerminalAppearance. xterm's own replies pass through the same mobile-lock check thatpty-input-forward.tsuses. It has 6 cases:?996nfrom the palette)Results:
main(27b823f): 3 of 6 fail. The flip case receives?997;2ntwice. The mismatch case receives?997;1nfollowed by?997;2n. The parked-grid case receives?997;2ntwice: xterm's report during the flip, then Orca's after the desktop takes the grid back.finallyrestore removed): 1 of 6 fails. The OSC 11 case receives nothing.?997;2ntwice.pnpm test src/renderer/src/components/terminal-pane: 486 files, 4673 passed, 1 skipped.pnpm tc:web,oxlint,oxfmt --check, andpnpm run check:code-quality:changedpass.What I did not verify: I did not run the Electron app or watch a real program such as Claude Code or Neovim receive the reports. The tests use xterm.js in happy-dom with a fake PTY transport. They ran on macOS only. I did not test on Linux, Windows, or over SSH.
AI Disclosure
Developed with Claude Code (Claude Opus 5.5).
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
CSI ?997;1n/CSI ?997;2n), so no RPC or stream format changes, and a new client with an older host (or the reverse) works the same way.main): if a phone's fit override is ever held while the phone is not driving the PTY, xterm's report reaches the program and Orca's record of the last mode stays stale, so a later appearance change can repeat that flip. Closing it means gating Orca's report on the mobile input lock instead, which also changes when a flip made during the lock is reported. That belongs in its own PR._core.coreService.decPrivateModes.colorSchemeUpdates(present in@xterm/xterm6.1.0-beta.303). If an xterm upgrade removes it, the duplicate returns; nothing else breaks.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). I ranpnpm tc:web, the terminal-pane tests, and the changed-file lint and format gates; I left full lint, typecheck, test, and build to CI.