Skip to content

fix(desktop): restore tray stop and simplify Rust state - #139241

Merged
steipete merged 4 commits into
mainfrom
codex/rust-deslop-land
Sep 5, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/rust-deslop-land

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where choosing Stop Gateway in the Tauri tray returned an error while the local service kept running. Native subprocesses have no terminal, and the app omitted the CLI’s required non-interactive stop consent.

Also completes the maintainer-requested Rust cleanup: consolidate repeated connection/reconnect setup, tray state, and unused navigation/auth/routing helpers, and refresh compatible desktop and Watch RTC dependencies.

Why This Change Was Made

Only Stop supplies the CLI’s --force consent flag; service shutdown remains graceful, and Restart keeps its existing drain behavior. Local connect, install, and restart now share their identical completion path. Gateway configure/clear share cache invalidation and reconnect signaling; the CLI adapter alone enforces process success before decoding JSON. Native menus own their items, Quick Chat reuses its existing WebView guard, and Watch uses derived initialization without changing its C ABI or entropy checks.

Reduces production Rust by 156 lines (+220/−376). Tests grow by four lines (+53/−49 across Rust and Swift), including the new service-action regression and repaired Swift callback wait. This includes canonical formatting that adds 56 lines to the Watch file. No new runtime setting, persistence representation, or protocol change. Existing navigation fences, TLS/identity checks, sleep generations, renderer callback ownership, and error visibility remain intact.

User Impact

Stop Gateway now stops the local service and exposes the stopped screen; Start and graceful Restart continue to work. The remaining cleanup preserves desktop onboarding, connection/reconnection, Quick Chat, and Watch audio behavior. Removes repeated configuration clones and keeps state transitions in one owner. The dependency refresh includes detached-opener child reaping and TLS read batching; no claimed end-to-end latency improvement from this refactor alone.

The desktop accepts 21 compatible transitive updates and advances the notifications plugin to its narrow Swift diagnostic fix. Watch updates getrandom to 0.4.3 and three compatible build dependencies, with matching license notices. Existing networking/crypto packages already match their current stable releases.

Evidence

  • macOS desktop: cargo test --locked --all-targets --manifest-path apps/linux/src-tauri/Cargo.toml — 136 passed; final build has no compiler warnings. The new service-action regression fails on the pre-fix Stop invocation.
  • Linux desktop on Blacksmith Testbox: 136 main Rust tests and 10 helper tests passed (one existing ignored test); baseline and candidate builds passed. Both revisions passed the real native first-run choices and two consecutive failed-local-start/retry attempts. Testbox run.
  • The private-D-Bus logind integration test also passed explicitly. Native Codex activation passed: Welcome at 0.919s, local install/start to model setup at 11.191s, Gateway detection 1.819s, wizard steps 4.176s and 1.735s. The enabled guided composer showed verified openai/gpt-5.6-sol. Codex guided handoff completed in 13.029s. Real tray-menu events opened Quick Chat and Open Dashboard; composited Quick Chat replied with visible Done in 4.970s, then replied again in 4.083s after a 3.987s managed Gateway restart.
  • Cold Ollama: /api/ps empty with one eligible installed 4B Instruct model; native Choose connection → Local only → Submit verified in 9.477s without a raw-API preload. Guided reply completed in 64.228s on CPU; talk to agent handed off in 458ms, and reopening reached chat.
  • Actual native tray lifecycle comparison: baseline Stop rejected the non-interactive call and left its Gateway running; candidate Stop sent the required flag, completed in 1.141s, reached MainPID 0 and visible standby, and stayed stopped during the 2s watchdog observation. Start restored the service in 3.498s and Restart changed its PID in 3.965s using only gateway restart --json. Lifecycle Testbox run.
  • Watch RTC: all 12 existing engine tests passed before and after the change, including authenticated ICE/DTLS/Opus, IPv4/IPv6/NAT64, admission, lost/late audio, and entropy cases.
  • Watch release archives built for arm64 and arm64_32 devices, and arm64 and x86_64 simulators. Physical Watch radio/audio and Windows installer execution are not claimed.
  • Both Rust format checks and git diff --check pass. The app changed gate passed on the final patch in an isolated normal checkout with pinned dependencies and Swift tools, including all 1,109 app/host tests. Final independent review found no actionable P0–P2 issues. CI then exposed a race in the existing macOS pending-verification test: the receipt preceded its deadline callback. The test now waits for the callback using the same budget and all original assertions; its focused 15-test suite and fresh independent review pass. A separate iOS CI polling failure was also diagnosed and validated locally (249 owner-suite tests). During landing, refactor(macos): move app settings into the Dashboard and keep Connection native #138092 independently merged the equivalent event-wait repair into main, so the rebased branch uses that canonical fix and drops the duplicate patch. The macOS callback test moved with that refactor; its identical repair now lives in OnboardingDashboardHandoffTests.swift. Rust source, Cargo locks, and the CLI service contract are byte-identical to the native-tested revision. The rebased CI run then exposed a pre-existing OpenClawKit test race: a late legacy refresh caller could request a second rotation after the fixture response. The test-only repair anchors the initial timed request before starting followers with their original observed URL, and removes a redundant late join from the timeout-survival case. Mixed deadlines, one-request, survivor, result-equality and TLS-route assertions remain. Nine focused tests and ten consecutive stress repetitions of both changed cases passed. Full CI passed on the final head, including macOS/iOS tests, Watch operation tests, Android, release builds and screenshot jobs.

