Skip to content

refactor(ui): share reactive browser resource lifetimes - #176364

Merged
steipete merged 1 commit into
mainfrom
solid2/w-zero-primitives
Oct 18, 2026
Merged

steipete merged 1 commit into
mainfrom
solid2/w-zero-primitives

Conversation

@steipete

@steipete steipete commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Control UI components repeat browser observer, media, visibility, and timer lifetimes, making the Solid cleanup and equal-value refresh rules easy to get wrong during the ongoing refactor.

User Impact

No intended user-visible change. This is the first shared-primitives batch for the Solid refactor; tags, markup, styles, routes, and selectors stay the same.

Why This Change Was Made

Add small, separately imported owner-scoped primitives for resize/intersection observation, media queries, document visibility, intervals, and restartable timeouts. Initial adopters are the mascot, plugin install elapsed time, catalog skeleton measurement, Cron editor clearance, and About copy/wave feedback. The primitives own browser-resource cleanup; each caller retains its measurement, visibility, and product policy. Catalog measurement remains frame-coalesced, and Cron clearance still observes both the footer and scrollport.

Intervals are isolated through a memo so equal effective delays preserve the pending tick. No dependency or startup registration is added. The primitive-selection table documents the APIs.

Evidence

Check Result
pnpm tsgo:ui Pass
Three focused primitive test files, --maxWorkers=1 11 tests pass; initial three-file run 4.63 seconds, ref-order regression rerun 2.69 seconds
Targeted lint and format Pass
Production Knip Same two unused core files on head and exact merge base: src/auto-reply/reply/reply-admission-ticket.ts and reply-turn-admission-owner.ts; both commands exit 1
Same-machine merge-base/head UI production builds and strict performance comparison Pass: base 336,539 B → head 336,321 B startup JS gzip (−218 B); 1 CSS request / 38,500 B on both; same host, pnpm ui:build Node 24.22.0; build identity variables differ, so the delta is not claimed as a pure source-only improvement
Independent review P0–P2 clean after fixing an eager ref-read finding
Broad UI/browser/Gateway proof ci:full run 39159924107: all checks pass except the two real-Gateway shards; all four failing names match scheduled main run 39158806323

This changes resource management, with no visual markup/style change; no screenshot claim is made. Existing mascot assertions now await the committed reactive update after platform events. Full UI E2E and retention/performance suites stay in CI under the campaign's local compute budget.

Refactor measurements

Counts cover the eight changed production files, including the three new primitive modules, against 1446ecc39398c6e4f53cda9a260342cb914e8cb8.

Pattern Before After
Rendering controller patterns 0 0
createEffect 2 5
createRenderEffect 0 0
untrack 0 0
addEventListener 0 0
querySelector(All) 0 0
Production LOC 638 728

The three added effects live in observer/timer primitives and implement genuine external synchronization. The existing mascot adds one playback reaction while the installer deletes its local timer effect. Production grows by 90 lines to provide six shared browser-resource contracts; the five initial adopters shrink overall. Tests add independent lifecycle/cancellation coverage.

Inventory and next batch

Inventory across production ui/src: 33 resize observers in 32 files, 11 intersection observers, 31 media-query calls in 27 files, 19 intervals, 220 timeout calls, and 7 document-title assignments. These include plain TypeScript owners and are not all conversion candidates. Existing listen, visible polling, stream following, scroll-state observation, near-viewport observation, dock persistence, and the resizable divider already cover part of the requested inventory. Domain persistence remains in plain owners; no competing localStorage signal is introduced.

Follow-up in this lane: remove redundant tracking suppression from reactive adapters, preserve deliberate initial snapshots, and cover the remaining matching resource patterns without copying transcript geometry, overlay focus policy, or domain storage into a second owner.

Review found that observer target memos ran before refs were assigned. The primitive now gates target reads until onSettled; a real mountSolid ref-order regression failed on the first draft and passes with the correction.

Remaining effect categories in the touched production files: observer-resource binding (ui/src/lib/reactive/observers.ts:24,41), interval-resource binding (ui/src/lib/reactive/timers.ts:5), and imperative canvas playback/render synchronization (ui/src/components/openclaw-mascot.tsx:95,107). No feature render effects, tracking suppression, DOM queries, or direct DOM listener registrations were introduced.

Inherited CI failures

The exact names below fail both on this PR and the latest completed scheduled main run, not merely in the same shards. Native inherited-failure admission is requested with the captured checkout and test evidence; failed CI is not represented as green.

