Repository navigation
refactor(ui): lazy-load chat panels and widgets - #181229
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesThis 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.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7eb270dadb0f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource -49, Tests +46. Total -3 across 27 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment 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.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* 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
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
pnpm tsgo:ui)828c38d27dc1; no introduced findings39902075358; 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=0setting 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 reportsCliHistoryOwnerChangedError; 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.
Current CI attribution
Run
39902075358completed on649bc17d7cc7. Its remaining failures areclears the visible Archived sidebar error after its failed roster recovers or retires, the correspondingAllcase (bothsession-management.filtered-errors.e2e.test.ts:180, expected zero alerts, got one), andexposes 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 run39901237962. 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.