refactor(web): ChatView's attachment preview handoff lives in useAttachmentPreviewHandoff#23067

merged1
refactor/split2-chatview-revert
refactor/split2-chatview-attachments
opened3d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 3d ago

The blob-preview handoff for sent images (state, refs, the preload effect, the unmount cleanup, and the URL map the timeline renders) moves into chat/useAttachmentPreviewHandoff.ts. Verbatim move.

BeforeAfter
ChatView.tsx lines4,7154,521

Tests: tsc-rs --noEmit for apps/web, oxlint on the changed files, vp test run src/components/ChatView.logic.test.ts, and the React Compiler coverage test for every changed file (0 bailouts). ChatView stays in the coverage test's slow set.

Part of the ChatView split (7,258 → 3,975 lines across the stack).

Opus 5.5, Claude Code.

🤖 Generated with Claude Code

Checks

All checks passed
Synced from GitHub

Approvability

Verdict: Approved at d9551c4

Macroscope's review found this PR approvable — This is a self-contained extraction of ChatView’s existing attachment-preview handoff logic into a custom hook, with the same inputs, cleanup, preloading, and timeline URL behavior. It introduces no new user-facing capability, schema change, product-default change, or static-analysis suppression.

No code changes detected at 4f54ed5. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Added 1 commit

  • refactor(web): ChatView's attachment preview handoff lives in useAttachmentPreviewHandoff4f54ed5
Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 509d9191-e587-482c-b0c9-4d101b03f4b2
📥 Commits

Reviewing files that changed from the base of the PR and between d9551c425cbe7cab187a483992173db0dc4c217a and 4f54ed53258b1892f22bfd3c6ca72e38e7d0189f.

📒 Files selected for processing: 1
  • apps/web/src/components/ChatView.tsx

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

ChatView now delegates attachment preview handoff and timeline URL mapping to useAttachmentPreviewHandoff. The hook tracks local blob previews, resolves server image URLs, preloads server images, and clears local handoffs after successful loads.

Changes: Attachment preview handoff

Layer / File(s)Summary
Handoff state and cleanup
apps/web/src/components/chat/useAttachmentPreviewHandoff.ts
The hook tracks handoff URLs and in-flight promotions by message. It revokes replaced or cleared blob URLs and cleans up previews on unmount.
Resolve and promote server images
apps/web/src/components/chat/useAttachmentPreviewHandoff.ts
The hook resolves server image URLs and preloads them when a matching server message has the same nonzero image count. It clears the local handoff after all images load and retains it after failures.
Timeline URLs and ChatView integration
apps/web/src/components/chat/useAttachmentPreviewHandoff.ts, apps/web/src/components/ChatView.tsx
The hook returns a timeline URL map that prefers active local previews. ChatView removes the inline handoff lifecycle and uses the hook’s callback and URL map.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Suggested reviewers: t3dotgg

Merge Risk: ⚪ Minimal · up to 4f54e

The attachment preview handoff appears to retain its prior behavior and is mergeable after normal checks.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check nameStatusExplanationResolution
Description checkWarningThe description explains the code change and lists verification commands, but it omits the required Problem and Scope and approval sections. It also does not report observed results for most checks or…Add Problem, Change, Scope and approval, and Verification sections. Describe the underlying problem and expected behavior, provide the triaged issue or explicit maintainer approval, and report the observed result of each verification comman…
Passed Passed checks: 3 passed
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main refactor: moving ChatView's attachment preview handoff into useAttachmentPreviewHandoff.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the code change and lists verification commands, but it omits the required Problem and Scope and approval sections. It also does not report observed results for most checks or explain why no issue or maintainer approval is required.

Resolution

Add Problem, Change, Scope and approval, and Verification sections. Describe the underlying problem and expected behavior, provide the triaged issue or explicit maintainer approval, and report the observed result of each verification command. If no issue or approval is required, explain why this focused refactor qualifies for the exemption.

✨ Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Comment @coderabbitai help to get the list of available commands.

Synced from GitHub

Thread transfer impact

⚠️ The latest CI run did not produce a thread transfer result for 4f54ed5.

This comment will update automatically after the next completed run.