Skip to content

fix(terminal): send CSI-u Shift+Enter to Droid on Windows (#7620) - #7668

Merged
nwparker merged 3 commits into
mainfrom
brennanb2025/droid-enter
Jul 11, 2026
Merged

nwparker merged 3 commits into
mainfrom
brennanb2025/droid-enter

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7620. On native Windows ConPTY panes, Shift+Enter now sends Droid's CSI-u newline sequence only while the current PTY process is freshly confirmed as Droid. Codex, Antigravity, shells, WSL, SSH, paired web, and remote runtimes retain the legacy Windows sequence; macOS and Linux behavior is unchanged.

Reliability proof

Reliability invariant: terminal-input.windows-modified-enter-routing — CSI-u may be routed only to a currently confirmed Droid process belonging to the active local Windows ConPTY. New commands, PTY replacement, exit evidence, focus/visibility recovery, and unavailable inspection revoke or fail closed to legacy routing.

Product change type: Runtime hardening plus experimental reliability-gate coverage.

Correctness evidence:

  • Exact ConPTY console membership filters global Windows descendants and rejects detached children.
  • Fresh confirmation cannot reuse cached process tables or resurrect a recognized fallback that disappeared during the scan.
  • Rapid and idle-separated Shift+Enter input remains CSI-u while Droid is current, including panes with live Droid hooks.
  • Launch metadata is display/confirmation context only; it never authorizes bytes by itself.
  • Stale PTY exit/rebind results and split/detach ownership cannot publish into a replacement pane.
  • WSL, SSH, remote-runtime, paired-web, unknown-agent, shell, Codex, and Antigravity paths fail closed to the pre-existing sequence.

Performance evidence: Ordinary keys and fast shell completion perform no process scan. Routing recovery uses cancellable one-shot reads on the existing 350 ms / 1.2 s / 6 s ladder; process snapshots are deduplicated, and the bounded ConPTY helper starts only after a recognized candidate exists. WSL/SSH/remote paths perform zero confirmation scans. No polling, provider fanout, hidden-pane wake loop, telemetry, or raw terminal logging was added.

Validation:

  • pnpm typecheck
  • pnpm lint
  • Focused reliability gate: 21 files, 1,215 tests passed on the final rebased tree
  • Electron terminal-shortcuts suite passed on macOS; the Windows-only assertion is platform-gated
  • Two independent final adversarial review lanes returned clean

Provider/platform coverage:

  • Local native Windows ConPTY: deterministic main/provider/renderer coverage; live Windows execution is the residual gap
  • Daemon: protocol v21, allowlisted launch identity, fresh confirmation, warm reattach, and stale-result guards covered
  • SSH / WSL / remote runtime / paired web: excluded from CSI-u authority and legacy-safe
  • macOS / Linux: unchanged shortcut behavior; local Electron suite passed

Promotion status: Experimental / partial. The deterministic gate is active, but native Windows ConPTY evidence is not yet blocking CI.

Rollback/demotion rule: Demote if any non-Droid/remote pane receives CSI-u, the Windows byte test flakes or silently skips on Windows, or routing adds polling, ordinary-key scans, provider fanout, or unbounded subprocess work.

Security audit

No dependency, credential, network, workflow, telemetry, raw-output logging, dynamic-evaluation, or arbitrary-filesystem behavior was added. The only new subprocess path is a fixed node-pty ConPTY membership helper with validated integer input, bounded output, a three-second timeout, and fail-closed cleanup.

Residual gap

Native Windows ConPTY was unavailable during maintainer takeover. The Windows-specific Electron assertion and deterministic process/membership suites cover the contract, but a live Windows Droid artifact remains follow-up evidence.

nwparker and others added 2 commits July 6, 2026 22:00
#7620)

On Windows, Shift+Enter was always sent as the Alt+Enter byte ESC+CR (added in
#2418 for Codex, which reads win32-input-mode and ignores CSI-u). droid speaks
the kitty keyboard protocol, parses CSI-u directly, and treats ESC+CR as a plain
Enter — so Shift+Enter SUBMITTED the message instead of inserting a newline.
droid works in other terminals (Windows Terminal, Warp) because those honor
win32-input-mode / kitty; Orca (xterm.js) withholds kitty from local Windows
ConPTY panes and emits neither.

Make the Windows Shift+Enter byte pane-aware: latch whether a pane's program
advertised the kitty keyboard protocol (query CSI ? u, push CSI > .. u, or set
CSI = .. u) and send CSI-u (\x1b[13;2u) to those panes, keeping the
Codex-compatible ESC+CR for win32-input-mode-only TUIs. Non-Windows is unchanged
(always CSI-u).

Verified end-to-end against the real droid and Codex CLIs through the actual
production functions: droid now newlines, Codex still newlines.

@nwparker nwparker 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.

Thanks for identifying the Droid-specific Windows encoding mismatch. I took over the implementation and replaced the sticky terminal-output heuristic with current-process, exact-ConPTY confirmation.

  • CSI-u is limited to freshly confirmed Droid in the active native Windows ConPTY.
  • Codex, Antigravity, shells, WSL, SSH, and remote runtimes keep legacy routing.
  • Stale launch, exit, rebind, detach, and delayed-scan authority now fail closed.
  • The focused reliability gate passes 1,215 tests on the final rebased tree.
  • Security and hot-path audits are clean; native Windows execution remains the explicit evidence gap.

@nwparker nwparker changed the title fix(terminal): send CSI-u Shift+Enter to kitty TUIs (droid) on Windows (#7620) fix(terminal): send CSI-u Shift+Enter to Droid on Windows (#7620) Jul 11, 2026
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The change adds a daemon foreground-confirmation protocol and propagates validated launch-agent identity through daemon, PTY, IPC, preload, and renderer layers. Foreground resolution now supports fresh availability-aware scans and Windows ConPTY membership validation. Renderer tracking records trusted routing evidence, performs reconfirmation after relevant input boundaries, and selects Windows Shift+Enter bytes per pane. Pane detach logic transfers agent state by pane identity, while tests and reliability-gate metadata cover protocol, process, routing, state, and end-to-end behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary, security, and release context, but misses required Screenshots, Testing, AI Review Report, and Notes sections. Add the missing template sections, especially screenshots, testing results, AI review report, and notes, and align the headings to the repo template.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main Windows Droid Shift+Enter fix.
Linked Issues check ✅ Passed The changes implement Windows-native Droid Shift+Enter CSI-u routing with fail-closed confirmation and preserve other agents/platforms, matching #7620.
Out of Scope Changes check ✅ Passed The modified files are all tied to Windows Shift+Enter routing, foreground confirmation, or supporting tests/config, with no clear unrelated feature work.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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: Pro

Run ID: 9cee1927-45eb-415a-b2b0-97b6cbc8fce5

📥 Commits

Reviewing files that changed from the base of the PR and between 5e10091 and ebfd975.

📒 Files selected for processing (59)
  • config/reliability-gates.jsonc
  • src/main/daemon/daemon-errors.ts
  • src/main/daemon/daemon-foreground-confirmation-protocol.test.ts
  • src/main/daemon/daemon-foreground-process-protocol.ts
  • src/main/daemon/daemon-pty-adapter.test.ts
  • src/main/daemon/daemon-pty-adapter.ts
  • src/main/daemon/daemon-pty-router.test.ts
  • src/main/daemon/daemon-pty-router.ts
  • src/main/daemon/daemon-server.test.ts
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/degraded-daemon-pty-provider.test.ts
  • src/main/daemon/degraded-daemon-pty-provider.ts
  • src/main/daemon/pty-subprocess-foreground-scan-cadence.test.ts
  • src/main/daemon/pty-subprocess.test.ts
  • src/main/daemon/pty-subprocess.ts
  • src/main/daemon/session.ts
  • src/main/daemon/terminal-host-create-contract.ts
  • src/main/daemon/terminal-host.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty.test.ts
  • src/main/ipc/pty.ts
  • src/main/providers/agent-foreground-process.test.ts
  • src/main/providers/agent-foreground-process.ts
  • src/main/providers/local-pty-provider.test.ts
  • src/main/providers/local-pty-provider.ts
  • src/main/providers/types.ts
  • src/main/providers/windows-agent-foreground-process.ts
  • src/main/providers/windows-conpty-process-membership.test.ts
  • src/main/providers/windows-conpty-process-membership.ts
  • src/main/providers/windows-foreground-process-rows.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/keyboard-handlers.ts
  • src/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.test.ts
  • src/renderer/src/components/terminal-pane/pane-foreground-agent-tracker.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.test.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-tab-detach.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.test.ts
  • src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts
  • src/renderer/src/components/terminal-pane/terminal-windows-shift-enter.test.ts
  • src/renderer/src/components/terminal-pane/terminal-windows-shift-enter.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/store/slices/pane-foreground-agent.ts
  • src/renderer/src/store/slices/store-cascades.test.ts
  • src/renderer/src/store/slices/terminal-pane-detach-agent-identity.test.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/web/web-preload-api.ts
  • src/shared/agent-process-recognition.test.ts
  • src/shared/process-table-snapshot.test.ts
  • src/shared/process-table-snapshot.ts
  • src/shared/tui-agent-config.ts
  • tests/e2e/terminal-foreground-confirmation.unit.test.ts
  • tests/e2e/terminal-shortcuts.spec.ts
💤 Files with no reviewable changes (1)
  • src/main/daemon/daemon-errors.ts

Comment on lines +121 to +126
execFileMock.mockImplementation(
(_cmd: string, _args: string[], _opts: unknown, cb: unknown) => {
const callback = cb as (err: unknown, result: { stdout: string; stderr: string }) => void
callback(new Error('ps unavailable'), { stdout: '', stderr: '' })
}
)

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the duplicate callback declarations.

Each mock callback declares const callback twice in the same scope, causing a TypeScript redeclaration error and preventing the test file from compiling.

Proposed fix
 const callback = cb as (err: unknown, result: { stdout: string; stderr: string }) => void
-const callback = cb as (err: unknown, result: { stdout: string; stderr: string }) => void
 callback(...)

Also applies to: 300-304, 320-327, 339-353, 384-398

@nwparker
nwparker merged commit b902f19 into main Jul 11, 2026
8 checks passed
@nwparker
nwparker deleted the brennanb2025/droid-enter branch July 11, 2026 04:00
OrcaWin added a commit that referenced this pull request Aug 2, 2026
* fix(terminal): trust Pi CSI-u Shift+Enter on Windows (#9703)

Pi enables the Kitty keyboard protocol at startup and decodes CSI-u, but
TUI_AGENT_CONFIG['pi'] never set windowsShiftEnterEncoding, so on Windows
Pi could only get CSI-u via the flaky live-KKP-flag path
(isKittyKeyboardActivePane). After a tool ran a subprocess that emitted a
reset sequence, the KKP flags dropped to 0, Orca sent Esc+CR, and Pi read
it as plain Enter -> submit. It recovered on the next pane refocus.

Set windowsShiftEnterEncoding: 'csi-u' for pi, mirroring the Droid fix
(#7668), so the trusted CSI-u route covers Pi reliably independent of
KKP-flag churn from tool subprocesses.

* fix(terminal): complete Pi Windows CSI-u trust lifecycle

* test(terminal): name foreground retry timing

* test(git): accept bounded SSH remote probes

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
) (stablyai#7668)

* fix(terminal): send CSI-u Shift+Enter to kitty TUIs (droid) on Windows (stablyai#7620)

On Windows, Shift+Enter was always sent as the Alt+Enter byte ESC+CR (added in
stablyai#2418 for Codex, which reads win32-input-mode and ignores CSI-u). droid speaks
the kitty keyboard protocol, parses CSI-u directly, and treats ESC+CR as a plain
Enter — so Shift+Enter SUBMITTED the message instead of inserting a newline.
droid works in other terminals (Windows Terminal, Warp) because those honor
win32-input-mode / kitty; Orca (xterm.js) withholds kitty from local Windows
ConPTY panes and emits neither.

Make the Windows Shift+Enter byte pane-aware: latch whether a pane's program
advertised the kitty keyboard protocol (query CSI ? u, push CSI > .. u, or set
CSI = .. u) and send CSI-u (\x1b[13;2u) to those panes, keeping the
Codex-compatible ESC+CR for win32-input-mode-only TUIs. Non-Windows is unchanged
(always CSI-u).

Verified end-to-end against the real droid and Codex CLIs through the actual
production functions: droid now newlines, Codex still newlines.

* fix(terminal): route Windows Shift+Enter safely for Droid

---------

Co-authored-by: Neil <neil@stably.ai>
Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#11769)

* fix(terminal): trust Pi CSI-u Shift+Enter on Windows (stablyai#9703)

Pi enables the Kitty keyboard protocol at startup and decodes CSI-u, but
TUI_AGENT_CONFIG['pi'] never set windowsShiftEnterEncoding, so on Windows
Pi could only get CSI-u via the flaky live-KKP-flag path
(isKittyKeyboardActivePane). After a tool ran a subprocess that emitted a
reset sequence, the KKP flags dropped to 0, Orca sent Esc+CR, and Pi read
it as plain Enter -> submit. It recovered on the next pane refocus.

Set windowsShiftEnterEncoding: 'csi-u' for pi, mirroring the Droid fix
(stablyai#7668), so the trusted CSI-u route covers Pi reliably independent of
KKP-flag churn from tool subprocesses.

* fix(terminal): complete Pi Windows CSI-u trust lifecycle

* test(terminal): name foreground retry timing

* test(git): accept bounded SSH remote probes

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
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.

[Bug]: [Droid] Shift + Enter for a line break, treating it simply as Enter instead.

2 participants