The notification-plugin exact upstream diff was directly inspected: only two Swift failure-diagnostic UTF-8 conversions change in build.rs; runtime sources, manifest, features, build commands and target selection are unchanged. This addresses ClawSweeper’s dependency-source review request; the complete upstream patch is also included inline in the maintainer disposition comment because the reviewer environment could not retrieve it.

Dependency holds: retain updater 2.10.1 because current 2.11.0 still runs Tauri cleanup before returning Windows installer errors. Retain blocking 1.6.2 in the existing lock: identical upstream probes show 1.6.2 returns from 13 threads to 1 after 750 ms, while 1.7.0 retains all 13 after 1.5 s. The latter proves an upstream idle-retirement regression, not a measured desktop leak. No new patch, override, or manifest pin was introduced.

QA also observed the documented graceful-stop drain (315 seconds); gateway stop --force permits non-interactive stop and does not bypass draining. Follow-up: cancel cancellable interactive prompt waiters before drain while preserving normal reconnects and commit-locked work. This is outside the Rust refactor.

Follow-ups: revisit blocking after upstream restores idle-worker retirement; lift the updater pin only after Windows cleanup follows successful installer launch. Broader widget-state consolidation needs separate renderer-restart/native lifecycle proof; existing legacy preference/config file storage remains a separately scoped migration topic. The focused package build also reported an existing unused Bool result in ChatViewModelSessionActionTests.swift:1067; that unrelated test warning is a follow-up.

Before/after native retry proof (synthetic fixtures, both inspected):

Before — actionable native retry screen

After — actionable native retry screen

Native Codex onboarding reached the verified model and enabled composer:

Native Codex onboarding ready

Quick Chat completed after Gateway restart

Cold Ollama setup completed a guided response

Actual native tray Stop, before and after the consent fix (idle Gateway):

Before: Stop rejected and Gateway still running

After: Gateway stopped and native app standing by

Both task-owned Blacksmith Testbox leases are stopped and independently verified completed. The model proof used the normal configured workloads; the separate lifecycle comparison used an explicitly idle Gateway.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added app: ios App: ios app: linux size: L maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 17:24
@openclaw-barnacle openclaw-barnacle Bot added the app: macos App: macos label Sep 5, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 4:12 PM ET / 20:12 UTC.

ClawSweeper review

What this changes

Restores desktop tray Stop, consolidates Rust connection and menu state, updates desktop and Watch dependencies, and repairs asynchronous Swift test waits.

Merge readiness

⛔ Blocked before merge - 1 item remains

The tray fix remains necessary on current main. No blocking introduced defect was found, and the latest Swift test changes preserve the relevant assertions. Maintainer-authored work also remains protected from automated closure.

