vibe-kanban
vibe-kanban copied to clipboard
Preserve original filename in uploaded image paths (Vibe Kanban)
Summary
Changes the image storage filename format from {UUID}.{ext} to {UUID}_{clean_name}.{ext}. The filename can be useful to help the model understand.
Changes Made
Added sanitize_filename() function
A new helper function that sanitizes filenames for filesystem safety:
- Converts to lowercase
- Replaces whitespace with underscores
- Removes special characters (keeps only alphanumeric and underscores)
- Truncates to 50 characters max to avoid filesystem limits
- Falls back to "image" if the result is empty
Updated filename generation
Modified store_image() in ImageService to use the new format:
let clean_name = sanitize_filename(original_filename);
let new_filename = format!("{}_{}.{}", Uuid::new_v4(), clean_name, extension);
Examples
| Original Filename | New Storage Filename |
|---|---|
Screenshot 2024-01-15.png |
a1b2c3d4-..._screenshot_2024_01_15.png |
My Cool Image!!!.jpg |
a1b2c3d4-..._my_cool_image.jpg |
résumé.png |
a1b2c3d4-..._rsum.png |
.png (no stem) |
a1b2c3d4-..._image.png |
Why This Change
-
Improved readability: File paths in markdown (
.vibe-images/uuid_screenshot.png) are now human-readable - Easier debugging: When inspecting cache directories or worktrees, files are identifiable by name
- Backwards compatible: Existing images continue to work since lookups use database IDs, not filename parsing
Files Modified
-
crates/services/src/services/image.rs
Testing
- ✅ Backend type check passes (
pnpm run backend:check) - ✅ All 195 workspace tests pass (
cargo test --workspace)
This PR was written using Vibe Kanban