Skip to content

fix(ui): avoid native notification downloads in browsers - #138541

Merged
steipete merged 3 commits into
mainfrom
codex/native-notification-lazy
Sep 4, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/native-notification-lazy

Conversation

@steipete

@steipete steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Browser startup loaded the native desktop notification bridge even though that capability only exists in a WebKit host. The unchanged startup-size guard was already failing on the translation PR's base; the generated native translations do not enter the Control UI bundle.

Why This Change Was Made

Load the notification capability only when the native host exposes its message handler. The existing startup lifecycle awaits initialization before Gateway/routing, fences an aborted import, and owns disposal. Native permission requests remain synchronous in the Send gesture, and notification messages and policy stay unchanged.

This follows the adjacent native-device-settings startup path. The 18-line production increase provides the conditional import, readiness, and cleanup boundary without adding a loader framework, option, dependency, or budget change. The test and test-support delta is +162 lines; the generated manifest delta is one removed line.

User Impact

Browsers download less startup JavaScript. Native notification permission and background-completion behavior retain their existing owner and interface.

Evidence

  • The two bootstrap regressions fail on the previous implementation; all 85 focused bootstrap, notification, auto-prompt, and background-send tests pass after the fix.
  • Independent P2 review of the runtime patch and the follow-up test scheduling/type corrections found no actionable issues. Focused lint and changed-file guards pass apart from the local dependency type limitation below.
  • The pre-refresh clean Blacksmith Testbox comparison using Node 24.20.0, Vite 8.2.2, and Pako 3.0.1 passes the unchanged guard: 350,034 B startup gzip against 350,141 B; CSS remains 43,900 B. All 806 precompressed sidecars validate.
  • Clean UI types and both source-mode Chromium cases pass. The production bundle also passes browser/native-host proof: browsers request no native notification chunk; a native host requests its emitted chunk and posts permission synchronously on the first Send click. Both mocked chat exchanges complete with zero page errors.
  • The first CI run caught a missing registration for the new source-server E2E. Its unchanged serial-owner guard reproduces the failure before the one-line registration; both scheduling and worker-limit cases pass afterward. No application code or measured bundle changed.
  • The core E2E typecheck also caught the test fixture using a separately named Window type. Extending typeof window resolves the reproduced diagnostic; only the erased annotation and formatting changed, with the same message and gesture assertions.
  • Regenerated the boot manifest through the existing /new and /chat capture tool. Current main already contains the neighboring graph maintenance; this diff removes the native parser from shared browser chunks.

The owned Testbox needed the existing browser setup helper to provision recording and pinned Chromium artifacts. Final commands passed; the lease was stopped after collecting evidence. The screenshots show the synthetic browser before Send and the native-host exchange after completion.

Local full type checks could not use the borrowed worktree dependencies: fs-safe 0.5.6 differs from the pinned 0.7.2, and installed grammY types and Mermaid/Pako declarations lag the checkout. Exact-head hosted CI remains the landing gate.

The final CI run inherited the older settings-layout cold-boot test and recorded idle script failures during document replacement. Refreshed onto main to inherit the existing repair in #138482, which keeps each observed document alive and retains all genuine network/error assertions. The old log contains URLs only, so the precise transport error was not recovered. All five candidate files are byte-identical across this required refresh; the new exact-head CI remains the landing gate.

The wider notification-delivery feature in #133164 overlaps this startup owner and should retain this host-conditional loading boundary when refreshed. This PR changes no delivery policy or protocol.

Synthetic browser before Send

Synthetic native-host exchange after completion

@clawsweeper

clawsweeper Bot commented Sep 4, 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: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Sep 4, 2026
@steipete steipete self-assigned this Sep 4, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 4, 2026
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR defers the native notification bridge until a WebKit host exposes its notification handler, updates the generated boot-module manifest, and adds browser/native-host bootstrap coverage.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. Current main still eagerly imports and constructs the native notification bridge for browser startup; this branch fixes that boundary. No P0–P2 functional or security defect was found, but the new lazy import needs the repository-required runtime-module boundary and exact-head CI is still incomplete.

