fix(export): disambiguate export filenames with generation id - #956
Conversation
Export filenames were derived from only the first 30 characters of the generation text. Generations with similar wording (a common workflow when iterating on the same line) produced identical filenames, so exports collided on disk — the browser appended " (1)"/" (2)" and users ended up opening audio that didn't match the expected filename. Append the first 8 chars of the generation id to the .wav and .voicebox.zip export filenames, in both the backend Content-Disposition headers and the frontend save-file hooks. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📝 WalkthroughWalkthroughExport filenames for voicebox ZIP and audio WAV downloads now combine sanitized text prefixes with the first eight characters of each generation identifier in both frontend and backend history flows. ChangesExport filename generation
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/lib/hooks/useHistory.ts (1)
50-57: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winKeep frontend and backend filename sanitization consistent.
The frontend replaces invalid characters with
-and lowercases the text, whilebackend/routes/history.pyremoves invalid characters and preserves case. The same export can therefore receive different filenames depending on the download path. Reuse a shared convention or explicitly document that these names intentionally differ.Also applies to: 78-85
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/lib/hooks/useHistory.ts` around lines 50 - 57, Align the filename sanitization in the frontend export logic around safeText and filename with the backend history route’s convention, so both download paths produce identical names. Reuse a shared sanitization rule where available; otherwise update the frontend transformations to match the backend behavior and apply the same change to the additional filename construction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@app/src/lib/hooks/useHistory.ts`:
- Around line 50-57: Align the filename sanitization in the frontend export
logic around safeText and filename with the backend history route’s convention,
so both download paths produce identical names. Reuse a shared sanitization rule
where available; otherwise update the frontend transformations to match the
backend behavior and apply the same change to the additional filename
construction.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 636d2ac9-d944-49e3-82f1-9c709cc7b422
📒 Files selected for processing (2)
app/src/lib/hooks/useHistory.tsbackend/routes/history.py
Problem
Export filenames are derived from only the first 30 characters of the generation text:
backend/routes/history.py—Content-Dispositionfor/history/{id}/export-audio({text}.wav) and/history/{id}/export(generation-{text}.voicebox.zip)app/src/lib/hooks/useHistory.ts— the filename passed toplatform.filesystem.saveFilein both export hooksWhen iterating on the same line — a very common workflow — generations share the same 30-char prefix and therefore get identical filenames. Exporting several of them collides on disk: the browser appends
(1)/(2), and users end up opening audio that doesn't match the filename, which looks like the app exported the wrong audio.Reproduction
Two distinct generations whose text both starts with "Martina se fai la brava stasera puoi rientrare domani…":
95ac48a0…63967a68…Martina se fai la brava staser.wav4ed9b3cc…0c404d44…Martina se fai la brava staser.wavDifferent audio, identical filename.
Fix
Append the first 8 characters of the generation id to the
.wavand.voicebox.zipexport filenames, in both the backendContent-Dispositionheaders and the frontend save-file hooks.After the fix:
Testing
/export-audioand/exportnow return uniqueContent-Dispositionfilenames for the colliding pair above, against a running backend.tsc -p app/tsconfig.json --noEmit— passes.biome linton the changed file — clean.🤖 Generated with Claude Code
Summary by CodeRabbit