Priority: P2
Reviewed head: 3d1c20a5a4956502006e083c042293f581a2d887

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused service-control repair with strong recorded native proof and behavior-preserving cleanup; no blocking finding remains.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied native Linux lifecycle comparison exercises tray events through the desktop CLI adapter and real service manager, recording failed baseline Stop followed by successful Stop, standby, Start, and graceful Restart. The latest commit leaves that production code unchanged; linked artifacts could not be independently reopened here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied native Linux lifecycle comparison exercises tray events through the desktop CLI adapter and real service manager, recording failed baseline Stop followed by successful Stop, standby, Start, and graceful Restart. The latest commit leaves that production code unchanged; linked artifacts could not be independently reopened here.
Evidence reviewed 8 items Stop repair matches the production CLI contract: The desktop adapter uses null stdin. The introduced service-command change supplies --force only for Stop; current main rejects non-interactive Stop without that flag before accessing the service.
Current-main failure boundary: runDaemonStop checks terminal interactivity and explicit force consent; the remaining service-mutation guard stays active afterward.
Necessity and release check: Both fetched main and v2026.9.2 retain the desktop invocation without Stop consent. No supplied merged related PR owns this tray repair.
Findings None None.
Security None None.

How this fits together

The desktop companion turns tray actions into local OpenClaw CLI commands, then updates its connection, dashboard, and Quick Chat state from Gateway results. The secondary Watch changes simplify initialization in its native audio transport.

flowchart TD
  A[Native tray action] --> B[Serialized desktop operations]
  B --> C[CLI command adapter]
  C --> D[Gateway service]
  D --> E[Service status]
  E --> F[Tray and connection state]
  F --> G[Dashboard and Quick Chat]
Loading

Before merge

  • Resolve merge risk (P1) - Independent inspection of the pinned notifications dependency remains unavailable in this environment; its diagnostic-only scope is supported by the author's documented exact-revision audit.
Agent review details

Security

None.

PR surface

Docs +2, Other -117. Total -115 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 0 0 0 0
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 20 393 510 -117
Total 21 395 510 -115

Review metrics

Metric Value Why it matters
Production versus test scope Author-reported Rust production −156 lines; Rust/Swift tests +4 lines The cleanup reduces production state-handling code while retaining behavioral coverage and adding the Stop regression.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep explicit Stop consent in the desktop CLI adapter while preserving graceful Restart, existing preferences, and the shared lifecycle owners.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep explicit Stop consent in the desktop CLI adapter while preserving graceful Restart, existing preferences, and the shared lifecycle owners.

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

Yes: current main combines null subprocess stdin with a Stop invocation lacking the consent flag required by the CLI. The supplied native comparison corroborates that path; this review did not execute it.

Is this the best way to solve the issue?

Yes for the tray defect: supplying consent at the explicit desktop action preserves the CLI safety guard and avoids changing Restart semantics. The surrounding refactors preserve the inspected owner contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a concrete desktop service-control failure with a limited blast radius.
  • 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 (linked_artifact): The supplied native Linux lifecycle comparison exercises tray events through the desktop CLI adapter and real service manager, recording failed baseline Stop followed by successful Stop, standby, Start, and graceful Restart. The latest commit leaves that production code unchanged; linked artifacts could not be independently reopened here.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied native Linux lifecycle comparison exercises tray events through the desktop CLI adapter and real service manager, recording failed baseline Stop followed by successful Stop, standby, Start, and graceful Restart. The latest commit leaves that production code unchanged; linked artifacts could not be independently reopened here.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-05T18:14:29.173Z sha b4a985c :: blocked before merge. :: none
  • reviewed 2026-09-05T18:52:05.423Z sha 3e0cd1a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-05T19:39:50.591Z sha ec2f771 :: blocked before merge. :: none

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Completed the notification-plugin source review requested by the review and its rank-up move. The exact upstream comparison is one commit and one file, build.rs, with two additions and two deletions. Both changes replace UTF-8 expect calls for failed Swift-build stdout/stderr with String::from_utf8_lossy. I inspected the complete build script and both trees: build commands, target/deployment selection, Cargo manifest, Swift sources, runtime code, features and dependency definitions are unchanged. The updated revision has built successfully in the macOS Rust test run. This resolves the dependency-source review gap; the pin is retained.

Since the reviewed head, the final shutdown audit also found and fixed an actual native tray bug: Stop ran gateway stop --json with null stdin, which the CLI's non-interactive consent guard rejects. Commit 3e0cd1a adds --force only to Stop. Restart remains graceful without that flag. The subprocess regression fails before the fix and all 136 desktop Rust tests pass afterward; real native before/after Stop/Start/Restart proof is running before landing. No new configuration, protocol, schema, or IPC permission was added.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

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

Re-review progress:

