Skip to content

refactor(tray): extract final App orchestration owners - #1088

Merged
karkarl merged 3 commits into
mainfrom
bkudiess-app-lifecycle-owners
Aug 14, 2026
Merged

karkarl merged 3 commits into
mainfrom
bkudiess-app-lifecycle-owners

Conversation

@bkudiess

@bkudiess bkudiess commented Aug 4, 2026 •

Copy link
Copy Markdown
Collaborator

Extracts the final App orchestration owners while keeping startup and service construction in App. PR #1085 is merged, so this branch is based directly on main.

Summary

  • Add ActivationRouter for launch, toast, deep-link, and forwarded single-instance activation planning, confirmation, redaction, current-user IPC, and lifecycle quiescence.
  • Keep one typed activation route path through App and remove the legacy DeepLinkActions and ToastActivationActions callback bags that production no longer used.
  • Add a synchronous SettingsChangeCoordinator that owns detached snapshot classification and exact post-save effect ordering. A reentrant monitor lock serializes concurrent MCP writes while preserving per-caller exceptions and mainline reentrant behavior.
  • Add AppShutdownCoordinator for first-wins shared-task shutdown, ordered per-step catch/log/continue, and final Exit exactly once.
  • Remove the three one-implementation coordinator interfaces and the unused async settings admission, persisted-version, disposal, and retry protocol.
  • Keep custom current-user named-pipe activation transport. Replacing it with Windows App SDK AppInstance redirection is intentionally deferred because packaged, portable, dev, post-setup, and isolated-test behavior require separate proof.
  • Update the architecture ledger and ownership closure guards.

Reduction result

Compared with the prior PR head, the reduction commit removes 1,377 lines and adds 350.

Scope versus main Before reduction Current
Production net growth +1,152 +535
Test net growth +1,393 +930
Total net growth +2,557 +1,477

The remaining production growth is primarily the extracted App route application, shutdown-plan construction, current-user IPC owner, and their typed plans. It is not a new parallel platform layer.

Ownership transfer

Old owner New owner Preserved invariant
App activation parsing, confirmation, IPC, and routing decisions ActivationRouter Current-user IPC, strict size/UTF-8 guards, redaction, confirmation, launch precedence, exact routes, and no dispatch after stop
App.OnSettingsSaved classification and effect order SettingsChangeCoordinator Mainline snapshot timing, browser proxy/reconnect/MCP/hotkey/autostart/telemetry/surface order, serialized concurrent writes, MCP-only behavior, and credential precedence
App shutdown guard and safe-step executor AppShutdownCoordinator First-wins published task, UI-thread continuation, field clearing on failure, failure continuation, null-before-await, and Exit once

App remains the sole composition root and startup owner.

Validation

  • .\build.ps1: all 5 projects passed; documentation validation passed
  • OpenClaw.Shared.Tests: 3,654 passed, 32 skipped, 0 failed
  • OpenClaw.Tray.Tests: 2,468 passed, 0 skipped, 0 failed
  • Focused activation/settings/shutdown/deep-link/toast/contract tests: 229 passed
  • Concurrent settings serialization and exception-attribution stress: 20 repeated runs, 40 test executions passed

Real behavior proof

Current-head automated proof covers activation route equivalence, current-user IPC bounds and forwarding, confirmation cancellation/drain, settings effect order and concurrent MCP admission, shutdown ordering, first-wins behavior, and failure continuation.

Interactive UI proof was not repeated for this reduction commit because it intentionally changes no visible UI. Fresh current-head CI and E2E proof is pending after this push. Previous live proof on the branch covered isolated MCP-only startup, second-process deep-link forwarding, Connection fallback UI, natural tray shutdown, and ordered shutdown logs.

Adversarial review

Claude Opus and GPT Codex independently reviewed the complete reduced diff. Verified findings were fixed:

  • concurrent MCP settings writes now serialize under a reentrant monitor lock
  • each settings caller receives its own effect failure
  • snapshot advancement again matches main by occurring before effects
  • stale source-contract assertions now target the synchronous delegate path
  • ActivationRouter.StopAsync no longer exposes an ignored cancellation token

Both reviewers found no remaining actionable correctness or security issues in the final diff.

Architecture

Adds authoritative and closed ledger rows for activation, settings coordination, and shutdown. Startup remains in App.OnLaunchedAsync; AppBootstrapper remains planned and deferred.

@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: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 4, 2026
@clawsweeper

clawsweeper Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 9:42 PM ET / August 14, 2026, 01:42 UTC.

ClawSweeper review

What this changes

