refactor(web): ChatView's attachment preview handoff lives in useAttachmentPreviewHandoff#23067
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.
| Before | After | |
|---|---|---|
ChatView.tsx lines | 4,715 | 4,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
- SuccessfulCodeRabbitGitHub
Review completed
- Skipped
- Skipped
- Skipped
- SuccessfulRemove preview downloadGitHub
- SuccessfulCheckGitHub
- SuccessfulLabel PR 23067GitHub
- SuccessfulCollect PR targetsGitHub
- SkippedRelease SmokeGitHub
- Skipped
- SkippedRustGitHub
- SuccessfulTest WebGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulTestGitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulLintGitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulChangesGitHub
- SuccessfulCheckGitHub
- SkippedRelease SmokeGitHub
- SkippedRustGitHub
- Skipped
- SuccessfulTest WebGitHub
- SuccessfulTestGitHub
- SuccessfulBuild and TypecheckGitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulChangesGitHub
- SuccessfulTest Server 6GitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulLintGitHub
- FailedCheckGitHub
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulNative fingerprint diffGitHub
- SkippedRustGitHub
- SkippedRelease SmokeGitHub
- Skipped
- CancelledBuild and TypecheckGitHub
- CancelledTestGitHub
- CancelledTest WebGitHub
- SuccessfulTest Server 4GitHub
- SuccessfulTest Server 7GitHub
- SuccessfulTest Server 2GitHub
- SuccessfulTest Server 5GitHub
- SuccessfulTest Server 3GitHub
- SuccessfulTest Server 1GitHub
- SuccessfulChangesGitHub
- SuccessfulTest Server 8GitHub
- SuccessfulTest Server 6GitHub
- CancelledLintGitHub
- Skipped
- Skipped
- Skipped
- SuccessfulLabel PR sizeGitHub
- SuccessfulLabel PR 23067GitHub
- Skipped
- Skipped
- Skipped
- CancelledLabel PR sizeGitHub
- CancelledLabel PR 23067GitHub
- Cancelled
- CancelledTestGitHub
- FailedCheckGitHub
- SuccessfulNative fingerprint diffGitHub
- CancelledRelease SmokeGitHub
- CancelledRustGitHub
- CancelledBuild and TypecheckGitHub
- CancelledTest WebGitHub
- SkippedDeploy web previewGitHub
- SkippedEAS PreviewGitHub
- SkippedDeploy web previewGitHub
- SkippedEAS PreviewGitHub
- CancelledTest Server 7GitHub
- CancelledTest Server 1GitHub
- CancelledTest Server 3GitHub
- CancelledTest Server 4GitHub
- CancelledTest Server 6GitHub
- CancelledTest Server 8GitHub
- CancelledNative fingerprint diffGitHub
- CancelledTest Server 2GitHub
- CancelledLintGitHub
- CancelledTest Server 5GitHub
- CancelledChangesGitHub
- SuccessfulPrepare PR size configGitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulCollect PR targetsGitHub
- SuccessfulPrepare PR size configGitHub
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
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.tsThe 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.tsThe 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.tsxThe 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 name Status Explanation Resolution Description check Warning 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… 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 name Status Explanation Title check Passed The title clearly and concisely describes the main refactor: moving ChatView's attachment preview handoff into useAttachmentPreviewHandoff. Linked Issues check Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Passed Check 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
- Mode: Continue automatically
- Reviewed files: 1
- Charged: $0.25
- View usage details
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.
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.