Repository navigation
fix(terminal): route Shift+Enter by PTY host - #8065
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds terminal input host platform resolution using SSH connection metadata, runtime host status, or the client platform. Terminal shortcut resolution now accepts a host-platform callback and uses it for 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: Pro
Run ID: 1a0fdcdb-28c5-426c-82bb-cc778cb23c1e
📥 Commits
Reviewing files that changed from the base of the PR and between e4c7aab and 1f06d7f519250ada2368da11e003e37f7693e0ab.
📒 Files selected for processing (5)
src/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-input-host-platform.test.tssrc/renderer/src/components/terminal-pane/terminal-input-host-platform.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
1381546 to
98ae41d
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts (1)
36-43: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider simplifying the conditional type assertion.
The
extends Map<string, infer T> ? T : neverpattern on line 41 is correct but unnecessarily verbose for a test fixture. A simpleras anyor extracting a local type alias would improve readability without losing meaning.♻️ Optional simplification
runtimeStatusByEnvironmentId: new Map([ [ 'windows-box', - { - status: { hostPlatform: 'win32' } - } as AppState['runtimeStatusByEnvironmentId'] extends Map<string, infer T> ? T : never + { status: { hostPlatform: 'win32' } } as any ] ])
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c38a5797-a15a-4762-ac5d-6c9e0a5b7abb
📥 Commits
Reviewing files that changed from the base of the PR and between 138154672c9da7850543d26ce8265446e6753f09 and 98ae41dbd272987535f68b602c7461fffeafc27b.
📒 Files selected for processing (5)
src/renderer/src/components/terminal-pane/keyboard-handlers.tssrc/renderer/src/components/terminal-pane/terminal-input-host-platform.test.tssrc/renderer/src/components/terminal-pane/terminal-input-host-platform.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.tssrc/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
- src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts
- src/renderer/src/components/terminal-pane/terminal-input-host-platform.ts
- src/renderer/src/components/terminal-pane/keyboard-handlers.ts
21495f8 to
3577184
Compare
Co-authored-by: Orca <[email protected]>
# Conflicts: # src/renderer/src/components/terminal-pane/keyboard-handlers.ts # src/renderer/src/components/terminal-pane/terminal-input-host-platform.test.ts # src/renderer/src/components/terminal-pane/terminal-input-host-platform.ts # src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
Co-authored-by: Orca <[email protected]>
Jinwoo-H
left a comment
There was a problem hiding this comment.
Thanks for the cross-OS fix. Maintainer review integrated this with current main and tightened the routing contract:
- active Kitty keyboard protocol authorizes CSI-u on every host
- trusted Droid remains an additional Windows-only authorization
- active SSH/runtime/local PTY ownership survives worktree-host changes and reattach
- 208 focused tests, full typecheck/lint, reliability gates, and a live Linux SSH relay raw-byte check passed
The final independent review is clean; remaining live Windows/WSL/runtime gaps are documented in the PR proof section.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: adaf47b6-9369-4bd1-964d-4795f68b2e57
📥 Commits
Reviewing files that changed from the base of the PR and between 21495f896aeea1636cf1d59d89d9b7a75431e702 and a138ef9.
📒 Files selected for processing (1)
config/reliability-gates.jsonc
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: adaf47b6-9369-4bd1-964d-4795f68b2e57
📥 Commits
Reviewing files that changed from the base of the PR and between 21495f896aeea1636cf1d59d89d9b7a75431e702 and a138ef9.
📒 Files selected for processing (1)
config/reliability-gates.jsonc
🛑 Comments failed to post (1)
config/reliability-gates.jsonc (1)
2243-2250: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Record evidence for the newly added host-routing command.
The sole evidence entry runs the 22-file command at Line 2246, not the new
keyboard-handlers,remote-runtime-pty-transport, andterminal-input-host-platformcommand at Line 2049. Add its actual run record, or narrow the executed-coverage claims, so the gate remains auditable.
… Bash) (stablyai#7620) Shift+Enter still submitted instead of inserting a newline when Droid ran in Git Bash on Windows, even after the PowerShell fix (stablyai#7620/stablyai#8065/stablyai#8427). On Windows, Orca sends Droid the kitty CSI-u byte (ESC [ 13;2u) for Shift+Enter only when the active pane has fresh, trusted process evidence that Droid is the foreground app; otherwise it falls back to the Codex-compatible ESC+CR, which Droid decodes as a plain Enter and submits. That trusted evidence comes from a confirming foreground read. PowerShell triggers that read from its OSC 133 command-start event. Git Bash (and cmd.exe) emit no OSC command boundary, and an Orca-launched agent delivers its command programmatically (no typed-command inference), so a fresh Droid spawn in those shells never earned routing trust -- leaving Shift+Enter on the ESC+CR fallback forever. Fix: on a fresh spawn into a no-OSC shell, seed the SAME command-start confirmation the manually-typed launch path already uses (paneForegroundAgentTracker.onCommandStarted). Its bounded retry ladder spans Droid boot, and -- crucially -- a miss publishes shellForeground:false, so the pane stays recoverable by later focus/reveal samples. (A visible-pty sample was rejected here: on a pathologically slow boot its known-agent shell-confirm would latch, clear launch identity, and permanently poison Shift+Enter for the rest of the session.) A real OSC 133;C, if it arrives, simply supersedes this. Verified on Windows 11 + Git Bash with the real Droid CLI and node-pty ConPTY: - Droid's TUI treats ESC [ 13;2u as a newline (two-line composer) and ESC+CR as a submit -- exactly the reported bug and the fix's mechanism. - droid.exe is a descendant of bash inside the ConPTY console process list (so the main-side scan resolves it) and becomes a live process ~0.8s after launch, well within the retry ladder. Tests: regression test drives the real connectPanePty spawn path and asserts csi-u; a slow-boot test exercises the shell->droid ladder transition; a recoverability test proves a total-miss does NOT poison the pane (it fails against the visible-pty approach and passes with onCommandStarted).
… Bash) (#7620) (#8948) Shift+Enter still submitted instead of inserting a newline when Droid ran in Git Bash on Windows, even after the PowerShell fix (#7620/#8065/#8427). On Windows, Orca sends Droid the kitty CSI-u byte (ESC [ 13;2u) for Shift+Enter only when the active pane has fresh, trusted process evidence that Droid is the foreground app; otherwise it falls back to the Codex-compatible ESC+CR, which Droid decodes as a plain Enter and submits. That trusted evidence comes from a confirming foreground read. PowerShell triggers that read from its OSC 133 command-start event. Git Bash (and cmd.exe) emit no OSC command boundary, and an Orca-launched agent delivers its command programmatically (no typed-command inference), so a fresh Droid spawn in those shells never earned routing trust -- leaving Shift+Enter on the ESC+CR fallback forever. Fix: on a fresh spawn into a no-OSC shell, seed the SAME command-start confirmation the manually-typed launch path already uses (paneForegroundAgentTracker.onCommandStarted). Its bounded retry ladder spans Droid boot, and -- crucially -- a miss publishes shellForeground:false, so the pane stays recoverable by later focus/reveal samples. (A visible-pty sample was rejected here: on a pathologically slow boot its known-agent shell-confirm would latch, clear launch identity, and permanently poison Shift+Enter for the rest of the session.) A real OSC 133;C, if it arrives, simply supersedes this. Verified on Windows 11 + Git Bash with the real Droid CLI and node-pty ConPTY: - Droid's TUI treats ESC [ 13;2u as a newline (two-line composer) and ESC+CR as a submit -- exactly the reported bug and the fix's mechanism. - droid.exe is a descendant of bash inside the ConPTY console process list (so the main-side scan resolves it) and becomes a live process ~0.8s after launch, well within the retry ladder. Tests: regression test drives the real connectPanePty spawn path and asserts csi-u; a slow-boot test exercises the shell->droid ladder transition; a recoverability test proves a total-miss does NOT poison the pane (it fails against the visible-pty approach and passes with onCommandStarted).
* fix(terminal): route Shift+Enter by PTY host * fix(terminal): resolve SSH platform from execution host * fix(terminal): preserve restored runtime input routing * fix(terminal): route Shift+Enter by PTY host * fix(terminal): resolve SSH platform from execution host * fix(terminal): preserve active PTY host routing Co-authored-by: Orca <[email protected]> * test(terminal): remove superseded host-routing cases Co-authored-by: Orca <[email protected]> --------- Co-authored-by: Jinwoo-H <[email protected]> Co-authored-by: Orca <[email protected]>
… Bash) (stablyai#7620) (stablyai#8948) Shift+Enter still submitted instead of inserting a newline when Droid ran in Git Bash on Windows, even after the PowerShell fix (stablyai#7620/stablyai#8065/stablyai#8427). On Windows, Orca sends Droid the kitty CSI-u byte (ESC [ 13;2u) for Shift+Enter only when the active pane has fresh, trusted process evidence that Droid is the foreground app; otherwise it falls back to the Codex-compatible ESC+CR, which Droid decodes as a plain Enter and submits. That trusted evidence comes from a confirming foreground read. PowerShell triggers that read from its OSC 133 command-start event. Git Bash (and cmd.exe) emit no OSC command boundary, and an Orca-launched agent delivers its command programmatically (no typed-command inference), so a fresh Droid spawn in those shells never earned routing trust -- leaving Shift+Enter on the ESC+CR fallback forever. Fix: on a fresh spawn into a no-OSC shell, seed the SAME command-start confirmation the manually-typed launch path already uses (paneForegroundAgentTracker.onCommandStarted). Its bounded retry ladder spans Droid boot, and -- crucially -- a miss publishes shellForeground:false, so the pane stays recoverable by later focus/reveal samples. (A visible-pty sample was rejected here: on a pathologically slow boot its known-agent shell-confirm would latch, clear launch identity, and permanently poison Shift+Enter for the rest of the session.) A real OSC 133;C, if it arrives, simply supersedes this. Verified on Windows 11 + Git Bash with the real Droid CLI and node-pty ConPTY: - Droid's TUI treats ESC [ 13;2u as a newline (two-line composer) and ESC+CR as a submit -- exactly the reported bug and the fix's mechanism. - droid.exe is a descendant of bash inside the ConPTY console process list (so the main-side scan resolves it) and becomes a live process ~0.8s after launch, well within the retry ladder. Tests: regression test drives the real connectPanePty spawn path and asserts csi-u; a slow-boot test exercises the shell->droid ladder transition; a recoverability test proves a total-miss does NOT poison the pane (it fails against the visible-pty approach and passes with onCommandStarted).
Summary
Fix Shift+Enter when the Orca client and active terminal PTY run on different operating systems, such as a macOS client connected to a Windows host.
Shortcut recognition still follows the client keyboard platform, while the bytes written to the terminal follow the active PTY host and application protocol:
ESC+ carriage return by default.ESC+ carriage return.The active pane's captured SSH connection, paired runtime, or live local session wins over later worktree-host changes. Missing platform metadata safely falls back to the client platform.
This prevents
[13;2ufrom being inserted literally in Windows-hosted terminals reached from macOS without regressing applications that explicitly negotiate Kitty keyboard mode.Screenshots
No visual change. This is terminal byte routing; validation used exact renderer-to-PTY byte assertions.
Testing
pnpm typecheckpnpm lintpnpm check:reliability-gatespnpm check:max-lines-ratchetgit diff --check1b0d1b5b31333b3275mainTerminal reliability proof
terminal-input.windows-modified-enter-routing. Shift+Enter bytes follow the active application's negotiated protocol and active PTY host; stale worktree ownership, sibling panes, or prior PTYs cannot change routing authority.Security audit
No auth, secrets, dependencies, filesystem paths, command construction, telemetry, or new IPC behavior. Existing trusted platform and pane metadata select between two fixed terminal byte sequences.