Skip to content

refactor(tray): extract Hub and tray presentation models - #1082

Merged
karkarl merged 2 commits into
mainfrom
bkudiess-presentation-models
Aug 13, 2026
Merged

karkarl merged 2 commits into
mainfrom
bkudiess-presentation-models

Conversation

@bkudiess

@bkudiess bkudiess commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

Establishes WinUI-free, behavior-tested presentation owners for Hub navigation/search, notification banners, and the complete tray menu. This is layer 2 of the App architecture stack and depends on #1075.

What changed

  • Add HubPageRegistry as the single owner of Hub tag aliases, page mapping, command metadata/order/search, and gateway back-prune classification.
  • Add AppNotificationInfoBarPresenter for Warning/Error banner selection, semantic severity, action-vs-Show-more projection, and current-page action state.
  • Add immutable TrayMenuPresentation/TrayMenuPresenter plus ConnectionTogglePresenter as the only owners of tray semantic presence, ordering, text, actions, enabled/checked state, accelerators, and accessibility names.
  • Add TrayMenuRenderer as the mechanical WinUI control/resource/callback applicator.
  • Delete the mixed 1,589-line TrayMenuStateBuilder and remove duplicate semantic paths from Hub/App tray rendering.
  • Preserve TrayMenuWindow Win32 positioning/focus/light-dismiss ownership and App action/lifetime orchestration.
  • Preserve the A0 Permissions page-to-view-model activation, deactivation, disposal, legacy alias, and reopen behavior.
  • Update the architecture ledger with authoritative/closed owners and anti-regression guards.

Ownership transfer

  • Old owners: HubWindow inline page/command/banner policy and TrayMenuStateBuilder mixed presentation/render logic.
  • New owners: HubPageRegistry, AppNotificationInfoBarPresenter, TrayMenuPresenter, and ConnectionTogglePresenter.
  • View residue: HubWindow retains Frame/NavView/back-stack/control/route application; TrayMenuRenderer and TrayMenuWindow retain WinUI and Win32 mechanics; App remains the composition/action owner.
  • Preserved invariant: the same tags, search results, banner actions, tray rows/flyouts/toggles, callbacks, accelerators, accessibility names, and A0 page lifecycles render from one semantic source.

Validation

  • ./build.ps1: all projects passed
  • OpenClaw.Shared.Tests: 3,415 passed, 32 skipped, 0 failed
  • OpenClaw.Tray.Tests: 2,187 passed, 0 skipped, 0 failed
  • Focused Hub/InfoBar/tray/navigation/Permissions suites: 75 passed, 0 skipped, 0 failed after review fix
  • Real-process accessibility suite: 19/19 passed
  • git diff --cached --check: clean before commit

Real behavior proof

Current-head isolated App ran with local MCP on port 8766.

  • Authenticated tool discovery exposed app.navigate, app.menu, and app.search.
  • app.navigate {"page":"permissions"} and the legacy capabilities alias both returned navigated=true.
  • Windows UI Automation confirmed the live A0 Permissions page, Node mode, capability rows, and the 8766 MCP endpoint.
  • app.menu returned the current disconnected/idle state with zero sessions and nodes.
  • Invoking the tray icon through UI Automation in the disconnected state visibly routed the Hub to Connection.
  • Current command title/order/search/action behavior is covered by HubPageRegistry characterization tests; this isolated runtime had no search-result data and returned [].

Right-click popup and deterministic runtime InfoBar triggering were not automation-addressable on this host because the controller lacked computer-use and SendInput was rejected by UIPI. Complete menu/flyout/toggle and InfoBar state matrices are covered by pure presentation, source-contract, and accessibility tests.

UI media proof

Not verified / blocked: no screenshot or video is published for exact head a69043d08c239d926117c37647d558a3c7ec3d9b. Crabbox is not installed in the approved local paths, and this RDP session has no computer-use or GitHub attachment uploader. No blank or unverifiable frame was published.

Manual capture steps:

  1. Use a clean checkout of bkudiess-presentation-models and verify git rev-parse HEAD equals a69043d08c239d926117c37647d558a3c7ec3d9b.
  2. Set $env:OPENCLAW_TRAY_PREVIEW_DATA='1', then run .\run-app-local.ps1 -Isolated -AllowNonMain.
  3. Right-click the isolated OpenClaw tray icon and keep the full tray menu open. Confirm the status card, Gateway, Sessions, Usage, Permissions, Dashboard, Chat, Canvas, Diagnostics, Companion Settings, and connection toggle are visible and not clipped.
  4. Capture only the OpenClaw tray menu and desktop area needed for context. Verify the image is nonblank and contains no tokens, personal notifications, or unrelated application content.
  5. Upload the image in the GitHub PR editor under this section, caption it with the exact head SHA and OPENCLAW_TRAY_PREVIEW_DATA=1, save the draft body, and verify the rendered image URL resolves.

