TT-7124 Enhance useBurritoAudio fore resource burrito creation#291
Merged
Conversation
gtryus
commented
May 4, 2026
Contributor
- Introduced new utility functions for handling media file paths and extensions, improving file management.
- Updated the useBurritoAudio hook to ensure proper directory creation and error handling for media downloads.
- Added logic to prevent duplication of section-level resources during media export.
- Implemented new tests for getBurritoMediaExportStem and getMediaExt to validate media file handling.
- Refactored existing code for better readability and maintainability.
- Introduced new utility functions for handling media file paths and extensions, improving file management. - Updated the useBurritoAudio hook to ensure proper directory creation and error handling for media downloads. - Added logic to prevent duplication of section-level resources during media export. - Implemented new tests for getBurritoMediaExportStem and getMediaExt to validate media file handling. - Refactored existing code for better readability and maintainability.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances Burrito resource/audio export in the renderer by improving how media filenames/extensions are derived, ensuring export directories exist before writing/copying, and reducing duplicate exports (especially for section-level resources).
Changes:
- Added safer media extension detection (
getMediaExt) and a stable burrito export filename stem helper (getBurritoMediaExportStem) with unit tests. - Updated
useBurritoAudioto create parent directories before export, improve error messages, support exporting inline text resources, and avoid duplicating section-level resources in the book root. - Expanded Burrito “Resources” export to include
ArtifactTypeSlug.AIResource, plus added/extended hook tests around section-resource path uniqueness and duplication avoidance.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/renderer/src/utils/getMediaExt.ts | Safer extension derivation (basename-only) with contentType fallback. |
| src/renderer/src/utils/getMediaExt.test.ts | Tests for basename-only behavior and extension detection. |
| src/renderer/src/utils/burritoMediaFileStem.ts | New helper to generate stable filesystem-safe output stems for burrito exports. |
| src/renderer/src/utils/burritoMediaFileStem.test.ts | Tests for stem derivation from inline text, Windows paths, and URLs. |
| src/renderer/src/burrito/useCreateBurrito.ts | Includes AIResource artifact type in Resources export filter. |
| src/renderer/src/burrito/useBurritoAudio.ts | Directory creation + richer export routing (media vs inline text vs links) + dedupe logic + stem usage. |
| src/renderer/src/burrito/useBurritoAudio.test.ts | New tests for section resource uniqueness, dedupe behavior, and inline text export. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+20
to
+28
| if (ct === 'audio/mpeg') return 'mp3'; | ||
| if (ct === 'audio/mp4' || ct === 'audio/x-m4a' || ct === 'audio/m4a') | ||
| return 'm4a'; | ||
| if (ct === 'audio/wav' || ct === 'audio/x-wav') return 'wav'; | ||
| if (ct === 'audio/ogg' || ct === 'audio/opus') return 'ogg'; | ||
| if (ct === 'text/markdown') return 'md'; | ||
| if (ct.startsWith('text/')) return 'txt'; | ||
| if (ct.startsWith('audio/')) return 'mp3'; | ||
| return 'dat'; |
- Enhanced the `getMediaExt` utility to utilize content type for determining file extensions, including new cases for webm and opus formats. - Introduced a mapping for audio MIME types to their corresponding file extensions in `mimeTypes.ts`. - Updated tests for `getMediaExt` to cover additional scenarios, ensuring robust media file handling. - Refactored `useBurritoAudio` and `useCreateBurrito` for improved readability and maintainability.
sarahentzel
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.