Priority: P3
Reviewed head: b5e576aaa9fb570618cf6068829f99ba6678b2fd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and behaviorally well-covered, with one small repository-convention correction before it is ready.
Proof confidence 🌊 off-meta tidepool Not applicable: This PR is authored by a repository MEMBER, so the external-contributor proof gate does not apply; its supplied evidence nevertheless maps browser/native-host behavior to the changed bootstrap path.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This PR is authored by a repository MEMBER, so the external-contributor proof gate does not apply; its supplied evidence nevertheless maps browser/native-host behavior to the changed bootstrap path.
Evidence reviewed 6 items Current-main behavior: Fetched main statically imports and unconditionally constructs the notification capability; its internal no-handler return occurs only after the module has loaded.
Boot-chunk owner: The current generated shared boot manifest includes the native notification module, and chunking uses this manifest for eagerly grouped boot modules.
Introduced repair: The introduced production hunk replaces eager construction with a handler-gated awaited import before the Gateway and router startup steps; blame attributes the added lines to the substantive PR commit.
Findings 1 actionable finding [P3] Move the lazy notification bridge behind a runtime module
Security None None.

How this fits together

The Control UI boot sequence prepares host-specific capabilities before routing and Gateway startup. Native notification state is then consumed by the chat-send and Settings flows, while ordinary browsers use Web Push instead.

flowchart LR
  A[Browser or WebKit host] --> B[Control UI bootstrap]
  B --> C{Notification handler present?}
  C -->|Yes| D[Load native notification bridge]
  C -->|No| E[Skip native bridge]
  D --> F[Gateway and routing startup]
  E --> F
  F --> G[Chat send and Settings]
Loading

Before merge

  • Move the lazy notification bridge behind a runtime module (P3) - The new lazy import targets native-notifications.ts, but the repository requires a *.runtime.ts boundary for newly lazy production code. Split or rename the implementation before merge so the chunk boundary is explicit and remains guarded; this is not a demonstrated runtime regression.
  • Resolve merge risk (P1) - Exact-head CI is still running, so the final integrated build and test state has not yet been established.
  • Complete next step (P2) - Move the lazy notification implementation to a *.runtime.ts boundary and let the remaining exact-head CI checks complete before merge.

Findings

  • [P3] Move the lazy notification bridge behind a runtime module — ui/src/app/bootstrap.ts:555
Agent review details

Security

None.

PR surface

Source +17, Tests +162. Total +179 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 24 7 +17
Tests 3 162 0 +162
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 186 7 +179

Review metrics

Metric Value Why it matters
Production versus test delta production +24/-6 (net +18); tests/support +162/-0; generated manifest -0/+1 The production growth is limited to host-gated initialization and lifecycle ownership; most of the diff is targeted regression coverage.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Move the lazily loaded notification implementation behind a *.runtime.ts boundary while preserving its typed capability contract, then land after focused coverage and exact-head CI are green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Move the lazily loaded notification implementation behind a *.runtime.ts boundary while preserving its typed capability contract, then land after focused coverage and exact-head CI are green.

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

Yes, from source: current main statically imports and constructs the native bridge during all Control UI bootstraps, and the generated shared boot manifest includes it. The supplied source E2E also defines the browser-versus-native-host scenario, though it was not executed in this read-only review.

Is this the best way to solve the issue?

Yes, with one correction: bootstrap is the correct owner because a handler check inside the capability would still download and evaluate it. The lazy implementation should use the required *.runtime.ts boundary rather than importing native-notifications.ts directly.

Full review comments:

  • [P3] Move the lazy notification bridge behind a runtime module — ui/src/app/bootstrap.ts:555
    The new lazy import targets native-notifications.ts, but the repository requires a *.runtime.ts boundary for newly lazy production code. Split or rename the implementation before merge so the chunk boundary is explicit and remains guarded; this is not a demonstrated runtime regression.
    Confidence: 0.97

