feat: Add comprehensive image support for TUI mode
Resolved 💬 1 comment Opened Aug 10, 2025 by zemaj Closed Oct 27, 2025
Problem
Currently, image support in TUI mode is limited and doesn't handle common use cases well:
- Drag-and-drop doesn't work properly - When dragging image files into the terminal, they either don't get recognized or cause immediate submission
- Complex filenames fail - Files with spaces, parentheses, or special characters (e.g.,
Screenshot 2025-01-10 at 12.30.45 PM.png) aren't handled correctly - No inline image detection - Users can't simply type image paths in their messages
- Build issues on stable Rust - The codebase uses unstable let-chains syntax that prevents compilation on stable Rust
Solution
This PR adds comprehensive image support to the TUI with the following improvements:
1. Smart Drag-and-Drop
- When users drag image files into the terminal, they now see placeholders like
[image: filename.png]in the compose field - The message isn't submitted immediately - users can add text around the images
- Supports file:// URLs (common when dragging from Finder on macOS)
- Handles terminal escape sequences for special characters
2. Automatic Image Detection
- Detects image paths typed directly in messages
- Example: typing "Look at screenshot.png" automatically includes the image
- Supports both absolute and relative paths
- Checks if files exist before including them
3. Complex Filename Support
- Properly handles filenames with spaces:
My Screenshot.png - Supports parentheses:
Screenshot (1).png - URL decodes special characters from file:// URLs
- Removes terminal escape sequences (
\→,\(→()
4. Stable Rust Compatibility
- Fixes unstable let-chains syntax in
client.rs,error.rs, andprotocol.rs - Code now compiles on stable Rust without requiring nightly features
Technical Details
The implementation adds a pending_images HashMap to track image placeholders and their paths. When a message is submitted, the system:
- Checks for
[image: ...]placeholders from drag-and-drop - Scans the text for image file paths
- Validates all paths exist
- Includes them as
InputItem::LocalImagein the submission
Testing
- ✅ Drag single/multiple images into terminal
- ✅ Type image paths directly in messages
- ✅ Complex filenames with spaces and special characters
- ✅ Mix text and images in the same message
- ✅ Compiles on stable Rust
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