Skip to content

fix: keep the migration window responsive while finalizing - #2391

Open
shanselman wants to merge 1 commit into
openclaw:mainfrom
shanselman:shanselman-fix-migration-finalize-thread
Open

shanselman wants to merge 1 commit into
openclaw:mainfrom
shanselman:shanselman-fix-migration-finalize-thread

Conversation

@shanselman

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 274a40786644e76d4ccff7adfe4eafb54dbaeafb

Dimension Assessment Rationale
Change confidence 9/10 ↑ Mirrors the existing Task.Run pattern of PrepareAsync and CompleteAsync.
↑ Coordinator already resumes with ConfigureAwait(false) and touches no UI state; the workflow still awaits on the dispatcher.
↑ 22 StoreMigration UI tests, 148 Connection StoreMigration tests, full Tray tests pass.
↓ No packaged Store-to-Inno migration run on a real machine.
Diagnosis confidence 9.5/10 ↑ New production-facade test fails without the fix: detection runs on the dispatcher thread.
Evidence fit 8/10 ↑ Reported timings show 97-99% of the work before the Task is returned, matching the synchronous prefix.
↓ Frozen progress indicator not independently observed.

Closes #2244

What Problem This Solves

When Companion launches after a completed migration from the previous installer, the migration window checks the old install and hashes the migrated identity files. That work ran on the window's UI thread, so the window could freeze for a couple of seconds before continuing.

User Impact

User impact: the migration window stays responsive while finalization checks run. No change to what finalization verifies or decides.

Why This Change Was Made

StoreMigrationOperations.FinalizeAsync called the coordinator directly, and the coordinator does all of its blocking work (detection, removal checks, receipt read, inventory hashing) before its first await. It now starts on the thread pool with Task.Run, like its PrepareAsync and CompleteAsync siblings. The startup-task call keeps its own existing off-UI-thread marshalling.

Evidence

  • New StoreMigrationOperationsThreadTests calls the production facade from the WinUI dispatcher with a stub detector. Without the fix it fails ("Finalization started on the dispatcher thread."); with the fix it passes.
  • dotnet test tests/OpenClaw.Tray.UITests -c Debug -r win-x64 --filter "StoreMigrationOperationsThreadTests|StoreMigrationWindowProofTests": 22 passed.
  • ./build.ps1: passed.
  • dotnet test tests/OpenClaw.Tray.Tests: 7050 passed.
  • dotnet test tests/OpenClaw.Shared.Tests: first run 1 failure (unrelated; this change is not compiled into Shared), rerun 6175 passed, 28 skipped.
  • dotnet test tests/OpenClaw.Connection.Tests --filter StoreMigration: 148 passed.

Not verified: a real packaged Store migration with an Inno source on a live machine.

Required proof pools

  • none: thread scheduling fix with no visual, installer, or Gateway change; covered by the dispatcher-thread regression test.

StoreMigrationOperations.FinalizeAsync invoked the coordinator directly, so
detection, removal verification, receipt reading and inventory hashing ran on
the migration window's dispatcher before the first await. Wrap it in Task.Run
like PrepareAsync and CompleteAsync, and add a UI-thread regression test.

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

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codex review: passed.

What this changes

This PR schedules migration finalization on the thread pool and adds a WinUI dispatcher regression test.

Example: Companion finalizes an Inno-to-Store migration with a completed receipt and 64 identity directories.

  • Before: Inventory hashing runs on the migration window's dispatcher before FinalizeAsync returns its task.
  • After: The facade schedules finalization on the thread pool while the workflow awaits its result on the dispatcher.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is minimal and source-consistent, with a targeted regression and reported validation; required evidence through the shipped migration path is absent, while persisted record formats and mutation rules are unchanged.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The migration window can stop responding while finalization reads and hashes migrated identity files.
Reason: This maintainer-authored change repairs a source-established responsiveness defect without changing migration policy or adding configuration.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a focused fix for a dispatcher-blocking path still present on main, and no concrete code defect was found.

Reviewed head: 274a40786644e76d4ccff7adfe4eafb54dbaeafb

Before merge

None.

Findings

None.

Agent review details

How this fits together

The migration window invokes StoreMigrationWorkflow, which awaits StoreMigrationOperations; the connection-layer coordinator verifies source removal, validates the receipt and inventory, applies startup preferences, and returns a finalization decision.

flowchart TD
  A[Migration window] --> B[StoreMigrationWorkflow]
  B --> C[StoreMigrationOperations]
  C --> D[Thread pool]
  D --> E[Finalization coordinator]
  E --> F[Source checks and migration records]
  E --> G[Startup preference and cleanup]
  E --> B
Loading

Technical review

Best possible solution:

Keep scheduling at the existing WinUI facade boundary while preserving dispatcher-bound workflow updates and every migration validation and cleanup rule.

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

The window's Loaded handler reaches the workflow and direct facade call on the dispatcher, where the coordinator performs synchronous inventory work before its first await; this establishes the main-branch failure path without a live reproduction.

Is this the best way to solve the issue?

Task.Run around the complete coordinator invocation is the smallest complete repair, matches the sibling operations, and leaves UI continuation and migration decisions with their existing owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8d31176d3ad4.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Natalie Aguinaldo: Raw commit 244f684 adds src/OpenClaw.Tray.WinUI/Helpers/StoreMigrationOperations.cs:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 244f684ef291; files: src/OpenClaw.Tray.WinUI/Helpers/StoreMigrationOperations.cs)
  • RoboClaw: Raw commit 18a9663 adds src/OpenClaw.Tray.WinUI/Helpers/StoreMigrationOperations.cs:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 18a9663f36a5; files: src/OpenClaw.Tray.WinUI/Helpers/StoreMigrationOperations.cs)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Capture responsive finalization through the current-head packaged app using an existing migration receipt and real inventory, including the resulting startup outcome and preserved identity data.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 12:37 PM ET / 17:37 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FinalizeAsync runs the whole migration finalization on the caller's thread

1 participant