Skip to content

TT-7124 Enhance useBurritoAudio fore resource burrito creation#291

Merged
gtryus merged 2 commits into
developfrom
TT-7124-burrito-res
May 4, 2026
Merged

TT-7124 Enhance useBurritoAudio fore resource burrito creation#291
gtryus merged 2 commits into
developfrom
TT-7124-burrito-res

Conversation

@gtryus

@gtryus gtryus commented May 4, 2026

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 useBurritoAudio to 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 thread src/renderer/src/burrito/useBurritoAudio.ts
Comment thread src/renderer/src/burrito/useBurritoAudio.ts
Comment thread src/renderer/src/utils/getMediaExt.ts Outdated
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.
@gtryus gtryus merged commit 36cb316 into develop May 4, 2026
2 checks passed
@gtryus gtryus deleted the TT-7124-burrito-res branch May 4, 2026 21:52
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