Skip to content

perf(ui): load the media lightbox on open - #174830

Merged
steipete merged 2 commits into
mainfrom
solid2/w-perf-lightbox
Oct 17, 2026
Merged

steipete merged 2 commits into
mainfrom
solid2/w-perf-lightbox

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening Chat or New Session loaded the complete image/video lightbox, Panzoom, gallery navigation, and download helpers before the user opened any media.

User Impact

Chat boot avoids 10,898 B gzip of JavaScript and New Session avoids 10,945 B, with unchanged request counts. The existing native tag, properties, media ownership, zoom controls, and close behavior remain intact.

Implementation

Keep the native openclaw-image-lightbox registration in its small existing entry. Load the single renderer with Solid's lazy/Loading when that host mounts. The renderer's native host identity stays fixed; media props remain live while the import resolves. Regenerate the canonical cold/warm boot manifest so the viewer, Panzoom, and its inline styles leave both boot graphs.

The browser fixture now waits for the lazy dialog, and a delayed-import regression verifies current media props and removal before the renderer resolves. Existing media/download/zoom tests remain intact. No dependency or route changes, and no rendered style/content changes requiring screenshots.

Proof

Same machine/toolchain, fixed timestamp and build ID; base cfd38b92ce040b7638b69bf06e48aa4030bfa5ae.

Metric Base Head Change
Startup JS gzip 340,589 B 340,553 B -36 B
Startup JS requests 7 7 0
Startup CSS requests 1 1 0
Chat boot JS gzip 1,641,783 B 1,630,885 B -10,898 B
Chat boot JS requests 30 30 0
New Session JS gzip 1,331,276 B 1,320,331 B -10,945 B
New Session JS requests 27 27 0
Chat / New Session CSS gzip 131,348 / 108,697 B 131,348 / 108,697 B 0
  • Base/head production builds and strict base comparison: pass, zero violations.
  • Canonical boot manifest generation: cold/warm Chat and New Session captures pass.
  • Existing lightbox unit suite: 20 pass. Delayed-import regression: pass (after correcting its test-helper invocation).
  • Independent Codex review: no actionable P0–P2 findings.
  • pnpm tsgo:ui, targeted lint/format, production Knip, and git diff --check: pass.
  • ci:full selects all UI unit/E2E, browser-extension, and real-Gateway shards.
Scoped count Before After
Controllers / render effects / owner capture / flush 0 0
Effects 2 2
untrack 1 2
Native listeners 3 3
DOM queries 5 5
Manual class strings (checklist pattern) 0 0
Production TSX LOC 708 720
Generated manifest LOC 2,677 2,675

The extra untrack captures the fixed native host once; the other snapshots the title without resetting media when renamed. Existing effects synchronize the gallery/media owner and native player. This focused loading-boundary change adds a small wrapper rather than duplicating a renderer. No state owner or new abstraction was added.

Full CI found one retained-presentation test still assuming that opening the image host synchronously creates its modal. It now waits for the dynamic renderer before checking modal registration and parking cleanup. The complete retained-presentation file passes all 21 cases locally. Production inputs and the measured bundle graph are unchanged by this test-only correction. Independent review of the correction found no actionable P0–P2 findings.

CI attribution

Replacement-head CI run 38983358524 passes the UI unit tests and all selected checks except the six metadata-observation cases already failing on scheduled main 38981593815. Each is shares pending catalog reads across metadata invalidations (single, shared, late follower, late follower without metadata, late follower without metadata/metadata first, late follower/catalog first): models.list received 3 versus expected 2. The test and four request-owner source blobs are identical between the tested merge, its main parent, and scheduled main. Landing uses the native inherited-failure route; CI is not claimed green.

@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.

@steipete
steipete marked this pull request as ready for review October 16, 2026 23:30
@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-16T23:33:23.761176Z c221b73 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c221b737d7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +29
<Loading>
<Content {...props} host={host} />
</Loading>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add an error surface for the lazy lightbox chunk

When a tab survives a Gateway update while a New Session draft blocks document reload, this dynamic import can request a now-removed hashed chunk. installStaleChunkReloadListener cannot reload in that guarded state, and this Loading boundary has no Errored fallback or retry, so clicking an attachment produces an empty host with no explanation or actionable recovery. Wrap the lazy content in the same visible stale-chunk error/retry handling used by other lazy UI surfaces.

AGENTS.md reference: AGENTS.md:L79-L82

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. 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 loads the shared image and video lightbox renderer when media opens instead of during Chat or New Session boot.

Example: Open Chat without opening an attachment.

  • Before: The boot graph includes Panzoom and the complete lightbox renderer.
  • After: The lightweight host registers at boot, and opening an attachment imports the renderer.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The optimization has focused source and performance evidence, but an import-recovery defect and a directly affected failing fixture prevent a clean verdict.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports production boot captures, while the supplied renderer behavior evidence consists of tests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Chat and New Session download and evaluate viewer code before users open media.
Reason: The maintainer-authored direction fits the UI policy of deferring unused surfaces and preserves one renderer behind the existing host.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this maintainer-authored PR open: deferring unused viewer code is worthwhile, but chunk-load recovery and an affected CI fixture need repair.

Priority: P2
Reviewed head: c221b737d7e9c591f9df15ac6eb15bea18cec122

Before merge

  • Provide visible recovery when the lightbox import fails (P2) - A tab retained across a Gateway update can request a removed hashed renderer chunk when an attachment is first opened. New Session drafts and attachment work can block scheduleStaleChunkReload, and this Loading boundary has no error surface, retry, or close action. The user receives no usable viewer or explanation. Add an error boundary with the existing lazy-view recovery controls, preserving the document reload guard and draft state.
  • Await lazy modal readiness in the retained-pane fixture (P2) - Making the renderer asynchronous leaves chat-pane-retained-presentation.test.ts awaiting only the host's synchronous updateComplete before querying its modal. Its earlier dynamicImportSettled call runs before the image opens, so it cannot settle this import. The exact-head checks-ui job fails at line 473 with a null modal. Update this fixture to await the rendered dialog, as the changed browser fixture already does, while retaining its parking and cleanup assertions.

