You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(wsl): keep a stopped distro's worktrees and re-list once it runs - #35733
When a WSL distro is stopped, Orca won't start it just to list worktrees. Before this change, the sidebar treated that refusal as an error and dropped the project's worktrees until someone pressed Retry. Now it keeps showing the worktrees it already knew about, calls the stopped distro a state instead of a failure, and refreshes the list by itself once the distro is running.
What Changed
Before: relaunch Orca with a WSL distro stopped, and every project in that distro shows a red "Worktree scan failed for pN … Retry" warning with no worktree rows. Nothing refreshes them until Retry is pressed after the distro has started.
After: those projects keep their rows. A grey power icon says "WSL distro Ubuntu is stopped", or "Couldn't confirm WSL distro Ubuntu is running" when WSL didn't answer. The list refreshes once a user action starts the distro (for example, opening a terminal in it) or the next running-distro read shows it running. Clicking the icon is itself a user action: it starts the distro and scans again.
Mechanism:
Host listing (detected-provider-listing.ts, wsl-stopped-worktree-listing.ts): when the scan fails with the gate's stopped or unverifiable refusal, the listing returns rows rebuilt from stored worktree metadata, plus the main checkout. These are the same rows a disconnected SSH repo gets. The result is non-authoritative, so nothing treats it as proof that a worktree was deleted. A new optional field, wslDistroStopped: { distro, state }, tells the client why. unavailableReason and failureKind keep their old values.
Re-scan (wsl-stopped-worktree-listing.ts, wsl-stopped-worktree-rescan-registry.ts): the listing registers a re-scan, keyed worktree-scan:<repoId>, with the existing background-distro gate. It fires on a settled confirmed-running read or on a 'woken' note, then sends worktrees:changed (to the window and remote clients) so the client lists again. It never probes. Each repo holds at most one pending re-scan. A successful scan drops it, and so does removing the repo, from the same store removal path that retires the repo's scan generation.
Client (fetched-worktree-merge.ts): when the client already has scanned rows, a stopped-distro result keeps them, because stored rows have no branch information. A fresh launch with no rows shows the stored ones.
Retry is a user act (wsl-distro-starting-scan.ts, IPC worktrees:scanStartingWslDistro): the click runs the scan inside runAsWslUserAct for the repo's distro, so it may start the distro, then re-lists. Before, Retry re-ran the gated background scan, which could never start it, even though the refusal text said "Retry… to start it". The bridge method is optional, so the web client and older hosts simply re-list.
Sidebar (RepoWslDistroStoppedIndicator.tsx): neutral text-muted-foreground icon, no destructive color. Strings are added in all 11 locales.
Folder workspaces never run Git and are unchanged; a test pins this.
Why
The gate's refusal is expected E9 behavior, not a failure. The alternatives were:
A new failureKind value: older clients reject unknown values when they validate a listing, so this would break them.
Keeping worktrees: [] and relying on the client to keep its rows: a fresh launch has no rows to keep, which is exactly this bug.
An optional field plus non-authoritative rows is wire-compatible. An older client sees the non-authoritative rows and the old warning text, and it still prunes nothing. Old-client behavior was audited:
The client purge, the missing-worktree terminal sweep, and main's invalid-workspace layout purge all require authoritative: true.
The existing test "does not purge remembered state from a non-authoritative partial refresh" pins the old client path.
This PR adds a stopped-distro case to the main-side purge test.
Linked Issue
N/A (internal, E9 background-boot work)
Visual Proof
Pending a Windows/WSL run by the WSL verification lane. Earlier evidence of the bug: p2-after-retry.png. Unit tests render both new indicator states.
stored rows plus the main checkout, and the flag, for both stopped and unverifiable
other failures unchanged
re-scan fires once on a settled running read and once on a wake, never for another distro, and with no wsl --list probe
one pending re-scan per repo
a successful scan drops the pending re-scan
folder workspaces unchanged
Retry runs its scan inside the distro's user act, and does nothing for folder workspaces, repos outside WSL, or unknown repos
persistence-repo-lifecycle.test.ts: removing the repo drops its pending re-scan.
persistence-invalid-workspace-layout-purge.test.ts: stopped-distro rows purge no workspace layout.
worktrees-fetch-listing-merge.test.ts: the client keeps scanned rows and their tabs and records the flag.
RepoScanUnavailableIndicator.test.tsx: both states render neutral, and a click starts the distro first, then re-lists.
Ran pnpm tc, pnpm run typecheck:ci, check:code-quality:changed, the anti-slop oxlint, and import boundaries. Tested on macOS only; the WSL runtime path needs the Windows lane.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Reviewers: e9-reviewer, fix-reviewer-2.
User-risk: low. This only changes listings whose scan the E9 gate refused. Those listings are non-authoritative, so no path prunes from them. The remaining risk is metadata-fallback visibility: as with disconnected SSH, it fails open, so an external worktree a user hid could show while the distro is stopped.
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
Paired runtime clients list through a separate runtime path that this PR does not change.
No change to dead panes or toasts; that work lives elsewhere.
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)
Keeps remembered worktrees visible when WSL refuses a background scan.
Stopped WSL repos keep their known worktree rows.
Worktree lists refresh when a stopped WSL distro wakes.
The sidebar can start a stopped WSL distro and scan its repo.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Background scan] --> B{WSL permits access?}
B -->|Yes| C[Return scanned worktrees]
B -->|No| D[Return remembered rows without proof of deletion]
D --> E[Wait for wake or confirmed running read]
E --> F[Notify clients to list again]
D --> G[User clicks start and scan]
G --> H[Scan inside WSL user-act scope]
H --> A
The reason will be displayed to describe this comment to others. Learn more.
Stopped distro clears review links
This guard runs too late to preserve scanned rows. When an existing worktree has linkedPR or pushTarget, the stored row's empty branch reaches routeListingBranchSwitchesThroughGitIdentity first. That helper treats it as detached HEAD, clears the branch and review links, and schedules the cleared links to be saved. Returning here does not undo those changes.
Skip branch-switch updates for stopped-distro rows before calling that helper, and add a test with a linked review.
When a WSL distro is stopped or its running state cannot be verified, worktree listing returns known rows with non-authoritative status metadata and schedules a rescan. Renderer merge logic retains existing rows, and the sidebar shows the distro state and a start-and-scan action. Pending rescans are released after a successful scan or repository removal.
Priority: Normal
Merge Risk: Moderate · up to 5fac4
Stopped WSL repositories can lose review state, refresh the wrong same-ID host, or fail to respond to the start-and-scan action. Resolve these edge cases before merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 40.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 checks: 4 passed
Check name
Status
Explanation
Title check
The title is concise, specific, and accurately summarizes the primary change: preserving worktrees for stopped WSL distributions and re-listing them when the distribution runs.
Description check
The description is detailed and covers the required explanation, user-visible behavior, implementation, rationale, testing, risks, compatibility, and checklist items. Visual proof is still pending, an…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description is detailed and covers the required explanation, user-visible behavior, implementation, rationale, testing, risks, compatibility, and checklist items. Visual proof is still pending, and manual testing was not completed locally, but the overall description is substantially complete.
Full details: Docstring Coverage
Explanation
Docstring coverage is 40.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 15 functions across 21 files. (11 skipped: 11 unsupported.)
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
nl -ba src/renderer/src/store/slices/worktrees/metadata/worktree-git-identity-update.ts | sed -n '1,240p'
Repository: stablyai/orca
Length of output: 12179
Skip branch reconciliation for stopped-WSL fallback rows.
When wslDistroStopped is set, fallback rows have branch: '' and head: ''. The merge routes these rows before the keepCurrent guard. If the request-started and current rows still agree, a current row with branch-scoped review context can call updateWorktreeGitIdentity, which replaces its identity with the detached fallback and clears that context. The later guard does not undo this update.
The reason will be displayed to describe this comment to others. Learn more.
Start button leaves WSL stopped
Clicking “Start distro and scan” can leave the distro stopped when a background listing is already checking it. scanWorktreesStartingWslDistro uses the same scan cache, so it can join a scan started outside the user-act scope. That scan still rejects with WslDistroStoppedError instead of starting Git. The click finishes, and the follow-up listing is another background read, so the user must click again.
Retry with a new user-act scan after that refusal, or keep user-act scans from joining background scans.
After a relaunch with a WSL distro stopped, the E9 gate refused the
worktree scan and the sidebar showed "Worktree scan failed" with no rows
until the user pressed Retry. The listing now answers with the stored
rows (non-authoritative, so nothing is pruned), marks the distro stopped
or unverifiable in a new optional field, and re-lists once a wake or a
settled running read shows the distro running. The re-scan is held once
per repo and dropped when the repo is removed. The sidebar shows a
neutral state instead of a failure.
… distro
The indicator's click now runs the scan inside runAsWslUserAct for the
repo's distro (new worktrees:scanStartingWslDistro IPC), then re-lists,
so clicking it can start the distro instead of re-running the gated
background scan that never could.
Pass the execution host through the start-and-scan IPC operation.
When two repositories share repo.id, findExactRepoOwner(store, repoId) finds multiple valid candidates and returns undefined. The indicator already has the selected repository's execution host, but sends only repoId. The operation therefore returns before runAsWslUserAct and performs no scan.
Pass getRepoExecutionHostId(repo) through the IPC boundary. Use it in both findExactRepoOwner and isCapturedRepoCurrent.
Files skipped from review as they are similar to previous changes: 11
src/renderer/src/i18n/locales/de.json
src/renderer/src/i18n/locales/pt.json
src/renderer/src/i18n/locales/es.json
src/renderer/src/i18n/locales/en.json
src/renderer/src/i18n/locales/zh-Hant.json
src/renderer/src/i18n/locales/tr.json
src/renderer/src/i18n/locales/ja.json
src/renderer/src/i18n/locales/zh.json
src/renderer/src/i18n/locales/ko.json
src/renderer/src/i18n/locales/ru.json
src/renderer/src/i18n/locales/fr.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
nl -ba src/main/ipc/worktrees/listing/detected-provider-listing.ts | sed -n '1,130p'printf'%s\n''--- host-qualified dispatch ---'
nl -ba src/main/ipc/worktrees/listing/host-qualified-worktree-listing.ts | sed -n '1,125p'printf'%s\n''--- detected handler dispatch ---'
nl -ba src/main/ipc/worktrees/listing/register-detected-worktree-handlers.ts | sed -n '90,155p'
Repository: stablyai/orca
Length of output: 13711
Release the rescan when the removed host is local.
The stopped-WSL rescan is registered only by the non-folder, non-SSH path. That path represents the local host. The current cleanup releases it only when no same-ID repository remains. If an SSH repository retains the ID, the local rescan remains pending after local removal.
When it later runs, the callback sends a shared repoId notification. notifyWorktreesChanged invalidates by that ID and emits the event without a host discriminator. This can invalidate and refresh the surviving same-ID repository.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When a WSL distro is stopped, Orca won't start it just to list worktrees. Before this change, the sidebar treated that refusal as an error and dropped the project's worktrees until someone pressed Retry. Now it keeps showing the worktrees it already knew about, calls the stopped distro a state instead of a failure, and refreshes the list by itself once the distro is running.
What Changed
Before: relaunch Orca with a WSL distro stopped, and every project in that distro shows a red "Worktree scan failed for pN … Retry" warning with no worktree rows. Nothing refreshes them until Retry is pressed after the distro has started.
After: those projects keep their rows. A grey power icon says "WSL distro Ubuntu is stopped", or "Couldn't confirm WSL distro Ubuntu is running" when WSL didn't answer. The list refreshes once a user action starts the distro (for example, opening a terminal in it) or the next running-distro read shows it running. Clicking the icon is itself a user action: it starts the distro and scans again.
Mechanism:
detected-provider-listing.ts,wsl-stopped-worktree-listing.ts): when the scan fails with the gate's stopped or unverifiable refusal, the listing returns rows rebuilt from stored worktree metadata, plus the main checkout. These are the same rows a disconnected SSH repo gets. The result is non-authoritative, so nothing treats it as proof that a worktree was deleted. A new optional field,wslDistroStopped: { distro, state }, tells the client why.unavailableReasonandfailureKindkeep their old values.wsl-stopped-worktree-listing.ts,wsl-stopped-worktree-rescan-registry.ts): the listing registers a re-scan, keyedworktree-scan:<repoId>, with the existing background-distro gate. It fires on a settled confirmed-running read or on a 'woken' note, then sendsworktrees:changed(to the window and remote clients) so the client lists again. It never probes. Each repo holds at most one pending re-scan. A successful scan drops it, and so does removing the repo, from the same store removal path that retires the repo's scan generation.fetched-worktree-merge.ts): when the client already has scanned rows, a stopped-distro result keeps them, because stored rows have no branch information. A fresh launch with no rows shows the stored ones.wsl-distro-starting-scan.ts, IPCworktrees:scanStartingWslDistro): the click runs the scan insiderunAsWslUserActfor the repo's distro, so it may start the distro, then re-lists. Before, Retry re-ran the gated background scan, which could never start it, even though the refusal text said "Retry… to start it". The bridge method is optional, so the web client and older hosts simply re-list.RepoWslDistroStoppedIndicator.tsx): neutraltext-muted-foregroundicon, no destructive color. Strings are added in all 11 locales.Folder workspaces never run Git and are unchanged; a test pins this.
Why
The gate's refusal is expected E9 behavior, not a failure. The alternatives were:
failureKindvalue: older clients reject unknown values when they validate a listing, so this would break them.worktrees: []and relying on the client to keep its rows: a fresh launch has no rows to keep, which is exactly this bug.An optional field plus non-authoritative rows is wire-compatible. An older client sees the non-authoritative rows and the old warning text, and it still prunes nothing. Old-client behavior was audited:
authoritative: true.Linked Issue
N/A (internal, E9 background-boot work)
Visual Proof
Pending a Windows/WSL run by the WSL verification lane. Earlier evidence of the bug: p2-after-retry.png. Unit tests render both new indicator states.
Testing
src/main/ipc/worktrees/listing/wsl-stopped-worktree-listing.test.tschecks:wsl --listprobepersistence-repo-lifecycle.test.ts: removing the repo drops its pending re-scan.persistence-invalid-workspace-layout-purge.test.ts: stopped-distro rows purge no workspace layout.worktrees-fetch-listing-merge.test.ts: the client keeps scanned rows and their tabs and records the flag.RepoScanUnavailableIndicator.test.tsx: both states render neutral, and a click starts the distro first, then re-lists.Ran
pnpm tc,pnpm run typecheck:ci,check:code-quality:changed, the anti-slop oxlint, and import boundaries. Tested on macOS only; the WSL runtime path needs the Windows lane.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Reviewers: e9-reviewer, fix-reviewer-2.
User-risk: low. This only changes listings whose scan the E9 gate refused. Those listings are non-authoritative, so no path prunes from them. The remaining risk is metadata-fallback visibility: as with disconnected SSH, it fails open, so an external worktree a user hid could show while the distro is stopped.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)