Skip to content

feat: add file drag-and-drop support for images and PDFs#1658

Open
ambigois wants to merge 1 commit intodocker:mainfrom
ambigois:feature/file-drag-drop
Open

feat: add file drag-and-drop support for images and PDFs#1658
ambigois wants to merge 1 commit intodocker:mainfrom
ambigois:feature/file-drag-drop

Conversation

@ambigois
Copy link

@ambigois ambigois commented Feb 9, 2026

  • Add ParsePastedFiles() to detect file paths from paste events
  • Support Unix (space-separated with escaping) and Windows (quoted) formats
  • Validate file types (PNG, JPG, GIF, WebP, BMP, SVG, PDF)
  • Enforce 5MB size limit per file
  • Add visual file type indicators with emoji icons
  • Integrate with existing attachment system
  • Handle edge cases (null chars, trailing backslash, etc.)
  • Add comprehensive test coverage (10+ test cases)
  • Works with all major terminal emulators
  • 100% backward compatible

Assisted-By: cagent

@ambigois ambigois requested a review from a team as a code owner February 9, 2026 14:46
github-actions[bot]

This comment was marked as outdated.

@ambigois ambigois force-pushed the feature/file-drag-drop branch from 83267b5 to d7860a9 Compare February 10, 2026 10:25
@rumpl
Copy link
Member

rumpl commented Feb 11, 2026

/review

docker-agent[bot]

This comment was marked as outdated.

@ambigois ambigois force-pushed the feature/file-drag-drop branch from d7860a9 to ab3a8d0 Compare February 11, 2026 12:36
@ambigois
Copy link
Author

/review

docker-agent[bot]

This comment was marked as outdated.

@ambigois ambigois force-pushed the feature/file-drag-drop branch 3 times, most recently from 598f53e to fe3db9b Compare February 11, 2026 14:21
@ambigois
Copy link
Author

/review

docker-agent[bot]

This comment was marked as outdated.

- Add ParsePastedFiles() to detect file paths from paste events
- Support Unix (space-separated with escaping) and Windows (quoted) formats
- Validate file types (PNG, JPG, GIF, WebP, BMP, SVG, PDF)
- Enforce 5MB size limit per file (>= boundary)
- Add visual file type indicators with emoji icons
- Integrate with existing attachment system
- Handle edge cases (null chars, trailing backslash, etc.)
- Add comprehensive test coverage

Security hardening:
- Add validateFilePath() to reject path traversal (..) and symlinks
- Check for '..' BEFORE filepath.Clean() to prevent bypass
- Use os.Lstat() instead of os.Stat() in all file validation paths
- Return errors from addFileAttachment() and AttachFile()
- Return error notification on failed attach instead of opening file picker
- Eliminate TOCTOU by removing redundant allFilesValid() pre-check;
  AttachFile() is the single validation point with rollback on failure
- Strip trailing backslash as malformed input
- Add TestValidateFilePath, TestValidateFilePath_TraversalBeforeClean,
  and TestAddFileAttachment_SizeLimit

Assisted-By: cagent
@dgageot dgageot force-pushed the feature/file-drag-drop branch 2 times, most recently from fe3db9b to 1d6cd30 Compare March 5, 2026 19:17
@dgageot
Copy link
Member

dgageot commented Mar 5, 2026

/review

Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Review Summary

Assessment: 🟢 APPROVE

This PR adds comprehensive file drag-and-drop support for images and PDFs with proper validation and testing. The implementation includes:

  • Robust path parsing: Character-by-character state machine parsers for both Windows (quoted paths) and Unix (escaped paths) formats
  • Type validation: Extension-based file type checking without requiring file I/O
  • Size limits: 5MB enforcement per file
  • Visual indicators: Emoji-based file type icons
  • Comprehensive tests: 10+ test cases covering edge cases
  • Backward compatibility: Fully compatible with existing attachment system

All automated verification checks passed with no confirmed bugs in the changed code. The state machine approach for path parsing correctly handles complex edge cases like spaces in filenames, quoted paths, and escape sequences.

✅ Ready for merge

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.

3 participants