Repository navigation
fix(terminal): preserve startup query reply order (STA-3948) - #14609
brennanb2025 wants to merge 1 commit into
Conversation
Answer cooked-mode terminal queries in the originating turn when the native PTY can prove echo is quiet, and hold later query-only replies behind deferred replies on upstream SSH relays. Keep renderer replies atomic and bound both renderer and host-side queues with local, daemon, relay, native, and Docker SSH fish regression coverage. Co-authored-by: Neil <[email protected]>
📝 WalkthroughWalkthroughThe change adds patched node-pty ECHO-state support and shared capability checks. PTY startup reply delivery now supports immediate quiet-state writes and ordered deferred replies. Daemon, local, relay, and remote-runtime paths preserve query-reply boundaries and input ordering with bounded buffering. New tests cover native support, PTY wiring, terminal replies, fish handoffs, SSH relays, and CI reliability gates. Merge Risk: 🟠 High · up to This PR changes terminal startup query-reply ordering and native PTY handling, but the current head removes Spectre mitigation from Windows native builds and leaves new same-turn tests unguarded where the synchronous probe is unavailable, creating security exposure and Windows validation risk. Merge should be blocked until the mitigation is restored and the tests are POSIX-gated. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
config/patches/[email protected] (1)
9-11: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick winRetain Spectre mitigation for Windows native builds.
The patch removes
SpectreMitigation: 'Spectre'frombinding.gypand both winpty targets. No/Qspectreor equivalent setting replaces it. Restore the mitigation and provision the matching Spectre-mitigated MSVC libraries in Windows build environments.
🧹 Nitpick comments (2)
src/shared/pty-startup-reply-delivery.ts (1)
4-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueCondense the explanatory comments.
Keep the safety invariant. Remove the detailed incident narrative and repeated mechanics. One brief rationale per path is sufficient.
As per coding guidelines: “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Also applies to: 210-215
Source: Coding guidelines
src/shared/fish-query-reply-child-stdin.node-pty.test.ts (1)
217-245: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winWait for the OSC query instead of using a fixed handoff delay.
Replace
sleep(1_500)with a boundedwaitUntil(() => oscQueryCount > oscQueriesBeforeHandoff, ...). The reliability gate tracks the related SSH oracle, not this test file; its flake status remains unknown, with no CI or soak data.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 355de8ac-12a1-4554-ac9d-abc64d401b5f
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (34)
.github/workflows/pr.ymlconfig/patches/[email protected]config/reliability-gates.jsoncconfig/scripts/pr-workflow-parallelism.test.mjssrc/main/daemon/pty-subprocess.test.tssrc/main/daemon/pty-subprocess.tssrc/main/daemon/session-same-turn-query-reply-wiring.test.tssrc/main/daemon/session.tssrc/main/providers/local-pty-provider.test.tssrc/main/providers/local-pty-provider.tssrc/relay/pty-handler.test.tssrc/relay/pty-handler.tssrc/renderer/src/components/terminal-pane/pty-input-write-queue.test.tssrc/renderer/src/components/terminal-pane/pty-input-write-queue.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-batching.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-batching.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-query-reply-immediate.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.tssrc/renderer/src/components/terminal-pane/remote-runtime-pty-transport.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.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-live-query-reply.test.tssrc/shared/pty-startup-ingress.tssrc/shared/pty-startup-reply-delivery.test.tssrc/shared/pty-startup-reply-delivery.tssrc/shared/terminal-query-reply-delivery.tssrc/shared/terminal-query-reply.test.tssrc/shared/terminal-query-reply.tstests/e2e/pty-input-write-queue-ssh.spec.ts
| "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/pty-input-write-queue.test.ts src/renderer/src/components/terminal-pane/pty-transport.test.ts src/shared/terminal-query-reply.test.ts src/shared/pty-startup-ingress-live-query-reply.test.ts", | ||
| "pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-batching.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-query-reply-immediate.test.ts src/renderer/src/components/terminal-pane/remote-runtime-pty-transport.test.ts", | ||
| "pnpm exec vitest run --config config/vitest.config.ts src/shared/pty-startup-reply-delivery.test.ts", | ||
| "pnpm exec playwright test tests/e2e/terminal-osc-color-queries.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", | ||
| "pnpm exec playwright test tests/e2e/terminal-typing-latency.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", | ||
| "ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1" | ||
| ], |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Two new commands have no corresponding evidenceRuns entry.
The commands array adds two vitest invocations at lines 9918-9919: one covering remote-runtime-pty-batching.test.ts, remote-runtime-pty-query-reply-immediate.test.ts, and remote-runtime-pty-transport.test.ts, and one covering src/shared/pty-startup-reply-delivery.test.ts. Both commands have matching testFiles entries and assertionRefs (lines 9927-9932, 9958-9976, 9989-9994). Neither command has a matching entry in evidenceRuns (lines 10015-10061).
This file exists to record proof that each declared command actually ran and passed. Without an evidenceRuns entry, a reader cannot confirm these two commands were executed, even though the gate's flakeHistory and redGreenEvidence narratives describe broader validation.
Add an evidenceRuns entry for each of the two commands, or remove them from commands until evidence exists.
Also applies to: 9927-9932, 9958-9976, 9989-9994, 10015-10061
| { | ||
| "date": "2026-08-14", | ||
| "runner": "local", | ||
| "platform": "macos", | ||
| "command": "ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", | ||
| "result": "passed", | ||
| "durationSeconds": 36.9, | ||
| "summary": "Run with SKIP_BUILD=1 against the existing e2e bundle. Both Docker OpenSSH Electron tests passed: the live OSC query returned its RGB reply, and an upstream-node-pty Linux ARM64 relay without echoState kept OSC/DA1 bytes out of the next fish 4.8.1 child's stdin." | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
The recorded command does not match the summary's description of how it ran.
The command field at line 10056 is:
ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1
The summary field at line 10059 states: "Run with SKIP_BUILD=1 against the existing e2e bundle." SKIP_BUILD=1 does not appear in the recorded command.
A reader who reruns the exact recorded command will perform a full build, not reuse the existing bundle as the summary claims. Add SKIP_BUILD=1 to the command string, or correct the summary to match the command that was actually recorded.
📝 Proposed fix
- "command": "ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1",
+ "command": "ORCA_E2E_SSH_DOCKER=1 SKIP_BUILD=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1",📝 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.
| { | |
| "date": "2026-08-14", | |
| "runner": "local", | |
| "platform": "macos", | |
| "command": "ORCA_E2E_SSH_DOCKER=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", | |
| "result": "passed", | |
| "durationSeconds": 36.9, | |
| "summary": "Run with SKIP_BUILD=1 against the existing e2e bundle. Both Docker OpenSSH Electron tests passed: the live OSC query returned its RGB reply, and an upstream-node-pty Linux ARM64 relay without echoState kept OSC/DA1 bytes out of the next fish 4.8.1 child's stdin." | |
| } | |
| { | |
| "date": "2026-08-14", | |
| "runner": "local", | |
| "platform": "macos", | |
| "command": "ORCA_E2E_SSH_DOCKER=1 SKIP_BUILD=1 pnpm exec playwright test tests/e2e/pty-input-write-queue-ssh.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1", | |
| "result": "passed", | |
| "durationSeconds": 36.9, | |
| "summary": "Run with SKIP_BUILD=1 against the existing e2e bundle. Both Docker OpenSSH Electron tests passed: the live OSC query returned its RGB reply, and an upstream-node-pty Linux ARM64 relay without echoState kept OSC/DA1 bytes out of the next fish 4.8.1 child's stdin." | |
| } |
|
|
||
| // Wiring guard for #13892; see session-same-turn-query-reply-wiring.test.ts for why | ||
| // this is asserted per host rather than once on PtyStartupIngress. | ||
| describe('same-turn query reply wiring', () => { | ||
| const OSC11_REPLY = '\x1b]11;rgb:1e1e/1e1e/1e1e\x07' | ||
|
|
||
| it('hands the pty’s sync ECHO probe to the startup ingress', async () => { | ||
| const write = vi.fn() | ||
| const readEchoState = vi.fn(() => 0) | ||
| spawnMock.mockReturnValueOnce({ ...mockProc, write, readEchoState }) | ||
| const { id } = await provider.spawn({ cols: 80, rows: 24 }) | ||
|
|
||
| provider.write(id, OSC11_REPLY) | ||
|
|
||
| // Both matter: the probe must be CONSULTED, and a `quiet` verdict must reach the | ||
| // pty in this turn rather than behind the deferral timer. | ||
| expect(readEchoState).toHaveBeenCalled() | ||
| expect(write).toHaveBeenCalledWith(OSC11_REPLY) | ||
| }) | ||
|
|
||
| it('still defers the reply when the pty reports the slave would echo', async () => { | ||
| const write = vi.fn() | ||
| spawnMock.mockReturnValueOnce({ ...mockProc, write, readEchoState: () => 1 }) | ||
| const { id } = await provider.spawn({ cols: 80, rows: 24 }) | ||
|
|
||
| provider.write(id, OSC11_REPLY) | ||
|
|
||
| expect(write).not.toHaveBeenCalled() | ||
| }) | ||
|
|
||
| it('does not let DA1 overtake a held OSC reply', async () => { | ||
| const da1 = '\x1b[?1;2c' | ||
| const write = vi.fn() | ||
| spawnMock.mockReturnValueOnce({ ...mockProc, write, readEchoState: () => 1 }) | ||
| const { id } = await provider.spawn({ cols: 80, rows: 24 }) | ||
|
|
||
| provider.write(id, OSC11_REPLY) | ||
| provider.write(id, da1) | ||
|
|
||
| expect(write).not.toHaveBeenCalled() | ||
| }) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
The new same-turn query reply wiring suites run unguarded on Windows. createPtySlaveEchoSyncProbe returns undefined when platform === 'win32', so neither host installs an echoSyncProbe on a Windows runner. In both suites the first test fails, because readEchoState is never called and the reply is deferred. The remaining tests pass vacuously and stop guarding the deferral behavior. The sibling suites already gate this: src/main/daemon/pty-subprocess.test.ts uses itOnPosixHost, and src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts uses itOnPosix.
src/main/providers/local-pty-provider.test.ts#L2294-L2335: declare a POSIX gate in thesame-turn query reply wiringblock and apply it to all threeit(calls, unless the suite already pinsprocess.platformto a POSIX value.src/relay/pty-handler.test.ts#L3930-L3971: apply the identical POSIX gate to all threeit(calls in the matching block.
As per coding guidelines, "commands and scripts must work on macOS, Linux, and Windows".
📍 Affects 2 files
src/main/providers/local-pty-provider.test.ts#L2294-L2335(this comment)src/relay/pty-handler.test.ts#L3930-L3971
Source: Coding guidelines
| }) | ||
|
|
||
| const echoProbe = createPtySlaveEchoProbe(readPtySlavePath(term)) | ||
| const echoSyncProbe = createPtySlaveEchoSyncProbe(term) | ||
| // Vacuity guard: a DEFINED probe proves nothing — the JS patch alone yields one that | ||
| // answers 'unknown' forever. Only a definite verdict off this live pty proves the | ||
| // native echoState is really being read, and so that there is a fast path to regress. | ||
| expect( | ||
| echoSyncProbe?.(), | ||
| `the sync probe gave no definite verdict, so #13892's same-turn reply is off. ${NODE_PTY_SOURCE_BUILD_HINT}` | ||
| ).toMatch(/^(quiet|echoing)$/) | ||
|
|
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🌐 Web query:
Vitest onTestFinished hook availability and version
💡 Result:
The onTestFinished hook is an available and officially supported feature in Vitest for cleaning up state after a test has finished running [1][2]. It is called after afterEach hooks and is not affected by the sequence.hooks configuration option [1][2]. You can use onTestFinished in two primary ways: 1. As a global import from vitest: import { onTestFinished, test } from 'vitest'; test('example', => { onTestFinished( => { /* cleanup logic / }); }); 2. From the test context (recommended for concurrent tests): When running tests concurrently, it is best practice to use the hook provided by the test context because Vitest does not track concurrent tests in global hooks [1][2]. import { test } from 'vitest'; test.concurrent('concurrent example', ({ onTestFinished }) => { onTestFinished( => { / cleanup logic */ }); }); The hook is available in current versions of Vitest, including v4.x [2][3][4]. It is designed to ensure cleanup code runs even if a test assertion fails, making it a reliable way to manage resources like database connections or mock restorations [1][2].
Citations:
- 1: https://vitest.dev/api/hooks.html
- 2: https://github.com/vitest-dev/vitest/blob/v4.1.10/docs/api/hooks.md
- 3: https://github.com/vitest-dev/vitest/blob/v4.1.9/docs/api/hooks.md
- 4: https://github.com/vitest-dev/vitest/blob/v4.1.7/docs/api/hooks.md
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
git ls-files | rg '(^|/)(package\.json|pnpm-lock\.yaml|yarn\.lock|package-lock\.json|src/shared/fish-query-reply-child-stdin\.node-pty\.test\.ts)$'
printf '%s\n' '--- Vitest declarations and versions ---'
rg -n '"vitest"|vitest@|onTestFinished' package.json package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true
printf '%s\n' '--- test imports and cleanup context ---'
sed -n '1,280p' src/shared/fish-query-reply-child-stdin.node-pty.test.tsRepository: stablyai/orca
Length of output: 10643
🌐 Web query:
Vitest v4.1.5 onTestFinished API hooks
💡 Result:
In Vitest v4.1.5, the onTestFinished API hook is a powerful tool designed to perform cleanup tasks after a test has completed, regardless of whether it passed or failed [1][2]. Key details for using onTestFinished: Usage: It is called during test execution to register a cleanup function [1][3]. This is particularly useful for managing resources—such as closing database connections or cleaning up temporary files—where you want the cleanup logic to remain close to the resource's initialization [1][3]. Concurrent Tests: When running tests concurrently, you must use the version of onTestFinished provided via the test context to ensure it correctly associates the cleanup logic with the specific test being executed [1][4][5]. Example: test.concurrent('performs a task', ({ onTestFinished }) => { const resource = setupResource; onTestFinished( => resource.cleanup); //... test code }); Behavior: 1. Execution Order: This hook runs after all afterEach hooks [1][4]. 2. LIFO Order: Multiple onTestFinished hooks are executed in reverse order of their registration (Last-In, First-Out) [1][2]. 3. Independence: Its execution is not affected by the sequence.hooks configuration option [1][4]. 4. Limitations: The hook is not called if a test is skipped using a dynamic ctx.skip call [2]. Comparison to Spies: It is considered best practice to use onTestFinished for cleaning up spies (e.g., spy.mockClear) rather than relying on standard afterEach blocks, as onTestFinished is guaranteed to run even if an assertion within the test fails [1][4].
Citations:
- 1: https://vitest.dev/api/hooks.html
- 2: https://github.com/vitest-dev/vitest/blob/9423dc08/packages/runner/src/hooks.ts
- 3: https://vitest.dev/guide/learn/setup-teardown
- 4: https://github.com/vitest-dev/vitest/blob/v4.1.10/docs/api/hooks.md
- 5: https://v2.vitest.dev/api/
Register PTY cleanup before the vacuity assertion. Import onTestFinished from vitest and register term.kill() immediately after nodePty.spawn; otherwise an assertion failure before try leaves fish running.
| // The host gate, verbatim from local-pty-provider.write(). | ||
| if (extractOnlyCookedEchoSafeQueryReplies(OSC11_REPLY)) { | ||
| ingress.answerLiveQueryReply(OSC11_REPLY) | ||
| } | ||
| }, |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Verify the host write gate shape and remaining users of the echo-safe extractor.
set -euo pipefail
echo '== current host write gates =='
ast-grep run --pattern 'answerLiveQueryReply($$$)' --lang typescript src
echo '== remaining references to the extractor =='
rg -n -C 3 'extractOnlyCookedEchoSafeQueryReplies' srcRepository: stablyai/orca
Length of output: 182
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '== target test imports and query-reply section =='
sed -n '1,45p;105,140p' src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts
echo '== provider write implementation =='
rg -n -C 12 'answerLiveQueryReply|extractOnlyCookedEchoSafeQueryReplies' src/main/providers/local-pty-provider.ts
echo '== all extractor references =='
rg -n -C 3 'extractOnlyCookedEchoSafeQueryReplies' src || true
echo '== all answerLiveQueryReply references =='
rg -n -C 5 'answerLiveQueryReply' src || trueRepository: stablyai/orca
Length of output: 31892
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '== ingress delivery semantics =='
sed -n '1,190p' src/shared/pty-startup-ingress.ts
rg -n -C 12 'function deliverTerminalQueryReplyPayload|const deliverTerminalQueryReplyPayload|deliverTerminalQueryReplyPayload' src/shared
echo '== relevant test assertions and cleanup =='
sed -n '140,240p' src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts
echo '== structural comparison of production and test host-write shapes =='
python3 - <<'PY'
from pathlib import Path
provider = Path('src/main/providers/local-pty-provider.ts').read_text()
test = Path('src/shared/pty-cooked-querier-reply-delivery.node-pty.test.ts').read_text()
for name, text, needles in [
('provider', provider, ['answerLiveQueryReply(data)', 'ptyProcesses.get(id)?.write(data)']),
('test', test, ['extractOnlyCookedEchoSafeQueryReplies(OSC11_REPLY)', 'answerLiveQueryReply(OSC11_REPLY)']),
]:
print(name)
for needle in needles:
print(f' {needle!r}: {text.count(needle)}')
PYRepository: stablyai/orca
Length of output: 12523
Align the test with the production reply path
Call ingress.answerLiveQueryReply(OSC11_REPLY) directly, remove the stale “verbatim” comment, and delete the unused extractOnlyCookedEchoSafeQueryReplies import. PtyStartupIngress now performs the reply classification.
|
Closing in favour of #15567, which carries this work forward. That PR is this branch rebased onto
The approach here was the right one and is unchanged: the Your commit is preserved with its |
ELI5
Some shells ask the terminal questions while they start. Orca could delay an early OSC answer while keyboard echo was active, let a later DA1 answer pass it, and then deliver the delayed bytes to the next child process as if the user had typed them. This change answers immediately when the kernel proves echo is quiet and otherwise keeps every later query reply behind the earlier delayed one.
What Changed
echoStateprobe to node-pty so safe replies can be delivered in the same turn.main.This focused maintainer PR supersedes #13998.
Why
The bug is ordering, not only timing: once an OSC/private DSR reply is deferred, DA1/CPR replies must not overtake it. Moving the kernel echo check into the same native call turn closes the local race, while an ordered fallback protects upstream SSH hosts that cannot expose the synchronous probe.
There is no wire-format change. Patched native hosts use the synchronous probe; older or unpatched SSH hosts preserve reply order but may retain the existing bounded 200 ms fallback. Windows ConPTY is unaffected. Modified-F3/CPR ambiguity shares the same bounded reply budget.
Linked Issue
Fixes #13892
Linear: STA-3948
Visual Proof
N/A — this changes terminal input routing and has no visible UI or layout change. Contextual Linux SSH/fish validation:
Testing
pnpm lint(LINT_OK)pnpm typecheck(TYPECHECK_OK)"hello\n"; the relay node-pty did not exposeechoStatetcgetattrreads measured approximately 0.25–0.324 μs/readReview
Reviewed for native/local/daemon/SSH/remote-runtime behavior, folder workspaces, mixed-version compatibility, Windows/ConPTY degradation, bounded storage, query-reply atomicity and ordering, security, and performance. Two independent reviewers returned CLEAN on the exact final head.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (lint, typecheck, affected tests, and SSH E2E pass locally; CI covers the full matrix)Author