openclaw-windows-node icon indicating copy to clipboard operation
openclaw-windows-node copied to clipboard

refactor: extract UpdateCoordinator from App.xaml.cs

Open AlexAlves87 opened this issue 6 months ago • 3 comments

Summary

App.xaml.cs had grown to over 4000 lines with update check, download, install, and dialog coordination mixed in alongside unrelated concerns. This moves the entire update flow into a dedicated UpdateCoordinator service.

What changed

  • New Services/UpdateCoordinator.cs — holds the three concurrency fields, six methods, and all update-related logic
  • App.xaml.cs — adds a single _updateCoordinator field, wires it up during startup, and delegates all four call sites (startup check, CLI arg, IAppCommands, deep link handler)
  • XamlRoot is resolved at call time via a Func<XamlRoot?> (hub window first, keep-alive fallback), so the coordinator has no direct reference to any window
  • Fixes a latent bug where UpdateCommandCenterInfo.Detail was mutated in-place on the existing object; AppState.UpdateInfo only fires PropertyChanged on assignment, so the mutation was silently dropped by the UI

Testing

  • ./build.ps1
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Connection.Tests/OpenClaw.Connection.Tests.csproj --no-restore
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore

Proof

Manual run after the UpdateCoordinator extraction. The log shows the update flow firing through the new coordinator on startup:

  • Checking for updates...
  • Update available: v0.5.0
  • Skipping update prompt for remembered version v0.5.0

Behavior preserved: the check runs, the version is detected, and the remembered-version skip is honored — identical to the pre-refactor path.

https://github.com/user-attachments/assets/ddb3cca6-bf3c-4316-90a9-0a533de00bd4

Notes

No behavior change is intended. The update dialog, skip logic, concurrency model, and #if DEBUG paths are preserved exactly. Addresses part of #554.

Co-Authored-By: Claude Sonnet 4.6 [email protected]

AlexAlves87 avatar May 30 '26 13:05 AlexAlves87

Codex review: needs maintainer review before merge. Reviewed May 30, 2026, 11:10 AM ET / 15:10 UTC.

Summary This PR adds UpdateCoordinator, moves update check/prompt/download/install logic out of App.xaml.cs, and delegates startup, tray, app-command, and deep-link update entrypoints to the new service.

Reproducibility: not applicable. this is a refactor PR rather than a bug report. The attached recording provides after-refactor behavior proof for the startup update-check and remembered-skip path.

Review metrics: 2 noteworthy metrics.

  • Diff surface: 2 files changed, +484/-466. The refactor is concentrated in one new service and one delegation edit, so maintainers can focus review on update-flow behavior preservation.
  • Delegated entrypoints: 4 entrypoints delegated. Startup, tray menu, app command, and deep-link update paths all move through the new coordinator and are the main behavior surface to verify.

Merge readiness Overall: 🐚 platinum hermit Proof: 🐚 platinum hermit ✨ media proof bonus Patch quality: 🐚 platinum hermit Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Mantis proof suggestion A short desktop proof would still be useful if maintainers want visual coverage of the manual Check for Updates/status-dialog path beyond the submitted startup log recording. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify manual Check for Updates still updates command center status and shows the expected update dialog after the UpdateCoordinator extraction.

Risk before merge

  • [P1] GitHub test and e2etests were still in progress at review time, so merge should wait for the normal required checks to finish.
  • [P1] The attached recording covers startup update check and remembered-version skip, but not a full download/install path; maintainers may ask for that separately if they want full updater-flow proof before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused extraction after the in-progress checks complete, preserving the existing updater semantics and keeping the whole-object UpdateInfo replacement.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is indicated because no actionable patch defect was found; this needs normal maintainer review and CI completion.

Security Cleared: The diff moves existing updater logic without changing dependencies, workflows, permissions, secrets handling, release sources, or package references.

Review details

Best possible solution:

Land the focused extraction after the in-progress checks complete, preserving the existing updater semantics and keeping the whole-object UpdateInfo replacement.

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

Not applicable: this is a refactor PR rather than a bug report. The attached recording provides after-refactor behavior proof for the startup update-check and remembered-skip path.

