Repository navigation
feat(macos): native-feel dashboard hosting — instant reopen, preload, frame autosave, ⌘N/⌘K, route memory - #106997
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 14, 2026, 6:26 AM ET / 10:26 UTC. Summary PR surface: Source +186, Tests +90, Other +618. Total +894 across 34 files. Reproducibility: not applicable. as a bug reproduction: this PR adds new macOS hosting behavior. The two review defects are source-reproducible on the unchanged current head through the queue timing and incomplete persisted-route shape. Review metrics: 2 noteworthy metrics.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Rebase onto current main, preserve its current Control UI ownership boundaries, deliver native commands through a shell-ready acknowledgement path, persist the complete safe committed route including hash, and demonstrate the result in a redacted signed-app recording. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: this PR adds new macOS hosting behavior. The two review defects are source-reproducible on the unchanged current head through the queue timing and incomplete persisted-route shape. Is this the best way to solve the issue? No, not yet. The native-shell/web-owner split is the right direction, but the current implementation must use a shell acknowledgement for commands, preserve the full safe committed route, and be rebased onto the reorganized current-main host. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b9d0473b2e98. Label changesLabel justifications:
Evidence reviewedPR surface: Source +186, Tests +90, Other +618. Total +894 across 34 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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
Review history (13 earlier review cycles; latest 8 shown)
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b277e0f9a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.controller = controller | ||
| controller.loadInBackground(url: url, auth: auth) |
There was a problem hiding this comment.
Adopt the endpoint revision when preloading
When a hidden preload succeeds, this stores a controller without starting endpoint observation or recording the current route revision. On the first later open or ⌘N/⌘K command, showConfiguredWindowIfPossible() starts observeEndpointChanges(), whose subscription immediately yields the current ready state; because displayedRouteRevision is still nil, handleEndpointState() treats any nonzero routeRevision as a route change and replaces the just-shown preloaded controller. That throws away the preloaded page, and can also wipe out the native command that was just dispatched into it, so first open after preload reloads/resets instead of being instant.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5043628a13
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| function shouldRestore(routeId: RouteId, search: string, nativeHost: boolean): boolean { | ||
| return nativeHost && routeId === "chat" && search === ""; |
There was a problem hiding this comment.
Allow route restore after default session injection
When the native dashboard opens at the bare root/base path, normalizeInitialApplicationLocation() injects the stored/default ?session=main before OpenClawShell.updateRouteState() calls considerRouteRestore(). Because this guard only treats an empty search as the default boot route, the common native launch path skips the stored route and then persists chat?session=main, clobbering the route memory the feature is meant to restore. This still lets explicit deep links win, but the injected default session query needs to be distinguished from a user-supplied query.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49b297f332
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.hasLiveContent = false | ||
| self.isShowingFailurePage = true |
There was a problem hiding this comment.
Clear stale native commands on load failure
When a native command is queued while the dashboard is still loading (dispatchNativeCommand appends while hasLiveContent is false), a non-cancelled load failure reaches this failure-page path but leaves pendingNativeCommands intact. The failure page skips the didFinish flush, so the next successful reload/reconnect later executes the old ⌘N/⌘K command unexpectedly; clear the pending queue when switching to a terminal load-failure page.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0fdfb4b1e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard self.hasLiveContent else { | ||
| // Ordered queue, duplicates included: two ⌘K presses while loading | ||
| // must toggle twice, and ⌘N followed by ⌘K must deliver both. | ||
| self.pendingNativeCommands.append(command) | ||
| return |
There was a problem hiding this comment.
Clear queued commands when loading is cancelled
When a native command is queued while the dashboard is still loading, closing the window before didFinish cancels the navigation via windowWillClose/stopLoading(), and the NSURLErrorCancelled branch in showLoadFailure returns without clearing this array. Because the controller is retained after close, the next successful reopen flushes that stale ⌘N/⌘K into a fresh page, so the queue also needs to be cleared when a load is terminally cancelled by close.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5ed5aeba0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| guard self.hasLiveContent else { | ||
| // Ordered queue, duplicates included: two ⌘K presses while loading | ||
| // must toggle twice, and ⌘N followed by ⌘K must deliver both. | ||
| self.pendingNativeCommands.append(command) |
There was a problem hiding this comment.
Clear queued native commands when closing the dashboard
When a native command is queued while the dashboard is still loading, closing the dashboard before navigation finishes leaves this queued command in memory: windowWillClose only stops the load, and the resulting cancellation is ignored by showLoadFailure. Reopening the retained controller later reloads the page and didFinish flushes the stale queue, so an old ⌘N/⌘K can unexpectedly create a session or toggle the palette after the user has already dismissed the window.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f057ef7c02
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| self.hasLiveContent = true | ||
| self.publishNativeHistoryState() | ||
| // History state must reach the shell before a queued command can navigate it. | ||
| self.flushPendingNativeCommands() |
There was a problem hiding this comment.
Wait for the shell before flushing native commands
When the first native open uses stored credentials, the UI can still be on the connecting splash when WK didFinish fires: ui/src/app/gateway-store.ts sets a non-null client before connected, and OpenClawApp.render() keeps returning the splash until hello. Flushing queued ⌘N/⌘K here dispatches window events before <openclaw-app-shell> has mounted its listeners, so commands pressed during the initial load are dropped instead of running after the shell appears; keep them queued until the shell listener exists or acknowledges receipt.
Useful? React with 👍 / 👎.
| export type StoredNativeRoute = { | ||
| routeId: RouteId; | ||
| search: string; | ||
| }; |
There was a problem hiding this comment.
Persist route hashes in native route memory
Routes can carry meaningful hash state: the settings route includes location.hash in its loader dependencies, and the settings sidebar navigates to specific blocks with hash. Storing only routeId and search means native route memory restores a settings block/search-result route as the bare settings page, losing the selected section after reload or relaunch; persist and replay the hash alongside search so the committed route is restored exactly.
Useful? React with 👍 / 👎.
…gate Replace the failure-page-only fast-path check with canDeliverNativeCommands (live document or in-flight load); a terminally cancelled reload now falls through to the reload path instead of queueing ⌘N/⌘K forever.
The one-shot startup restore now checks the rendered/pending match against the committed bootstrap route; an explicit navigation already in flight (replayed native new-session, fast click) is no longer clobbered.
Queued ⌘N/⌘K are moment-bound; surviving a failure page meant a later recovery reload replayed stale commands (double palette toggle nets closed, surprise navigation). Both failure entry points now clear the queue.
Mid-navigation emissions still carry the stale committed bootstrap route; an interrupted restore could overwrite the remembered destination with it.
One in-flight open drains a manager-level queue in press order; a Task per key press could race window creation (duplicate windows) and reorder ⌘N/⌘K delivery on the non-immediate remote path.
setFrameAutosaveName re-applies the stored frame; run ensureOnScreen after both autosave-name assignments so a frame saved on a disconnected monitor cannot restore the window off-screen.
…l document Swipe-back/⌘[ off the failure page commits an http(s) document without passing through load(); the flag previously stayed set and forced a reload on the next native command.
An open/update during the launch preload previously cancelled and restarted the same-URL load; in-flight non-failure documents now count as usable in the reload decision.
Command palette dispatch now sends a cancelable toggle event and falls back to the shipped open-search event when no handler acknowledges it, so ⌘K keeps working against older gateway-served bundles. Route memory strips one-shot action params (?draft=) before persisting; navigation state like ?session= still restores.
…ry export native:i18n:sync inventory + per-locale artifacts for New Session / Command Palette…; StoredNativeRoute is module-internal after the considerRouteRestore refactor (deadcode exports gate).
The lazy-custom-element extraction moved three internal load-failure labels out of app-host.ts; refresh the keyless raw-copy baseline to match (main's new ui:i18n:verify gate).
bf2b88f to
3faeaf6
Compare
|
Merged via squash.
|
… frame autosave, ⌘N/⌘K, route memory (openclaw#106997) * feat(macos): native-feel dashboard hosting: instant reopen, preload, frame autosave, ⌘N/⌘K, route memory The hosted Control UI dashboard now skips SPA reloads when reopening an unchanged endpoint (auth-equality gated), preloads after launch when a credentialed local/direct config exists, autosaves its window frame, maps ⌘N/⌘K menu items onto the shipped native web events, filters browser-tell context-menu items, restores the last committed route via web-side localStorage memory, and themes the pre-paint background. * refactor(ui): satisfy TS LOC ratchet: move optional lazy-element helpers out of app-host app-host.ts is over the 500-line ratchet ceiling and may not grow; move the self-contained optional custom-element block into lazy-custom-element.ts (its natural owner) and fold the route-restore decision into native-route-memory's considerRouteRestore so the shell only replaces-or-persists. * fix(macos): recover stuck dashboard command queue via deliverability gate Replace the failure-page-only fast-path check with canDeliverNativeCommands (live document or in-flight load); a terminally cancelled reload now falls through to the reload path instead of queueing ⌘N/⌘K forever. * fix(ui): let in-flight navigation win over native route restore The one-shot startup restore now checks the rendered/pending match against the committed bootstrap route; an explicit navigation already in flight (replayed native new-session, fast click) is no longer clobbered. * docs(ui): note idempotent collapse of pending native new-session replays * fix(macos): drop queued dashboard commands on terminal load failure Queued ⌘N/⌘K are moment-bound; surviving a failure page meant a later recovery reload replayed stale commands (double palette toggle nets closed, surprise navigation). Both failure entry points now clear the queue. * fix(ui): persist native route memory only for settled router states Mid-navigation emissions still carry the stale committed bootstrap route; an interrupted restore could overwrite the remembered destination with it. * fix(macos): coalesce dashboard opens for queued native commands One in-flight open drains a manager-level queue in press order; a Task per key press could race window creation (duplicate windows) and reorder ⌘N/⌘K delivery on the non-immediate remote path. * fix(macos): correct dashboard placement after frame-autosave restore setFrameAutosaveName re-applies the stored frame; run ensureOnScreen after both autosave-name assignments so a frame saved on a disconnected monitor cannot restore the window off-screen. * fix(macos): clear dashboard failure state when history restores a real document Swipe-back/⌘[ off the failure page commits an http(s) document without passing through load(); the flag previously stayed set and forced a reload on the next native command. * fix(macos): keep in-flight dashboard loads instead of restarting them An open/update during the launch preload previously cancelled and restarted the same-URL load; in-flight non-failure documents now count as usable in the reload decision. * fix(macos,ui): ⌘K legacy fallback + transient search param filtering Command palette dispatch now sends a cancelable toggle event and falls back to the shipped open-search event when no handler acknowledges it, so ⌘K keeps working against older gateway-served bundles. Route memory strips one-shot action params (?draft=) before persisting; navigation state like ?session= still restores. * chore(i18n): register dashboard menu strings + drop unused route-memory export native:i18n:sync inventory + per-locale artifacts for New Session / Command Palette…; StoredNativeRoute is module-internal after the considerRouteRestore refactor (deadcode exports gate). * chore(i18n): rebaseline raw-copy for relocated lazy-element labels The lazy-custom-element extraction moved three internal load-failure labels out of app-host.ts; refresh the keyless raw-copy baseline to match (main's new ui:i18n:verify gate).
… frame autosave, ⌘N/⌘K, route memory (openclaw#106997) * feat(macos): native-feel dashboard hosting: instant reopen, preload, frame autosave, ⌘N/⌘K, route memory The hosted Control UI dashboard now skips SPA reloads when reopening an unchanged endpoint (auth-equality gated), preloads after launch when a credentialed local/direct config exists, autosaves its window frame, maps ⌘N/⌘K menu items onto the shipped native web events, filters browser-tell context-menu items, restores the last committed route via web-side localStorage memory, and themes the pre-paint background. * refactor(ui): satisfy TS LOC ratchet: move optional lazy-element helpers out of app-host app-host.ts is over the 500-line ratchet ceiling and may not grow; move the self-contained optional custom-element block into lazy-custom-element.ts (its natural owner) and fold the route-restore decision into native-route-memory's considerRouteRestore so the shell only replaces-or-persists. * fix(macos): recover stuck dashboard command queue via deliverability gate Replace the failure-page-only fast-path check with canDeliverNativeCommands (live document or in-flight load); a terminally cancelled reload now falls through to the reload path instead of queueing ⌘N/⌘K forever. * fix(ui): let in-flight navigation win over native route restore The one-shot startup restore now checks the rendered/pending match against the committed bootstrap route; an explicit navigation already in flight (replayed native new-session, fast click) is no longer clobbered. * docs(ui): note idempotent collapse of pending native new-session replays * fix(macos): drop queued dashboard commands on terminal load failure Queued ⌘N/⌘K are moment-bound; surviving a failure page meant a later recovery reload replayed stale commands (double palette toggle nets closed, surprise navigation). Both failure entry points now clear the queue. * fix(ui): persist native route memory only for settled router states Mid-navigation emissions still carry the stale committed bootstrap route; an interrupted restore could overwrite the remembered destination with it. * fix(macos): coalesce dashboard opens for queued native commands One in-flight open drains a manager-level queue in press order; a Task per key press could race window creation (duplicate windows) and reorder ⌘N/⌘K delivery on the non-immediate remote path. * fix(macos): correct dashboard placement after frame-autosave restore setFrameAutosaveName re-applies the stored frame; run ensureOnScreen after both autosave-name assignments so a frame saved on a disconnected monitor cannot restore the window off-screen. * fix(macos): clear dashboard failure state when history restores a real document Swipe-back/⌘[ off the failure page commits an http(s) document without passing through load(); the flag previously stayed set and forced a reload on the next native command. * fix(macos): keep in-flight dashboard loads instead of restarting them An open/update during the launch preload previously cancelled and restarted the same-URL load; in-flight non-failure documents now count as usable in the reload decision. * fix(macos,ui): ⌘K legacy fallback + transient search param filtering Command palette dispatch now sends a cancelable toggle event and falls back to the shipped open-search event when no handler acknowledges it, so ⌘K keeps working against older gateway-served bundles. Route memory strips one-shot action params (?draft=) before persisting; navigation state like ?session= still restores. * chore(i18n): register dashboard menu strings + drop unused route-memory export native:i18n:sync inventory + per-locale artifacts for New Session / Command Palette…; StoredNativeRoute is module-internal after the considerRouteRestore refactor (deadcode exports gate). * chore(i18n): rebaseline raw-copy for relocated lazy-element labels The lazy-custom-element extraction moved three internal load-failure labels out of app-host.ts; refresh the keyless raw-copy baseline to match (main's new ui:i18n:verify gate).
What Problem This Solves
The macOS app hosts the web Control UI in a WKWebView dashboard window, but the hosting still leaks "this is a website" tells and wastes work on every open:
DashboardWindowController.updatealways calledload), so the dashboard felt slow even when nothing changed.replaceController) re-centered it, and relaunches lost position entirely.Why This Change Was Made
Part of the macOS hybrid-shell direction: the web Control UI owns product surfaces, the native app owns platform capability and must make the hosted UI feel native. This deepens the existing native web-chrome handshake instead of duplicating product UI in SwiftUI.
Design notes:
openclaw:native-new-session/openclaw:native-open-searchsince the pre-web-chrome app builds (app-host.ts). The new ⌘N/⌘K menu items dispatch those same events rather than introducing a parallel command channel — one canonical path, richer existing behavior (agent preselection, onboarding guard) for free.ui/src/app/native-route-memory.tspersists the last committed route (localStorage, gated onisNativeWebChromeHost()) and restores it only when boot lands on the default chat route with no explicit search — deep links (?approval=…,?session=…) always win. Keeping this out of Swift avoids polluting the native URL/trust model (token stays in the fragment; auth paths untouched).hasLiveContent); any endpoint, base-path, or token change still reloads with fresh auth injection. Failure pages (loadHTMLStringalso firesdidFinish) are excluded viaisShowingFailurePage.User Impact
Evidence
apps/macos:swift buildclean;swift test --filter DashboardWindowSmokeTests→ 34/34 pass, including new coverage for context-menu filtering, reload-decision, command queueing before page load, frame-autosave name, and failure-page gating.ui:node scripts/run-vitest.mjs ui/src/app/native-route-memory.test.ts ui/src/app/app-host.test.ts ui/src/app/native-web-chrome.test.ts→ pass (route persist/restore incl. corrupt entries and non-native no-op; native titlebar events).config/swiftformat,config/swiftlint.yml); oxfmt applied.gpt-5.6-sol, xhigh): 16 rounds until clean. Accepted and fixed: auth-equality in the reload decision (password-only rotation); ordered native-command queue with press-order preservation; dedicated cancelableopenclaw:native-toggle-searchevent with automatic fallback to the shipped open-onlynative-open-searchon older gateway bundles;hasLiveContentreset atdidCommitwith cancelled-provisional survival; failure-state clearing when history restores a real document (swipe-back off the failure page); moment-bound command queues dropped on terminal failure (no stale ⌘K replay); manager-level coalesced open (prevents duplicate windows and reordered ⌘N/⌘K on the async remote path); in-flight loads counted as usable so opening mid-preload doesn't restart the load;ensureOnScreenafter frame-autosave restore (disconnected-monitor case); storage-getter guard; context-gated restore/persist with historyreplace, settled-state persistence, and in-flight-navigation priority; transient?draft=stripped from route memory; web-side retention of ⌘N until the shell context exists.showLoadFailurenever orders the window front; preload skips the endpoint observer). Accepted limitations (commented in source): per-originlocalStorageroute memory degrades to the default route on remote-tunnel port swaps; repeated pre-context ⌘N presses collapse (destination is idempotent).c8895c42772:autoreview clean: no accepted/actionable findings reported.pnpm check:changed(delegated Blacksmith Testbox): green — https://github.com/openclaw/openclaw/actions/runs/29301412986 (also caught the TS LOC ratchet, which drove thelazy-custom-elementextraction).