Skip to content

refactor(ui): settle source preview cleanup - #179730

Closed
steipete wants to merge 5 commits into
mainfrom
solid2/chat-source-preview-lifecycle
Closed

steipete wants to merge 5 commits into
mainfrom
solid2/chat-source-preview-lifecycle

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Family Files Production LOC I1 I2 raw I3 I4 I5 I6 I7 raw I8 I9 I10 raw
attachments 34 4072 0 4 2 1 0 0 0 0 0 0
automations 7 1514 0 0 2 1 0 0 0 0 0 0
cards 10 2148 0 0 0 2 0 1 0 0 0 0
context 2 542 0 1 0 0 0 0 0 0 0 0
details 18 4828 0 0 0 0 0 1 0 0 0 0
header-navigation 12 4143 0 0 0 0 0 1 0 0 0 0
indicators-other 65 7831 0 1 1 0 0 0 0 0 0 3
media_previews 23 3659 0 5 2 1 0 1 0 0 0 0
panels_files_sidebar 23 6045 0 2 1 3 0 1 0 0 0 0
publication 3 843 0 0 0 0 0 0 0 0 0 0
pull_request_ci 9 2256 0 0 1 2 0 0 0 0 0 0
questions 13 2529 0 0 0 0 0 0 0 0 0 0
review_diff 17 3957 0 0 2 0 0 1 0 0 0 0
sharing 6 1955 0 0 0 0 0 0 0 0 0 0
sidebar 10 3374 0 0 0 1 0 0 0 0 0 0
source_previews 1 144 0 1 → 0 0 0 0 0 0 0 0 0
tools 7 1552 0 0 0 0 0 0 0 0 0 0
workspace 15 4740 0 0 4 0 0 1 0 0 0 0

Whole CHAT-D scope: f6b226188d91 → af7dfab6d18d; 275 → 275 production files, 56,132 → 56,132 LOC. I1–I10 follow wave ten. Raw API sites include documented computation-cleanup and foreign-DOM exceptions; unlanded work remains counted.

Totals I1–I10: 0, 14 → 13, 15, 11, 0, 7, 0, 0, 0, 3.

What Problem This Solves

Finishes the Solid 2 component lifecycle migration for chat source previews. Register the existing disposal guard as the cleanup returned by onSettled, the component lifecycle API.

User Impact

Source dialogs, per-image failure handling, and favicon caching retain their existing behavior. The disposal guard still prevents completed asynchronous favicon work from publishing after the component retires. The shared favicon cache keeps its page lifetime.

Production LOC: 144 → 144. Two production lines change, with no new state, helper, dependency, or import boundary.

Evidence

Check Result
Source-preview tests 2/2 passed on the unchanged production patch
Independent review through P2 Scoped-clean; final source delta is the same reviewed lifecycle change
Current main integration Exact f6b226188d91; resolved the sole boot-test conflict verbatim from main, preserving its complete current sharing test. No boot-test change remains in this PR
UI typecheck, focused lint, format, whitespace Passed on exact integrated head af7dfab6d18d
Production Knip Passed on exact integrated head af7dfab6d18d
Exact-base/head production build and strict startup comparison Passed, exact f6b226188d91 → af7dfab6d18d; zero strict violations
Full PR CI ci:full selected; Exact run 39688644243: one delegated-work details E2E failure; all other jobs passed

The remaining failing name is Chat header and delegated work > keeps new batches collapsed until Subagents is opened manually without duplicate wait status: the test waits at line122 for a hidden details section after releasing the held chunk. Exact-name baseline investigation is shared with the other lane that observed the same case; no inherited exception is claimed yet.

No markup, styles, rendered text, handler behavior, or lazy boundary changes, so before/after screenshots are not applicable. The prior exact-head full CI passed, but its result is retained as earlier evidence and does not substitute for the new integrated-head run.

Built surface Base gzip Head gzip Requests (base → head)
Startup JavaScript 324,966 B 324,986 B (+20 B) 9 → 9
Startup CSS 40,796 B 40,796 B 1 → 1
Chat JavaScript 1,441,887 B 1,441,893 B (+6 B) 27 → 27
New Session JavaScript 1,020,126 B 1,020,143 B (+17 B) 22 → 22

Both builds use Node24.22.0/pnpm12.12.1 on the same machine, fixed build identity, and disabled build cache. Startup raw JavaScript bytes are identical; small gzip differences follow generated hashes. The first comparison encountered the still-copying baseline archive; only that comparison was repeated after the archive completed.

Solid 2 Touched-File Checklist

I2 component-level onCleanup: 1 → 0. Component onSettled registration: 0 → 1. I1 and I3–I10: 0 → 0. Raw effects, untrack, direct listeners, DOM queries, and owner escape APIs remain 0. Existing signal and draft-store ownership stays unchanged.

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 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 21, 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-21T22:50:05.419788Z af7dfab 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.

@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: 85c1f27c53

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

