t3code/support non-image chat attachments - #3927
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR introduces a new feature enabling text file attachments in chat, adding a new RPC endpoint, validation logic, and state management across multiple layers. New user-facing capabilities of this scope warrant human review. You can customize Macroscope's approvability policy. Learn more. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f044e403be
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7e248cb18
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a5cf3e282
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26a4c8e14f
ℹ️ 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".
26a4c8e to
2b01a69
Compare
There was a problem hiding this comment.
💡 Codex Review
t3code/apps/web/src/components/chat/ChatComposer.tsx
Lines 1926 to 1928 in 2b01a69
When the composer already has eight images, or the current drop reaches that limit, encountering one additional image executes this break and silently skips every later file in the same drop. This now incorrectly discards otherwise supported text attachments that happen to follow the excess image, even though the reported limit applies only to images; record the image error and continue scanning the remaining files instead.
ℹ️ 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".
|
I need this, plenty of times I want to give context to the chat and I had to copy the path manually in order to work, in codex cli automatically I can paste and it gives the filepath so the model can fetch it. |
2b01a69 to
58a0171
Compare
There was a problem hiding this comment.
Effect service conventions: two error-modeling issues in the new projects.writeTextAttachment path.
Posted via Macroscope — Effect Service Conventions
58a0171 to
2955bbd
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a36b386. Configure here.

Verification
Summary
.t3/attachmentsand insert standard file-link chips into the promptWhy
The composer previously rejected every dropped file that was not an image. This made it impossible to attach Markdown, source, configuration, or other text files as agent context.
Text attachments now reuse the existing project file-writing and Markdown file-link paths, so they render and behave like other file references. Files are limited to 1 MB and rejected when they contain NUL bytes or invalid UTF-8.
The message collapse heuristic also now measures displayed link labels instead of their backing absolute paths. Without this, prompts containing several attachments could appear hidden even though their visible content was short.
Validation
pnpm exec vp test apps/web/src/components/chat/MessagesTimeline.test.tsxpnpm exec vp checkpnpm exec vp run typecheckNote
Medium Risk
Changes attachment ID shape for new files and rewrites filesystem cleanup on delete/revert with SQL-backed legacy handling; mistakes could delete wrong attachment data or leave orphans.
Overview
Adds UTF-8 text file attachments in the chat composer (paste/drag alongside images), persisted under the attachments root via a new
projects.writeTextAttachmentRPC and inserted into the prompt as standard Markdown file links.Attachment IDs for new files now use a SHA-256–suffixed thread segment (
toOwnedThreadAttachmentSegment) so threads that share the same slug (e.g.thread/avsthread-a) do not collide; helpers parse text links in message bodies, match thread ownership, and support both flat image files and per-id text directories.Projection attachment cleanup on thread delete/revert is reworked: it removes only referenced root entries (images + text dirs), prunes unreferenced owned entries after revert, handles legacy slug-only image IDs with a SQL check before delete, and avoids wiping unrelated threads’ files.
The composer blocks send/stash while text uploads are in flight; user message collapse uses visible Markdown length (
measureComposerMarkdownVisibleLength) so long attachment URLs do not force “Show full message” on short prompts.Reviewed by Cursor Bugbot for commit 335f5ed. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add non-image text file attachments to chat composer
projects.writeTextAttachmentWebSocket RPC and a canonical file link is inserted into the prompt.toOwnedThreadAttachmentSegment) to avoid collisions between threads with the same safe slug.runAttachmentSideEffects) is rewritten to handle directory-based text attachments, prune only thread-owned entries, and avoid deleting legacy image attachments referenced by other threads.shouldCollapseUserMessagenow uses visible markdown length (viameasureComposerMarkdownVisibleLength) so messages with long attachment paths are not incorrectly collapsed.Macroscope summarized 335f5ed.