Skip to content

refactor(ui): own file preview state in Solid - #174101

Merged
steipete merged 1 commit into
mainfrom
solid2/w-idiom-chat-c-preview
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
solid2/w-idiom-chat-c-preview

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The file sidebar still routed HTML preview state through a Lit-style controller and host invalidation adapter. It now owns preview/source mode with Solid writable derivations, resetting on file or line-navigation changes and preserving retained drafts. The lazy preview loader remains behind its existing boundary.

The panel passes editor/search refs directly and lets the existing menu primitive own outside-click dismissal. File editing remains a synchronous domain operation; CodeMirror still mounts after the DOM commits. Tags, classes, selectors, and appearance are unchanged.

User Impact

No user-visible change. Preview/source mode, retained edits, line navigation, and search focus keep their current behavior.

Evidence

Check Result
pnpm tsgo:ui Passed
Sidebar unit file 34 passed; follow-up focused preview/focus group 2 passed without strict-read warnings
Focused lint and formatting Passed
Production Knip Passed
Independent review No actionable P0–P2 findings
Codemod dry run Completed for all three production files; no unresolved markers
Broad UI proof ci:full requested

This is a state/lifecycle refactor with unchanged rendered output and no startup imports. No local build, E2E, or visual capture was run under the campaign's bounded proof policy. Startup bytes were not remeasured because no boot/startup boundary changed.

Touched production metrics

Metric Before After
LOC 1,264 1,250
Controller-pattern lines 6 0
createEffect 1 1
createRenderEffect 0 0
untrack 0 3
addEventListener 1 0
querySelector(All)?( 1 0
Class-string patterns / flush / owner capture 0 0

The checklist's query regex excludes generic calls; all four actual panel DOM queries were removed. The three untrack calls deliberately capture lifetime-stable native ref identity. The remaining effect integrates CodeMirror with committed DOM. Test LOC grows by 86 to exercise preview/source mode, file replacement, line navigation, retained edits, and search focus through the real detail-panel element.

@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-16T10:19:43.093632Z 23f3403 PR opened
ℹ️ 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 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 replaces the HTML preview controller with Solid-owned state and passes editor and search elements through refs.

Example: Enter “Retain this page” in report.html’s preview, follow report.html:2, then return to Preview.

  • Before: The hidden iframe survives, preserving the entered text.
  • After: Line navigation removes the iframe, so returning to Preview clears the entered text.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful ownership cleanup with focused element coverage, but the introduced iframe-lifetime regression blocks merge.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored refactor is outside the ordinary contributor proof gate; supplied validation exercises the real detail-panel element with mocked CodeMirror, and the body explicitly records no local browser capture.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: File previews must preserve editing, focus, and interactive document state through the Solid migration.
Reason: Maintainer-authored direction aligns with the established migration and removes the obsolete controller and host adapter together.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this maintainer-authored refactor open; the ownership change is useful, but one introduced preview-retention regression needs repair.

Priority: P2
Reviewed head: 23f340331df4ba715aac638097c991d937732de7

Before merge

  • Preserve the existing HTML preview across line navigation (P2) - When an HTML file already has a rendered preview, following a line link to that same file changes navigation and reruns this derivation. initialSource() becomes true, so preview becomes null. SidebarFile’s presentation Show then removes the preview element and destroys its iframe; clicking Preview recreates the document and loses form values, script state, and scroll position. Previously this navigation only called showSource(), leaving the hidden preview mounted. Reset source mode for navigation while retaining preview content for the same file, and cover returning to Preview with an unchanged iframe and local form value.
  • Explain or restore the original intent of Preview state and iframe retention - 65c8b06: Retain interactive HTML documents and source/editor state in file tabs; the prior navigation path hides the existing preview without clearing it.

Findings

  • [P2] Preserve the existing HTML preview across line navigation — ui/src/pages/chat/components/chat-html-preview.ts:55-60

Provenance

  • Preview state and iframe retention changes intended behavior without addressing why it exists (65c8b06: Retain interactive HTML documents and source/editor state in file tabs; the prior navigation path hides the existing preview without clearing it.)

Tests

  • Missing end-to-end proof: The existing HTML browser scenario stops after line navigation and never returns to Preview to check iframe identity or local form values.
Agent review details

How this fits together

The Control UI detail panel receives selected file content and navigation requests, manages source editing and drafts, and renders HTML through the existing sandboxed preview element.

flowchart LR
  A[File selection and line links] --> B[Detail panel]
  B --> C[Solid preview state]
  B --> D[CodeMirror editor]
  C --> E[HTML preview element]
  E --> F[Sandboxed iframe]
Loading

Technical review

Best possible solution:

Keep Solid ownership while resetting source mode on navigation without clearing an existing same-file preview.

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

Source inspection establishes navigation → null presentation → preview removal; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The controller cutover fits the existing Solid direction, but mode selection and retained preview content need separate reset dependencies.

Full review comments:

  • [P2] Preserve the existing HTML preview across line navigation — ui/src/pages/chat/components/chat-html-preview.ts:55-60
    When an HTML file already has a rendered preview, following a line link to that same file changes navigation and reruns this derivation. initialSource() becomes true, so preview becomes null. SidebarFile’s presentation Show then removes the preview element and destroys its iframe; clicking Preview recreates the document and loses form values, script state, and scroll position. Previously this navigation only called showSource(), leaving the hidden preview mounted. Reset source mode for navigation while retaining preview content for the same file, and cover returning to Preview with an unchanged iframe and local form value.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Solid rendering, refs, and menu dismissal keeps the original intent (5ef9e1a: Move sidebar rendering to Solid while preserving host selectors, editor mounts, and existing menu ownership.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm --dir ui test src/pages/chat/components/chat-sidebar.test.ts --maxWorkers=1
  • pnpm test:ui:e2e ui/src/e2e/chat-html-preview.e2e.test.ts
  • pnpm tsgo:ui

What I checked:

PR surface

Source -14, Tests +86. Total +72 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 142 156 -14
Tests 1 86 0 +86
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 228 156 +72

Review metrics

Metric Value Why it matters
Production versus test LOC Production net −14; tests +86 Production shrinks while added element-level coverage checks mode changes, retained drafts, and search focus.

Labels

Label changes:

  • add P2: Same-file line navigation can discard interactive preview state, with impact limited to the file-preview workflow.
  • 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: Same-file line navigation can discard interactive preview state, with impact limited to the file-preview workflow.
  • 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, 6:31 AM ET / 10:31 UTC.

@steipete
steipete merged commit fde0186 into main Oct 16, 2026
105 of 107 checks passed
@steipete
steipete deleted the solid2/w-idiom-chat-c-preview branch October 16, 2026 10:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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: M 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