This PR moves tray-app activation routing, saved-settings effect sequencing, and ordered shutdown mechanics into dedicated coordinators while retaining App as the startup composition root.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep open: the author is a collaborator and the PR is actively landing, so it requires explicit maintainer handling. Local read-only source inspection was blocked by the sandbox before an exact-head lifecycle review could be completed.

Priority: P2
Reviewed head: c5331f2b89e5daf886c096942133a2a3f6515bd3

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The reported proof is substantial, but exact-head source review could not be completed in the local read-only environment.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): The supplied PR context carries proof: sufficient and describes current-head automated lifecycle coverage plus prior live branch proof for the unchanged visible flows.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The supplied PR context carries proof: sufficient and describes current-head automated lifecycle coverage plus prior live branch proof for the unchanged visible flows.
Evidence reviewed 4 items Collaborator and active-landing guard: The supplied PR context identifies the author association as COLLABORATOR and shows the active-landing label applied on 2026-08-13; both require retaining this PR for maintainer handling.
Lifecycle-sensitive scope: The supplied current-head diff adds activation routing, serialized settings-effect coordination, and shutdown sequencing, including current-user named-pipe activation transport.
Prior review continuity: The prior completed review at 260f287 reported no unresolved code findings, but the current head contains the later reduction commit and needs exact-head review.
Findings None None.
Security None None.

How this fits together

The WinUI tray app converts launches, toasts, deep links, and forwarded activations into UI actions, then applies saved settings to gateway, MCP, tray, and telemetry services. These paths also determine how the app drains work and releases those services during shutdown.

flowchart LR
  A[Launch and toast input] --> B[Activation router]
  C[Saved settings] --> D[Settings coordinator]
  B --> E[Tray App actions]
  D --> F[Gateway MCP tray telemetry]
  E --> G[Shutdown request]
  F --> G
  G --> H[Ordered shutdown coordinator]
Loading

Before merge

  • Resolve merge risk (P1) - Activation forwarding, saved-settings effects, and ordered shutdown can affect existing deep-link, reconnect, and exit behavior; exact-head source verification was blocked locally.
  • Resolve merge risk (P1) - The refactor retains a current-user named-pipe activation boundary, so maintainers should rely on the pending exact-head checks and a focused review before landing.
  • Complete next step (P2) - A collaborator-owned, actively landing lifecycle refactor needs maintainer review and exact-head validation; no discrete repair is established for automation.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Diff size 28 files, 2,546 additions, 1,016 deletions The change crosses App composition, service ownership, architecture guards, and focused tray tests.

Merge-risk options

Maintainer options:

  1. Wait for exact-head verification (recommended)
    Pause merge until a maintainer can review the current head and the pending checks cover activation forwarding, settings effects, and shutdown behavior.

Technical review

Best possible solution:

Land only after a maintainer completes exact-head review and the pending lifecycle checks confirm equivalent activation, settings, and shutdown behavior.

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

Not applicable. This is a refactor PR, and review concerns behavioral equivalence rather than reproducing a reported defect.

Is this the best way to solve the issue?

Unclear. The proposed ownership split matches the documented App reduction direction, but the exact current head could not be independently inspected because the read-only sandbox failed.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded but substantial tray lifecycle refactor with moderate user-flow impact.
  • merge-risk: 🚨 compatibility: Activation and settings coordination can change existing launch, reconnect, and persisted-preference behavior.
  • merge-risk: 🚨 security-boundary: The diff changes deep-link handling and current-user named-pipe activation transport.
  • merge-risk: 🚨 availability: The diff changes startup-adjacent and exactly-once shutdown coordination for the tray process.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The supplied PR context carries proof: sufficient and describes current-head automated lifecycle coverage plus prior live branch proof for the unchanged visible flows.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied PR context carries proof: sufficient and describes current-head automated lifecycle coverage plus prior live branch proof for the unchanged visible flows.

Evidence

What I checked:

  • Collaborator and active-landing guard: The supplied PR context identifies the author association as COLLABORATOR and shows the active-landing label applied on 2026-08-13; both require retaining this PR for maintainer handling. (c5331f2b89e5)
  • Lifecycle-sensitive scope: The supplied current-head diff adds activation routing, serialized settings-effect coordination, and shutdown sequencing, including current-user named-pipe activation transport. (src/OpenClaw.Tray.WinUI/Services/ActivationRouter.cs:1, c5331f2b89e5)
  • Prior review continuity: The prior completed review at 260f287 reported no unresolved code findings, but the current head contains the later reduction commit and needs exact-head review. (src/OpenClaw.Tray.WinUI/Services/SettingsChangeCoordinator.cs:1, 260f287a28ee)
  • Inspection infrastructure failure: Read-only local inspection could not run: the sandbox returned bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted even for git status --short.

