Skip to content

Test#1504

Merged
sidneyswift merged 11 commits intomainfrom
test
Jan 29, 2026
Merged

Test#1504
sidneyswift merged 11 commits intomainfrom
test

Conversation

@sidneyswift
Copy link
Collaborator

@sidneyswift sidneyswift commented Jan 29, 2026

Summary by CodeRabbit

Release Notes

New Features

  • Added support for attaching text files (CSV and Markdown formats) to chat messages
  • Text attachments now display as preview cards showing filename, line count, and file type badge
  • Users can remove individual text attachments before sending messages
  • Text attachment content is automatically included in the message context when sending
  • Enhanced attachment layout to properly wrap multiple attachments

✏️ Tip: You can customize this high-level summary in your review settings.

sidneyswift and others added 11 commits January 27, 2026 12:37
Move helper functions out of usePureFileAttachments hook into
separate lib files following Open/Closed Principle.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Follow the CSV pattern - read markdown content and append to chat input
instead of sending as a file attachment. This ensures compatibility with
all AI models, not just those that support markdown file attachments.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add TextAttachment type and textAttachments state to manage CSV/markdown files
- Create TextFilePreview component showing filename, line count, and type badge
- Update AttachmentsPreview to render text file cards alongside other attachments
- Inject text file content into message at send time (like audio URLs)
- Remove old useAttachCsv and useAttachMarkdown hooks

This provides a cleaner UX for text file attachments - users see a compact card
preview instead of the full file content dumped into the input field.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Extract useTextAttachments hook from useAttachments (single responsibility)
- Create formatTextAttachments utility for message content formatting (DRY)
- Compose clearAttachments in provider to clear both types
- useAttachments now only handles file attachments (images, PDFs, audio)
- useTextAttachments handles text files (CSV, markdown)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update send button logic to check for text attachments in addition to
typed input. Users can now attach a markdown/CSV file and send without
typing additional text.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add parseTextAttachments utility to extract file sections from message text
- Add TextAttachmentCard component for read-only display in messages
- Update ViewingMessage to parse user messages and show cards for attachments
- User's typed text still displays as normal bubble

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Create single TextFileCard component with optional onRemove prop
- Delete TextFilePreview and TextAttachmentCard (duplicates)
- Used in both input preview (with remove) and message history (without)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link
Contributor

vercel bot commented Jan 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
recoup-chat Building Building Preview Jan 29, 2026 7:14pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR adds support for text file attachments (CSV and Markdown) within the VercelChat system. New hooks manage text attachment state, utility functions serialize and deserialize attachments, and UI components display them. The dedicated CSV hook is replaced with a generic text attachment system.

Changes

Cohort / File(s) Summary
New Text Attachment Infrastructure
hooks/useTextAttachments.ts, lib/chat/formatTextAttachments.ts, lib/chat/parseTextAttachments.ts
Introduces hooks and utilities for managing text file attachments in-memory, formatting them into message context, and parsing them from received messages.
File Handling & Utilities
lib/files/isAllowedByExtension.ts, lib/chat/config.ts
Adds extension-based file validation for browsers with generic MIME types, and extends supported file types to include Markdown (.md, .markdown).
Provider & Context Updates
providers/VercelChatProvider.tsx, hooks/useVercelChat.ts
Extends VercelChatProvider to manage text attachments and updates useVercelChat to prepend formatted text attachment content to messages.
File Processing
hooks/usePureFileAttachments.ts, hooks/useAttachments.ts
Replaces CSV-specific attachment logic with generic text attachment handling; routes CSV and Markdown files to addTextAttachment; removes dependency on useAttachCsv.
UI Component Updates
components/VercelChat/TextFileCard.tsx, components/VercelChat/AttachmentsPreview.tsx, components/VercelChat/ChatInput.tsx, components/VercelChat/ViewingMessage.tsx
Introduces TextFileCard component for rendering text attachments, and updates existing components to display and manage text attachments throughout the chat interface.
Removed Code
hooks/useAttachCsv.ts
Removes deprecated CSV-specific attachment hook, replaced by generic text attachment system.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant ChatInput
    participant usePureFileAttachments as usePureFileAttachments<br/>(Hook)
    participant useTextAttachments as useTextAttachments<br/>(Hook)
    participant VercelChatProvider
    participant useVercelChat

    User->>ChatInput: Select CSV/Markdown file
    ChatInput->>usePureFileAttachments: handleFileInput(file)
    
    alt CSV or Markdown file
        usePureFileAttachments->>usePureFileAttachments: Detect file type
        usePureFileAttachments->>useTextAttachments: addTextAttachment(file, type)
        useTextAttachments->>useTextAttachments: Read file as text,<br/>compute lineCount
        useTextAttachments->>VercelChatProvider: Update textAttachments state
    else Other file type
        usePureFileAttachments->>VercelChatProvider: Create temp URL,<br/>upload to /api/upload
    end
    
    User->>ChatInput: Click send
    ChatInput->>useVercelChat: handleSendMessage()
    useVercelChat->>useVercelChat: formatTextAttachments()<br/>prepend to message
    useVercelChat->>VercelChatProvider: Send message with context
Loading
sequenceDiagram
    actor User
    participant ViewingMessage as ViewingMessage<br/>(Component)
    participant parseTextAttachments as parseTextAttachments<br/>(Util)
    participant TextFileCard

    User->>ViewingMessage: Render message with text attachments
    ViewingMessage->>parseTextAttachments: Extract attachments from text
    parseTextAttachments->>parseTextAttachments: Regex parse formatted blocks,<br/>extract filename/type/lineCount
    parseTextAttachments->>ViewingMessage: Return attachments +<br/>remaining text
    
    alt Has text attachments
        ViewingMessage->>TextFileCard: Render for each attachment
        TextFileCard->>User: Display card with filename,<br/>line count, type badge
    else No text attachments
        ViewingMessage->>User: Display text content
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • sweetmantech

Poem

📎 Text files now dance with images bright,
CSV and Markdown in unified light,
No more special cases, just generic care—
From upload to message, attachments flow fair.
One hook to bind them, one format to share! ✨

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@sidneyswift sidneyswift merged commit 6cd0f47 into main Jan 29, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant