Skip to content

test(e2e): keys typed into a new remote terminal before its first prompt reach the shell - #35312

Merged
nwparker merged 4 commits into
mainfrom
nwparker/e2e-remote-early-typing
Oct 28, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/e2e-remote-early-typing

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​127 $\color{#cf222e}{\Huge{\mathbf{−}}}$​7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120
Prod 0 0 0 0

ELI5

Orca's managed-SSH end-to-end tests used to wait for the remote shell to print its first prompt before typing into a new terminal. The helper's comment said keys typed earlier "can be lost, as they would be for a user too." I checked: on current main, keys typed into a new remote terminal before the prompt all reach the shell. This PR adds a test that pins that guarantee and removes the wait, so those SSH tests now check it too.

What Changed

  • New spec tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts. A headless paired host runs bash, whose .bash_profile waits on a release file (bounded at about 30s). For each of 3 new remote terminals, the test:

    • waits for the pane to bind and asserts no prompt is drawn yet;
    • types echo EARLY_TYPING_n_$((40+2)) + Enter;
    • releases the shell, then requires the exact EARLY_TYPING_n_42 output line.

    This is deterministic rather than timing-based: the keys always land while the rc file is still running. The release file starts present, because the host's own startup shell probe reads the same rc file.

  • Helper openTerminalTab (tests/e2e/helpers/orcad-managed-workspace.ts) no longer waits for a prompt before returning.

Test-only change. No product code changes.

Why

The "keys typed before the first prompt lose a prefix" checklist item was reported for WSL and SSH. I traced it layer by layer on main:

  • Shell line discipline: I captured raw PTY transcripts of Debian bash 5.2 under Orca's real shell-ready rcfile, with keys sent from 20 ms to 2.5 s, both as a burst and one key per 10 ms. All 12 ran: the kernel echoes them during the rc file and readline replays them after the prompt. Nothing flushes stdin. The daemon's Session.write passes human input straight to the PTY; only Orca's own startup command waits for shell-ready.
  • Full remote path: renderer → remote-runtime transport → host daemon → PTY. With bash and zsh, a 1.5 s rc file, and keys typed right after bind or split across the bind, every valid round (26/26) ran the whole command.
  • CI history: every instance found predates fix(terminal): keep keys typed into a remounted remote pane before it re-attaches #34630. That PR showed the WSL "first terminal" in that test is really a remounted pane whose attach discarded held keys, and it fixed that. The SSH case is the same remount shape: it fails after switching back from the browser tab.

So I'm not adding a "hold input until the prompt" mechanism. It would delay every remote pane and fixes nothing that reproduces. Instead, this pins the guarantee in CI on Linux.

One deliberate drop remains and is out of scope: pre-bind typing is discarded in panes with startup work, or panes that may show an old terminal (the #10065 safety rule). That's tracked as a product question.

  • Flag-off: N/A. Test-only, with no feature flag and no product code change.
  • User risk: None. No shipped code changes. The risk is only CI flakiness, which the 5× Linux repeat below did not show.

Linked Issue

N/A. This is internal: the flag-on checklist item "keys typed after bind but before the remote shell's first prompt lose a prefix". Related: #34630.

Visual Proof

N/A. Test-only change.

Testing

  • Linux CI, repeated 5×. A single e2e.yml dispatch (run 40681220911) ran on a diag-only branch: this commit plus repeatEach: 5, with the WSL spec's non-terminal cases skipped to fit the job limit. All selected runs passed with no flakes:

    • changed-specs job: the WSL fake-transport terminal case 5/5, and this new spec 5/5;
    • managed-SSH Docker shards: ssh-orcad-terminal-browser-link 5/5, and ssh-orcad-terminal-journeys 15/15 (3 tests × 5), both using the helper without the prompt wait.

    The diag branch has been deleted.

  • Locally on macOS (hidden, ORCA_BACKGROUND_LAUNCH=1, ORCA_E2E_WEB_CLIENT=1), the new spec passed 4/4.

  • pnpm tc and pnpm run typecheck:ci pass. So do oxlint on tests/e2e, the anti-slop lint, the ast-grep gates (flaky-test ratchet OK), check:process-host-imports and check:code-quality:changed.

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

The other five ssh-orcad-* specs that use openTerminalTab (desktop-browser-bridge, terminal-reconnect-idle-frame, pairing-repair, sleep-disconnected, terminal-network-outage) were not in the 5× dispatch, so this PR's own CI covers them.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…mpt reach the shell

Add a headless paired-host spec that types into each new remote terminal after
it binds while the host shell's rc file is still running, then requires the
whole command to run. Drop the managed-SSH helper's wait for a prompt before
typing, so those specs assert the same guarantee.
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The changes since the last review appear safe to merge; they only update wording.

Summary

Adds a remote-terminal test that sends input before the shell’s first prompt and checks that the command runs once.

  • Remote terminal tests can type before the first shell prompt.

Reviews (4) · Last reviewed commit: "test(e2e): name the early-typing test fo..." · Reviewed by Greptile

…an exactly once

The tty echo of the typed command must precede the rc file's own prompt, the
command's output must appear exactly once, and the rc wait outlasts the bind
wait. Throw if the host has no isolated HOME.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d98535c-56a8-4bb0-899d-bdb7176baf7f
Commits

Reviewing files that changed from the base of the PR and between 7f3784b and b8bdb27.

Files selected for processing: 1
  • tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts
Walkthrough

The terminal helper now proceeds after the terminal pane mounts, without waiting for a shell prompt. A new end-to-end test runs three rounds that submit a command while the shell is held in startup, then releases the shell and checks for the command output and echoed-command order.

Priority: Low

Merge Risk: Low · previous review 7f378

The test verifies input before the prompt, but a narrow timing window can leave the intended held-shell case unproven. This is a bounded test-coverage follow-up.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly identifies the main change: an end-to-end test for keys typed into a new remote terminal before its first prompt.
Description check Passed The description follows the repository template and explains the change, rationale, testing, scope, visual proof, and checklist status. It also references related issue #34630 and clearly identifies t…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the repository template and explains the change, rationale, testing, scope, visual proof, and checklist status. It also references related issue #34630 and clearly identifies this as an internal test-only change.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

🔇 Additional comments: 1
tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts-105-110: 1

105-110: Minor · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Assert the output in the rendered terminal.

paneText reads xterm's buffer, so this assertion can pass when the terminal does not render the output. Keep the exact-line buffer check if useful, but also assert the output through the terminal DOM or its accessibility tree. As per coding guidelines, “assert user-visible behavior through the DOM (getByRole, toBeVisible, toHaveText).” The repository has a terminal accessibility-text helper for that check. (raw.githubusercontent.com)

Source: Coding guidelines


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9dcbbd7f-28f5-42ce-bbfa-1a95e46d59f0
Commits

Reviewing files that changed from the base of the PR and between 8866280 and 11d2775.

Files selected for processing: 2
  • tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts
  • tests/e2e/helpers/orcad-managed-workspace.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

mkdirSync(home, { recursive: true })
// Each shell waits in its rc file for the release file (bounded at ~30s), so typing lands first.
const rc = [
'for _ in $(seq 600); do [ -f "$HOME/.orca-e2e-release-rc" ] && break; sleep 0.05; done',

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.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

cat tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts

Repository: stablyai/orca

Length of output: 4938


Script executed:

set -o pipefail
printf '%s\n' '--- helper and terminal-launch references ---'
rg -n -F --glob '*.ts' -e 'launchHeadlessPairedRuntimeHost' -e 'openNewTerminalTabInActiveWorkspace' -e 'openTerminalTab' -e 'SHELL' tests/e2e src | head -240
printf '%s\n' '--- candidate helper files ---'
rg --files tests/e2e | rg 'headless-paired-runtime-host|paired-electron-client|terminal|pty' | head -160

Repository: stablyai/orca

Length of output: 37584


Script executed:

set -o pipefail
printf '%s\n' '--- headless host helper ---'
nl -ba tests/e2e/helpers/headless-paired-runtime-host.ts | sed -n '1,230p'
printf '%s\n' '--- terminal creation implementation ---'
nl -ba src/renderer/src/store/terminals/terminal-active-workspace-creation.ts | sed -n '1,180p'
printf '%s\n' '--- PTY/shell creation references ---'
rg -n -F --glob '*.ts' -e 'createPty' -e 'shellPath' -e 'login shell' -e 'ORCA_DISABLE_MACOS_LOGIN_SHELL' src tests/e2e/helpers | head -220

Repository: stablyai/orca

Length of output: 38580


Script executed:

set -o pipefail
printf '%s\n' '--- web runtime terminal creation ---'
rg -n -F --glob '*.ts' -e 'createWebRuntimeSessionTerminal' -e 'createPtyShellLaunchPlan' -e 'resolveUnixPaneShellPath' -e 'createLocalPty' src tests/e2e
printf '%s\n' '--- relevant file list ---'
rg --files src | rg 'web-runtime-terminal-creation|local-pty-launch-plan|shell-launch-plan|terminal.*creation|pty.*provider'

Repository: stablyai/orca

Length of output: 26172


Script executed:

set -o pipefail
printf '%s\n' '--- renderer runtime terminal path ---'
nl -ba src/renderer/src/runtime/web-runtime-terminal-creation.ts | sed -n '1,120p'
nl -ba src/renderer/src/runtime/web-runtime-terminal-create-operation.ts | sed -n '1,180p'
printf '%s\n' '--- local PTY launch plan ---'
nl -ba src/main/providers/local-pty-launch-plan.ts | sed -n '1,280p'
printf '%s\n' '--- shell launch plan ---'
nl -ba src/main/daemon/pty-subprocess/shell-launch-plan.ts | sed -n '1,150p'
printf '%s\n' '--- shell selection ---'
nl -ba src/main/daemon/shell-ready.ts | sed -n '1,150p'

Repository: stablyai/orca

Length of output: 38366


Script executed:

set -o pipefail
printf '%s\n' '--- shell-ready bash branch and config ---'
nl -ba src/main/daemon/shell-ready.ts | sed -n '119,245p'
printf '%s\n' '--- daemon PTY subprocess launch ---'
nl -ba src/main/daemon/pty-subprocess.ts | sed -n '1,180p'
printf '%s\n' '--- local PTY spawn/readiness application ---'
nl -ba src/main/providers/local-pty-spawn.ts | sed -n '1,180p'
nl -ba src/main/providers/local-pty-shell-readiness-session.ts | sed -n '1,150p'

Repository: stablyai/orca

Length of output: 22742


Prove that the shell is still in the rc wait before typing.

paneIsBound only proves that the PTY is attached. The rc loop can finish after about 30 seconds, show PROMPT, and leave the release file absent. The test can then type the command, create the release file, and pass the output assertion without exercising pre-prompt input.

Emit a marker when the selected shell enters the wait, poll for that marker, and make the shell fail if the wait expires without the release file. The normal Unix path uses /bin/bash -l, so .bash_profile is normally read; the timeout remains a real detection gap.

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

Nitpick comments: 1
tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts: 1

116-121: Trivial · Functional Correctness · Quick win

Wait for a deterministic completion boundary before asserting one match.

The poll succeeds as soon as one output appears. The following paneText read does not wait for terminal output to settle. A duplicate execution whose output arrives later can therefore pass the test. Add a shell-side execution counter or another deterministic completion signal, then assert the exact count after that signal.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d628e401-7021-4e69-888e-1d2ccf7362f1
Commits

Reviewing files that changed from the base of the PR and between 11d2775 and 7f3784b.

Files selected for processing: 1
  • tests/e2e/headless-paired-remote-terminal-early-typing.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

…d exactly-once proofs

The check that the typed line's tty echo precedes the rc file's prompt failed on
Linux CI 2 of 2 (run 40763469331): the pane began with the prompt and the typed
line followed it, while the command still ran exactly once. macOS echoes it during
the rc. Where the echo lands depends on when the host's line discipline sees the
bytes, which this test cannot pin; it is not evidence of loss. What the test keeps
proving: the keys were typed while the rc file still waited (release file absent),
the rc ran (its own PROMPT appears), and the command ran whole, exactly once.
Rename it to say every key typed before the first prompt is delivered exactly
once, and drop the header's claim about how the tty keeps type-ahead.
@nwparker
nwparker merged commit b47f12a into main Oct 28, 2026
84 of 87 checks passed
@nwparker
nwparker deleted the nwparker/e2e-remote-early-typing branch October 29, 2026 00:51
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.

1 participant