Review

  • Rubber-duck, Claude Opus 4.8, and GPT-5.3 Codex full-diff reviews found no actionable issues.
  • Independent coordinator Gemini review was clean.
  • GPT-5.6 Sol and Claude Sonnet 5 independently found one immutable-session snapshot regression; AbortedLastRun preservation and a full snapshot/build-path regression test were added.
  • Final Sol/Opus delta reviews found no actionable findings.
  • Final independent GPT-5.6 Sol review of exact head a69043d08c239d926117c37647d558a3c7ec3d9b found no significant issues with 92% confidence and confirmed the A1 ownership boundary and A0 Permissions lifecycle remain preserved.

Deferred work

  • ITrayController and IWindowManager ownership move in the next stack layer.
  • App activation/settings/startup/shutdown ownership remains a later layer.
  • Known icon/copy design drift remains unchanged and requires a separate visible-design change.

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 session-state 🚨 Merging this PR could lose, corrupt, stale, or mis-associate session or agent state. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 5:29 PM ET / 21:29 UTC.

ClawSweeper review

What this changes

This PR moves Hub navigation, notification-banner, and tray-menu presentation policy into WinUI-free, tested components while keeping WinUI rendering and application actions in their existing layers.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open. Current main does not contain the extracted Hub or tray presentation owners, and this actively landing collaborator PR remains the coherent implementation for that layer with no confirmed patch defect.

Priority: P2
Reviewed head: 843893018f7c204979e49a8869271edd7a866906

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong current-head runtime and UI evidence plus focused coverage support a mergeable refactor, subject to the current integration gate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): A current-head collaborator comment records a fresh isolated run with UI Automation captures for Sessions, Permissions, and Hub gating, plus a passing real-process accessibility suite.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): A current-head collaborator comment records a fresh isolated run with UI Automation captures for Sessions, Permissions, and Hub gating, plus a passing real-process accessibility suite.
Evidence reviewed 6 items Current main does not implement this layer: The current-main tree has none of the new Hub or tray presentation-owner files, so the central ownership transfer is not already implemented or released.
Architecture boundary follows repository policy: The architecture ledger requires presentation code to remain WinUI-free and unit-tested, matching the split between the new semantic presenters and renderer.
Immutable tray projection: The PR snapshots live gateway, session, usage, and settings data before presentation, including the current-run and aborted-run fields used by session state logic.
Findings None None.
Security None None.

How this fits together

Cached connection, session, settings, and notification state feeds the tray menu and Hub. The new presentation layer converts that state into menu, route, search, and banner decisions before WinUI applies controls and the App performs actions.

flowchart LR
A[Cached connection, session, and settings state] --> B[Tray snapshot]
B --> C[Tray presentation]
C --> D[WinUI tray menu]
E[Hub routes, search, and notifications] --> F[Hub presentation registry]
F --> G[Hub window controls]
D --> H[App actions and persisted settings]
G --> H
Loading

Before merge

  • Resolve merge risk (P1) - This replaces a broad tray semantic owner and re-routes capability toggles through action identifiers, so the current-head integration and tray validation must continue to cover settings, session, and Hub route parity before landing.
  • Complete next step (P2) - This collaborator PR is actively landing, no line-level repair was found, and the remaining action is normal current-head integration review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Refactor surface 26 files, 3,549 added, 2,021 removed The replacement spans Hub, App, tray semantics, rendering, snapshots, and focused tray tests, so the integration boundary deserves a full current-head check.

Merge-risk options

Maintainer options:

  1. Complete current-head integration validation (recommended)
    Review the finishing current-head checks and retain the tray, Hub, session, and permission-toggle coverage before merging this ownership transfer.

Technical review

Best possible solution:

Land the A1 presentation layer only after the current-head integration checks remain clean, preserving one semantic source for tray and Hub behavior and leaving WinUI mechanics in the renderer and views.

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

Not applicable: this is a behavior-preserving refactor rather than a reported defect. Current-head isolated runtime and UI Automation proof exercise the changed tray and Hub paths.

Is this the best way to solve the issue?

Yes. The split keeps pure semantic projection in tested presentation owners while retaining WinUI control construction and App-side effects at their established boundaries.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a substantial but bounded native-tray refactor with no confirmed user-facing regression.
  • merge-risk: 🚨 compatibility: Hub routes, legacy aliases, tray actions, and capability-toggle behavior move to new semantic owners.
  • merge-risk: 🚨 session-state: The tray now projects immutable session snapshots for visibility, run state, titles, and usage summaries.
  • merge-risk: 🚨 security-boundary: Tray controls continue to mutate local node capability settings, including system-tool and browser-control permissions.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): A current-head collaborator comment records a fresh isolated run with UI Automation captures for Sessions, Permissions, and Hub gating, plus a passing real-process accessibility suite.
  • proof: sufficient: Contributor real behavior proof is sufficient. A current-head collaborator comment records a fresh isolated run with UI Automation captures for Sessions, Permissions, and Hub gating, plus a passing real-process accessibility suite.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. A current-head collaborator comment records a fresh isolated run with UI Automation captures for Sessions, Permissions, and Hub gating, plus a passing real-process accessibility suite.

