Skip to content

refactor(ui): lazy-load chat panels and widgets - #181229

Merged
steipete merged 5 commits into
mainfrom
solid2/w-zero-loaders-followup
Oct 23, 2026
Merged

steipete merged 5 commits into
mainfrom
solid2/w-zero-loaders-followup

Conversation

@steipete

@steipete steipete commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Optional chat panels and widgets still carry manual component-loading and registration state that duplicates Solid’s lazy boundaries.

User Impact

This refactor preserves panel tags, cold activation, retained previews, and local loading/error actions. Queued panel commands reach the current mounted recipient.

Why This Change Was Made

Chat sidebar panels and transcript widgets now use Solid's lazy component boundary instead of a global custom-element registration/loading registry. Saved Files and Dashboard panels stay cold until first shown, then retain their controls while hidden. Terminal, browser, desktop, portal, companion, processes, subagents, discussion, file/detail previews, Canvas, and MCP content keep their existing tags and lazy import points.

Queued panel commands wait for the actual mounted recipient and recheck the owning session before delivery. Canvas parking and one-second retention remain in their existing owner, which now creates the registered bridge’s native element directly. Detached MCP hosts retain native context admission. Loading and retry errors remain local to the optional panel, preserving the conversation and composer. Ordinary render and load failures offer local Retry; stale assets retain the guarded Reload action.

Evidence

Check Result
UI typecheck Passed (pnpm tsgo:ui)
Controller guard / prune Passed; syntactic baselines unchanged
Focused sidebar lazy suite 4 passed, including SyntaxError recovery through the guarded document reload
Focused panel-toggle suite 17 passed
Focused widget-card suite 25 passed
CI-discovered board/widget consumer tests 50 passed
Files, Review and Desktop retention 17 tests passed across the focused repair runs
Production Knip Every integrated-head finding also reported on clean main 828c38d27dc1; no introduced findings
Matched production builds + strict performance comparison Passed on integrated head; startup +8 B, Chat −1,469 B, New Session +71 B gzip; all configured budgets pass
Independent autoreview Initial migration, prior repairs, and final five-file repair scoped clean, P0–P2
Terminal lifecycle 23/23 final suite passes; delayed-connection and lazy-initial-picker regressions both fail their original owner, then pass fixed
Portals lazy initial target Regression fails original state owner; all 27 Portal tests pass fixed
Full UI/browser-extension/real-Gateway CI Completed run 39902075358; all selected jobs pass except three exact-match inherited sidebar cases in two UI shards. Both real-Gateway shards pass.

The first full CI run found that creating ref registrations inside a loading boundary made it depend on freshly produced callback props. A normal pane update then replaced the region or board and discarded retained controls. Ref registration now belongs to the stable component lifetime. The widget loading placeholder also uses the saved height to avoid a first-frame jump. Tests await component readiness and supply the existing application context where they previously relied on native-only context transport.

The second full CI run exposed delayed native-host connections and initial property admission at the new lazy boundary. Terminal attachment now registers its connection callback for the component lifetime, so a host inserted after settlement still drains its queued open intent. Portals waits for settlement before its first request, preserving an initial environment target instead of issuing an unrelated portal list. Sidebar refs now belong to the conditional region: ordinary updates retain controls, while removing the region releases its refs. A lazy terminal regression also proved that its initial picker state was sampled before bridge inputs bound: PTY startup succeeded, but the picker stayed closed and never listed sessions. The picker now samples that one-time initial state after settlement, while preserving later user dismissal across theme updates. Module-evaluation errors preserve the original guarded document-reload recovery. MCP fixtures wait for the new lazy readiness. Confirmation readiness selects the actual confirmation card when a Channels dialog is already open; custom Stop Worker and Gateway Switch dialogs pass their own content selector.

The first local sidebar attempt could not start a Bun thread worker. Focused proof uses the same pinned Bun runtime with one fork worker. The lazy-error fixture was corrected to inspect Vitest’s wrapped cause and await the surviving lazy boundary after closing a panel; the final run passes all four cases. No Node runtime override or broad local E2E run. Later cold Bun runs used the documented BUN_RUNTIME_TRANSPILER_CACHE_PATH=0 setting after a sampled cache-rename stall; those interrupted setup attempts are not assertion evidence.

The original exact-base/head production Knip logs are byte-identical. After integrating main, every reported finding also appears on clean main 828c38d27dc1b2e28c0d1ed8d9569c3b4432b057: the Telegram test-support file, eight unused-export groups (including existing terminal-independent sidebar renderer exports), and five unused types. The clean-main run additionally reports CliHistoryOwnerChangedError; this PR introduces no finding. The final production Knip report is byte-identical to the integrated-head report; the independent main audit used the same full command.

