Skip to content

fix(wsl-mover): undo's host checks fail closed with one deadline; label moved automations - #34686

Merged
nwparker merged 2 commits into
mainfrom
nwparker/wsl-mover-undo-followups
Oct 28, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/wsl-mover-undo-followups

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​195
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

ELI5

Four small follow-ups to the WSL project mover (#34059). Two make "Use on this computer again" (undo) refuse instead of guessing when the WSL host gives odd answers or is slow. One adds a missing test. One stops the automations list from calling a moved project's automation "Enabled" on this computer, when the WSL host is the one that runs it.

Base: main (rebased onto 1eaaf85, where #34059 landed). Everything here is behind ORCA_INTERNAL_WSL_HOSTS, like the mover.

What Changed

  • Undo fails closed on odd host answers. Before undo releases a moved project, it counts the host's live terminals in each of the project's host workspaces.
    • Before: any error answer, or an answer it couldn't read, counted as "0 running", so undo could proceed with agents still running there.
    • Now: only the host's "no such workspace" answer (selector_not_found) counts as 0. Anything else counts as the host not answering, and undo refuses with the existing "host isn't answering" message.
  • One deadline for the stop. Undo's wait for the host's terminals to exit counted polls (20 s in 500 ms steps) rather than time, so a host taking 10 s per answer could stretch it about 40-fold. The stop now has one wall-clock deadline of 30 s. That budget covers the preflight, the sleeps and the exit wait together. When it runs out, undo reports "still running" and refuses. The terminals always get at least 5 s to exit after the last sleep, so a slow but healthy host with many workspaces doesn't read as still running just because sleeping them used up the budget.
  • A test for D1b-7a's hydration purge rule. The rule keeps a moved project's chats through the startup purge of stale worktrees. It lives in hydrated-worktree-purge.ts and had no test. The new test fails if the rule is removed.
  • "Runs on the {distro} host" in the automations list. After a move, the desktop deliberately keeps its own copy of the project's automations unchanged, so undo can bring them back as they were. That copy never runs here: dispatch already refuses it as host-owned. Before, the list still showed it as "Enabled". Now its status cell reads "Runs on the Ubuntu host". Every other automation is unchanged.

Why

  • Undo checks: both undo items come from the review of Land the WSL project mover dark (merges only after verify-15b, the flag-off audit and green CI) #34059's fix for verify-15c, where undo with an unanswering host proceeded. Refusing is safe: the user connects or removes the host and tries again. Proceeding risks agents running on both sides of the same files.
  • Automation label:
    • A label is better than disabling the local copy, because undo restores that copy exactly as it was.
    • It reuses the renderer's existing moved-projects list, so no new IPC is needed.

Linked Issue

N/A (maintainer follow-up to #34059).

Visual Proof

The automations list row text changes from "Enabled" to "Runs on the Ubuntu host" for a moved project's local automation only. It's gated behind ORCA_INTERNAL_WSL_HOSTS, so with the flag off the list is unchanged. A render test covers it, and the WSL verify run on awin will screenshot it.

Testing

  • I manually tested these changes locally

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

  • New tests:

    • wsl-move-undo-wiring.test.ts:
      • not-found reads as 0, and undo proceeds;
      • another error code, or an unreadable answer, reads as unreachable, and undo refuses.
    • wsl-move-host-copy-stop.test.ts: with fake timers, a host taking 10 s per answer gives up by the deadline after at most 4 checks, not 40 polls; and when 8 slow sleeps use up the budget, terminals that exit 3 s after the last sleep still read as stopped.
    • worktrees-hydration-purge.test.ts: a moved project's chat key survives the purge and a stale worktree is still purged.
    • AutomationListLocalRows.test.tsx and wsl-moved-project-automation.test.ts: the label appears for a moved project's local automation, but not for other projects or other targets.
  • Local checks:

    • tc and typecheck:ci pass.
    • check:code-quality:changed, audit:anti-slop, ast-grep-gates and the full pnpm lint pass.
    • The touched suites pass (118 files, 983 tests).

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

  • Cross-platform: the undo checks run in main on every platform, but only for WSL moves, which exist only on Windows behind the gate.
  • SSH and older hosts:
    • SSH is untouched.
    • An older WSL host that answers with an error code other than selector_not_found for a missing workspace now makes undo refuse rather than proceed. That's the intended fail-closed behavior.

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)

… label moved automations

Follow-ups from the #34059 undo review, stacked on it:
- A host workspace's terminal count reads as zero only when the host says it no longer has the
  workspace (selector_not_found); any other error, or an answer it cannot read, now counts as the
  host not answering, so undo refuses.
- The exit wait keeps one wall-clock deadline for the whole stop instead of counting polls, so a
  slow host can no longer stretch it many times over.
- A test for D1b-7a's hydration purge rule: a moved project's chats survive, a stale worktree
  still goes.
- A moved project's local automation reads "Runs on the <distro> host" in the list, where it
  read Enabled though this computer never runs it.
…xit after the last sleep

A slow but healthy host with many workspaces could spend the whole stop budget sleeping them and
then read as still running on the first exit check. The exit wait now runs at least 5 s past the
last sleep, within or beyond the overall deadline.
@nwparker
nwparker force-pushed the nwparker/wsl-mover-undo-followups branch from faa04bd to 1d2d4bb Compare October 28, 2026 07:13
@nwparker
nwparker changed the base branch from nwparker/wsl-mover-land-2 to main October 28, 2026 07:13
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Host-copy stopping now treats a missing host workspace as having no live terminals and treats other terminal-list errors or unreadable data as unknown. The stop process uses a wall-clock deadline and continues terminal-exit polling until its exit deadline. Local automation rows now show the distro for matching WSL-moved projects. Added tests cover these changes and moved-project state during hydration purge.

Priority: Low

Merge Risk: Moderate · up to 1d2d4

Undo can remain blocked well beyond its stated deadline when several host calls are slow. Bound those calls before merging; the incorrect automation status and slow test are narrower issues.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.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 summarizes the two primary changes: fail-closed WSL undo host checks with one deadline and updated moved-automation labeling.
Description check Passed The description is complete and aligned with the template. It explains the user impact, implementation, rationale, testing, compatibility considerations, and checklist status. Visual proof is describe…
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 complete and aligned with the template. It explains the user impact, implementation, rationale, testing, compatibility considerations, and checklist status. Visual proof is described but not yet attached, and some full checks remain pending or delegated to CI.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.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 10 files. (1 skipped: 1 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.

❤️ 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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Use a controlled clock in this test. · wsl-move-host-copy-stop.test.ts:28

src/main/persistence/moving-wsl-projects/wsl-move-host-copy-stop.test.ts:28
🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Use a controlled clock in this test.

The new five-second minimum makes this test spin for five real seconds because port().wait resolves immediately. Both mocks also retain every call, increasing memory use throughout the loop. (vitest.dev)

Advance a fake clock in wait, as the slow-host tests do. Based on learnings: time-dependent tests should use a controlled clock.

Source: Learnings


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: 644ce08a-ddef-4a9f-a674-1e8cc7394d7c
Commits

Reviewing files that changed from the base of the PR and between 7cdfebd and 1d2d4bb.

Files selected for processing: 11
  • src/main/ipc/wsl-move-undo-wiring.test.ts
  • src/main/ipc/wsl-move-undo-wiring.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-host-copy-stop.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-host-copy-stop.ts
  • src/renderer/src/components/automations/AutomationListLocalRow.tsx
  • src/renderer/src/components/automations/AutomationListLocalRows.test.tsx
  • src/renderer/src/components/automations/AutomationListStatusCell.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/store/repos/wsl-moved-project-automation.test.ts
  • src/renderer/src/store/repos/wsl-moved-projects.ts
  • src/renderer/src/store/slices/worktrees-hydration-purge.test.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.

return 'stopped'
}
if (waited >= exitWaitMs) {
if (now() >= exitDeadline) {

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 · Stability & Availability · Heavy lift

Enforce the deadline during host calls.

The deadline is checked only after every preflight, sleep, and exit check completes. For ten workspaces whose terminal checks each take nine seconds, preflight and one exit sweep alone take about three minutes. RPC queueing and WSL setup also occur outside the request timeout. (raw.githubusercontent.com)

Enforce the budget between checks and bound in-flight calls. Preserve the five-second post-sleep exit window and handle cancellation safely.

: translate('auto.components.automations.enablement.paused', 'Paused')
const isSelected = isSelectedLocal && selectedRowKey === row.key
const movedToDistro = useAppStore(
(state) => wslMovedProjectForAutomation(state.wslMovedProjects, automation)?.distro ?? null

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.

Minor · Functional Correctness · Quick win

Limit the moved-host label to the retained desktop row.

When the host catalog lists the host’s copy of a moved automation, that row can also have executionTargetType: 'local' and the same project ID. This lookup ignores row.catalogRef, so the host-owned row receives movedToDistro too. A paused host-owned automation then displays “Runs on the Ubuntu host” instead of “Paused.” Check the row’s originating authority before applying the retained-copy label. (raw.githubusercontent.com)

@nwparker
nwparker merged commit 4b7eaa3 into main Oct 28, 2026
2 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