Is this the best way to solve the issue?

Yes: extracting one cohesive update coordinator is a narrow maintainability step, and the UpdateInfo assignment change matches the AppState notification contract. Merge should still wait for the in-progress checks and ordinary maintainer review.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against eb06fba21c44.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
  • add proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P3: This is a low-risk maintainability refactor with no urgent user-facing regression reported.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (recording): The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The PR body now links an inspected MP4 recording showing after-refactor startup update logs and the remembered-version skip path in a real Windows session.
Evidence reviewed

What I checked:

  • Repository policy read: Full target AGENTS.md was read; its validation expectations were applied as review context, but no build/test commands were run because this review is explicitly read-only. (AGENTS.md:1, eb06fba21c44)
  • Current main still has old shape: On current master, update initialization and all update helpers remain in App.xaml.cs, and no Services/UpdateCoordinator.cs exists, so the PR is not implemented on main. (src/OpenClaw.Tray.WinUI/App.xaml.cs:3286, eb06fba21c44)
  • PR delegates update entrypoints: The PR constructs UpdateCoordinator during startup and delegates the startup update check, tray menu action, app command, and deep-link action to it. (src/OpenClaw.Tray.WinUI/App.xaml.cs:444, e41c322b0544)
  • Extracted implementation inspected: The new UpdateCoordinator contains the moved metadata check, remembered-skip handling, manual-check guard, status dialogs, and download/install helper using injected updater/AppState/settings callbacks. (src/OpenClaw.Tray.WinUI/Services/UpdateCoordinator.cs:47, e41c322b0544)
  • UpdateInfo assignment contract: AppState.UpdateInfo raises observers through assignment via SetField, which supports the PR's whole-object replacement for the remembered-skip detail update. (src/OpenClaw.Tray.WinUI/Services/AppState.cs:165, eb06fba21c44)
  • Real behavior proof inspected: The linked 11-second MP4 was downloaded to the scratch area; extracted frames show terminal logs for checking updates, update available v0.5.0, remembered-version prompt skip, and the WinUI app opening after the refactor. (e41c322b0544)

Likely related people:

  • shanselman: GitHub commit history shows Scott added the updater/installer flow and later rewrote the update dialog/progress window behavior that this PR extracts. (role: feature owner / original update-flow contributor; confidence: high; commits: bfa0e6c0f96f, ad1409ca68e1, 6e2069d0adfd; files: src/OpenClaw.Tray.WinUI/App.xaml.cs, src/OpenClaw.Tray.WinUI/Dialogs/UpdateDialog.cs, src/OpenClaw.Tray.WinUI/Dialogs/DownloadProgressDialog.cs)
  • RBrid: GitHub path history shows RBrid authored the manual Check for Updates feedback and AppVersionInfo/status update flow that is moved by this PR. (role: update command-center contributor; confidence: high; commits: f3d3fd2772f3; files: src/OpenClaw.Tray.WinUI/App.xaml.cs, src/OpenClaw.Tray.WinUI/Dialogs/UpdateDialog.cs)
  • ranjeshj: Recent history and blame show Ranjesh touched the App.xaml.cs and UpdateDialog update path while enforcing warning-clean builds and broader WinUI cleanup. (role: recent area contributor; confidence: medium; commits: a727197dd709; files: src/OpenClaw.Tray.WinUI/App.xaml.cs, src/OpenClaw.Tray.WinUI/Dialogs/UpdateDialog.cs)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

clawsweeper[bot] avatar May 30 '26 13:05 clawsweeper[bot]

@clawsweeper re-review

AlexAlves87 avatar May 30 '26 14:05 AlexAlves87

🦞🧹 ClawSweeper re-review requested.

I asked ClawSweeper to review this item again. Action: item re-review queued (workflow sweep.yml, event repository_dispatch). Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

  • State: Failed
  • Detail: The targeted re-review did not finish cleanly. Check the workflow run for details.
  • Run: https://github.com/openclaw/clawsweeper/actions/runs/26686750519
  • Updated: 2026-05-30T14:50:17.261Z

clawsweeper[bot] avatar May 30 '26 14:05 clawsweeper[bot]