Skip to content

fix(local-ai): clarify unavailable Local AI setup states (clean replacement for #1204) - #1263

Merged
shanselman merged 10 commits into
mainfrom
shanselman-salvage-pr-1204-local-ai-setup
Aug 28, 2026
Merged

shanselman merged 10 commits into
mainfrom
shanselman-salvage-pr-1204-local-ai-setup

Conversation

@shanselman

@shanselman shanselman commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Clean replacement for #1204 (karkarl-refine-local-ai-setup-ux), built directly on current main. That branch's history mixes unrelated, already-landed commits with the real contribution, so this PR recomputes the true diff (merge-base 911f3686 to PR head 568db5c1) and rebases it onto today's main instead of rewriting/force-pushing the original branch. Rebased twice more since as main kept advancing on the same files (#1203, #1254, and others); each rebase was validated fresh.

  • share Local AI eligibility diagnostics between setup and the Hub via a new LocalAiSetupAvailabilityCoordinator and locale-neutral LocalInferenceEligibilityDiagnostics
  • place unavailable Local AI guidance above dependent setup content; the native InfoBar.ActionButton keeps See why independently usable and on the message line
  • show a green Local AI availability badge beside Recommended on the local WSL gateway choice
  • center the Local AI Hub page at wide window sizes using the same finite-width Grid/900px pattern as other Hub pages
  • gray/disable unavailable setup choices while preserving controls for an already installed managed runtime
  • hide Local AI-only progress groups when Local AI is unavailable, keeping the WSL installation stage active
  • localize all new setup/Hub copy (en-us, fr-fr, nl-nl, zh-cn, zh-tw) — see below
  • gate Local AI availability on device-level eligibility, not the selected model, and never dead-end step 3 — see "Round 2" below

What changed vs. #1204 (retained vs. discarded)

Retained (all 24 files, ~1.6k LOC): the entire real contribution from #1204 applies here, nothing was dropped as "already landed" or unrelated. Verified by grepping current main for the PR's new symbols (LocalAiSetupAvailabilityCoordinator, IsLocalAiOnlyGroup, LocalInferenceEligibilityDiagnostics, LocalAiUnavailablePanel) before starting: none existed, confirming every touched file carries a real, non-trivial diff against main.

Discarded: only the stale, already-merged commits that #1204's branch carried from its outdated base (e.g. #1111, #1226, #1229, #1210, #1230, #1234, already on main independently). None of that reappears here.

Fixed beyond #1204's last pushed head, all covered by focused tests:

  1. Delayed-dispatch race in the Hub view model. A queued UI-thread update could be silently dropped if DispatcherQueue.TryEnqueue genuinely deferred the callback; the result is now applied and the probe's cancellation released together, gated by one currency check.
  2. Setup toggle clobbered a configured selection while checking. The toggle now mirrors the current config value during a check instead of forcing off; only a completed probe changes the selection.
  3. Primary button could stay stuck disabled after a definitive unsupported result (ShowLocalAiUnavailable was missing the UpdatePrimaryButtonState() call its siblings had).
  4. Availability tied to the wrong model. The Hub's device-availability probe now evaluates the best catalog model this hardware can run instead of the currently selected/installed model, so a stale/removed model no longer blocks Retry Setup.
  5. Incomplete hardware facts treated as permanent. A partial/transient NVML read is now routed through the same retryable/probe-error path as a thrown probe failure, in both the setup page and the Hub.
  6. Change Model bypassed the availability gate (CanChangeModel, added independently by main's fix(local-ai): model setup unavailable after install #1254 while this branch was being rebased, didn't check IsSetupAvailable like CanRetrySetup does).
  7. Setup toggle also clobbered a configured selection on a retryable probe failure (ShowLocalAiProbeUnknown, the sibling of fix Rename MoltBot to OpenClaw across entire codebase #2 above): a transient failure unconditionally cleared LocalAi.Enabled, so a successful recheck afterward initialized from the already-cleared value instead of restoring the prior selection.
  8. All new availability copy was hardcoded English (ClawSweeper review on this PR): the setup InfoBar title/message/action, the checking/probe-error state messages and accessibility help text, the detailed diagnostic reason shown in the setup dialog and the Hub tip, and the Welcome-page "Local AI available" badge/accessible name. See the dedicated section below.

Each fix has a dedicated regression test.

Round 2 (external Codex + Opus review on this PR)

  • Device-level gating, not model-level (Codex HIGH). CapabilitiesPage/WelcomePage now gate device availability on LocalInferenceEligibility.Evaluate(hardware) first, then reconcile the configured SelectedModelId separately: a model that no longer exists in the catalog, or exists but this specific hardware cannot install at all (!CanInstall, i.e. truly Unsupported, not merely EligibleButBusy), falls back to the recommended/device-eligible model instead of leaving setup stuck on a stale or hardware-incompatible selection. WelcomePage's badge is evaluated device-only (no model parameter).
  • Remaining hardcoded .wslconfig failure reason localized (Codex MEDIUM) through SetupLocalization across all 5 locales.
  • Availability-probe CTS could leak or, on a worker-thread path, race a UI-thread cancel (Codex LOW → hardened further by review). LocalAiPageViewModel now guarantees the probe's CancellationTokenSource is released/disposed exactly once on every path (dispatched apply, non-enqueued, rejected-enqueue, or already-disposed/inactive), using Interlocked.Exchange/CompareExchange so a worker thread releasing the token can never race the UI thread's CancelAvailabilityRefresh() into a double-cancel/double-dispose. RecheckAvailability() also now enforces its own CanRecheckAvailability gate instead of only the weaker "not already in flight" check.
  • Step-3 dead end when Local AI is enabled and availability is Checking/ProbeUnknown (Opus HIGH). Both states now keep the toggle itself genuinely clickable (including restoring LocalAiOptionContent.IsHitTestVisible, which a naive re-enable of just the toggle's own IsEnabled would not undo) so turning Local AI off is always an escape hatch. Continue's own gate is unchanged and never bypasses eligibility or an as-yet-undetermined WSL networking-consent decision merely because availability is still pending.
  • Hub InfoBar didn't distinguish definitive-unavailable from checking/probe-unknown (Opus MEDIUM x2). The Hub now shows an explicit "checking" title/message/progress ring while a probe (initial or recheck) is in flight, and a distinct localized title/severity (Warning) for a retryable probe error vs. Informational for a definitive unavailable result — instead of one static title/message and silently hiding all chrome mid-check.
  • SetupLocalization/probe failure diagnostics now use Trace.TraceWarning, not Debug.WriteLine (Opus LOW), since Debug.WriteLine is compiled out entirely in Release builds; Trace is not, and its default listener reaches DebugView/ETW.
  • Welcome badge accessible-name suffix made idempotent (Opus LOW): the base name is captured once so repeated detections don't re-append the suffix, and a LiveRegionChanged automation event (with peer creation forced, since one may not exist yet) announces the change.

Localization (fix #8)

OpenClaw.Shared's LocalInferenceEligibilityDiagnostics now returns a LocalInferenceUnavailableReason (a kind enum plus plain facts: model name, required/detected GPU memory in GB, driver version) instead of a formatted English sentence, keeping Shared locale-neutral. Each UI owner localizes at its own boundary:

  • OpenClaw.SetupEngine.UI has no .resw files of its own and cannot reference the Tray app project (which references it, so the reverse would be circular). It gets a small new SetupLocalization helper that resolves resource keys against the same merged app resource map the Tray app's LocalizationHelper already reads (the existing x:Uid="Onboarding_LocalAi_RecheckAvailabilityButton" binding relies on the same mechanism). CapabilitiesPage.xaml.cs now routes every checking/probe-error/unavailable title, message, help text, the "why unavailable" dialog, the .wslconfig inspection failure, and the Welcome-page badge/accessible name through it.
  • LocalAiPageViewModel (source-linked into OpenClaw.Tray.Tests without a WinUI resource host) exposes the locale-neutral LocalInferenceUnavailableReason instead of a formatted string, so it stays testable without LocalizationHelper. LocalAiPage.xaml.cs (the View, which already has full WinUI/LocalizationHelper access) formats it into localized text, including the new checking/probe-unknown title distinction — matching the existing resource-key-on-ViewModel / format-in-View pattern already used for engine/model/gateway status.

Resource keys were added to all five supported locales (en-us, fr-fr, nl-nl, zh-cn, zh-tw), and localization regression coverage was added: contract tests proving the setup page's checking/probe-error/unavailable copy, the "why unavailable" dialog, the Welcome-page badge/accessible name, and the Hub's checking/probe-unknown titles all route through SetupLocalization/LocalizationHelper/x:Uid (not hardcoded English) with matching keys in every locale; a test proving the shared diagnostics stay fact-only while both UI owners localize the same reason kinds; and a source test proving SetupLocalization implements the same "Key.Property" → "Key/Property" XAML-resource fallback LocalizationHelper already uses.

Owner boundary (why all these files are one cohesive change)

Everything here belongs to a single seam: "is Local AI available, and does the UI correctly reflect, escape, and localize that during checking/unsupported/error states." LocalAiSetupAvailabilityCoordinator, LocalInferenceEligibilityDiagnostics, and SetupLocalization are the shared policy/diagnostics/localization layer; CapabilitiesPage/WelcomePage/ProgressPage are the setup-time consumers; LocalAiPage/LocalAiPageViewModel are the Hub-time consumer; the .resw files are the copy for both; the test files are 1:1 with the production files they cover.

Concurrency note

Fetched and diffed against #1204's live head repeatedly during this work; its branch was never touched, read, or force-pushed. #1204 should be closed/superseded only after this PR is reviewed, green, and ready.

Validation

$env:OPENCLAW_REPO_ROOT = '<worktree path>'
.\build.ps1                                                                    # Shared, Cli, WinNodeCli, SetupEngine, WinUI all built (clean, 0 warnings/errors, including a from-scratch obj/bin rebuild of OpenClaw.SetupEngine.UI)
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj         # 3819 passed, 0 failed, 32 skipped
dotnet test .\tests\OpenClaw.SetupEngine.Tests\OpenClaw.SetupEngine.Tests.csproj # 1025 passed, 0 failed
dotnet test .\tests\OpenClaw.Tray.Tests\...csproj --filter "FullyQualifiedName~LocalAiSetupUxContractTests|...LocalAiPageViewModelTests|...AppRefactorContractTests|...LocalizationValidationTests|...CapabilitiesPageLocalizationCoverageTests|...LocalizationHelperSourceTests"
                                                                                # 154 passed, 0 failed (every file this PR touches, run repeatedly for stability)

Full, untargeted OpenClaw.Tray.Tests run: still blocked in this environment (hangs with no test output after ~6 minutes; reproduces the same way on a clean pre-fix checkout, so it is a pre-existing environmental blocker in this sandbox, not a regression from this change). Recommend a maintainer/CI run of the full untargeted suite before merge.

Real behavior proof

  • Setup wizard, fresh isolated data dir: the WSL gateway choice on the Welcome page shows the "Local AI available" badge beside "Recommended" (accessibility-tree confirmed: WelcomeInstallLocalGatewayChoice -> "Recommended" + "Local AI available").
  • Local AI Hub, real hardware (this host has an NVIDIA GeForce RTX 4080 SUPER): launched directly to openclaw://hub/local-ai in an isolated data dir with no prior config. NotInstalled state renders correctly, no spurious unavailable banner, "Retry setup or download" enabled, engine/model status all correct, confirming no regression on the common/available happy path.
  • Unavailable / retryable / probe-error / checking / selection-preservation / consent-gate states: this validation host has real qualifying hardware and cannot naturally exercise the unsupported-device path, so those invariants (including the new checking-progress UI, the toggle escape hatch during pending states, and the networking-consent gate never being bypassed while pending) are proven by the automated LocalAiPageViewModelTests/LocalAiSetupUxContractTests with controlled fake hardware probes and dispatcher fakes.

Review

autoreview (Codex, gpt-5.6-sol, high reasoning) was run to convergence across this round's fix cycles, each producing a real, verified bug (device/model eligibility gating, wslconfig localization, CTS ownership races across two hardening passes, the step-3 dead end plus its hit-test-visibility follow-up, the pending-state consent-bypass gap, a checking-notification ordering gap, and the model-eligibility reconciliation gap) that was fixed and covered by a new or updated regression test, then re-reviewed clean of that finding. One reviewer-reported finding (a claimed C# definite-assignment compile error for the eligibility local on the device-ineligible path) was investigated and rejected: eligibility is explicitly initialized to null at declaration, and a from-scratch obj/bin rebuild of OpenClaw.SetupEngine.UI compiles with 0 warnings/errors, confirming the finding does not reproduce.

Not verified / blocked: full untargeted Tray suite (environmental hang, see above); WSL install E2E (would require actually installing a WSL distro on a shared host, skipped as out of scope for this validation pass; the setup-flow code paths are covered by the existing SetupStepsTests/WslGlobalConfigManagerTests/LocalAiSetupUxContractTests).

Supersedes #1204.

@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@shanselman shanselman added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codex review: needs changes before merge. Reviewed August 28, 2026, 9:35 AM ET / 13:35 UTC.

ClawSweeper review

What this changes

The PR adds localized Local AI availability and retry states to onboarding and the Tray Local AI Hub, with guarded setup controls and accessibility updates.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this collaborator PR open. The current head has one concrete P2 localization defect: an introduced Local AI model selector suffix remains English outside en-US.

Priority: P2
Reviewed head: 8c7199fa1b54868969e79f1b9158369bc8156fec

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The PR has substantial focused implementation and current-head evidence, but one user-visible localization defect remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a collaborator, so the external-contributor proof gate does not apply; the supplied body nevertheless reports current-head UI Automation and an isolated Hub run.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a collaborator, so the external-contributor proof gate does not apply; the supplied body nevertheless reports current-head UI Automation and an isolated Hub run.
Evidence reviewed 5 items Introduced untranslated UI text: The introduced model-selector row appends the literal " - Recommended" directly to the displayed model name, so this new label bypasses the resource-based localization used by the surrounding Local AI states.
Localization surface checked: The five locale resource files contain the new availability and diagnostic keys, but the selector's direct suffix has no Local AI model-recommendation resource lookup.
Current-main necessity check: The fetched main delta after the pinned base contains only unrelated chat changes on the inspected Local AI paths; this PR's Local AI availability work is not already present on current main.
Findings 1 actionable finding [P2] Localize the recommended-model suffix
Security None None.

How this fits together

A host hardware probe determines whether Local AI can run and feeds that result into onboarding and the Tray Hub. Those UI surfaces then enable setup actions or show recovery guidance.

flowchart LR
A[Host hardware probe] --> B[Eligibility evaluation]
B --> C[Availability state]
C --> D[Setup wizard]
C --> E[Tray Local AI Hub]
D --> F[Setup actions]
E --> G[Runtime management]
Loading

Before merge

  • Localize the recommended-model suffix (P2) - The introduced selector content appends - Recommended directly, so the new model recommendation remains English in fr-FR, nl-NL, zh-CN, and zh-TW even though the surrounding availability copy uses RESW resources. Route this segment through a localized resource or format key and cover all five locales.
  • Complete next step (P2) - A localized selector suffix and five-locale regression check are a narrow mechanical repair on this PR branch.

Findings

  • [P2] Localize the recommended-model suffix — src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs:648
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta production +1,266/-179, tests +1,462/-23 The broad onboarding and Hub state change has more added test code than production code, but still needs the remaining localization defect corrected.

Technical review

Best possible solution:

Format the recommended-model marker through a dedicated onboarding resource in every supported locale, then retain the existing locale-neutral eligibility boundary.

Do we have a high-confidence way to reproduce the issue?

Yes. Select any non-English supported locale and reach the eligible-hardware model selector: the introduced code unconditionally appends the English word "Recommended".

Is this the best way to solve the issue?

No. The availability UI is otherwise localized, but this direct display suffix bypasses the same resource boundary; a localized format/key and regression coverage are the narrow repair.

Full review comments:

  • [P2] Localize the recommended-model suffix — src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs:648
    The introduced selector content appends - Recommended directly, so the new model recommendation remains English in fr-FR, nl-NL, zh-CN, and zh-TW even though the surrounding availability copy uses RESW resources. Route this segment through a localized resource or format key and cover all five locales.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 56a169f5b71e.

Labels

Label changes:

  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The author is a collaborator, so the external-contributor proof gate does not apply; the supplied body nevertheless reports current-head UI Automation and an isolated Hub run.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.

Label justifications:

  • P2: The PR has a bounded user-visible localization defect in the Local AI setup flow, without emergency impact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The author is a collaborator, so the external-contributor proof gate does not apply; the supplied body nevertheless reports current-head UI Automation and an isolated Hub run.

Evidence

Acceptance criteria:

  • [P1] ./build.ps1.
  • [P1] dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore.
  • [P1] dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore --filter FullyQualifiedName~LocalAiSetupUxContractTests.

What I checked:

Likely related people:

  • shanselman: Introduced the current-main Change Model setup route that this PR extends. (role: recent Local AI Hub contributor; confidence: high; commits: a14dc72b7616; files: src/OpenClaw.Tray.WinUI/Presentation/LocalAiPageViewModel.cs)
  • karkarl: Authored the immediately preceding WSL-readiness setup integration. (role: recent setup prerequisite contributor; confidence: high; commits: fb14564dda1f; files: src/OpenClaw.SetupEngine.UI/Pages/CapabilitiesPage.xaml.cs)
  • joelagnel: Authored the merged managed Local AI feature that owns the eligibility contract. (role: managed Local AI feature originator; confidence: high; commits: ccd64bbb7d68; files: src/OpenClaw.Shared/Inference/Catalog/LocalInferenceEligibility.cs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Replace the direct recommended-model suffix with a localized resource and add coverage for every supported locale.
  • Run the repository-required build, Shared suite, and Tray suite after the correction.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-28T09:42:39.770Z sha 0290231 :: needs changes before merge. :: [P2] Localize the new setup availability copy
  • reviewed 2026-08-28T11:08:23.087Z sha 50f6a84 :: needs maintainer review before merge. :: none

shanselman and others added 9 commits August 28, 2026 03:30
Salvage the reviewable diff from PR #1204 (karkarl-refine-local-ai-setup-ux)
onto current main. PR #1204's branch carries unrelated already-landed
history from a stale base; this replaces it with the true contribution
computed from the merge-base (911f368) to the PR head (568db5c).

- share Local AI eligibility diagnostics between setup and the Hub via
  LocalInferenceEligibilityDiagnostics and LocalAiSetupAvailabilityCoordinator
- place unavailable Local AI guidance above dependent setup content, using
  the native InfoBar action slot so "See why" stays independently usable
- gray and disable unavailable setup choices while preserving controls for
  an already installed managed runtime
- hide Local AI-only progress groups when Local AI is unavailable while
  keeping the WSL installation stage active
- keep incomplete/failed Local AI probes retryable
- localize new setup/Hub copy (en-us, fr-fr, nl-nl, zh-cn, zh-tw)
- add focused coordinator, view-model, and UX contract tests

Co-authored-by: Copilot App <[email protected]>
RefreshAvailabilityAsync queued its UI-thread state application via
ApplyOnUiThread, then unconditionally cleared _availabilityCancellation in
its own finally block. When the dispatcher genuinely defers the callback
(a real DispatcherQueue.TryEnqueue does not run inline), the finally block
raced ahead and nulled the field before the queued callback ran, so the
callback's own IsCurrentAvailabilityProbe guard failed against itself and
silently dropped a completed probe result (success or failure).

Apply the result and clear the cancellation together, inside the single
dispatched callback, gated by one currency check, so a delayed dispatch
can no longer race the clear. Add delayed-dispatcher tests that hold the
dispatcher's queued callback back (RecordingUiDispatcher with
HasThreadAccess=false, RunEnqueuedImmediately=false) and prove both a
successful and a failed probe are still applied once the callback finally
runs. Update the existing publishes-change test: the failed-probe result
and the recheck-availability unlock now land in one notification instead
of two, so the prior "error but not yet rechecked" transient state is no
longer produced.

Co-authored-by: Copilot App <[email protected]>
ShowLocalAiAvailabilityChecking unconditionally set _config.LocalAi.Enabled
to false and reset SkipWizard as soon as an availability check started,
before the probe had a result. A preconfigured or restored setup session
with Local AI already opted in silently lost that selection the moment a
recheck began, even when the machine turned out to be eligible. Keep the
toggle in sync with the current config value instead of forcing it off,
and stop mutating LocalAi.Enabled/SkipWizard during the transient
"checking" state; only a completed probe should change the selection.

Also keep the hardware and WSL networking probe results in local
variables until CanApplyLocalAiAvailability confirms the check is still
current, so a stale/superseded generation cannot write over page state
(matches the same currency-check-before-assignment pattern used
elsewhere in this method).

Extend LocalAiSetupUxContractTests with source-shape assertions for both
fixes.

Co-authored-by: Copilot App <[email protected]>
Two follow-up fixes from structured review:

- ShowLocalAiUnavailable never called UpdatePrimaryButtonState after
  turning LocalAi.Enabled off, unlike its sibling ShowLocalAiProbeUnknown
  and ShowLocalAiAvailabilityChecking. This was latent on main because the
  checking state always forced the toggle off first; now that checking
  preserves the configured toggle value, a definitive-unsupported result
  reached from an enabled toggle could leave the primary setup button
  disabled with no way to continue without Local AI. Call
  UpdatePrimaryButtonState() to match the sibling methods.

- LocalAiPageViewModel.RefreshAvailabilityAsync evaluated device
  eligibility against the currently selected/installed model ID. A
  selection-specific failure (a model removed from the catalog, or one
  that no longer fits) was reported as the *device* being unavailable,
  which also disabled CanRetrySetup, the action needed to switch to a
  different compatible catalog model. Evaluate eligibility for the best
  catalog model this hardware can run instead of pinning to the current
  selection.

Add a regression test proving a stale/unknown selected model ID no
longer blocks qualified hardware from reporting available and
retry-setup-eligible.

Co-authored-by: Copilot App <[email protected]>
…pported

Two more follow-ups from structured review, same bug class in both the
setup page and the tray Hub page:

Both InitializeLocalAiReviewAsync (CapabilitiesPage) and
RefreshAvailabilityAsync (LocalAiPageViewModel) folded every non-null
eligibility failure into a single "definitively unsupported" outcome.
LocalInferenceEligibility.Evaluate can also return
FailureCode.HardwareFactsIncomplete without throwing, for example when an
NVML read comes back partial or transient (missing stable GPU ID, driver
version, or CUDA capability) rather than because the device truly cannot
run Local AI. Folding that into "unsupported" permanently disabled the
option and hid the Recheck affordance the rest of this change exists to
provide, exactly like the thrown-probe-failure path already avoids doing.

Route HardwareFactsIncomplete through the same retryable path used for a
thrown probe failure (TryApplyProbeFailure / ShowLocalAiProbeUnknown on
setup, hasAvailabilityProbeError on the Hub view model) instead of
TryApplyUnsupported / a definitive IsLocalAiAvailable=false, so recheck
stays available.

Add a regression test proving incomplete hardware facts read as a
retryable probe error, and extend the setup contract test to assert the
new branch shape.

Co-authored-by: Copilot App <[email protected]>
…able

CanChangeModel did not check IsSetupAvailable, unlike its sibling
CanRetrySetup, so an installed (Verified/Loaded) model kept the Change
Model action live even after a definitive unsupported-hardware probe
result. ChangeModel() routes into the same onboarding flow as
RetrySetup(), so a device that cannot run Local AI at all should not
offer a live path back into that setup, while runtime management
(start/stop/restart/logs) correctly remains available for the existing
installation.

Add a regression assertion proving CanChangeModel and ChangeModel() are
blocked once hardware is confirmed unsupported.

Co-authored-by: Copilot App <[email protected]>
ClawSweeper review flagged that all new Local AI availability copy from
this salvage was hardcoded English: the CapabilitiesPage InfoBar
title/message/action, the checking and probe-error state titles/messages
and accessibility help text, and the detailed diagnostic reason shown in
the setup dialog and the Hub tip.

Shared stays locale-neutral: LocalInferenceEligibilityDiagnostics now
returns a LocalInferenceUnavailableReason (a kind enum plus plain facts —
model name, required/detected GPU memory in GB, driver version) instead
of a formatted English sentence.

Each UI owner localizes at its own boundary:
- OpenClaw.SetupEngine.UI has no .resw files and cannot reference the Tray
  app project (circular), so it gets its own small SetupLocalization
  helper that resolves resource keys against the same merged app resource
  map the Tray app's LocalizationHelper reads (the existing
  x:Uid="Onboarding_LocalAi_RecheckAvailabilityButton" binding already
  relies on this). CapabilitiesPage.xaml.cs now routes every checking/
  probe-error/unavailable title, message, help-text, and the "why
  unavailable" dialog through SetupLocalization; the InfoBar action
  ("See why") gets an x:Uid.
- LocalAiPageViewModel (source-linked into OpenClaw.Tray.Tests without a
  WinUI resource host) now exposes the locale-neutral
  LocalInferenceUnavailableReason instead of a formatted string, so it
  stays testable without LocalizationHelper. LocalAiPage.xaml.cs (the
  View, which already has full WinUI/LocalizationHelper access) formats
  it into localized text, matching the existing ResourceKey-on-ViewModel/
  format-in-View pattern already used for engine/model/gateway status.

Add resource keys to all five supported locales (en-us, fr-fr, nl-nl,
zh-cn, zh-tw) and localization regression coverage: a contract test
proving the setup page's checking/probe-error/unavailable copy and
dialog route through SetupLocalization (not hardcoded English) with
matching keys in every locale, and a test proving the shared diagnostics
stay fact-only while both UI owners localize the same reason kinds.
Update existing tests that asserted on formatted English text to assert
on the locale-neutral Kind instead.

Co-authored-by: Copilot App <[email protected]>
Structured review caught a gap in the prior localization commit: the
Welcome page's "Local AI available" badge text and the accessible name
AutomationProperties.SetName appends to the install choice when Local AI
is detected were still hardcoded English, so every non-English locale
showed and announced English copy on this path.

Route the badge text through x:Uid, and have the accessible name append
the same localized fragment (via SetupLocalization, reading it from the
current AutomationProperties.Name instead of duplicating the base
sentence as a second hardcoded literal). Extend SetupLocalization with
the same "Key.Property" -> "Key/Property" XAML resource-path fallback
LocalizationHelper already uses, so the code-behind accessible name can
share the exact resw entry the x:Uid binding resolves for the visible
badge instead of a duplicate key.

Add resw entries for all five locales and regression coverage: a
contract test proving the badge and accessible name route through
SetupLocalization with a matching key in every locale, and a source test
proving SetupLocalization implements the same XAML-property fallback
shape as LocalizationHelper.

Co-authored-by: Copilot App <[email protected]>
ShowLocalAiProbeUnknown unconditionally set _config.LocalAi.Enabled to
false whenever a probe failure was reported, even though that state is
retryable rather than definitive (matches ShowLocalAiAvailabilityChecking
before an earlier fix in this same series). If Local AI was already
selected (e.g. after navigating back to review, or loading a
preconfigured session) and a transient probe failure occurred, the
toggle was forced off; a subsequent successful recheck then initialized
from the already-cleared value, so a successful recovery silently left
Local AI unselected.

Preserve the toggle from the current config value, matching the checking
state's behavior, so only a definitive ShowLocalAiUnavailable result
clears the selection.

Co-authored-by: Copilot App <[email protected]>
@shanselman
shanselman force-pushed the shanselman-salvage-pr-1204-local-ai-setup branch from 0290231 to 50f6a84 Compare August 28, 2026 10:57
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 28, 2026
…ecking progress

- CapabilitiesPage/WelcomePage: gate availability on device-level
  LocalInferenceEligibility.Evaluate(hardware), reconciling a stale or
  removed SelectedModelId to a valid/recommended model instead of
  hiding the badge or marking a capable device unavailable (Codex HIGH).
- CapabilitiesPage: localize the remaining .wslconfig inspection
  failure reason through SetupLocalization (Codex MEDIUM).
- LocalAiPageViewModel: guarantee the availability probe CTS is
  disposed on every stale/non-enqueued/rejected callback path via a new
  ApplyAvailabilityResultOnUiThread wrapper, and release the
  current-probe slot (not just dispose the token) when the dispatcher
  refuses the enqueue, so the ViewModel is never stuck reporting
  IsCheckingAvailability or throws ObjectDisposedException on a later
  deactivate/cancel (Codex LOW, hardened after a second-pass review
  finding on the rejected-enqueue path).
- CapabilitiesPage.UpdatePrimaryButtonState: do not block Continue at
  step 3 while Local AI availability is merely Checking/Unknown; only a
  concrete negative/busy result gates forward progress. The install
  stage already tolerates Local AI resolving unavailable later, so
  this closes a dead end where neither the toggle nor Continue could
  be used (Opus HIGH).
- LocalAiPage (Hub): distinguish a definitive unavailable result from
  a probe-unknown/checking state with a different localized title and
  severity, and show explicit checking/recheck progress (progress
  ring, checking title/message) instead of silently hiding all
  availability chrome while a probe is in flight (Opus MEDIUM x2).
- SetupLocalization/LocalAiPageViewModel/CapabilitiesPage: replace
  Debug.WriteLine (compiled out in Release) with a release logger
  path so probe/localization failures remain diagnosable (Opus LOW).
- LocalAiPageViewModel.RecheckAvailability: enforce CanRecheckAvailability
  in the command itself, not only in UI binding (Opus LOW).
- WelcomePage: make the Local AI badge's accessible-name suffix
  idempotent across repeated detections and raise a live-region
  automation event so it is announced (Opus LOW).
- Add regression coverage: device-eligibility gating and stale-model
  reconciliation, checking-state visibility, recheck command gating,
  step-3 non-dead-end, Hub title/severity distinction, Welcome
  accessible-name idempotency, and rejected-enqueue CTS release.

Co-authored-by: Copilot App <[email protected]>
@shanselman

Copy link
Copy Markdown
Collaborator Author

Pushed a new commit (50f6a84c -> 8c7199fa) addressing the external Codex + Opus review round on this PR:

  • Device-level eligibility gating for setup's CapabilitiesPage/WelcomePage (Codex HIGH), including a follow-up hardening to also reconcile a selected model that exists in the catalog but is Unsupported for this specific hardware (not just missing from the catalog), while never reconciling away a merely EligibleButBusy selection.
  • Remaining .wslconfig inspection failure reason localized (Codex MEDIUM).
  • Availability-probe CancellationTokenSource ownership hardened across three review passes: guaranteed exactly-once disposal on every path, then made the worker-thread release paths (rejected-enqueue, disposed/inactive) atomically coordinate with the UI-thread CancelAvailabilityRefresh() via Interlocked.Exchange/CompareExchange instead of racing it (Codex LOW -> hardened).
  • RecheckAvailability() now enforces its own CanRecheckAvailability gate.
  • Step-3 dead end when Local AI is enabled and availability is Checking/ProbeUnknown, fixed via a toggle escape hatch (not by ever letting Continue bypass eligibility or an undetermined WSL networking-consent decision) -- including a follow-up fix restoring LocalAiOptionContent.IsHitTestVisible so the re-enabled toggle is actually clickable, not just flagged enabled underneath a non-hit-testable container (Opus HIGH -> hardened).
  • Hub InfoBar now distinguishes definitive-unavailable from checking/probe-unknown with distinct localized titles/severity, and shows explicit checking/recheck progress (progress ring + title/message) instead of silently hiding all chrome mid-probe; a follow-up fix also moved StartAvailabilityRefresh()'s notification to after the new probe token is assigned so a UI bound to PropertyChanged reliably observes IsCheckingAvailability the moment a recheck starts (Opus MEDIUM x2 -> hardened).
  • Debug.WriteLine (compiled out in Release) replaced with Trace.TraceWarning for probe/localization failure diagnostics (Opus LOW).
  • Welcome badge accessible-name suffix made idempotent across repeated detections, with a LiveRegionChanged announcement (forcing peer creation, since one may not exist yet) (Opus LOW).

Full details and the updated validation/proof are in the PR description above.

Requesting fresh review (ClawSweeper/Codex/Opus) on 8c7199fa.

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@shanselman
shanselman merged commit ae766dc into main Aug 28, 2026
24 checks passed
@shanselman
shanselman deleted the shanselman-salvage-pr-1204-local-ai-setup branch August 28, 2026 15:38
@shanselman shanselman removed the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant