Skip to content

refactor(ui): simplify shared Solid listener lifetimes - #173689

Merged
steipete merged 2 commits into
mainfrom
solid2/w-idiom-core
Oct 16, 2026
Merged

steipete merged 2 commits into
mainfrom
solid2/w-idiom-core

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The Solid migration needs one documented controller replacement recipe and a guard against bringing the old lifecycle back after retirement. Shared event bindings also repeat native listener teardown.

User Impact

No user-visible change. Avatar loading/error behavior, native overlay events, routes, tags, selectors, and lazy loading remain unchanged.

Why This Change Was Made

Add a worked controller-to-Solid example to the existing playbook, expose the small lib/reactive/listener.ts teardown helper for explicit effect/settle lifetimes, and use it for overlay event forwarding. Avatar load/error listeners use the same explicit teardown, including retained detached images; the Gateway page effect no longer wraps its already-untracked apply phase in untrack.

The existing syntax-aware Lit inventory now counts lifecycle identifiers and controller classes. Growth remains advisory while production callers exist; once the production baseline has no controller patterns, the same guard rejects reintroductions. Comments, strings, and test fixtures do not hold enforcement open.

Remaining shared controller adapters still have production callers in the assistant panel, command palette, session widgets, and custodian setup. Their removal belongs with those callers' cutovers; this PR does not introduce another implementation or change domain ownership.

Evidence

Proof Result
pnpm tsgo:ui Passed
Listener + identity-avatar focused UI tests 4 passed
Agent-select stale image regression Reproduced the initial CI failure; passed after restoring explicit listener teardown
Lit ratchet focused tests 14 passed
Independent autoreview No actionable P0–P2 findings
Full exact-head PR CI (ci:full) Run 38846274132 passed on 2ccb519de145776465f97be31759287837812a4c
pnpm ui:build, merge base and head on the same Mac Passed both
Startup JS gzip 347,378 B → 347,366 B; raw bytes identical (1,056,383 B)
Startup CSS 1 request, 38,844 B gzip on both
Strict performance comparison Passed
Production Knip Passed
Targeted lint Passed with the repository's core, script, and root-test configs. Initial commands requested unnecessary plugin declarations and timed out; corrected commands did not rebuild them.

Touched production files: 372 → 371 LOC; controller-pattern references 0 → 0; createEffect calls 4 → 4; untrack calls 11 → 10; native addEventListener registrations 5 → 1. Counts include the new helper. Documentation/tooling/test additions are separate from production LOC.

The first CI run passed all nine UI E2E shards and both real-Gateway shards, but caught a detached-image event regression in keeps a failed avatar on its fallback until the image changes. The repaired head removes those listeners on owner disposal, and the existing regression passes locally. Full CI passed on the repaired head in run 38846274132.

This is lifecycle-only refactoring with unchanged rendered markup and styling, so no visual captures are needed. Full UI CI is selected because these shared primitives affect overlays and avatar consumers.

Document the controller-to-Solid recipe and extend the existing migration ratchet with syntax-aware controller patterns. Keep growth advisory until the production baseline is empty, then reject reintroductions. Share imperative event teardown, let avatar JSX own image events, and remove redundant effect untracking. No user-visible behavior change.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 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 16, 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-16T03:38:08.847017Z 2ccb519 New commits
ℹ️ 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.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: S labels Oct 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR documents controller replacement, extends the migration guard, and simplifies shared Solid event bindings.

Example: An agent avatar changes from a failed image to data:image/png;base64,cmVwbGFjZW1lbnQ=, then the retired image emits an error.

  • Before: Explicit listener cleanup prevents the retired image from affecting the replacement.
  • After: The retired JSX handler invokes the current error callback and removes the replacement image.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused validation supports the refactor, but exact-head CI exposes a concrete lifetime regression.
Proof confidence 🦐 gold shrimp (3/6) The supplied task classifies this as maintainer-authored, so the ordinary contributor proof gate does not apply; supplied validation consists of tests, builds, and performance checks.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Repeated lifecycle wiring makes the Solid migration harder to maintain while existing avatar and overlay behavior must remain intact.
Reason: The maintainer-authored direction consolidates existing responsibilities without adding configuration, public APIs, or persisted state.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the refactor has clear maintenance value, but removing avatar listener cleanup introduces a regression confirmed by exact-head CI.

Priority: P2
Reviewed head: 1fe7b046c43b66767617ff958e7fd30a912c9a11