Test PR / scheduled main
Managed image ordering through real chat.send and history > keeps headings, managed images and trailing prose ordered live and after reload without duplicates Fails / fails
Speech supplements through real chat.send and cursor history > attaches delayed speech to each original answer live and after reload Fails / fails
Control UI media transcript replay with a real Gateway > delivers PowerPoint and keeps persisted attachment failures replay-safe Fails / fails
Chat Stop after a real Gateway finished the run > restores the composer after Stop targets a run the Gateway already finished Fails / fails

The PR run tested merge a30c73ed9074c18d44ee107e53f670c7c1c82e5f, with ordered parents a8307013add13130826a2ceb5b7c14a923a02aa4 and 9057da791b8ea21f4b94ef826d0c4c015bd91f5a. The failed test sources are unchanged between that baseline and tested merge.

Centralize resize and intersection observation, media and document visibility, and owned timers. Preserve initial adopter policies and defer observer target reads until refs settle.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T19:44:43.119922Z 9057da7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete enabled auto-merge (squash) October 18, 2026 19:54
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR centralizes browser observer, media, visibility, and timer cleanup for five Control UI consumers.

Example: The About page displays copy feedback for 1800 milliseconds.

  • Before: The page schedules and cancels its own reset timeout.
  • After: An owner-scoped timeout provides the same feedback duration and cancellation on removal.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent with no actionable findings; changed-path evidence is primarily unit-level, and matching main failures explain the red browser checks.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply to this maintainer-authored refactor; supplied validation covers primitive lifecycle tests, typechecking, lint, and paired builds.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Repeated browser-resource setup makes consistent cleanup and refresh behavior harder to maintain.
Reason: The maintainer-authored direction consolidates genuine repeated lifetimes while preserving existing product policy and avoiding new public configuration or storage.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored refactor open. The shared lifecycle helpers preserve caller policy, and no actionable correctness or security defect was found; the failing browser checks have matching failures on main.

Priority: P3
Reviewed head: 9057da791b8ea21f4b94ef826d0c4c015bd91f5a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied focused tests do not demonstrate every migrated consumer through a shipped browser entry point; this maintainer-authored PR is outside the ordinary contributor proof gate.
Agent review details

How this fits together

Control UI components pass element references, browser events, and timer delays into reactive helpers, which deliver callbacks and release browser resources when their Solid owner ends.

flowchart TD
  A[Control UI components] --> B[Reactive resource helpers]
  B --> C[Browser observers and listeners]
  B --> D[Browser timers]
  C --> E[Caller presentation policy]
  D --> E
  F[Solid owner disposal] --> B
Loading

Technical review

Best possible solution:

Retain the narrow resource helpers and caller-owned policies, with inherited CI handled through the existing landing workflow.

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

This PR reports repeated lifecycle machinery rather than a specific user-visible bug; source inspection confirms that repetition, and no reproduction was run.

Is this the best way to solve the issue?

The smallest coherent approach is the proposed owner-scoped helpers with local setup removed from each adopter; existing polling policy and domain owners remain separate.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Mascot playback and cleanup keeps the original intent (59bb148: Keep canvas ownership explicit and pair listener cleanup while preserving animation, branding, visibility, and reduced-motion behavior.)
  • Plugin installation elapsed time and catalog measurement keeps the original intent (442d0dc: Simplify reactive lifecycles while retaining timer and DOM synchronization.)
  • Cron editor clearance keeps the original intent (0d43ba6: Keep keyboard-focused controls clear of sticky actions and restore scroll padding on teardown.)
  • About feedback timers keeps the original intent (b8a69f6: Simplify cancellation while preserving timer reset order and lifecycle behavior.)
  • Solid primitive-selection guidance keeps the original intent (b19d554: Document Solid 2 ownership and primitive choices to prevent migration mistakes.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +90, Tests +244, Docs +6. Total +340 across 13 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 8 172 82 +90
Tests 4 248 4 +244
Docs 1 18 12 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 438 98 +340

Review metrics

Metric Value Why it matters
Production versus test growth Production +90 net lines; tests +244 net lines Production growth supplies six resource contracts with initial consumers; added tests cover ref ordering, target replacement, unavailable APIs, cadence preservation, cancellation, and disposal.

Labels

Label changes:

  • add P3: This is a behavior-preserving internal UI refactor with no established urgent user-facing defect.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is a behavior-preserving internal UI refactor with no established urgent user-facing defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 18, 2026, 4:01 PM ET / 20:01 UTC.

@steipete
steipete disabled auto-merge October 18, 2026 20:04
@steipete
steipete merged commit 642333b into main Oct 18, 2026
115 of 120 checks passed
@steipete
steipete deleted the solid2/w-zero-primitives branch October 18, 2026 20:12
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

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 ci:full Keep ordinary native-locale CI selection on the next PR run. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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