Repository navigation
Conversation
A startup/live color reply on a POSIX pty is deferred until an `stty` subprocess proves the slave's ECHO bit is clear. Any deferral, however short, lets a reply written later in the same turn overtake it — fish's DA1 read sentinel is exactly that — so the held OSC 11 reply lands in the NEXT child process's stdin (#13892). Read the ECHO bit synchronously instead: POSIX redirects a master's mode ioctls to the slave, so `tcgetattr` on the master fd Orca already owns answers for the slave with no fork and no extra fd. When it says quiet and nothing is already queued, the reply is written inside the query's turn. Degrades to today's behavior on any host whose node-pty lacks the patch (no method -> no probe), on Windows/ConPTY, and on `unknown`/`echoing`. Co-authored-by: Orca <[email protected]>
📝 WalkthroughWalkthroughThe change adds native Unix PTY ECHO-state access through the patched 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
config/patches/[email protected] (2)
8-14: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy liftRestore Spectre mitigation for the Windows native targets.
Lines 8-14 and Lines 54-71 remove
SpectreMitigation: 'Spectre'. This weakens the security posture of the shipped PTY binaries. Keep the mitigation enabled. If the build toolchain lacks the required libraries, install the Visual Studio Spectre component in CI and release builds.Also applies to: 54-71
40-50: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse an MSYS-safe
cmd.exeinvocation.Line 41 and Line 50 invoke batch files with bare
cmd /c. Git Bash can rewrite/c, which prevents these GYP commands from running. Use the MSYS-safecmd.exe //d //cform for both commands.As per coding guidelines: “Never launch a
.cmdrunner with barecmd.exe /cfrom a Git Bash pane because MSYS rewrites/c.”Source: Coding guidelines
🧹 Nitpick comments (4)
tests/tools/fish-query-reply-order/capture-reply-order-trace.mjs (3)
229-253: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winDeclare
deferredByReplybefore the ingress that reads it.The
writecallback at Line 232 readsdeferredByReply, but theconstis declared at Line 253, after thePtyStartupIngressconstruction. The callback works today only becausePtyStartupIngressdoes not invokewriteduring its constructor. If the constructor ever flushes a pending reply, this hits the temporal dead zone and throwsReferenceError.Move the declaration above the ingress.
♻️ Proposed change
+/** Reply text -> records awaiting the delivery flush, so the trace can pair them up. */ +const deferredByReply = new Map() + // FIFO model: an immediate reply may not overtake an echo-safe reply queued ahead of it. const fifo = { deferred: 0, held: [] } @@ }) -/** Reply text -> records awaiting the delivery flush, so the trace can pair them up. */ -const deferredByReply = new Map() - // VERBATIM from local-pty-provider.write() (src/main/providers/local-pty-provider.ts ~:1082).
94-94: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winResolve the default fish path instead of hardcoding the Homebrew location.
/opt/homebrew/bin/fishexists only on Apple Silicon with Homebrew. On Linux and on Intel macOS the harness fails until the operator passes--shell. The repository already hasresolveFishBinaryinsrc/shared/fish-binary-requirement, which the sibling test imports.Use that resolver as the default, and keep
--shellas the override.
424-425: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winReturn a non-zero exit code when the run does not reach its markers.
waitForlogsTIMEOUTand returnsfalseat Line 425, but the return value is discarded. Line 511 then exits0unconditionally. A run in which fish never printed a prompt reports success. If anyone wires this harness into a script, the failure is silent.Track the timeout results and exit non-zero when a required marker never appeared.
Also applies to: 511-511
src/shared/pty-startup-reply-delivery.test.ts (1)
54-60: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winClose each deferred delivery at the end of the loop iteration.
answer()arms a write timer, andclose()clears it.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d83d26a4-4a46-4e00-b66a-7b8577400fe6
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
.github/workflows/pr.ymlconfig/patches/[email protected]config/scripts/pr-workflow-parallelism.test.mjssrc/main/daemon/pty-subprocess.tssrc/main/daemon/session.tssrc/main/providers/local-pty-provider.tssrc/relay/pty-handler.tssrc/shared/fish-query-reply-child-stdin.node-pty.test.tssrc/shared/pty-cooked-querier-reply-delivery.node-pty.test.tssrc/shared/pty-slave-line-discipline-echo.test.tssrc/shared/pty-slave-line-discipline-echo.tssrc/shared/pty-startup-ingress-contract.tssrc/shared/pty-startup-ingress.tssrc/shared/pty-startup-reply-delivery.test.tssrc/shared/pty-startup-reply-delivery.tstests/tools/fish-query-reply-order/capture-reply-order-trace.mjs
| 'src/main/pty/omp-shell-wrapper.node-pty.test.ts', | ||
| 'src/shared/fish-query-reply-child-stdin.node-pty.test.ts', | ||
| 'src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts' |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Show the full list and how it is asserted, then compare against the workflow job.
rg -n -B 10 -A 40 'patchedNodePtyContractFiles' config/scripts/pr-workflow-parallelism.test.mjs
rg -n 'node-pty.test.ts' .github/workflows/pr.ymlRepository: stablyai/orca
Length of output: 3786
🏁 Script executed:
#!/bin/bash
sed -n '55,95p' config/scripts/pr-workflow-parallelism.test.mjs
sed -n '220,295p' .github/workflows/pr.yml
rg -n -B 5 -A 8 'node-pty-fd-leak|fish-color-scheme-child-stdin' config/scripts .github/workflows src testsRepository: stablyai/orca
Length of output: 11111
Add src/renderer/src/components/terminal-pane/fish-color-scheme-child-stdin.node-pty.test.ts to patchedNodePtyContractFiles. The file runs in shell_contracts and is excluded from the general shards, but the contract test does not assert either relationship for this file.
Source: Learnings
| { | ||
| re: /^\x1b\]1[012];\?(\x07|\x1b\\)/, | ||
| reply: (m: RegExpExecArray) => `\x1b]11;rgb:1e1e/1e1e/1e1e${m[1]}` | ||
| }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reply with the OSC index that was queried.
The pattern matches OSC 10, 11, and 12, but the reply always uses index 11 and the background color value. An OSC 10 query therefore receives a background-color answer, and an OSC 12 query receives an answer for a different parameter. fish can treat that as an unmatched reply, which weakens the ordering evidence this test collects. tests/tools/fish-query-reply-order/capture-reply-order-trace.mjs keeps OSC10, OSC11, and OSC12 as separate grammars with matching indices.
Echo the captured index back.
🔧 Proposed fix
{
- re: /^\x1b\]1[012];\?(\x07|\x1b\\)/,
- reply: (m: RegExpExecArray) => `\x1b]11;rgb:1e1e/1e1e/1e1e${m[1]}`
+ re: /^\x1b\](1[012]);\?(\x07|\x1b\\)/,
+ reply: (m: RegExpExecArray) =>
+ m[1] === '11' ? `\x1b]11;rgb:1e1e/1e1e/1e1e${m[2]}` : `\x1b]${m[1]};rgb:ffff/ffff/ffff${m[2]}`
},📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| { | |
| re: /^\x1b\]1[012];\?(\x07|\x1b\\)/, | |
| reply: (m: RegExpExecArray) => `\x1b]11;rgb:1e1e/1e1e/1e1e${m[1]}` | |
| }, | |
| { | |
| re: /^\x1b\](1[012]);\?(\x07|\x1b\\)/, | |
| reply: (m: RegExpExecArray) => | |
| m[1] === '11' ? `\x1b]11;rgb:1e1e/1e1e/1e1e${m[2]}` : `\x1b]${m[1]};rgb:ffff/ffff/ffff${m[2]}` | |
| }, |
| onEmission: (emission) => { | ||
| rendered += emission.data | ||
| if (!emission.data.includes(OSC11_QUERY)) { | ||
| return | ||
| } | ||
| verdictsAtQuery.push(echoSyncProbe?.() ?? 'unknown') | ||
| // The host gate, verbatim from local-pty-provider.write(). | ||
| if (extractOnlyCookedEchoSafeQueryReplies(OSC11_REPLY)) { | ||
| ingress.answerLiveQueryReply(OSC11_REPLY) | ||
| } | ||
| }, |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Match the query against an accumulated buffer, not a single emission.
emission.data.includes(OSC11_QUERY) requires all 8 bytes of \x1b]11;?\x07 to arrive in one emission. A pty read can split that sequence across two emissions. If the split happens, the reply is never written, verdictsAtQuery stays empty, and the test fails after the 15s wait. The sibling test in src/shared/fish-query-reply-child-stdin.node-pty.test.ts carries a tail for exactly this reason.
Match against the accumulated rendered buffer and answer once.
🔧 Proposed fix
let rendered = ''
+ let answered = false
const verdictsAtQuery: PtySlaveLineDisciplineEcho[] = []
const ingress = new PtyStartupIngress({
ownerBackend: 'posix-pty',
write: (data) => term.write(data),
onEmission: (emission) => {
rendered += emission.data
- if (!emission.data.includes(OSC11_QUERY)) {
+ if (answered || !rendered.includes(OSC11_QUERY)) {
return
}
+ answered = true
verdictsAtQuery.push(echoSyncProbe?.() ?? 'unknown')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onEmission: (emission) => { | |
| rendered += emission.data | |
| if (!emission.data.includes(OSC11_QUERY)) { | |
| return | |
| } | |
| verdictsAtQuery.push(echoSyncProbe?.() ?? 'unknown') | |
| // The host gate, verbatim from local-pty-provider.write(). | |
| if (extractOnlyCookedEchoSafeQueryReplies(OSC11_REPLY)) { | |
| ingress.answerLiveQueryReply(OSC11_REPLY) | |
| } | |
| }, | |
| let rendered = '' | |
| let answered = false | |
| const verdictsAtQuery: PtySlaveLineDisciplineEcho[] = [] | |
| const ingress = new PtyStartupIngress({ | |
| ownerBackend: 'posix-pty', | |
| write: (data) => term.write(data), | |
| onEmission: (emission) => { | |
| rendered += emission.data | |
| if (answered || !rendered.includes(OSC11_QUERY)) { | |
| return | |
| } | |
| answered = true | |
| verdictsAtQuery.push(echoSyncProbe?.() ?? 'unknown') | |
| // The host gate, verbatim from local-pty-provider.write(). | |
| if (extractOnlyCookedEchoSafeQueryReplies(OSC11_REPLY)) { | |
| ingress.answerLiveQueryReply(OSC11_REPLY) | |
| } | |
| }, |
…ding Two ways the #13892 fix could be off with the suite still green. The probe reaches production through four spreads — pty-subprocess's handle, session.ts, local-pty-provider.ts and the relay's pty-handler — and deleting any of them left 29962 tests passing. Each host now proves the behavior the spread buys: with a pty whose readEchoState says quiet, the probe is consulted and the reply reaches the pty inside the caller's own turn; an `echoing` verdict, or no probe at all, still defers. The other way is a stale node_modules: the JS half of the patch ships in the pnpm patch, so createPtySlaveEchoSyncProbe hands back a probe even when the loaded native binding is the upstream prebuild with no `echoState`. Every verdict is then 'unknown', the fast path never fires, and the old `toBeDefined()` vacuity guard saw nothing. The node-pty suites now require a definite live verdict and, mirroring ORCA_REQUIRE_FISH, skip with the source-build remedy locally while ORCA_REQUIRE_NODE_PTY_ECHO_STATE=1 fails the shell-contracts lane. That remedy names the flag, because plain `pnpm rebuild node-pty` finds the darwin prebuild and exits 0. Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/daemon/session-same-turn-query-reply-wiring.test.ts (1)
1-13: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce the module comments.
Keep one short sentence for the non-obvious invariant.
src/main/daemon/session-same-turn-query-reply-wiring.test.ts#L1-L13: State that the test guards#13892ECHO-probe wiring.src/shared/node-pty-echo-state-requirement.ts#L1-L12: State that nativeechoStateexports must be verified.As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9122f674-7f39-44b0-b7c9-ba716bcbb961
📒 Files selected for processing (9)
.github/workflows/pr.ymlsrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/session-same-turn-query-reply-wiring.test.tssrc/main/providers/local-pty-provider.test.tssrc/relay/pty-handler.test.tssrc/shared/fish-query-reply-child-stdin.node-pty.test.tssrc/shared/node-pty-echo-state-requirement.test.tssrc/shared/node-pty-echo-state-requirement.tssrc/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/shared/fish-query-reply-child-stdin.node-pty.test.ts
- .github/workflows/pr.yml
Upstream stablyai#13904 (between fork base and PR stablyai#13998 base) introduced this self-contained test helper; stablyai#13998's node-pty tests import it. Pull the two files directly so the cherry-picked PR compiles without dragging in stablyai#13904.
|
Current-main audit (2026-09-19): this fix still has strong historical proof and green CI on its original base, but it is not review-ready against today’s |
ELI5
fish asks the terminal "what colour is your background?" and, a moment later, "are you
there?". Orca used to hold the colour answer back for a fraction of a second (to avoid a
different bug) while sending the "are you there?" answer immediately. fish uses that second
answer as its signal that the prompt is done, so it handed the terminal to the program you
just launched — and the colour answer arrived a beat later, straight into that program's
stdin. Now Orca checks, without leaving the current turn, whether holding back is even
necessary; when it isn't, it answers immediately and nothing can overtake it.
What Changed
config/patches/[email protected](extends the existing patch; no new file target,no new module, no new prebuild artifact):
src/unix/pty.cc: newPtyEchoStateexported asechoState—tcgetattr(fd)->1(ECHO set) /0(clear) /-1(bad arg or error).<termios.h>was alreadyreachable in this file (it uses
struct termiosandtcsetattr), so nothing was added.lib/unixTerminal.js(andsrc/unixTerminal.tsfor consistency):readEchoState(),guarded on
typeof pty.echoState === 'function'. Typings untouched — step 2 reads itdefensively, exactly as
readPtySlavePathreadsptsNametoday.src/shared/pty-slave-line-discipline-echo.ts:PtySlaveEchoSyncProbeandcreatePtySlaveEchoSyncProbe(pty, platform)—undefinedon win32 or whenreadEchoStateis absent;1 -> 'echoing',0 -> 'quiet', anything else (including athrow or
-1) ->'unknown'.src/shared/pty-startup-reply-delivery.ts: the sync probe is a 4th ctor param. Inanswer(), after the!defersWrite(...)early return and before theMAX_TRACKED_REPLIESbranch:Three load-bearing properties:
pendingWrites.length === 0preserves ORDER (a replyarriving behind a held one queues instead of jumping, which also makes this mutually
exclusive with the
MAX_TRACKED_REPLIESbranch);kernelEchoImpossible = truematcheswhat today's
'quiet'verdict passes, so the readline/BEL projection stays armed and onlythe kernel caret projection is skipped; and it fails OPEN — no probe,
'unknown'or'echoing'is today's behavior byte for byte.Wired at the three sites that already build the async probe: local provider, daemon
session (via a new optional
echoSyncProbeonSubprocessHandle, produced inpty-subprocess.tsnext toslavePath, because the daemon's pty object lives there), andthe relay pty handler.
Tests plus CI registration — both the
shell_contractsrun list and the shard--excludelist inpr.yml, andpr-workflow-parallelism.test.mjsso the registrationitself is guarded — and the repro harness under
tests/tools/.Why
The earlier "deadline flush" framing was WRONG
The first hypothesis was that the 200 ms probe deadline flushes the reply into a tty that is
still cooked. That is factually wrong, and it was disproven with a native
tcgetattrprobesampling the slave's ECHO bit at the moment each query is observed:
echoAtObserve=0forall 13 queries across 3 runs — the tty is NEVER echoing when a query is observed. The
200 ms hold is pure PROBE LATENCY: the async probe is
execFile('stty'), a subprocess perpoll. The leak also reproduces at a 5.0 ms and a 15.6 ms defer. So the real rule is:
any deferral past the query's own event-loop turn is sufficient to lose the race, because
DA1 (fish's read sentinel) is written in that same turn and overtakes the held OSC reply.
Every "fix the deadline branch" design is therefore dead, and so are these, all measured and
rejected:
sttyfork. DA1 defer p90 102-172 ms with 8panes, max 228-309 ms, and fish BLOCKS on DA1 every prompt. Also failed to close the bug.
blocked on, i.e. reintroduces [Bug]: Raw OSC 10/11 color-query replies leak as text in Linux agent pane (opencode) #12112's shape. Breaks 4 existing tests that encode "the wait
always ends in a write".
isCoalescibleInputalready excludesreplyOnly items.
What the native patch does, and how it degrades
A POSIX pty master's mode ioctls are redirected to the slave, so
tcgetattron the masterfd Orca already owns reads the slave's ECHO bit with no fork and no extra fd. Verified by
direct C on macOS (master ECHO tracks the slave: 0 after clear, 1 after set) at 0.331
microseconds/op, and on Linux in
gcc:13.Degradation is the important half:
defaults SET. That reads as
'echoing', i.e. today's deferral. It fails SAFE, never to afalse
'quiet'.node_modules) —readEchoStateis absent,createPtySlaveEchoSyncProbereturnsundefined, theechoSyncProbeoption is simply not passed, and delivery is byte-for-byte what shipstoday. No wire change and no capability negotiation:
echoSyncProbeis a host-localfunction reference that is never serialized, and
PtyStartupIngressIntent— the thing thatactually crosses the client/host boundary — is untouched. A new client against an old host
and an old client against a new host both keep working; per host, whoever owns the pty
decides locally with what its own node-pty offers.
createPtySlaveEchoSyncProbereturnsundefinedon win32, anddefersWrite()already returns early forwindows-conptybefore the fast path is reached.Entirely unaffected;
src/unix/pty.ccis not even compiled there.Measured result
leaked=true, childStdin"ESC]11;rgb:1e1e/1e1e/1e1e ESC\ hello\n"leaked=false, childStdin"hello\n", 4 consecutive runs'echoing'at raw-delays 5/50/150/250/500 ms, so the fast path never firesIt matches the pure-ordering ceiling (
--bypass-echo-safe) exactly.Linked Issue
Fixes #13892
Visual Proof
N/A — there is no UI change. The defect and the fix are both invisible on screen by
construction: the leaked bytes are consumed by a child process's stdin, which is exactly
why the regression test asserts on what a child process read rather than on what rendered.
Testing
Everything below is real output from this branch on macOS arm64 (darwin 25.3.0), fish 4.
npm_config_build_from_source=true pnpm rebuild node-pty— the patch applies and compiles:CXX(target) Release/obj.target/pty/src/unix/pty.o...gyp info ok, with only node-pty'stwo pre-existing
kevent-Wmissing-field-initializerswarnings and none from the addedcode. The loaded binding exports
[ 'fork', 'open', 'resize', 'process', 'echoState' ]from
build/Release/.npx tsc --noEmit -p config/tsconfig.node.json— clean.npx tsc --noEmit -p config/tsconfig.tc.web.json— clean.npx oxlint— no errors.node config/scripts/check-max-lines-ratchet.mjs— "max-linesratchet OK — 347 grandfathered suppression(s), no new bypasses." No
max-linesdisable wasadded;
pty-startup-ingress.tswas kept under its 300-line cap by collapsing a five-lineonEmission({...})object literal that fits on one line.npx vitest run --config config/vitest.config.ts src/shared src/main/providers src/main/daemon src/relay— 698 files / 7916 tests passed. The one failure,src/relay/agent-exec-handler.test.ts(2 tests), reproduces identically on a clean stashof this branch: it asserts on a spawn env that this machine's ambient environment
perturbs, and is unrelated to this change.
issue-12112-agent-pane-startup-color-reply-leak.repro.test.ts,src/shared/pty-startup-ingress.test.ts,src/shared/pty-startup-ingress-live-query-reply.test.ts,src/main/ipc/pty.test.ts,config/scripts/pr-workflow-parallelism.test.mjs— 549 tests passed. Existing node-ptycontract suites (
fish-color-scheme-child-stdin,omp-shell-wrapper,node-pty-fd-leak)— 20 passed. No existing test was edited to match new behavior.
node tests/tools/fish-query-reply-order/capture-reply-order-trace.mjs --json, 4 runs:{"leaked":false,"childStdin":"hello\n","inversions":0,"maxEchoSafeDeferMs":0.1-0.2}.Tests added
src/shared/pty-slave-line-discipline-echo.test.ts— the sync probe's mapping and everyfail-open case: win32, missing method, non-function property,
null/undefinedpty,-1,undefined, and a throwingreadEchoState, plus a live toggle read through theterminal.
src/shared/pty-startup-reply-delivery.test.ts—answer()takes the fast path ONLY whenthe queue is empty AND the probe says
'quiet'; a non-empty queue still queues and thepair flushes in query order (the ordering property);
'echoing'/'unknown'/ no-probedefer exactly as before; the readline/BEL projection stays armed while the caret
projection retires; ConPTY consults no probe; and a same-turn write reports its own
failure instead of the deferred path's optimistic
true.src/shared/fish-query-reply-child-stdin.node-pty.test.ts— real fish, realPtyStartupIngress/PtyStartupReplyDelivery/ both probes, andlocal-pty-provider.write()'s gate verbatim; the child reads a full LINE (a leaked replycarries no newline, so a
once('data')child would report it alone whenever it landed inits own read);
itWithFishplusfishRequirementViolationso CI cannot go green byskipping. Proven to fail against pre-fix code: with the fast-path condition disabled
it fails with
expected 'CHILD-READ:"^[]11;rgb:1e1e/1e1e/1e1e^[\\hello\n"' to be 'CHILD-READ:"hello\n"'— the issue's exact payload; restored, it passes.src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts— the durable version ofthe
slow-raw-querierharness, and the guard that killed drop-on-expiry: a querier thatasks while COOKED and arms raw mode 50 ms and 250 ms later (the second outruns the 200 ms
probe budget, so the deadline flush answers instead of the probe) must still receive its
reply, and the sync probe must read
'echoing'at query time so the fast path is nevereligible.
Review hardening (second commit)
A reviewer found two ways this fix could be switched off with the suite still green. Both
are now closed by tests only — no runtime behavior changed.
1. The production wiring was unguarded. Deleting the
echoSyncProbespread at everysite left 2391 files / 29962 tests passing, so the fix's only real-world delivery path could
be refactored away silently. Each of the four links now proves the BEHAVIOR the spread buys
rather than matching source text — given a pty whose
readEchoStatesays quiet, the probe isconsulted and the reply reaches the pty inside the caller's own turn:
pty-subprocess.ts(builds the handle's probe)pty-subprocess.test.ts— "sync ECHO probe on the handle"expected undefined to be 'quiet'session.tssession-same-turn-query-reply-wiring.test.tsexpected "vi.fn()" to be called at least oncelocal-pty-provider.tslocal-pty-provider.test.ts— "same-turn query reply wiring"relay/pty-handler.tspty-handler.test.ts— "same-turn query reply wiring"Each deletion was actually performed and the failure observed, then reverted. Each host also
keeps a negative case: an
echoingverdict (and, for the daemon, no probe at all) stilldefers, so the guard cannot be satisfied by writing unconditionally.
2. The vacuity guard could not detect a prebuilt binding. The JS half of the patch ships
in the pnpm patch, so
createPtySlaveEchoSyncProbereturns a DEFINED probe even when theloaded native module is the upstream prebuild — exports
['fork','open','resize','process'],no
echoState.readEchoState()then answersundefined, the probe maps it to'unknown'forever, the fast path never fires, and the old
expect(probe).toBeDefined()saw nothing.New
src/shared/node-pty-echo-state-requirement.tsmirrorsfish-binary-requirement.ts: itinspects node-pty's
nativebinding for a realechoStateexport, both node-pty suites nowrequire a DEFINITE
'quiet' | 'echoing'verdict off the live pty instead of a defined probe,and an always-running requirement test fails when
ORCA_REQUIRE_NODE_PTY_ECHO_STATE=1. Theshell contractslane sets it (along withORCA_REQUIRE_FISH=1, whose comment alreadypromised a test-time re-check that was never actually wired), so CI fails loudly while a
developer with a stale
node_modulesgets a skip naming the remedy — and the remedy namesthe flag, because plain
pnpm rebuild node-ptyfinds the shipped darwin prebuild andexits 0.
Verified by simulating the prebuild (stripping
echoStatefrom the loaded binding): withoutthe env var both suites report
3 passed | 3 skipped; withORCA_REQUIRE_NODE_PTY_ECHO_STATE=1both fail with
ORCA_REQUIRE_NODE_PTY_ECHO_STATE=1 but the patched-node-pty tests would skip: the loaded node-pty native binding exports [fork, open, resize, process] and has no echoState.... Restored, both suites pass against real fish 4.7.1.After the hardening commit, on the same machine:
npx tsc --noEmit -p config/tsconfig.node.jsonclean;npx oxlintexit 0 with no new warnings;node config/scripts/check-max-lines-ratchet.mjs"OK — 347 grandfathered suppression(s), nonew bypasses" (no
max-linesdisable added, andpty-startup-ingress.tsuntouched);npx vitest run --config config/vitest.config.ts src/shared src/main/providers src/main/daemon src/relay— 701 files / 7933 tests passed, 21 skipped, 0 failures (theagent-exec-handlernoise above is this machine's ambientGIT_CONFIG_COUNT; unsetting itmakes that file pass unchanged);
config/scripts/pr-workflow-parallelism.test.mjs12 passed.The tests read no ambient
process.envbeyondPATH, which they pass explicitly into thepty rather than mutating.
Platforms: macOS verified end to end. Linux is covered by the
shell_contractsCI lane(where both new node-pty suites are registered) and always builds node-pty from source, so
echoStateis present there. Windows is unaffected by construction (win32 short-circuit,defersWriteearly return, andsrc/unix/pty.ccnot compiled). SSH/relay, WSL and folderworkspaces are unaffected: the probe is built per-pty by whichever host owns it.
AI Disclosure
Written with Claude (Opus 5).
Review
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH,
Mobile, general backwards compatibility, performance.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)Made with Orca 🐋