Evidence

What I checked:

  • Current main does not implement this layer: The current-main tree has none of the new Hub or tray presentation-owner files, so the central ownership transfer is not already implemented or released. (f4e1cf3a9894)
  • Architecture boundary follows repository policy: The architecture ledger requires presentation code to remain WinUI-free and unit-tested, matching the split between the new semantic presenters and renderer. (docs/ARCHITECTURE.md:28, f4e1cf3a9894)
  • Immutable tray projection: The PR snapshots live gateway, session, usage, and settings data before presentation, including the current-run and aborted-run fields used by session state logic. (src/OpenClaw.Tray.WinUI/Services/TrayMenuSnapshot.cs:86, 843893018f7c)
  • Focused regression coverage: The branch adds pure presenter, Hub registry, notification, and presentation-boundary test classes alongside adapted tray and navigation tests. (tests/OpenClaw.Tray.Tests/Services/TrayMenuPresenterTests.cs:11, 843893018f7c)
  • Current-head behavior proof: The collaborator comment reports a fresh isolated run at the final head with UI Automation captures for Sessions, Permissions, and Hub capability gating, plus a 21/21 real-process accessibility result. (843893018f7c)
  • Feature-history routing: History identifies the earlier tray dashboard work, Hub notification redesign, and original tray builder extraction as the relevant ownership trail. (src/OpenClaw.Tray.WinUI/Services/TrayMenuStateBuilder.cs:1, acfbf62b4c45)

Likely related people:

  • Barbara Kudiess: Recent main history includes the merged Permissions ownership transfer and earlier Hub notification and tray dashboard work. (role: recent Hub and tray area contributor; confidence: high; commits: f4e1cf3a9894, acfbf62b4c45, dd1c7916204c; files: src/OpenClaw.Tray.WinUI/App.xaml.cs, src/OpenClaw.Tray.WinUI/Windows/HubWindow.xaml.cs, src/OpenClaw.Tray.WinUI/Services/TrayMenuStateBuilder.cs)
  • AlexAlves87: History attributes the original extraction of TrayMenuStateBuilder to this contributor, making them relevant to its replacement boundary. (role: introduced prior tray-menu owner; confidence: high; commits: 565fba8feffa; files: src/OpenClaw.Tray.WinUI/Services/TrayMenuStateBuilder.cs)

Rank-up moves

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

  • Review the finishing current-head CI results before merge.

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 (7 earlier review cycles)
  • reviewed 2026-08-03T22:11:02.825Z sha 53006e8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T23:02:25.247Z sha a69043d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T06:27:32.065Z sha a69043d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T07:24:14.314Z sha a69043d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-05T20:21:09.865Z sha b77dfba :: needs maintainer review before merge. :: none
  • reviewed 2026-08-06T08:13:13.758Z sha b77dfba :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T19:47:21.331Z sha b77dfba :: needs maintainer review before merge. :: none

@bkudiess
bkudiess force-pushed the bkudiess-presentation-models branch from 53006e8 to a69043d Compare August 3, 2026 22:26
@bkudiess
bkudiess marked this pull request as draft August 5, 2026 06:23
@bkudiess
bkudiess force-pushed the bkudiess-presentation-models branch from a69043d to b77dfba Compare August 5, 2026 20:16
@clawsweeper clawsweeper Bot removed the proof: sufficient Contributor real behavior proof is sufficient. label Aug 5, 2026
@bkudiess
bkudiess marked this pull request as ready for review August 6, 2026 08:08
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 6, 2026
Base automatically changed from bkudiess-permissions-mvvm-pilot to main August 12, 2026 19:42
@karkarl karkarl added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 12, 2026
bkudiess and others added 2 commits August 12, 2026 12:49
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 529161b9-67ce-4fde-98b4-c96d8991faff
@karkarl

karkarl commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Current-head UI proof

Re-launched a single fresh isolated tray instance from 843893018f7c204979e49a8869271edd7a866906 after terminating all existing tray processes. Capture state uses preview session data and intentionally has no gateway credential, so disconnected and node-disabled states are expected.

Sessions presentation

Tray Sessions flyout showing three preview sessions, one working session, models, ages, and context usage

Permissions presentation

Tray Permissions flyout showing Windows node plus all eight capability toggles

Hub routing and capability gating

Hub Permissions page selected with Node mode disabled and capability controls gated

The fresh instance was the only running OpenClaw.Tray.WinUI process during capture. The current-head real-process accessibility suite also passes 21/21 with no failures or skips.

@karkarl
karkarl force-pushed the bkudiess-presentation-models branch from b77dfba to 8438930 Compare August 12, 2026 21:25
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@karkarl
karkarl merged commit bc518f7 into main Aug 13, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 Merging this PR could lose, corrupt, stale, or mis-associate session or agent state. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. 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.

2 participants