Repository navigation
fix(setup): stop WSL inspection flake from dead-ending onboarding - #1235
Conversation
Selecting the recommended "Install a local gateway (WSL)" option could end the setup flow with "Could not inspect WSL" and no way forward, telling the user to run `wsl --list --quiet` by hand. It reproduces on a machine where that command succeeds every time when run manually. Three separate defects combine to produce it. CommandRunner gave the redirected pipes a flat 250ms grace to reach EOF after the process exited. The OutputDataReceived callbacks are queued to the thread pool, so on a saturated pool (a WinUI cold start is exactly that) they can miss that window even though the process already exited and wrote its output. The command is then reported with an exit code but empty stdout and stderr, and every caller that classifies command output reads that as silence. The EOF wait is now bounded by a short cap instead, clamped by whatever remains of the caller's own deadline so the accepted timeout is never exceeded. The cap keeps the existing protection against a surviving descendant holding the pipes open, which RunAsync_ReturnsWhenDescendantKeepsOutputPipesOpen covers. InterpretDistroList gated both of its success paths behind !result.TimedOut, so a run that timed out after wsl.exe had already reported that WSL is not installed threw instead of using that answer. The output proves no distro can exist, and WslViabilityInspector already treats that state as Installable rather than a blocker, so the conclusive answer is now kept. WelcomePage replaced the option's title with "Checking existing setup..." for the duration of the check, hiding which option was being acted on, and offered only Close when inspection failed. The progress ring already carries the busy state (its automation name is "Checking existing WSL setup"), so the title now stays put, and a failed inspection offers Try again instead of ending the flow. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01YbwoyZNVT3qnRexUnCLZUx
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 26, 2026, 8:57 PM ET / August 27, 2026, 00:57 UTC. ClawSweeper reviewWhat this changesThis PR makes WSL setup inspection retain conclusive results, keeps the selected setup option visible, and lets onboarding retry an inspection failure. Merge readinessKeep open. The previous timeout-boundary blocker remains at the current PR head, although the WSL classification and retry UX changes address the reported onboarding dead end. Priority: P0 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe setup wizard inspects local WSL state before moving to gateway installation. It uses the shared command runner’s output to either continue setup or show a recoverable inspection error. flowchart LR
A[User selects WSL setup] --> B[Setup wizard]
B --> C[WSL inspection]
C --> D[Command output drain]
D --> E{Result conclusive?}
E -->|Yes| F[Continue setup]
E -->|No| G[Retry inspection]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Bound the post-exit output drain to the smaller of the remaining caller deadline and the cap, then cover the under-250 ms inherited-pipe case with a regression test. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows that an under-250 ms remaining deadline still retains a 250 ms output-drain delay when a descendant holds the redirected pipes open. Is this the best way to solve the issue? No. The WSL result and retry changes are narrow, but the shared runner still needs the remaining-deadline clamp corrected. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 911f36860b2d. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
Ensure a successfully exited process never waits past the caller's remaining timeout while draining redirected output, and cover the deadline and cap boundaries. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 142acc51-2688-41cf-8442-67a33ef49c59
|
Pushed maintainer fix 1cae216 for the remaining output-drain deadline finding. The drain budget is now bounded by the caller's actual remaining deadline and the existing cap, with deterministic boundary coverage. Full build, Shared tests (3,813 passed), and SetupEngine tests (1,003 passed) are green locally. The required Tray suite hit a pre-existing hang in BrowserProxyEndpointScopingTests while enumerating Windows TCP listeners; the isolated test reproduces unchanged, so CI is the clean full-suite signal for this head. @clawsweeper re-review |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(setup): stop WSL inspection flake from dead-ending onboarding This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
karkarl
left a comment
There was a problem hiding this comment.
Adversarial review verdict: SHIP TODAY
Dual-model review found no CRITICAL or HIGH defects and no release blockers. The change materially improves onboarding availability by preserving delayed WSL diagnostics, accepting timed-out but conclusive "WSL not installed" evidence, and providing explicit retry/cancel recovery. Destructive confirmation and app-ownership safeguards remain intact.
Both reviewers identified one non-blocking LOW-severity gap: the new redirected-output drain behavior does not have a focused regression test reproducing delayed callbacks or thread-pool pressure. Existing process coverage and the green build, test, setup-connect, recovery E2E, and CodeQL checks keep overall regression risk low.
Problem Selecting the recommended Install a local gateway (WSL) option could end the setup flow with a
Could not inspect WSLdialog whose only action was Close, telling the user to runwsl --list --quietby hand. There is no way forward from that state on the recommended path. It reproduces on a machine where that exact command succeeds every time when run manually, which is what makes it confusing to diagnose from a bug report. Three separate defects combine to produce it. ### 1.CommandRunnercan report a process that wrote output as silent After the child exits, the redirected pipes were given a flat 250 ms grace to reach EOF. TheOutputDataReceived/ErrorDataReceivedcallbacks are queued to the thread pool, so on a saturated pool (a WinUI cold start is exactly that) they can miss that window even though the process already exited and wrote its output. The command is then reported with an exit code but empty stdout and stderr. Every caller that classifies command output shares this exposure, so this is fixed at the runner. Reproduced by starving the thread pool and looping the call:iter 0: THREW exit=1 timedOut=False outLen=0 errLen=0 elapsed=1916ms ok=39 threw=1 emptyOutput=1The EOF wait is now bounded by a short cap instead of a flat grace, clamped by whatever remains of the caller's own deadline so the accepted timeout is never exceeded. The cap preserves the existing protection against a surviving descendant holding inherited pipe handles open, whichRunAsync_ReturnsWhenDescendantKeepsOutputPipesOpencovers. ### 2.InterpretDistroListdiscarded a conclusive answer Both success paths were gated behind!result.TimedOut:csharp if (!result.TimedOut && result.ExitCode == 0) return ContainsDistro(...); if (!result.TimedOut && LooksUnavailable(result)) return false; throw new InvalidOperationException(...);A run that timed out afterwsl.exehad already reported that WSL is not installed therefore threw, while holding stderr that readsThe Windows Subsystem for Linux is not installedand withLooksUnavailablereturningtrue. Observed directly:ExitCode : -1 TimedOut : True Stderr : len=332 (fully captured) LooksUnavailable => True Detect => THREW InvalidOperationExceptionThat output proves no distro can exist, andWslViabilityInspectoralready classifies the state asInstallablerather than a blocker (PreflightWslStep.cs), so the conclusive answer is now kept. Fail-closed behaviour is unchanged when the output is empty or genuinely unrecognised. ### 3. The wizard destroyed context and offered no way forwardWelcomePagereplaced the option's title withChecking existing setup...for the duration of the check, so the user could not see which option was being acted on, and offered only Close when inspection failed. The progress ring beside the title already carries the busy state (its automation name isChecking existing WSL setup), so the title now stays put, and a failed inspection offers Try again instead of ending the flow. ## Validation Required closeout subset fromAGENTS.md, all run on this branch's content: | Check | Result | |---|---| |./build.ps1| Pass (Shared, Cli, WinNodeCli, SetupEngine, WinUI) | |dotnet test ./tests/OpenClaw.Shared.Tests| 3813 passed, 0 failed, 32 skipped | |dotnet test ./tests/OpenClaw.Tray.Tests| Prior head: 2724 passed. Current-head local rerun was blocked by a pre-existing Windows TCP-listener enumeration hang; the GitHub Build and Test workflow passed on rerun. | |dotnet test ./tests/OpenClaw.SetupEngine.Tests| 1003 passed, 0 failed | Targeted tests added or updated: -OutputDrainBudget_ClampsToDeadlineAndCap(new maintainer follow-up) covers the remaining review finding by proving the drain wait uses the caller's actual remaining deadline, including the under-250 ms and exhausted-deadline boundaries. -ExistingConfigDetector_KeepsConclusiveUnavailableAnswerWhenRunAlsoTimedOut(new) covers defect 2. The existingExistingConfigDetector_FailsClosedWhenDistroStateIsUnknowncases still throw, so the fail-closed contract is intact. -SetupWelcomePage_RunsExistingConfigDetectionOffUiThreadupdated for the new busy-state contract, with regression guards added:Assert.DoesNotContain("InstallTitle.Text", method)and a requiredPrimaryButtonText = "Try again". -RunAsync_ReturnsWhenDescendantKeepsOutputPipesOpenis unchanged and still passes, which is what bounds the cap in defect 1. An earlier attempt that charged the full remaining timeout to the EOF wait failed this test at 20.28s against its 5s budget. Environment: Windows 11 ARM64 (NVIDIA GB10 class), .NET SDK 10.0.400, Windows SDK 10.0.26100. ## Real behavior proof Captured from a build of this branch's content, launched isolated withOPENCLAW_TRAY_DATA_DIRandOPENCLAW_FORCE_ONBOARDING=1, on a machine with WSL not installed (Microsoft-Windows-Subsystem-LinuxandVirtualMachinePlatformboth disabled), which is the configuration that triggers the bug. Before (release build, same machine): selecting the recommended option and pressing Next left the wizard on a dialog readingCould not inspect WSLwith the option title stuck atChecking existing setup...andNextdisabled. UI Automation, sampled at 1s, 3s, 6s and 10s after the click, showed no change at any point:[Text] 'Could not inspect WSL' [Text] 'OpenClaw could not safely inspect existing WSL distributions. Run `wsl --list --quiet` in ...' [Text] 'Checking existing setup...' [Button] 'Next' IsEnabled = FalseAfter (this branch): the same flow proceeds past WSL inspection to the next step rather than dead-ending, and the option title is preserved throughout:[Text] 'Set up OpenClaw' [ListItem] 'Install a local gateway (WSL), recommended' [Text] 'Install a local gateway (WSL)' <- title intact, not clobbered [Button] 'Next' ... [Text] 'Set up the WSL gateway' <- advanced past inspection [Text] 'Windows permissions'Runner timing after the fix, from the app log:cmd.done: C:\Windows\System32\wsl.exe exit=1 (67ms)Not verified / blocked: the end-to-end WSL gateway install itself is not exercised here, because WSL is not installed on this host and installing it is out of scope for this fix. The change is scoped to inspection and its failure handling.