Findings

  • [P2] Provide visible recovery when the lightbox import fails — ui/src/components/image-lightbox.tsx:27-29
  • [P2] Await lazy modal readiness in the retained-pane fixture — ui/src/pages/chat/chat-pane-retained-presentation.test.ts:468-473

Tests

  • Missing end-to-end proof: The delayed-import test exercises live props and disposal, but supplied evidence does not exercise rejected imports through the shipped media-opening flow or show a base-failing regression run.
Agent review details

How this fits together

Chat and New Session pass selected media and resource callbacks into a native bridge host, whose renderer owns the modal, gallery, zoom controls, and resource cleanup.

flowchart LR
  A[Chat or New Session] --> B[Selected media]
  B --> C[Native lightbox host]
  C --> D[Lazy renderer import]
  D --> E[Modal and gallery]
  E --> F[Media resources and zoom]
Loading

Technical review

Best possible solution:

Retain the lazy renderer while adding visible, draft-safe import recovery and updating the retained-pane fixture to await modal readiness.

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

Source establishes both eager loading on main and the rejected-import path without local recovery; exact-head CI independently records the affected modal-readiness assertion.

Is this the best way to solve the issue?

Splitting the existing renderer behind its stable native host is a focused optimization, provided loading failures remain visible and recoverable.

Full review comments:

  • [P2] Provide visible recovery when the lightbox import fails — ui/src/components/image-lightbox.tsx:27-29
    A tab retained across a Gateway update can request a removed hashed renderer chunk when an attachment is first opened. New Session drafts and attachment work can block scheduleStaleChunkReload, and this Loading boundary has no error surface, retry, or close action. The user receives no usable viewer or explanation. Add an error boundary with the existing lazy-view recovery controls, preserving the document reload guard and draft state.
    Confidence: 0.98
  • [P2] Await lazy modal readiness in the retained-pane fixture — ui/src/pages/chat/chat-pane-retained-presentation.test.ts:468-473
    Making the renderer asynchronous leaves chat-pane-retained-presentation.test.ts awaiting only the host's synchronous updateComplete before querying its modal. Its earlier dynamicImportSettled call runs before the image opens, so it cannot settle this import. The exact-head checks-ui job fails at line 473 with a null modal. Update this fixture to await the rendered dialog, as the changed browser fixture already does, while retaining its parking and cleanup assertions.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared lightbox renderer and resource lifecycle keeps the original intent (refactor(ui): migrate shared viewers to Solid #168790: The Solid migration preserved viewer tags, controls, events, and resource ownership; subsequent gallery and listener refactors retained those contracts.)
  • Boot-module inventory keeps the original intent (2077fb5: The generated inventory separates route-reachable boot work and avoids loading closed optional surfaces.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/components/image-lightbox-lazy.test.tsx --maxWorkers=1
  • pnpm test ui/src/components/image-lightbox.test.ts --maxWorkers=1
  • pnpm test ui/src/pages/chat/chat-pane-retained-presentation.test.ts --maxWorkers=1
  • pnpm tsgo:ui
  • git diff --check

What I checked:

  • Introduced loading boundary: The pinned introduced diff replaces the eager renderer with a lazy import and Loading boundary; the extracted renderer preserves its resource and event ownership. (ui/src/components/image-lightbox.tsx:27, c221b737d7e9)
  • Current main remains eager: Fetched main still imports Panzoom, gallery helpers, viewer chrome, and inline styles directly from the registered lightbox module. (ui/src/components/image-lightbox.tsx:1, a1bb732d30bc)
  • Guarded reload cannot replace local recovery: scheduleStaleChunkReload returns without reloading when a document guard blocks it; New Session registers guards for unsaved input, including attachments. The existing review at perf(ui): load the media lightbox on open #174830 (comment) identifies the same failure path. (ui/src/app/stale-chunk-reload.ts:157, c221b737d7e9)
  • Diff-caused CI fixture failure: The exact-head checks-ui job reports a null modal at chat-pane-retained-presentation.test.ts:473; that fixture awaits updateComplete but never waits for the newly asynchronous renderer after opening the image. (ui/src/pages/chat/chat-pane-retained-presentation.test.ts:473, c221b737d7e9)
  • Other CI failures remain unattributed: The E2E job reports models.list count mismatches, without evidence tying them to this diff. The context check rejects Evidence-section formatting. Full job-log retrieval was blocked by the artifact host allowlist, so neither is presented as an introduced code defect. (c221b737d7e9)
  • Supplied performance evidence: The complete PR body reports same-environment production captures saving 10,898 gzip bytes for Chat and 10,945 for New Session, with unchanged request counts; discussion adds no runtime attachment-opening artifact. (ui/config/control-ui-boot-modules.json:1, c221b737d7e9)

PR surface

Source +10, Tests +39. Total +49 across 5 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 686 676 +10
Tests 2 39 0 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 725 676 +49

Labels

Label changes:

  • add P2: This is a bounded boot-performance improvement with repairable media-loading and test-readiness defects.
  • 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: This is a bounded boot-performance improvement with repairable media-loading and test-readiness defects.
  • 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 16, 2026, 7:46 PM ET / 23:46 UTC.

@steipete
steipete merged commit 02d223b into main Oct 17, 2026
98 of 105 checks passed
@steipete
steipete deleted the solid2/w-perf-lightbox branch October 17, 2026 00:34
@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. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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