Size and ownership

Fifteen manual component loader callbacks become lazy components (13 sidebar/board/detail loaders and two widget loaders). These callback registrations were not counted by the current AST guard, so no baseline allowance can be removed for them. No new owner API or effect is introduced. Touched TypeScript/TSX files: production 9,932 → 9,908 lines; tests/helpers 7,271 → 7,592 lines. The wider test footprint keeps existing behavior assertions across the new asynchronous boundary and supplies explicit context to renderer fixtures.

Matched startup on integrated base 0df143235066: 315,648 → 315,656 B gzip JavaScript, 7 JS requests, 41,143 B gzip CSS, 1 CSS request. Chat: 1,346,686 → 1,345,217 B gzip, 23 JS + 8 CSS requests. New Session: 822,360 → 822,431 B gzip, 17 JS + 6 CSS requests. CSS bytes are unchanged. New Session grows by 71 B gzip (19 B raw), above the 64 B build-variance band but within its 833,875 B budget; startup stays within variance and Chat is smaller. All configured head budgets pass. The final candidate refresh uses the exact fixed build identity and toolchain of the recorded baseline; only the candidate was rebuilt after the three-line terminal initialization fix.

Main integration is pinned to 0df1432350664d90adeaa6cb2aeab1951fccb7fa; the merge was conflict-free. Its composer-registry import and keyed-ref changes were inspected, and the integrated UI typecheck passes. The exact-base/head comparison and final fixed-identity candidate refresh pass all configured budgets. Main also supplies #181272, which waits for the Hide menu action to complete before the mobile resize in the progress-card E2E test.

Visual proof uses synthetic content only at 1440×960: a managed Canvas status widget and a file-link preview. Screenshots below compare the same scenarios against the merge base and head.

Before: synthetic Canvas widget

After: synthetic Canvas widget

Before: synthetic file preview

After: synthetic file preview

Current CI attribution

Run 39902075358 completed on 649bc17d7cc7. Its remaining failures are clears the visible Archived sidebar error after its failed roster recovers or retires, the corresponding All case (both session-management.filtered-errors.e2e.test.ts:180, expected zero alerts, got one), and exposes the full request diagnostic with keyboard and clipboard access (cloud-workspace-conflict.e2e.test.ts:236, two matching alerts). All three names and assertions also fail on the latest completed scheduled main run 39901237962. The test files, session error owner, and error renderer are unchanged in the CI checkout and on that main head. Native inherited-failure admission retains the failed CI evidence. All other selected jobs pass or skip, including both real-Gateway shards; the sidebar repair lane owns the inherited error-state fix.

Replace shared chat panel registration state with local Solid lazy boundaries.
Preserve cold Files and Dashboard panels, retained Canvas documents, and queued
panel commands delivered to the current mounted recipient.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 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 23, 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-23T04:49:36.644909Z 649bc17 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces the shared chat component-loading registry with local Solid lazy boundaries.

Example: Open notes.md beside a chat containing a synthetic Canvas status report.

  • Before: The file preview and Canvas render through custom-element registration loaders.
  • After: The same visible content renders through local lazy boundaries while the conversation and composer remain available.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source simplification is useful and visual parity is documented, but demonstrated retained-state loss makes the patch unsuitable for merging.
Proof confidence 🦐 gold shrimp (3/6) The supplied host facts identify this as maintainer-authored, so the ordinary contributor-proof gate is exempt; inspected screenshots show Canvas and file-preview rendering, while hosted CI exposes failing retention behavior.
Patch quality 🧂 unranked krab (1/6) 4 actionable review findings remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Optional chat surfaces need isolated loading and recovery while preserving active controls, drafts, and embedded documents.
Reason: The maintainer-authored direction removes a competing loading registry without adding configuration or changing the intended user workflow.

Regression provenance

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

Merge readiness

⛔ Needs changes before merge - 4 items remain

Keep open: the refactor has approved direction, but the lazy-mount cutover breaks retained panel state and leaves failing test consumers and lint violations.

Priority: P2
Reviewed head: e2ebe7312457c3f15ed158dd8a32623d5dafe0d6