Before merge

  • Preserve avatar handler retirement when replacing native listeners (P2) - After an avatar errors, its image component is disposed and a replacement URL can mount a new image. The JSX error listener remains attached to the retired node, and error() reads the live input().onImageError callback. A subsequent error from that node therefore marks the replacement route failed and removes its image. The existing agent-select.test.ts:98–129 exercises this sequence, and exact-head checks-ui (1/3) fails at line 127. Restore owner-scoped listener removal or equivalent retirement at this binding.

Findings

  • [P2] Preserve avatar handler retirement when replacing native listeners — ui/src/components/solid/identity-avatar-image.tsx:100-101

Tests

  • Low-value test ui/src/lib/reactive/listener.test.ts: Remove this helper-only test: its assertions primarily recheck native DOM capture ordering and removeEventListener behavior rather than an overlay consumer's lifetime contract.
Agent review details

How this fits together

Control UI components consume avatar-loader and overlay state, bind browser events, and release those bindings when their Solid owners retire.

flowchart TD
  A[Avatar loader] --> B[Solid avatar component]
  B --> C[Browser image events]
  C --> D[Avatar error callback]
  E[Overlay lifecycle] --> F[Listener teardown helper]
  F --> G[Solid lifetime cleanup]
Loading

Technical review

Best possible solution:

Preserve owner-scoped avatar event retirement while retaining the other focused lifecycle simplifications.

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

Exact-head CI fails the existing avatar replacement test, and source inspection explains why the retired error handler reaches the replacement callback; no target code was run during this review.

Is this the best way to solve the issue?

The shared teardown helper and untracking removal preserve their contracts, but JSX event binding must retain the avatar owner's explicit retirement behavior.

Full review comments:

  • [P2] Preserve avatar handler retirement when replacing native listeners — ui/src/components/solid/identity-avatar-image.tsx:100-101
    After an avatar errors, its image component is disposed and a replacement URL can mount a new image. The JSX error listener remains attached to the retired node, and error() reads the live input().onImageError callback. A subsequent error from that node therefore marks the replacement route failed and removes its image. The existing agent-select.test.ts:98–129 exercises this sequence, and exact-head checks-ui (1/3) fails at line 127. Restore owner-scoped listener removal or equivalent retirement at this binding.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Avatar event retirement changes intended behavior with a stated reason (57d4e77: The identity migration preserved image resource ownership and retired asynchronous behavior; this PR explains replacing native listeners with JSX, but that replacement loses event retirement.)
  • Gateway page effect keeps the original intent (8130510: The shared binding owns connection and request lifecycle; removing redundant untrack from the already-untracked apply phase preserves that ownership.)
  • Overlay event binding keeps the original intent (be0d13c: Menu and popover control share the existing overlay owner; the helper retains matching event registration and teardown.)
  • Tooltip completion forwarding keeps the original intent (305dfd2: Only non-composed completion events need forwarding across the tooltip boundary; event filtering and cancellation remain intact.)
  • Migration guard keeps the original intent (650828c: Migration growth remains advisory while existing implementations are needed; controller enforcement starts only after the production baseline is empty.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm --dir ui test src/components/agent-select.test.ts src/components/solid/identity-avatar.test.tsx src/components/identity-avatar-view.test.tsx
  • pnpm tsgo:ui
  • pnpm check:control-ui-lit-ratchet
  • git diff --check

What I checked:

PR surface

Source -4, Tests +46, Docs +53, Other +35. Total +130 across 11 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 23 27 -4
Tests 2 46 0 +46
Docs 2 53 0 +53
Config 0 0 0 0
Generated 0 0 0 0
Other 2 35 0 +35
Total 11 157 27 +130

Labels

Label changes:

  • add P2: The patch introduces a confirmed avatar replacement regression with limited UI impact.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The patch introduces a confirmed avatar replacement regression with limited UI impact.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 15, 2026, 11:26 PM ET / October 16, 2026, 03:26 UTC.

@steipete
steipete merged commit b62a8f8 into main Oct 16, 2026
123 checks passed
@steipete
steipete deleted the solid2/w-idiom-core branch October 16, 2026 04:50
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
* refactor(ui): simplify shared Solid listener lifetimes

Document the controller-to-Solid recipe and extend the existing migration ratchet with syntax-aware controller patterns. Keep growth advisory until the production baseline is empty, then reject reintroductions. Share imperative event teardown, let avatar JSX own image events, and remove redundant effect untracking. No user-visible behavior change.

* fix(ui): retire avatar listeners with their Solid owner
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. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant