Skip to content

t3code/support non-image chat attachments - #3927

Open
jakeleventhal wants to merge 6 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/support-markdown-chat-attachments
Open

t3code/support non-image chat attachments#3927
jakeleventhal wants to merge 6 commits into
pingdotgg:mainfrom
jakeleventhal:t3code/support-markdown-chat-attachments

Conversation

@jakeleventhal

@jakeleventhal jakeleventhal commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Verification

Screenshot 2026-07-12 at 3 07 25 PM Screenshot 2026-07-12 at 3 09 10 PM [t3code-attachment-tests.zip](https://github.com/user-attachments/files/29944548/t3code-attachment-tests.zip)

Summary

  • allow UTF-8 text files to be dragged into the chat composer alongside images
  • persist text attachments under .t3/attachments and insert standard file-link chips into the prompt
  • avoid collapsing otherwise short user prompts when attachment links contain long hidden paths

Why

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.tsx
  • pnpm exec vp check
  • pnpm exec vp run typecheck
  • manual drag-and-drop verification with extensionless, Markdown, source, and configuration text files

Note

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.writeTextAttachment RPC 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/a vs thread-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

  • Users can now drag, paste, or select text files in the chat composer; files are uploaded via a new projects.writeTextAttachment WebSocket RPC and a canonical file link is inserted into the prompt.
  • Attachment IDs now include a SHA-256 hash suffix (via toOwnedThreadAttachmentSegment) to avoid collisions between threads with the same safe slug.
  • Text attachments are stored as directories (thread-owned-segment + UUID) outside the workspace; the server validates UTF-8, non-empty content, and a max byte limit defined in contracts.
  • Projection cleanup (runAttachmentSideEffects) is rewritten to handle directory-based text attachments, prune only thread-owned entries, and avoid deleting legacy image attachments referenced by other threads.
  • shouldCollapseUserMessage now uses visible markdown length (via measureComposerMarkdownVisibleLength) so messages with long attachment paths are not incorrectly collapsed.
  • Risk: Attachment ID format has changed to include a 64-char hash suffix, which is a breaking change for any existing attachment IDs stored without the hash.

Macroscope summarized 335f5ed.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 18b82a62-4d23-41e8-8dcb-8d148842e95e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jul 13, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
@jakeleventhal jakeleventhal changed the title t3code/support markdown chat attachments t3code/support non-image chat attachments Jul 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
@jakeleventhal
jakeleventhal force-pushed the t3code/support-markdown-chat-attachments branch from 26a4c8e to 2b01a69 Compare July 25, 2026 01:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

if (nextImageCount >= PROVIDER_SEND_TURN_MAX_ATTACHMENTS) {
error = `You can attach up to ${PROVIDER_SEND_TURN_MAX_ATTACHMENTS} images per message.`;
break;

P2 Badge Continue processing text files after reaching the image cap

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".

Comment thread apps/web/src/components/chat/MessagesTimeline.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
@Reston

Reston commented Jul 29, 2026

Copy link
Copy Markdown

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.

@jakeleventhal
jakeleventhal force-pushed the t3code/support-markdown-chat-attachments branch from 2b01a69 to 58a0171 Compare August 10, 2026 19:33
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Aug 10, 2026

@macroscopeapp macroscopeapp Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect service conventions: two error-modeling issues in the new projects.writeTextAttachment path.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/server/src/ws.ts Outdated
Comment thread packages/contracts/src/project.ts Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/server/src/workspace/WorkspaceFileSystem.ts
Comment thread apps/web/src/components/chat/ChatComposer.tsx
Comment thread apps/server/src/workspace/WorkspaceFileSystem.ts
Comment thread apps/web/src/components/chat/ChatComposer.tsx Outdated
Comment thread apps/web/src/components/chat/ChatComposer.tsx
@jakeleventhal
jakeleventhal force-pushed the t3code/support-markdown-chat-attachments branch from 58a0171 to 2955bbd Compare August 10, 2026 20:18
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Aug 10, 2026
Comment thread apps/server/src/attachmentStore.ts
Comment thread apps/server/src/orchestration/Layers/ProjectionPipeline.ts
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
Comment thread packages/shared/src/composerInlineTokens.ts Outdated
Comment thread apps/server/src/attachmentStore.ts
Comment thread apps/server/src/attachmentStore.ts
Comment thread apps/server/src/orchestration/Layers/ProjectionPipeline.ts
Comment thread apps/server/src/orchestration/Layers/ProjectionPipeline.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/server/src/orchestration/Layers/ProjectionPipeline.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL 500-999 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants