Skip to content

fix(wsl-host): a terminal that meets its stopped distro shows Start, and comes back with it - #35732

Merged
nwparker merged 3 commits into
mainfrom
nwparker/wsl-stopped-host-ux
Oct 29, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/wsl-stopped-host-ux

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​191 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​191
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176 $\color{#cf222e}{\Huge{\mathbf{−}}}$​41 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​135

ELI5

If a WSL distro that runs an Orca host is stopped from outside Orca (for example wsl --terminate), the terminal on that host used to sit there looking alive. It had a green dot and its old prompt, typing did nothing, and a red error showed raw internal text that never went away. Now the terminal shows the existing "{distro} is stopped" card with a Start button. When the distro runs again, by Start or any other way, the terminal reconnects by itself and the error clears.

What Changed

  • Before (verify-7 part 2, main 8d31916):
    • After an external terminate, the WSL-host terminal showed no stopped card.
    • Keystrokes produced nothing.
    • A toast read "Error invoking remote method 'runtimeEnvironments:call': Error: … was stopped. … If this persists, please file an issue". It stayed up after the distro ran again.
    • New Terminal worked.
  • After:
    • The pane shows the Start card and its error toast gives way, as it already did when liveness noticed a stop.
    • Start revives it.
    • If the distro comes back on its own, the host reconnects without a boot and the pane retries, so nothing stays dead.
    • Any remaining host-refusal toast drops Electron's IPC wrapper.
  • Mechanism:
    • The Start card shows only when the host's published status is distro-stopped, and only liveness published that. A keystroke's runtime call that found the distro stopped parked the host and threw, but published nothing. In this run liveness most likely saw a quick reboot (Orca's own background git status on the \\wsl.localhost path started the distro again, which another fix addresses), so the stop was never shown.
    • ensureForRuntimeCall, now ensureWslHostForRuntimeCall in wsl-host-runtime-call.ts (moved out of the service for size), publishes distro-stopped when it parks a host.
    • It also registers a deferred task that lifts the park once a running list confirms the distro runs again. Its open work then reconnects with noBoot.
    • useRetryPanesWhenWslHostReturns retries the host's panes when its status goes from stopped to ready. The card's Start already did this; now the host returning on its own does too.
    • useWorktreeActivityStatus counts no live terminals for a workspace whose WSL host is distro-stopped, so its card dot isn't green over dead panes. The panes keep their bindings for Start, which is why the dot stayed green. A cheap "any host stopped" check runs first, so other cards pay nothing.
    • humanizeTerminalError strips the runtimeEnvironments:* IPC wrapper from those lines only. Local spawn errors keep the wrapper their existing copy matches.

Why

  • The parked refusal stays final, not retryable. Existing tests pin that, so stopped panes don't retry in a loop. The card plus a retry when the host comes back gives the same result without polling a stopped distro.
  • Reusing the stopped status means no new UI. The card, the toast suppression and the Start flow already exist for liveness-detected stops.

Linked Issue

Internal: WSL hosts, verify-7 part 2, item 1. Item 2 (worktree rows) is with wsl-e9-git; item 3 is pending a separate check.

Visual Proof

N/A here. This reuses the existing stopped card, and a device re-check is planned in verify-7 part 3.

Testing

  • Automated tests added. Each was checked against the unfixed code: the service and toast tests fail without the fix; the hook test covers the new hook.
    • wsl-host-service-runtime-call-stop.test.ts:
      • a runtime call that finds the distro stopped publishes distro-stopped, once;
      • once the distro is confirmed running, a host with open work reconnects with noBoot;
      • a host nothing shows stays down until opened.
    • use-wsl-host-return-retry.test.ts: the host's panes retry once on stopped → ready, panes on other servers are untouched, and a stop already showing at mount counts.
    • TerminalErrorToast.test.ts: a runtimeEnvironments:call wrapper is dropped, and other lines are kept as they are.
    • use-worktree-activity-status.test.tsx: a workspace on a stopped host reads inactive; another distro's stop leaves it active. This fails without the fix.
    • Unchanged and still pinned by existing tests: the parked refusal stays a plain, final Error with the same text (wsl-host-service.test.ts, "keeps a parked host's refusal final"). So wsl-move-host-connect and wsl-host-automation-enable see exactly what they saw before.
  • pnpm tc, the src/main/wsl and WSL IPC suites, the terminal-pane portal and toast suites (988 tests), oxlint on the touched files, check:code-quality:changed, and the max-lines and flaky-pattern ratchets pass.

User risk: WSL hosts only, apart from one SSH-visible text change below.

  • A host whose distro is found stopped now shows the Start card instead of a dead pane.
  • When the distro runs again (never started by Orca without the user), the host reconnects and its panes retry.

AI Disclosure

Review

Two reviewers requested (terminal restore).

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

  • SSH: host status, the park and the retry hook are WSL-only, so SSH is unchanged there. The toast unwrap applies to any runtimeEnvironments:* refusal line, including SSH hosts': it removes only Electron's wrapper text.
  • Folder workspaces on a WSL host behave the same as git ones: the card is per pane.
  • Flag-off: without WSL hosts, nothing here runs except the toast unwrap above.
  • Follow-up (not in this PR): a bridge pane whose session was created by an earlier app run and never re-attached exits with no host-loss handling, because the daemon sends an exit only to the attached client. verify-7 confirmed the terminate that logged 2 lines had only p3/p4 attached.

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)

…and comes back with it

After an external `wsl --terminate`, the first keystroke's runtime call found the distro stopped and
parked the host, but only liveness ever published a stopped status, and here liveness saw a quick
reboot instead. So no Start card appeared: the pane kept its old prompt, typing did nothing, and a
red toast showed Electron's raw "Error invoking remote method 'runtimeEnvironments:call'" text that
stayed after the distro ran again.

- The runtime-call gate (moved to wsl-host-runtime-call.ts) publishes distro-stopped when it parks
  a host, as liveness does, so every pane on it shows the Start card and its error gives way.
- The park lifts once a running list confirms the distro runs again (never booting it), and a
  host with open work reconnects.
- Panes that gave up on the stop retry when their host is ready again, not only after Start.
- A host refusal's toast drops Electron's IPC wrapper.

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 29, 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 13 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: 720e6749-1af8-41bc-9a92-6b698c56c58b
Commits

Reviewing files that changed from the base of the PR and between a6f4d87 and 0297da5.

Files selected for processing: 4
  • src/renderer/src/components/sidebar/use-worktree-activity-status.ts
  • src/renderer/src/components/terminal-pane/TerminalPaneRecoveryPortals.tsx
  • src/renderer/src/components/terminal-pane/use-wsl-host-return-retry.test.ts
  • src/renderer/src/components/terminal-pane/use-wsl-host-return-retry.ts

No actionable comments were generated in the recent review.

Recent 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: 7b41c520-ccda-4a69-9e8a-75facbd06698
Commits

Reviewing files that changed from the base of the PR and between ae811d0 and a6f4d87.

Files selected for processing: 12
  • src/main/wsl/wsl-host-connector-contract.ts
  • src/main/wsl/wsl-host-runtime-call.ts
  • src/main/wsl/wsl-host-service-runtime-call-stop.test.ts
  • src/main/wsl/wsl-host-service.ts
  • src/renderer/src/components/sidebar/use-worktree-activity-status.test.tsx
  • src/renderer/src/components/sidebar/use-worktree-activity-status.ts
  • src/renderer/src/components/terminal-pane/TerminalErrorToast.test.ts
  • src/renderer/src/components/terminal-pane/TerminalErrorToast.tsx
  • src/renderer/src/components/terminal-pane/TerminalPaneRecoveryPortals.tsx
  • src/renderer/src/components/terminal-pane/terminal-error-ipc-unwrap.ts
  • src/renderer/src/components/terminal-pane/use-wsl-host-return-retry.test.ts
  • src/renderer/src/components/terminal-pane/use-wsl-host-return-retry.ts

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

Walkthrough

Runtime calls now park confirmed-stopped WSL hosts and retry visible work after the distro runs again. Renderer status reflects a stopped distro for its matching worktree, and pane recovery retries matching transports when the host becomes ready. Terminal error humanization unwraps host-refusal IPC lines before applying existing text transformations.

Priority: Normal

Merge Risk: Minimal · previous review a6f4d

The WSL stop-and-recovery change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the WSL-host fix: stopped-distro terminals show Start and recover when the distro returns.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, risks, visual proof, and checklist. Minor gaps remain: the linked issue is described but not provided as an …
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 is detailed and covers the user impact, implementation, rationale, testing, risks, visual proof, and checklist. Minor gaps remain: the linked issue is described but not provided as an actual issue link, and several standard validation checklist items remain unchecked despite partial test results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. 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 4 functions across 12 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge.

Summary

The PR shows Start when a runtime call finds a stopped WSL host and reconnects open panes after the distro returns.

  • A stopped WSL host shows Start and reconnects when its distro returns.
  • A WSL host returning to ready retries its own terminal panes.
  • Workspace activity dots go inactive when their WSL host stops.
  • Remote-host refusal messages no longer show Electron’s IPC wrapper.

Reviews (3) · Last reviewed commit: "perf(wsl-host): no new store listener pe..." · Reviewed by Greptile

nwparker and others added 2 commits October 28, 2026 23:20
Its panes keep their bindings for Start, so the card dot stayed green over dead terminals.

Co-Authored-By: Claude <[email protected]>
…pped host

The activity status folds the stopped-host check into its existing pty selector, and the pane
recovery portals derive both the Start card and the return retry from one host-status
subscription. The live-capture listener budget (8,000) is back under, with no budget change.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker merged commit 7d0982d into main Oct 29, 2026
65 of 66 checks passed
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