Before merge

  • Preserve retained panel hosts across ordinary updates (P1) - The native-to-lazy bridge cutover replaces mounted panel content during updates that previously retained it. Exact-head CI reports a new Files rail after a search update, a replaced Review diff with collapsed state reset, five dashboard document requests instead of one, and disconnected HTML-preview frames when returning to a file tab. The panel-layout scenario also loses typed release-note text while opening Discussion. Preserve the mounted region and its descendant bridge roots across layout and snapshot publications; restoring these assertions by accepting replacement nodes would discard the user state they protect.
  • Migrate the remaining consumers of the removed widget loader (P2) - widget-registration.test.tsx still spies on ensureCustomElementDefined and rejects its controlled promise, but neither new widget branch calls that owner. Its fault injection therefore no longer reaches rendering, and the suite now mounts real widget implementations without the necessary application context, producing unhandled errors in checks-ui. Update this existing suite to inject failure and recovery at the new lazy-module boundary, provide the real rendering context, and preserve its host/action recovery assertions.
  • Await lazy mounting in the remaining board fixtures (P2) - BoardSessionSurface no longer creates an openclaw-board-view host synchronously, but board-session-surface.test.tsx still queries it immediately after flush and asserts board.active. The hosted shard fails both presentation cases with undefined instead of true; chat-pane-board.test.tsx also reaches board.appendChild with a null host. Migrate these consumers to await the actual lazy host before exercising their existing activation and retention contracts.
  • Remove the two introduced lint-limit failures (P2) - The added readiness code raises chat-sidebar-region.runtime.tsx from the 700-counted-line limit to 714, and the Canvas type change raises canvas-widget-view.tsx from 698 to 702. Both appear in the failing check-lint-core-2 annotations. Reduce or coherently relocate only the necessary added code without increasing allowances; the other diagnostics in unchanged files are separate.

Findings

  • [P1] Preserve retained panel hosts across ordinary updates — ui/src/pages/chat/chat-pane-sidebar-view.tsx:649-652
  • [P2] Migrate the remaining consumers of the removed widget loader — ui/src/pages/chat/components/widget-card-view.tsx:62-67
  • [P2] Await lazy mounting in the remaining board fixtures — ui/src/pages/chat/board-session-surface.tsx:37-41

Tests

  • Missing end-to-end proof: Supplied screenshots establish rendering parity, while hosted retention scenarios fail; repaired mounts need the existing dashboard, HTML-preview, and editor-retention scenarios to pass.
Agent review details

How this fits together

The Control UI presents session-owned chat, panels, and widgets; layout changes, queued commands, and asynchronous component imports produce mounted native hosts without transferring session authority to rendering.

flowchart TD
  A[Session and layout owners] --> B[Retained chat pane]
  B --> C[Local lazy boundaries]
  C --> D[Native panel and widget hosts]
  E[Queued panel commands] --> D
  D --> F[Visible content and retained drafts]
Loading

Technical review

Best possible solution:

Keep local lazy boundaries while preserving existing native-host lifetimes, completing the test-consumer migration, and removing the two introduced lint violations.

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

The changed mount paths and existing retention scenarios identify reproducible failures, corroborated by exact-head hosted CI; no local execution was performed.

Is this the best way to solve the issue?

Replacing the registry fits the existing Solid design, but the cutover must preserve the native bridge's retained lifetime and update every affected test consumer.

