Skip to content

fix(wsl): never boot a stopped distro to check a folder workspace's path - #35899

Merged
nwparker merged 1 commit into
mainfrom
nwparker/wsl-folder-status-gate
Oct 29, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/wsl-folder-status-gate

Conversation

@nwparker

@nwparker nwparker commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​112 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​112
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​47

Flag-off: applies with the flag on or off. It covers folder workspaces whose folder is a \\wsl.localhost path on Windows.
User-risk: Low. While a folder workspace's distro is stopped, its sidebar row shows the existing muted "folder unavailable" mark instead of booting the distro to look. A restored terminal there waits with Start. A terminal the user opens still starts the distro, as before.

ELI5

Orca checks whether a folder workspace's folder still exists. It does this when drawing the sidebar, answering a status request, and before starting a terminal there. On Windows, simply looking at a folder inside a stopped WSL distro starts that distro. So these background checks could boot WSL when the user never asked for it. Now Orca first asks whether the distro is running. If it isn't, the check answers "unavailable right now" without touching the folder. The exception is when the user is the one asking, for example by opening a terminal.

What Changed

  • Before: statFolderPath in folder-workspace-path-status.ts ran fs.stat on the folder for every caller of getFolderWorkspacePathStatus. On a stopped distro, that stat booted it. This affected:
  • After:
    • statFolderPath checks blockedWslDistroForPath first. On a stopped or unverifiable distro, it returns the existing { exists: false, reason: 'unavailable' } and never stats. It never reports "missing", so nothing treats the folder as deleted. A user act on that distro (runAsWslUserAct) passes the gate.
    • pty:spawn runs no user-act scope today. So the folder check in spawn-cwd.ts now splits on the request's wslPassiveRestore flag, which the preflight passes through assertWorkspaceAcceptsNewPty:

Why

  • Gate the one stat function instead of each caller. Every background reader gets the fix, including the sidebar polling.
  • Use 'unavailable', not a new reason. It already exists on the wire, so older clients and remote peers show it unchanged, and it isn't the confirmed-stale (destructive) state.
  • Hold a passive restore with the hold message, not folder_workspace_path_unavailable. The renderer already turns the hold message into the Start card.

For review: the runtime's folder-workspace launch scope (resolveFolderWorkspaceLaunchScope, used by the runtime's terminal create, file sessions and emulator selectors) has no user-act signal. On a stopped distro it now refuses with folder_workspace_path_unavailable instead of booting. That is the conservative E9 choice. If a runtime launch should count as a user act, that belongs in a follow-up.

Linked Issue

Internal WSL tracker, E9. e9-reviewer found this gap during #35895's review. It existed before #35895, and this PR is independent of it.

Visual Proof

N/A: no new UI. The sidebar reuses the existing "unavailable" mark, and a held pane uses #35813's existing Start card.

Testing

New spawn-cwd-wsl-stopped-folder.test.ts, on win32 with a mocked running read and a mocked fs.stat. The first three cases fail without the change.

  • A background getFolderWorkspacePathStatus on a stopped distro returns unavailable and never stats.
  • A passive restore through assertWorkspaceAcceptsNewPty is refused with the hold message and never stats.
  • A user spawn stats the folder inside the user act on that distro.
  • Once the distro runs, a passive restore checks the folder as usual.

Also run:

  • the pty, project-groups, session-graph, project-group-controller and repos IPC suites: 1,568 pass;

  • pnpm tc, typecheck:ci, check:code-quality:changed, the anti-slop lint and the ast-grep gates.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

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

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

The gate is a no-op off Windows and for non-WSL paths. SSH folder workspaces take the existing remote branch before it. The running read is cached, so the sidebar polling adds no wsl.exe spawn per row.

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)

