Skip to content

feat: add document file upload support for spec creation and project expansion#227

Merged
leonvanzyl merged 1 commit intomasterfrom
feat/document-file-uploads
Mar 25, 2026
Merged

feat: add document file upload support for spec creation and project expansion#227
leonvanzyl merged 1 commit intomasterfrom
feat/document-file-uploads

Conversation

@leonvanzyl
Copy link
Collaborator

Summary

  • Add support for uploading Markdown, Text, Word (.docx), CSV, Excel (.xlsx), PDF, and PowerPoint (.pptx) files alongside existing JPEG/PNG images in the spec creation and project expansion chat interfaces
  • Documents are extracted to text in memory (never persisted to disk) and sent to Claude as text content blocks, while images continue as image content blocks
  • Rename ImageAttachment to FileAttachment across the full stack (backend schemas, routers, services, frontend types, hooks, components)

Changes

Backend:

  • New server/utils/document_extraction.py — in-memory text extraction using python-docx, openpyxl, PyPDF2, python-pptx
  • New build_attachment_content_blocks() helper in chat_constants.py to dispatch images vs documents
  • Separate size limits: 5MB for images, 20MB for documents
  • Graceful error handling for corrupt files and encrypted PDFs

Frontend:

  • Widened accepted file types with MIME fallback via resolveMimeType() for browsers that don't set MIME on .md files
  • Document attachments show FileText icon instead of image thumbnail
  • ChatMessage renders documents as compact pills with filename and size
  • Updated help text from "attach images" to "attach files"

Test plan

  • ruff check . passes
  • python test_security.py passes (169 tests)
  • npm run lint passes (0 errors)
  • npm run build passes
  • Upload each file type (.md, .txt, .csv, .docx, .xlsx, .pdf, .pptx, .jpg, .png) in spec creation chat
  • Upload each file type in expand project chat
  • Verify images show as thumbnails, documents show as file icons
  • Verify Claude responds with awareness of document content
  • Test edge cases: .md file (browser MIME), empty .txt, large PDF (>5MB <20MB), oversized files rejected

🤖 Generated with Claude Code

…expansion

Add support for uploading Markdown, Text, Word (.docx), CSV, Excel (.xlsx),
PDF, and PowerPoint (.pptx) files in addition to existing JPEG/PNG image
uploads in the spec creation and project expansion chat interfaces.

Backend changes:
- New server/utils/document_extraction.py: in-memory text extraction for all
  document formats using python-docx, openpyxl, PyPDF2, python-pptx (no disk
  persistence)
- Rename ImageAttachment to FileAttachment across schemas, routers, and
  chat session services
- Add build_attachment_content_blocks() helper in chat_constants.py to route
  images as image content blocks and documents as extracted text blocks
- Separate size limits: 5MB for images, 20MB for documents
- Handle extraction errors (corrupt files, encrypted PDFs) gracefully

Frontend changes:
- Widen accepted MIME types and file extensions in both chat components
- Add resolveMimeType() fallback for browsers that don't set MIME on .md files
- Document attachments display with FileText icon instead of image thumbnail
- ChatMessage renders documents as compact pills with filename and size
- Update help text from "attach images" to "attach files"

Dependencies added: python-docx, openpyxl, PyPDF2, python-pptx

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@leonvanzyl leonvanzyl merged commit b738859 into master Mar 25, 2026
2 checks passed
@leonvanzyl leonvanzyl deleted the feat/document-file-uploads branch March 25, 2026 10:52
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