refactor(web): composer file intake lives in useComposerAttachmentIntake#23049
addComposerAttachments, foldPastedText and removeComposerImage are about 300 lines in the composer body. They are the composer's file intake, and the paste, drop and attach-button paths all call them.
useComposerAttachmentIntake now holds:
- validation and attachment-slot reservation
- image compression
- inline chip insertion
- reattach-marker replacement
- folding large pastes into
pasted-text-N.txt, along with thepastedTextFileNamesRefthat only this code uses - the confirm before removing an image the prompt references
The composer passes in the draft helpers and the existing chip-insertion function. The hook is called where the intake code began, and this PR adds no useStableCallback.
| File | before | after |
|---|---|---|
| ChatComposer.tsx | 4,570 | 4,267 |
| useComposerAttachmentIntake.ts | 423 |
Renders are unchanged. Typing 20 chars, with or without an image attached, is 182 renders. ComposerAttachButton renders 0 times, so the handler the hook returns is still cached across keystrokes.
Tested:
- apps/web typecheck and lint on the touched files.
- React Compiler: 0 bailouts on both files.
- Hands-on in a dev build:
- Pasting an image attaches it and adds its chip.
- Pasting about 80 KB of text folds it into
pasted-text.txtand shows the "Large paste attached" toast. - Dropping a text file attaches
notes.txtwith a chip. - Removing images works.
🤖 Generated with Claude Code
Checks
Added 1 commit
- refactor(web): composer file intake lives in useComposerAttachmentIntake13c6e32
Approvability
Verdict: Approved at 13c6e32
Macroscope's review found this PR approvable — This PR moves existing composer attachment intake logic into a dedicated hook without changing its behavior, interfaces, defaults, or production configuration. The large diff reflects relocation of existing code rather than a new capability.
You can add or adjust custom eligibility rules. Learn more.
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:
63fa9827-9bbd-41fe-a56f-21ad47aaa4e6
📥 Commits
Reviewing files that changed from the base of the PR and between d7b37b81c32eeb84d581993d1906bd32d907feaa and 13c6e32e1074613f279304cccab27c176e8ec104.
📒 Files selected for processing: 2
apps/web/src/components/chat/ChatComposer.tsxapps/web/src/components/chat/useComposerAttachmentIntake.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
📝 Walkthrough
ChatComposer delegates attachment intake, image removal, and pasted-text folding to a new hook. The hook validates and stages files, prepares images, and handles referenced-image removal and oversized pasted text.
Changes: Composer Attachment Intake
Layer / File(s) Summary Intake contract and validation
apps/web/src/components/chat/useComposerAttachmentIntake.tsThe hook validates attachment eligibility, question state, staging limits, file types, and provider attachment caps. It stores eligible files and inserts context references. Image preparation and removal
apps/web/src/components/chat/useComposerAttachmentIntake.tsThe hook compresses and stores images, tracks pending preparation, reports failures, and requires confirmation before removing an image referenced inline in the prompt. Pasted text and composer wiring
apps/web/src/components/chat/useComposerAttachmentIntake.ts,apps/web/src/components/chat/ChatComposer.tsxThe hook stages oversized pasted text as text-file attachments when permitted and returns the attachment operations. ChatComposer uses the hook instead of its inline intake logic. Priority: ⬇️ Low
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Suggested reviewers:
maria-rcks
Merge Risk: ⚪ Minimal · up to 13c6e
This is a refactor that moves composer file-intake logic into its own hook, with no intended change in behavior. No actionable defect was found in the supplied context, so it looks safe to merge 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 implementation and includes focused verification results, but it does not follow the required template. It omits explicit Problem, Change, and Scope and approval sections,… Add the required Problem, Change, Scope and approval, and Verification headings. State the user or maintenance problem and expected behavior. Link the triaged issue or approval discussion, or explain why this focused refactor is exempt. Kee… Passed Passed checks: 3 passed
Check name Status Explanation Title check Passed The title clearly and concisely describes the main refactor: moving composer file-intake logic into useComposerAttachmentIntake. 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 implementation and includes focused verification results, but it does not follow the required template. It omits explicit Problem, Change, and Scope and approval sections, and it provides no issue or maintainer-approval reference.
Resolution
Add the required Problem, Change, Scope and approval, and Verification headings. State the user or maintenance problem and expected behavior. Link the triaged issue or approval discussion, or explain why this focused refactor is exempt. Keep the existing verification details under Verification.
✨ Finishing Touches
📝 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
Comment @coderabbitai help to get the list of available commands.