Repository navigation
fix(terminal): submit startup commands with CR on every platform (#23250) - #23264
aashish254 wants to merge 1 commit into
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 136669e5676f08897d162819707260172e6b1efd and f1a69c5. 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughStartup-command submissions now default to carriage return on all platforms. Daemon, local PTY provider, and relay call sites use the shared default. Tests update delivery expectations and verify behavior with zsh and Bash, including that LF can remain pending until CR is sent. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable issue was established that would prevent merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change makes startup commands submit with Enter’s carriage-return byte on every platform. The reviewed delivery paths retain their existing readiness and one-shot checks, and no security bypass was identified. Some production security coverage remains incomplete. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 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.
✅ No new issues found.
Reviewed changes — full pass over the 16-file diff at 136669e5.
- One submit byte — new
STARTUP_COMMAND_SUBMIT_BYTE = '\r'insrc/shared/startup-command-submission.ts:34;StartupCommandSubmissionOptions.submitbecomes optional and defaults to it, so the daemon (terminal-host-session-create.ts:198), local provider (local-pty-shell-ready-startup-command.ts:48), and relay (pty-handler.ts:917) each drop theirprocess.platform === 'win32' ? '\r' : '\n'branch. Windows bytes are unchanged; macOS/Linux startup writes switch LF → CR. - SSH path unchanged —
ssh-background-startup-delivery.ts:147keeps its explicitsubmit: '\r', so remote-shell bytes are identical; no wire or stored value changes. - Corrected rationale — the module header and the local-provider comment no longer claim POSIX shells read a raw LF as Enter; the new constant documents the raw-mode /
ICRNLreasoning. A caller-supplied trailing CR/LF is still written verbatim (endsWithSubmit), and that is now pinned by a test. - Tests — new
startup-command-submit-byte.live-shell.test.tsdrives real zsh (vi-mode^Jrebind) and real bash (readline"\C-j") on real ptys: the LF leg is typed-but-not-run, the builder's default runs. Byte-level suites plus nine affected files updated to expect CR; the new file is wired into theshell contractsjob and excluded from the sharded unit job.
I independently checked the cross-shell claim: CR is what submits for fish (default and vi bindings bind CR/enter/ctrl-m to execute), PSReadLine on POSIX (Enter → AcceptLine), and a canonical-mode tty (ICRNL translates CR → NL). The only state where CR would not submit while LF did — canonical mode with ICRNL cleared and no line editor — is unreachable for the shells Orca launches, so this is a safe improvement rather than a regression.
Worth noting without recommending a change: the live-shell proof covers zsh and bash; fish and pwsh-on-POSIX receive CR through the daemon/relay paths but rest on shell-default behavior, not a live fixture. The PR discloses this, and the local provider delivers fish via the wrapper env rather than a PTY write, so the untested exposure is narrow.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
While a line editor owns the terminal it runs in raw mode, so ICRNL is off and an LF arrives as `^J` — a key the user's keymap owns (zsh `bindkey -M viins '^J' …`, readline `"\C-j"`), not a submit byte. Enter sends CR, so CR is the one byte that runs the line in a configured shell and in a canonical-mode tty alike. The three startup paths that picked CR/LF by host OS now take the byte from `STARTUP_COMMAND_SUBMIT_BYTE` in the module that builds the payload, and the module's comment no longer claims a raw LF is always accept-line. Covered by a live-zsh and live-bash regression test that measures the LF case leaving the command at the prompt and the CR case running it.
136669e to
f1a69c5
Compare
|
Two corrections to my What I did not test / checklist wording, plus a rebase that follows from the first one. 1. The
So I rebased this branch onto
2. "CI covers both For completeness, the rebase did not touch a single line of the change: |
|
Hey @aashish254, thank you for this, and for the clear write-up on the issue! I've carried it forward in #23672 so we can get it merged, and you're credited there as a co-author. Closing this one in favour of that. Really appreciate the work 🙏 |

ELI5
When Orca opens a terminal tab and types your agent launch command for you, it has to finish the line the way Enter does. A keyboard's Enter sends a carriage return (
CR,^M). Orca was sending a line feed (LF,^J) on macOS and Linux and keepingCRfor Windows only.Those two bytes usually behave the same — but that sameness is a default binding, not a rule. zsh's line editor and bash's readline both let the user rebind
^J, and binding it to "insert a literal newline into a multiline prompt" is a common thing to do (it is how abindkey -vuser gets a second line without submitting). Once^Jis bound to that, Orca's^Jdoes what the user's widget does instead of submitting, and the command sits typed at the prompt with nothing launched — which is exactly what #23250 reports, and exactly why one press of Enter made it go away.CRis the byte Enter itself sends, so a keymap that has rebinded anything still has a reason to submit on it.What Changed
Before — macOS/Linux tabs:
With
^Jrebound — the reporter'sbindkey -vplusbindkey -M viins '^J' insert_newline, quoted verbatim from #23250 — the tab shows the command typed at the prompt followed by an empty line and waits. Their step 5 is the other half of the evidence: a laterorca terminal send --enter(which writes\r) submitted the whole buffer, and both the startup command and the send ran in the same second ~30 s after the split.After — one byte on every platform:
Mechanism:
src/shared/startup-command-submission.ts:34— new exportedSTARTUP_COMMAND_SUBMIT_BYTE = '\r', documented with the raw-mode/ICRNL reasoning and the measured result.StartupCommandSubmissionOptions.submitbecomes optional (submit?: string) and defaults to it, so the byte has one owner instead of three call sites each re-deriving it.const submit = process.platform === 'win32' ? '\r' : '\n'lines are gone:src/main/providers/local-pty-shell-ready-startup-command.ts:51,src/main/daemon/terminal-host-session-create.ts:201,src/relay/pty-handler.ts:918. Those are the whole set:grep -rn "buildStartupCommandSubmission(" src --include="*.ts" | grep -v "\.test\.ts"lists five call sites — these three, the SSH path below, and the builder itself — and no platform branch for a submit byte survives anywhere undersrc/.src/renderer/src/lib/ssh-background-startup-delivery.ts:146-147is the one caller that still namessubmit: '\r'. Left explicit on purpose: it records that a remote shell is being driven there, and it already sent CR, so its bytes do not change.local-pty-shell-ready-startup-command.tscarried "POSIX treats either as Enter under ICRNL", which is precisely the inference that fails in raw mode, so it is deleted.src/shared/startup-command-submit-byte.live-shell.test.ts— a real zsh and a real bash on a real pty, each run twice (see Testing). Wired into the repo's live-shell convention: added to theshell contractsjob in.github/workflows/pr.yml:559and--excluded from the sharded unit job in.github/workflows/unit-tests.yml:60, like every other*.live-shell.test.ts.Why
The platform branch was a guess about what a shell binds, made in the one place that never needed the guess. It bought nothing on Windows (which already took the
CRarm) and cost the POSIX shells their only byte that is guaranteed to submit. Concretely, on the byte a keyboard sends:ICRNLon, so aCRtyped at the kernel is delivered asLF—CRsubmits there too.ICRNLis off, and each byte arrives as itself:^Mand^Jbecome two independent keys, and only one of them is what Enter sends.So
CRis correct in both modes on every platform whileLFis correct only while nobody has touched the keymap. Choosing one byte also removes the class of bug rather than the instance: the multiline bracketed-paste path already ends with the samesubmit, so the payload's terminator and the terminal's Enter can no longer disagree.And Orca already agrees with this elsewhere: the other path that types into a live terminal — the draft-paste submit,
src/renderer/src/lib/agent-paste-draft.ts:237and its retry at:244— sends'\r'unconditionally, on every platform. So this change does not introduce a new rule; it makes the startup path stop contradicting the paste path, which is the one that has been working.What is deliberately not changed: a command that already arrives with its own trailing
CR/LFis still written verbatim and gets no second submit byte (buildStartupCommandSubmission(...)'sendsWithSubmitbranch), and the multiline bracketed-paste wrapper is untouched. Both are pinned by tests, including a new'keeps a caller-supplied LF on macOS instead of appending a second submit byte'.Linked Issue
Fixes #23250
Visual Proof
No UI and no interaction change, so no screenshot. Two pieces of evidence instead.
(a) The live-shell test, on this branch (macOS 26.6.2 arm64,
/bin/zsh5.9, GNU bash 3.2.57 — real ptys, real keymaps):vitest prints only the legs that took over a second, so the other two names (
zsh runs the command the builder submits by default,bash runs the command the builder submits by default) are quoted in the mutation excerpt under Testing, where they are the legs that fail.The first leg in each pair is the bug's shape, measured rather than asserted: the startup command written with
LFis typed (it appears on the tty) and not run (the file the command creates does not exist), and then a plain\r— Enter — runs it. The command's effect is observed through a file because a pty echoes the line being typed, so matching tty output would match the echo as readily as the result.(b) The standalone witness I posted on #23250, same mechanism, shells driven from a script outside the repo:
Rows 3–4 and 7–8 are why this stays hidden: with default bindings both bytes work, so a
LF-terminated startup command passes CI and every unconfigured shell, and fails only for the users whose keymap owns^J.Testing
Reviewer steps (
pnpm12 viacorepack enable):Measured on this branch (
136669e5, rebased on668fa719) and, for the control, on the base commit in a separate worktree with the same command:Test Files 10 passed (10),Tests 125 passed (125)668fa719Test Files 9 passed (9),Tests 114 passed (114)— +11 tests, all new, nothing previously passing lostpnpm run tc:nodepnpm run check:code-quality:changedChanged-code quality gate passed since 668fa719067e.—0 new finding(s)across 11 changed files on all six gatesMutation gate — each mutation reverts one decision; the suite has to catch every one. Run over the same 10 files (
baseline: Tests 119 passed (119)— that list minusdaemon-pty-startup-delivery.test.ts, which adds the 6 to make 125):The live-shell file is not decoration — on its own, with only the constant reverted to
'\n', it is the thing that fails:(The two
leaves an LF-terminated command at the promptlegs still pass under that mutation, as they should: they pin the mechanism, not the fix.)Whole-repo run (
pnpm exec vitest run --config config/vitest.config.ts, 9,790 files, ~20 min, macOS):79abfa28)Test Files 19 failed | 9664 passed | 107 skipped (9790),Tests 33 failed | 91754 passed | 1 expected fail | 836 skipped (92624)a85057ef, same command, separate worktreeTest Files 18 failed | 9665 passed | 107 skipped (9790),Tests 32 failed | 91748 passed | 1 expected fail | 836 skipped (92617)Both trees are red in
orca's own suite, and the difference between them is three files that are not touched by this change and that pass on the same head tree in isolation (Test Files 3 passed (3),Tests 19 passed (19),Duration 1.57s):structured-agent-session-lease-renewer.test.tsdied onENOTEMPTY: directory not empty, rmdir '/var/folders/…/orca-lease-renewer-hiILx0'(a temp-dir cleanup race),orchestration-adopted-run-binding.test.tsdied on its own wall-clock bound (expected 0.03845772950000003 to be less than 0.019375247999999828) with 25 concurrent workers, andbrowser-route-persisted-worker-egress.electron.test.tsfailed at base and not at head. Those runs predate the live-shell file, so neither number includes it; the 10-file and control rows above are the on-branch measurement.What I did not test, stated plainly:
I did not run a live Orca app with a vi-mode
.zshrcbefore/after. The live-shell test spawns a real/bin/zshand a real/bin/bashon a real pty with the keymap the issue describes, and it feeds thembuildStartupCommandSubmission(...)— the production builder — but it does not go through Orca's own shell wrapper. Consequence: those runs usebracketedPasteSafe: false, i.e. the raw single-line path. The wrapped-shell path that arms bracketed paste is covered by the byte-level tests ('ends a bracketed-paste multiline command when the caller names no submit byte','wraps a multiline startup command in bracketed paste when the shell supports it'), not by a live shell here.Windows is not exercised by anything I ran. It rests on the shape of the change: Windows already took the
CRarm of every branch removed here, so its bytes are identical before and after, andpnpm run tc:nodetypechecks those paths.Bash coverage is
/bin/bash3.2.57 (what macOS ships) locally; Linux CI's Bash 5.x and apt-installed zsh are covered by theshell contractsjob this file is wired into, not by me.pnpm lintandpnpm buildwere not run on this branch.pnpm lintfails at the base commit for a reason unrelated to terminals: re-measured on668fa719in a clean worktree, it gets through every ratchet andoxlintgate and then dies inverify-localization-catalog.mjson 4 keys missing fromsrc/renderer/src/i18n/locales/en.jsonforDiffCommentDraftCard.tsx(auto.components.diff.comments.DiffCommentPopover.f6c449191eand three more). Nothing in this diff is a renderer locale, and syncing that catalog would be its own PR, so I ran the gates that cover these files (oxlint,oxfmt,check:code-quality:changed,tc:node) instead. CI covers bothlintandbuild.I manually tested these changes locally — partly: the byte behaviour was verified on macOS directly against real zsh and real bash ptys, as printed above; no live Orca UI run, as noted above.
Automated tests added/updated, or explained why not below
AI Disclosure
Implementation, tests and this description were drafted by an AI agent (Anthropic Claude, agentic session) under my direction: I picked the approach, reviewed every hunk, and re-ran every number quoted above on this machine. The measured claims (the live-shell runs, the 10-file and base-control counts, the mutation gate, the
#23250witness table) were each re-run here; the "did not test" list should not be read as work a human verified either — that testing simply was not done.Review
Agent skill upstream boundary
Notes
CRarm at all three sites. macOS and Linux change fromLFtoCRfor the startup write only. A canonical-mode tty translates the incomingCRtoLF(ICRNL), so a shell that is not in raw mode reads exactly what it read before; a shell in raw mode gets the byte its Enter binding is expected to answer, which is the case that used to fail.CR. Which shells are paste-safe is decided byisBracketedPasteSafeShell, which this change does not touch. The fish cases inside the suites I ran (startup-command-submission.test.ts,terminal-host.test.ts,daemon-pty-startup-delivery.test.ts,pty-handler-startup-command-delivery.test.ts) are part of the 125 that pass; no fish process was driven live here, and fish was not part of the live-shell witness — a^Jrebound in fish is a different keymap question than the one [Bug]: Startup commands on macOS/Linux are submitted with LF instead of CR, so they don't run when ^J is rebound #23250 reports.src/relay/pty-handler.ts:918) and the SSH automation path (ssh-background-startup-delivery.ts:146) now emit the same byte; the remote-shell behaviour reported in [Bug]: Startup commands on macOS/Linux are submitted with LF instead of CR, so they don't run when ^J is rebound #23250 is fixed by the relay write, which is what drives the pane. No wire format or stored value changes — this is a write-time byte.src/rendererorsrc/preloadsource changed (only.github/workflows/*andsrc/main/src/relay/src/shared).StartupCommandSubmissionOptions.submitwent from required to optional, which is source- and type-compatible for every existing caller. A command that already carries its own trailingCR/LFis still written verbatim with no second byte, so anything that assembled its own terminator keeps its bytes.process.platformcomparison per write; no new I/O, no allocation, payload length unchanged (CRandLFare both one byte).shell contractsjob (pr.yml:559) and excluded from the sharded unit job (unit-tests.yml:60), matching every other*.live-shell.test.tsin the repo. That job installs zsh and requires fish 4+; if the zsh or bash probe is unavailable the file's cases skip rather than fail.Checklist
N/Awith reason —N/A, no UI change; live-shell and witness output quoted insteadpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) —pnpm run tc:node, the 10 affected suites (125 tests) andcheck:code-quality:changedpass locally as measured above;pnpm lintfails at the base commit on an unrelated localization-catalog gate (measured at668fa719, see What I did not test) andpnpm buildwas not run, so CI covers both.