Likely related people:

  • bkudiess: This contributor authored the current App-orchestration refactor and the merged preceding App surface-lifetime and presentation-owner work in the supplied history. (role: recent area contributor; confidence: high; commits: 27afcd4b0ada, 3a097bc85f7b; files: src/OpenClaw.Tray.WinUI/App.xaml.cs, src/OpenClaw.Tray.WinUI/Services/ActivationRouter.cs)

Rank-up moves

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

  • Complete a focused exact-head review of activation IPC, settings serialization, and shutdown paths.
  • Allow the pending exact-head CI and E2E checks to finish 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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-05T21:58:19.944Z sha 7a2b6b8 :: found issues before merge. :: [P2] Split the independent lifecycle ownership transfers
  • reviewed 2026-08-05T22:28:00.819Z sha 7a2b6b8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-06T08:12:49.260Z sha 7a2b6b8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T20:32:14.820Z sha 7a2b6b8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T20:37:46.807Z sha 7a2b6b8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T22:18:17.502Z sha 27afcd4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T22:37:50.376Z sha 27afcd4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-13T23:51:36.041Z sha 260f287 :: needs maintainer review before merge. :: none

@bkudiess
bkudiess marked this pull request as draft August 5, 2026 06:23
@clawsweeper clawsweeper Bot added 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. and removed 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. labels Aug 5, 2026
@bkudiess
bkudiess force-pushed the bkudiess-app-lifecycle-owners branch from 53a4d0b to 7a2b6b8 Compare August 5, 2026 21:52
@bkudiess

bkudiess commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer scope decision: keep A3 as one final App-orchestration layer.

The product owner explicitly requested fewer consolidated PRs. Activation routing, post-save settings coordination, and ordered shutdown are the three remaining App-owned orchestration seams and share the same composition adapters, lifecycle fencing, disposal order, ledger closeout, current-head runtime proof, and rollback boundary. Each owner still has its own typed contract, authoritative/closed ledger rows, deterministic behavioral guards, focused tests, and independently reviewed invariants. Splitting this already validated final layer would add stack/cascade risk without changing runtime ownership or proof.

I accept the combined A3 scope for normal maintainer review. The branch remains mergeable; local exact-current build, Shared, Tray, Connection, Setup, FunctionalUI, Integration, Native UI, Accessibility, focused lifecycle, and SetupAndConnect E2E are green.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed 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 5, 2026
@bkudiess
bkudiess marked this pull request as ready for review August 6, 2026 08:08
@karkarl karkarl added the status: 🚢 actively landing A maintainer or agent is actively driving this item through implementation, validation, or merge. label Aug 13, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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 13, 2026
Base automatically changed from bkudiess-app-surface-owners to main August 13, 2026 20:34
@clawsweeper clawsweeper Bot added 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 13, 2026
@karkarl
karkarl force-pushed the bkudiess-app-lifecycle-owners branch from 7a2b6b8 to 27afcd4 Compare August 13, 2026 22:14
@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 13, 2026
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: c9ce1f9c-5e46-4d33-bd1a-d670a04e36a6
Remove unused coordinator interfaces and callback compatibility paths, keep settings application synchronous and serialized, and trim tests for deleted protocols.

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

Copilot-Session: c9ce1f9c-5e46-4d33-bd1a-d670a04e36a6
@karkarl

karkarl commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Current-head UI proof

Rebuilt c5331f2 and launched the dev side-by-side identity with a fresh synthetic OPENCLAW_TRAY_DATA_DIR. The screenshots were reviewed before upload: no user account, gateway credential, device identifier, username, or filesystem path is rendered.

1. Connection deep link

A secondary-process openclaw-dev://hub/connection activation reached the isolated app and showed the expected no-gateway / MCP-only state.

Isolated Connection page

2. Settings deep link and persisted change

A secondary-process openclaw-dev://hub/settings activation opened Settings. UI Automation toggled Show tool calls and usage on, and the isolated settings file persisted ShowChatToolCalls: true.

Isolated Settings page after change

3. Chat deep link while disconnected

A secondary-process openclaw-dev://hub/chat activation routed to the native disconnected-chat fallback instead of silently doing nothing.

Isolated Chat disconnected fallback

@karkarl
karkarl merged commit 17a8b03 into main Aug 14, 2026
22 checks passed
@karkarl
karkarl deleted the bkudiess-app-lifecycle-owners branch August 14, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. 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. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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