Full review comments:

  • [P1] Preserve retained panel hosts across ordinary updates — ui/src/pages/chat/chat-pane-sidebar-view.tsx:649-652
    The native-to-lazy bridge cutover replaces mounted panel content during updates that previously retained it. Exact-head CI reports a new Files rail after a search update, a replaced Review diff with collapsed state reset, five dashboard document requests instead of one, and disconnected HTML-preview frames when returning to a file tab. The panel-layout scenario also loses typed release-note text while opening Discussion. Preserve the mounted region and its descendant bridge roots across layout and snapshot publications; restoring these assertions by accepting replacement nodes would discard the user state they protect.
    Confidence: 0.97
  • [P2] Migrate the remaining consumers of the removed widget loader — ui/src/pages/chat/components/widget-card-view.tsx:62-67
    widget-registration.test.tsx still spies on ensureCustomElementDefined and rejects its controlled promise, but neither new widget branch calls that owner. Its fault injection therefore no longer reaches rendering, and the suite now mounts real widget implementations without the necessary application context, producing unhandled errors in checks-ui. Update this existing suite to inject failure and recovery at the new lazy-module boundary, provide the real rendering context, and preserve its host/action recovery assertions.
    Confidence: 0.99
  • [P2] Await lazy mounting in the remaining board fixtures — ui/src/pages/chat/board-session-surface.tsx:37-41
    BoardSessionSurface no longer creates an openclaw-board-view host synchronously, but board-session-surface.test.tsx still queries it immediately after flush and asserts board.active. The hosted shard fails both presentation cases with undefined instead of true; chat-pane-board.test.tsx also reaches board.appendChild with a null host. Migrate these consumers to await the actual lazy host before exercising their existing activation and retention contracts.
    Confidence: 0.99
  • [P2] Remove the two introduced lint-limit failures — ui/src/pages/chat/components/chat-sidebar-region.runtime.tsx:95-107
    The added readiness code raises chat-sidebar-region.runtime.tsx from the 700-counted-line limit to 714, and the Canvas type change raises canvas-widget-view.tsx from 698 to 702. Both appear in the failing check-lint-core-2 annotations. Reduce or coherently relocate only the necessary added code without increasing allowances; the other diagnostics in unchanged files are separate.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Sidebar loading registry and readiness changes intended behavior with a stated reason (8d8ad5b: Publish lazy registration readiness through the existing owner while preserving optional loading and failed-import recovery.)
  • Retained panels and file readers keeps the original intent (feat(ui): add resizable catalog to file readers #176343: Preserve mounted editors, unsaved input, workspace navigation, and delivery to the intended lazy Desktop recipient.)
  • Canvas parking and native widget hosts keeps the original intent (4d18f99: Retain Canvas documents across transcript-row replacement and pause hidden widget activity under the existing frame owner.)
  • Local widget and chat-region recovery changes intended behavior with a stated reason (fix(ui): show recoverable lazy renderer errors #180742: Contain renderer failures locally and retain widget action controls while allowing retry.)
  • Shared bridge ownership keeps the original intent (8de33e4: Keep host registration, property transport, context replacement, moves, and foreign-DOM lifetime with the existing bridge while isolating provider composition.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm --dir ui test src/pages/chat/chat-pane-embedded-panels.test.ts src/pages/chat/chat-pane-panel-presentation.test.ts src/pages/chat/board-session-surface.test.tsx src/pages/chat/chat-pane-board.test.tsx src/pages/chat/chat-pane-board.loading.test.tsx --maxWorkers=1
  • pnpm --dir ui test src/pages/chat/components/widget-registration.test.tsx src/pages/chat/components/canvas-widget-mount.test.tsx src/pages/chat/components/widget-card.test.tsx src/pages/chat/chat-pane-session-panel-toggle.test.tsx src/pages/chat/chat-pane-sidebar-layout.lazy.test.tsx --maxWorkers=1
  • pnpm test:ui:e2e ui/src/e2e/dashboard-cold-load.e2e.test.ts ui/src/e2e/dashboard-session-retention.e2e.test.ts ui/src/e2e/chat-html-preview.e2e.test.ts ui/src/e2e/chat-panel-layout.e2e.test.ts
  • pnpm tsgo:ui
  • pnpm check:control-ui-controllers

What I checked:

PR surface

Source -49, Tests +46. Total -3 across 27 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 21 536 585 -49
Tests 6 200 154 +46
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 736 739 -3

Review metrics

Metric Value Why it matters
Production versus test changes Production +536/−585, net −49; tests/helpers +200/−154, net +46. The registry removal reduces production code; the test growth addresses distinct readiness, dismissal, retry, and queued-delivery contracts.

Labels

Label changes:

  • add P2: This is a normal-priority refactor with merge-blocking regressions, rather than an established incident on current main.
  • add merge-risk: 🚨 session-state: Hosted tests demonstrate discarded editor text and replaced retained iframe and panel state during ordinary UI transitions.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a normal-priority refactor with merge-blocking regressions, rather than an established incident on current main.
  • merge-risk: 🚨 session-state: Hosted tests demonstrate discarded editor text and replaced retained iframe and panel state during ordinary UI transitions.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦐 gold shrimp and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 22, 2026, 10:54 PM ET / October 23, 2026, 02:54 UTC.

Connect terminals when their retained host enters the document, scope sidebar refs to the conditional region, and defer initial Portal reads until host inputs settle. Preserve guarded reload recovery for module evaluation failures and align fixtures with lazy readiness.
@steipete
steipete merged commit 5b4ee4d into main Oct 23, 2026
121 of 127 checks passed
@steipete
steipete deleted the solid2/w-zero-loaders-followup branch October 23, 2026 05:22
@steipete

Copy link
Copy Markdown
Contributor Author

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

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
* refactor(ui): lazy-load chat panels and widgets

Replace shared chat panel registration state with local Solid lazy boundaries.
Preserve cold Files and Dashboard panels, retained Canvas documents, and queued
panel commands delivered to the current mounted recipient.

* fix(ui): preserve lazy panel lifetimes across updates

* fix(ui): preserve lazy host connection and admission lifetimes

Connect terminals when their retained host enters the document, scope sidebar refs to the conditional region, and defer initial Portal reads until host inputs settle. Preserve guarded reload recovery for module evaluation failures and align fixtures with lazy readiness.

* fix(ui): preserve lazy terminal initialization and custom confirms
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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL 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