Conversation
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]>
…chments (OCP) and DRY type definitions
Allow markdown attachments
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis 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
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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing touches
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 |
Summary by CodeRabbit
Release Notes
New Features
✏️ Tip: You can customize this high-level summary in your review settings.