[PR #1201] [MERGED] Fix bulk sprite folder imports #4976

Closed
opened 2026-10-22 04:12:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1201
Author: @cha1latte
Created: 5/25/2026
Status: ✅ Merged
Merged: 5/25/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/refactor-issue-1185-sprite-import


📝 Commits (2)

  • 98c3e07 Fix bulk sprite folder imports
  • 2e04968 Freeze sprite import category

📊 Changes

7 files changed (+258 additions, -41 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/media.rs (+9 -0)
📝 src-tauri/src/commands/storage/sprites.rs (+127 -0)
📝 src-tauri/src/lib.rs (+1 -0)
📝 src/features/catalog/characters/components/CharacterEditor.tsx (+50 -22)
📝 src/features/catalog/characters/hooks/use-characters.ts (+22 -0)
📝 src/features/catalog/personas/components/PersonaEditor.tsx (+47 -19)
📝 src/shared/api/image-generation-api.ts (+2 -0)

📄 Description

What?

Fixes #1185.

Adds a bulk sprite upload path for folder imports:

  • adds sprite_upload_bulk in Tauri storage commands
  • adds spriteApi.bulkUpload and useUploadSprites
  • updates character and persona folder uploads to prepare the selected files, call the bulk mutation once, and update the sprite query cache from the returned list
  • keeps the existing single-sprite upload path and its normal invalidation behavior unchanged

Why?

Folder sprite imports were using the single-upload mutation inside the file loop. That meant every successful file upload invalidated and refetched the full sprite list while the folder was still importing, and the Rust single-upload response also read the saved file back for each item.

How?

The new Rust bulk helper validates the character/persona sprite ID, writes each valid image payload, records per-file failures without aborting the whole batch, then returns one final list_sprites result. The editors use that final list to set the spriteKeys.list(characterId) cache once instead of invalidating it after every file.

Out of scope for this PR:

  • native folder-token import with Rust-side folder scanning/progress events
  • changing sprite_list away from base64 data URLs
  • changing runtime sprite consumers outside the editor upload cache path

Testing?

Machine verification:

  • node scratch\issue-1185-bulk-sprite-proof.mjs passed
  • cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests passed
  • pnpm check passed
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed
  • Bunny pass completed before opening this PR

Proof report:

Manual verification:

  • Runtime timing with real 10/50/100+ sprite folders in the Tauri app would quantify the performance improvement. This PR does not claim a numeric speedup; it verifies the repeated per-file list refresh path is removed.

Screenshots

N/A. This is a storage/cache behavior fix. The proof gist above includes the raw command output from the verification run.

Anything Else?

Targets refactor because the issue references the refactor-branch source layout and the request was to ship this to refactor.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1201 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/25/2026 **Status:** ✅ Merged **Merged:** 5/25/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1185-sprite-import` --- ### 📝 Commits (2) - [`98c3e07`](https://github.com/Pasta-Devs/Marinara-Engine/commit/98c3e07d7226472f1cd4f5bf4082476df95317d8) Fix bulk sprite folder imports - [`2e04968`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2e049682e491d64f868119926505bf58ea010c34) Freeze sprite import category ### 📊 Changes **7 files changed** (+258 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/media.rs` (+9 -0) 📝 `src-tauri/src/commands/storage/sprites.rs` (+127 -0) 📝 `src-tauri/src/lib.rs` (+1 -0) 📝 `src/features/catalog/characters/components/CharacterEditor.tsx` (+50 -22) 📝 `src/features/catalog/characters/hooks/use-characters.ts` (+22 -0) 📝 `src/features/catalog/personas/components/PersonaEditor.tsx` (+47 -19) 📝 `src/shared/api/image-generation-api.ts` (+2 -0) </details> ### 📄 Description ## What? Fixes #1185. Adds a bulk sprite upload path for folder imports: - adds `sprite_upload_bulk` in Tauri storage commands - adds `spriteApi.bulkUpload` and `useUploadSprites` - updates character and persona folder uploads to prepare the selected files, call the bulk mutation once, and update the sprite query cache from the returned list - keeps the existing single-sprite upload path and its normal invalidation behavior unchanged ## Why? Folder sprite imports were using the single-upload mutation inside the file loop. That meant every successful file upload invalidated and refetched the full sprite list while the folder was still importing, and the Rust single-upload response also read the saved file back for each item. ## How? The new Rust bulk helper validates the character/persona sprite ID, writes each valid image payload, records per-file failures without aborting the whole batch, then returns one final `list_sprites` result. The editors use that final list to set the `spriteKeys.list(characterId)` cache once instead of invalidating it after every file. Out of scope for this PR: - native folder-token import with Rust-side folder scanning/progress events - changing `sprite_list` away from base64 data URLs - changing runtime sprite consumers outside the editor upload cache path ## Testing? Machine verification: - `node scratch\issue-1185-bulk-sprite-proof.mjs` passed - `cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests` passed - `pnpm check` passed - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed - Bunny pass completed before opening this PR Proof report: - Gist: https://gist.github.com/cha1latte/5b636d9e399aeb8c28295905847024f3 - Raw verification output: https://gist.githubusercontent.com/cha1latte/5b636d9e399aeb8c28295905847024f3/raw/f2a82c384005483639ab0baa2686b05ada789fd6/issue-1185-verification-output.json Manual verification: - Runtime timing with real 10/50/100+ sprite folders in the Tauri app would quantify the performance improvement. This PR does not claim a numeric speedup; it verifies the repeated per-file list refresh path is removed. ## Screenshots N/A. This is a storage/cache behavior fix. The proof gist above includes the raw command output from the verification run. ## Anything Else? Targets `refactor` because the issue references the refactor-branch source layout and the request was to ship this to refactor. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:11 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4976
No description provided.