const [failedFavicons, setFailedFavicons] = createStore<Record<string, boolean>>({});
let active = true;
onCleanup(() => {
onSettled(() => () => {

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.

P2 Badge Keep the disposal guard registered synchronously

When this component is removed before its initial Solid settlement—for example, while a favicon request started during rendering is still pending—the onSettled body has not run, so no cleanup is registered and active remains true. readLinkFavicon later invokes the retained callback from its finally block, causing setRevision to update the already-disposed preview; the previous synchronous onCleanup prevented exactly this early-disposal case. Keep this lifetime-only guard on onCleanup rather than delaying its registration. .agents/skills/solid/references/idioms.mdL203-L207

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR replaces the source-preview component’s synchronous cleanup registration with cleanup returned from Solid’s onSettled callback.

Example: A preview for https://first.test/page starts loading its favicon and is disposed before initial settlement.

  • Before: Disposal immediately marks the preview inactive, suppressing the eventual favicon refresh.
  • After: The cleanup callback has not been registered, so the eventual favicon completion can still update the retired preview’s revision signal.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Focused scope and existing unit coverage support the migration, but delayed guard registration violates the preserved lifecycle contract.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its reported unit tests cover dialog retirement and isolated image failure, not the changed early-disposal timing.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: No user-visible defect is claimed; the goal is completing an internal Solid lifecycle migration.
Reason: The maintainer-authored migration direction is authorized, but this particular cleanup must preserve the synchronous retirement contract.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this maintainer-authored PR open, but preserve synchronous disposal registration before merging; the proposed change weakens the existing favicon retirement guard.

Priority: P3
Reviewed head: 85c1f27c53193ffa2bd2d7c5f52b55bef7a2599c

Before merge

  • Preserve synchronous registration of the favicon disposal guard (P2) - Favicon loading starts during rendering, before this onSettled callback runs. If the preview owner is disposed before its initial settlement, Solid skips the queued callback, so its returned cleanup is never registered and active stays true. The shared favicon cache later invokes refreshFavicons from finally, allowing setRevision on the retired preview. Restore onCleanup for this already-started work; the Solid guide explicitly preserves synchronous lifetime registration, and refactor(ui): use Solid lifetimes, actions, and stores in chat #179115 records why this exact cleanup was retained.
  • Explain or restore the original intent of Source-preview disposal guard - cb801e8: The Solid rendering migration replaced host.isConnected with an owner-lifetime active guard; the subsequent lifecycle migration explicitly retained synchronous cleanup for favicon work begun during rendering.

Findings

  • [P2] Preserve synchronous registration of the favicon disposal guard — ui/src/pages/chat/components/chat-source-previews.tsx:101-103

Provenance

  • Source-preview disposal guard changes intended behavior without addressing why it exists (cb801e8: The Solid rendering migration replaced host.isConnected with an owner-lifetime active guard; the subsequent lifecycle migration explicitly retained synchronous cleanup for favicon work begun during rendering.)

Tests

  • Missing end-to-end proof: The existing source-preview tests do not exercise disposal before initial settlement while a favicon request remains pending.
Agent review details

How this fits together

Chat run frames supply source descriptors and a favicon fetcher to the Solid source-preview component, which renders source cards and consumes callbacks from a shared page-lifetime favicon cache.

flowchart TD
 A[Chat run frame] --> B[Source preview component]
 B --> C[Shared favicon cache]
 C --> D[Favicon fetcher]
 D --> C
 C --> E[Preview refresh callback]
 E --> B
 B --> F[Source cards and dialogs]
Loading

Technical review

Best possible solution:

Retain the existing synchronous onCleanup guard for work that begins during rendering, without adding another lifecycle owner.

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

Source establishes the early-disposal path: rendering registers a retained favicon callback, disposal before settlement skips the onSettled body, and completion reaches setRevision while active remains true; no runtime reproduction was executed.

Is this the best way to solve the issue?

The existing guard already uses the appropriate owner and registration timing; moving only its registration to settlement does not pair setup with teardown and contradicts the documented exception.

Full review comments:

  • [P2] Preserve synchronous registration of the favicon disposal guard — ui/src/pages/chat/components/chat-source-previews.tsx:101-103
    Favicon loading starts during rendering, before this onSettled callback runs. If the preview owner is disposed before its initial settlement, Solid skips the queued callback, so its returned cleanup is never registered and active stays true. The shared favicon cache later invokes refreshFavicons from finally, allowing setRevision on the retired preview. Restore onCleanup for this already-started work; the Solid guide explicitly preserves synchronous lifetime registration, and refactor(ui): use Solid lifetimes, actions, and stores in chat #179115 records why this exact cleanup was retained.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Testing

Proof path: unit tests only.

Security

None.

Evidence

Acceptance criteria:

  • pnpm --dir ui test src/pages/chat/components/chat-source-previews.test.tsx src/pages/chat/link-favicon-cache.test.ts
  • pnpm tsgo:ui
  • git diff --check

What I checked:

PR surface

Source 0. Total 0 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 2 2 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 2 2 0

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a narrowly scoped internal lifecycle refactor with no intended user-visible change.
  • 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 21, 2026, 2:06 PM ET / 18:06 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Closing this mechanical conversion after reviewing the disposal lifecycle. readLinkFavicon registers completion callbacks during rendering, so the active = false disposal guard must be registered synchronously, including when the component is removed before its first settlement. Moving that registration into onSettled can miss this case.

The existing onCleanup is a justified synchronous lifetime exception in the Solid idioms. There is no setup resource to defer, and adding a computation or extra presentation state would only obscure the lifetime. Keeping the existing implementation is the smallest correct result. No change from this PR landed on main.

@steipete steipete closed this Oct 21, 2026
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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS 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