@steipete steipete changed the title refactor(native): simplify Rust lifecycle state and refresh dependencies fix(desktop): restore tray stop and simplify Rust state Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Sep 5, 2026
Consolidate desktop connection, reconnect, CLI status and tray ownership; remove dead helpers and use derived Watch state initialization. Reduce production Rust by 162 lines while preserving onboarding, native auth and lifecycle contracts.

Refresh compatible desktop and Watch dependencies. Retain blocking 1.6.2 after reproducing idle worker retention in 1.7.0, and preserve the existing updater pin pending correct Windows cleanup ordering.
CI could observe the persisted verified receipt before the outer retry continuation scheduled recovery. Wait for the actual deadline callback with the existing budget and retain all exact assertions.
Native CLI subprocesses are non-interactive, so an explicit Stop action must supply the CLI's --force consent flag. Keep Start and Restart unchanged; restart --force would bypass graceful draining.

A real-subprocess regression fails before the fix and verifies Stop, Start, Restart and Stop afterward. All 136 Rust tests pass on macOS; native Linux before/after tray proof follows before landing.
@steipete
steipete force-pushed the codex/rust-deslop-land branch from 8b7b195 to ec2f771 Compare September 5, 2026 19:32
Anchor the legacy timed refresh before creating observed-URL followers, and
remove the redundant late caller from the timeout-survival test. A delayed
legacy call legitimately requested another rotation after the fixture reply.
Keep mixed deadlines, one request, matching URLs/TLS, and survivor assertions.

The exact CI failure is captured; nine focused tests and ten consecutive
stress iterations of both changed cases pass. Independent review is clean.
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Maintainer disposition of the latest dependency-inspection limitation: resolved by direct exact-revision source inspection and successful native builds. The notifications update remains one commit, one file, and two diagnostic conversions. Here is the complete upstream patch so review does not depend on another API/raw-source fetch:

@@ -118,8 +118,8 @@ Stderr: {}
 Stdout: {}
 ",
         swift_target_triple(),
-        String::from_utf8(output.stderr).expect("Stderr must be valid UTF-8"),
-        String::from_utf8(output.stdout).expect("Stdout must be valid UTF-8"),
+        String::from_utf8_lossy(&output.stderr),
+        String::from_utf8_lossy(&output.stdout),
     );
 
     let output = swift_build_command()

Exact upstream comparison. The complete build script and both source trees were inspected: runtime Swift/Rust sources, Cargo manifest/features, build commands, and target/deployment selection are unchanged. The changed revision passed desktop Rust builds/tests on macOS and Linux; current-head macOS release and test CI also pass. The remaining review limitation is the reviewer environment’s source retrieval, not an unresolved source or behavior defect. No code change or additional upstream fetch is required for this item.

The latest review’s assertion-preserving Swift test changes have also passed the full OpenClawKit/macOS CI stages, nine focused local tests, and ten repeated runs of both repaired cases. The fresh final-patch app changed gate passed all 1,109 app/host tests with pinned dependencies. Final CI is completing its Watch screenshot job.

@steipete
steipete merged commit 4d10104 into main Sep 5, 2026
142 of 143 checks passed
@steipete
steipete deleted the codex/rust-deslop-land branch September 5, 2026 20:49
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
)

Fix Tauri tray Stop by forwarding its explicit operator intent through the CLI's existing noninteractive consent flag. Stop remains graceful; Start and Restart keep their existing arguments and drain behavior. A real subprocess regression and native before/after comparison cover the failure and recovery.

Consolidate Rust connection completion, Gateway reset state, CLI result handling and native menu ownership; remove unused navigation/auth helpers. Refresh compatible desktop and Watch RTC dependencies and notices. Retain blocking 1.6.2 after reproducing an upstream idle-thread retirement regression, and retain the existing updater pin pending the Windows cleanup-order repair. Net production Rust: -156 lines. No new configuration, schema or protocol surface.

Wait for the actual pending-verification deadline callback in the macOS test while preserving its timeout budget and assertions. Remove a redundant late surface-refresh test caller and preserve observed URLs across asynchronous admission; mixed deadlines and one-rotation assertions remain. Validation includes 136 desktop Rust tests on macOS, 136 + 10 on Linux, explicit logind integration, 12 Watch media tests, all four Watch release slices, native Codex and cold Ollama onboarding, retry recovery, Quick Chat after restart, and real tray Stop/Start/Restart. The nine focused surface tests and ten repeated runs of the changed cases passed. Full PR CI and independent review passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: linux app: macos App: macos maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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.

1 participant