A background read of a \\wsl.localhost folder workspace's status (sidebar
polling, runtime status RPC, a passive terminal restore) stat'ed the folder
and booted its stopped distro. The status now reports 'unavailable' without
touching it; a passive restore holds with Start; a spawn the user asked for
checks the folder as their act, which may start the distro as before.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

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 4 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: 3c6d240f-e7e7-4f06-916d-5638c6736332
Commits

Reviewing files that changed from the base of the PR and between bbb563e and b4638db.

Files selected for processing: 7
  • src/main/ipc/pty/host-env/spawn-cwd-wsl-stopped-folder.test.ts
  • src/main/ipc/pty/host-env/spawn-cwd.ts
  • src/main/ipc/pty/ipc/spawn-preflight.ts
  • src/main/ipc/pty/ipc/spawn-types.ts
  • src/main/ipc/pty/register-handlers.ts
  • src/main/ipc/pty/runtime/controller-deps.ts
  • src/main/project-groups/folder-workspace-path-status.ts
  • 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: 4/5

[Medium impact] The change affects folder checks and terminal restores for Windows WSL workspaces.

Fix explicit folder-workspace creation on stopped WSL distros before merging.

Findings

  1. P1 Folder creation fails ▶

Summary

Adds a WSL running-state check before checking local folder-workspace paths.

  • Folder status checks leave stopped WSL folders untouched.
  • Passive terminal restores wait for stopped WSL folders.

Acknowledged behavior:

  • nwparker intentionally accepts runtime launches being refused on a stopped distro and defers adding a user-act signal.
  • nwparker describes returning unavailable for an unverifiable distro as intentionally conservative.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Folder path check] --> B{SSH or ambiguous?}
  B -->|Yes| C[Existing refusal]
  B -->|No| D{Matching user act?}
  D -->|Yes| E[Check folder]
  D -->|No| F{Distro stopped or unverifiable?}
  F -->|No| E
  F -->|Yes| G[Return unavailable]
  H[Explicit terminal spawn] --> I[Run as user act]
  I --> A
  J[Explicit folder creation] --> A
  G --> K[Creation rejected before save]
Loading

Reviews (1) · Last reviewed commit: "fix(wsl): never boot a stopped distro to..." · Reviewed by Greptile

Comment on lines +117 to +118
if (await blockedWslDistroForPath(path)) {
return { path, exists: false, reason: 'unavailable' }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Folder creation fails

When an existing project group's parentPath points into a stopped WSL distro, clicking Create calls folderWorkspaces:create outside runAsWslUserAct. The new gate returns unavailable, so the handler throws before saving the workspace. The composer allows this submission, but an action that previously started the distro and succeeded now fails.

Keep background reads gated, but run explicit create and path-update checks inside the matching distro's runAsWslUserAct, as this PR does for explicit terminal spawns.

@nwparker
nwparker merged commit bccdb02 into main Oct 29, 2026
42 checks passed
nwparker added a commit that referenced this pull request Oct 29, 2026
…ssively

With #35899's folder stat gate, the runtime preflight passes passiveWslRestore = !wslUserAct, so a background start never stats a stopped distro's folder as a user act before the daemon hold.
nwparker added a commit that referenced this pull request Oct 29, 2026
… distro (#35865)

* fix(wsl): main's background terminal starts never start a stopped WSL distro

Every start main makes through the runtime controller is background work unless its caller names the user's act (CLI and window creates and splits, paired-client creates and tab opens, agent launches and sessions, conversation resumes). #35813's hold now also holds those fresh and restored starts while the distro is stopped or unverifiable.

* fix(wsl): headless Run now starts as the user's act; update create expectations

A headless automation's Run now names the user's act through launchAgentTerminal, so it may start a stopped WSL distro; a scheduled run stays background and is held. The paired-client background create expectation now includes wslUserAct.

* fix(wsl): main's background start checks a folder workspace's path passively

With #35899's folder stat gate, the runtime preflight passes passiveWslRestore = !wslUserAct, so a background start never stats a stopped distro's folder as a user act before the daemon hold.
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