Overall correctness: patch is correct
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded browser-startup optimization with no demonstrated loss of notification behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This PR is authored by a repository MEMBER, so the external-contributor proof gate does not apply; its supplied evidence nevertheless maps browser/native-host behavior to the changed bootstrap path.

Evidence

What I checked:

  • Current-main behavior: Fetched main statically imports and unconditionally constructs the notification capability; its internal no-handler return occurs only after the module has loaded. (ui/src/app/bootstrap.ts:56, f14b1027271c)
  • Boot-chunk owner: The current generated shared boot manifest includes the native notification module, and chunking uses this manifest for eagerly grouped boot modules. (ui/config/control-ui-boot-modules.json:1027, f14b1027271c)
  • Introduced repair: The introduced production hunk replaces eager construction with a handler-gated awaited import before the Gateway and router startup steps; blame attributes the added lines to the substantive PR commit. (ui/src/app/bootstrap.ts:555, 01d497ab18cc)
  • Lifecycle and native-owner contract: The notification capability installs its host listeners and initial status request only after creation, while the shared startup lifecycle fences an aborted step and disposes registered capabilities in reverse order. (ui/src/app/native-notifications.ts:91, b5e576aaa9fb)
  • Boundary coverage: The new source-mode E2E checks that browsers request no notification module while a synthetic native host requests one and preserves the first-send user-activation message; bootstrap coverage also checks startup ordering and stop fencing. (ui/src/e2e/native-notifications-loading.e2e.test.ts:28, b5e576aaa9fb)
  • Verified test-merge ownership: The GitHub test merge has the fetched main as first parent and this exact PR head as second parent; its resulting file set is limited to the five supplied introduced paths. (ui/src/app/bootstrap.ts:555, 3a48149c42ec)

Likely related people:

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

Rank-up moves

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

  • Move the lazy notification implementation to a *.runtime.ts boundary and rerun the focused bootstrap and source E2E coverage.
  • Let the remaining exact-head CI checks complete before landing.

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 (2 earlier review cycles)
  • reviewed 2026-09-04T19:55:11.212Z sha ad93acb :: blocked before merge. :: none
  • reviewed 2026-09-04T20:03:22.365Z sha ad93acb :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/native-notification-lazy branch from 975cb61 to b5e576a Compare September 4, 2026 20:49
@steipete

steipete commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

The exact reviewed head b5e576aaa9fb570618cf6068829f99ba6678b2fd has green CI, completed at 21:01:11 UTC. This satisfies the remaining CI item and rank-up move.

For the P3 naming recommendation, retain the existing native-notifications.ts owner for this bounded repair. The implementation has one conditional production dynamic import; all other production imports from that module are type-only. It follows the adjacent native-device-settings startup owner. The actual built bundle proof verifies that ordinary browsers do not request the native owner chunk, while a native host loads it once before Gateway startup and preserves synchronous permission requests in the first activated Send click. The filename-only .runtime.ts move is intentionally skipped as a scoped naming-convention exception; no facade or alternate loading path is added. The required runtime separation is established by the import graph and tested emitted chunk, with the unchanged size guard passing.

The full refreshed five-file independent P2 review is clean, all 85 focused owner/caller tests pass, and all five candidate files are byte-identical across the required refresh to inherit the already-landed settings-test repair in #138482. Production delta remains +18 lines for conditional initialization and lifecycle ownership. No translation data, notification policy, budget, assertion, or timeout was weakened.

Proceeding through native prepare and merge; this records the maintainer decision and review follow-through, not a completed merge.

@steipete
steipete merged commit d2c51a3 into main Sep 4, 2026
129 of 131 checks passed
@steipete
steipete deleted the codex/native-notification-lazy branch September 4, 2026 21:17
@steipete

steipete commented Sep 4, 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 5, 2026
…8541)

* perf(ui): defer native notification bridge loading

* test(ui): serialize native notification source proof

* test(ui): type injected proof on browser window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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