[PR #1941] [MERGED] Fix gallery media managed files #5352

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1941
Author: @cha1latte
Created: 6/2/2026
Status: ✅ Merged
Merged: 6/2/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1927-managed-gallery-files


📝 Commits (4)

  • f0443d3 Fix gallery media managed files
  • f074b6b Clean up gallery files on create failure
  • 8c5875f Merge upstream refactor into gallery media fix
  • a9d29dc Trigger review after base sync

📊 Changes

7 files changed (+289 additions, -33 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+117 -3)
📝 src-tauri/src/commands/storage/shared.rs (+85 -6)
📝 src-tauri/src/http_dispatch.rs (+12 -2)
📝 src-tauri/src/http_server.rs (+44 -11)
📝 src/features/catalog/characters/hooks/use-characters.ts (+8 -4)
📝 src/features/catalog/gallery/hooks/use-gallery.ts (+6 -6)
📝 src/shared/api/local-file-api.ts (+17 -1)

📄 Description

Linked issue

Closes #1927

Why this change

  • Gallery uploads and generated gallery images were persisted with inline data:image URLs in storage rows. That bloats storage records and leaves remote runtime without a managed gallery asset route.

What changed

  • Persist fresh chat and character gallery uploads under data/gallery and store managed filePath / filename metadata instead of inline image data.
  • Normalize generic storage_create writes for gallery and character-gallery so generated illustrations, selfies, and regenerations are also persisted as managed gallery files.
  • Add /api/assets/gallery/<filename> routing for remote runtime with filename-only path validation.
  • Resolve gallery rows from managed metadata in chat and character gallery queries, while keeping legacy inline url rows as fallback.
  • Updated focused Rust tests for generic create, upload, remote dispatch, remote asset routing, delete cleanup, and legacy gallery import rendering.

Refactor impact

Primary owner:

  • Rust storage

Impact areas reviewed:

  • Catalog gallery
  • Character gallery
  • Runtime generation gallery rows
  • Remote runtime managed asset routing
  • Managed media delete cleanup
  • Legacy gallery import compatibility

Boundary notes:

  • Engine callers continue to use storage capability APIs; the managed-file conversion lives at the Rust storage boundary.
  • Feature code uses the shared API gallery resolver rather than raw remote-runtime fetches.
  • Remote runtime now treats gallery as a managed asset kind alongside avatar/background/font/game/lorebook.

Pressure points touched:

  • src-tauri/src/commands/storage/commands/entities.rs
  • src-tauri/src/commands/storage/shared.rs
  • src-tauri/src/http_server.rs
  • src-tauri/src/http_dispatch.rs
  • src/shared/api/local-file-api.ts
  • src/features/catalog/gallery/hooks/use-gallery.ts
  • src/features/catalog/characters/hooks/use-characters.ts

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Before-fix repro: cargo test --manifest-path src-tauri\Cargo.toml gallery_create_persists_data_url_as_managed_file failed because the gallery row kept an inline data:image URL.
  • After-fix targeted proof: cargo test --manifest-path src-tauri\Cargo.toml gallery passed, covering generic generated-row create, chat/character upload dispatch, managed delete cleanup, legacy gallery import rendering, and gallery route positive/negative controls.
  • Baseline: pnpm check passed after the final diff.
  • Proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed locally.
  • No human-only verification blocker. This is a storage/remote-runtime contract fix with focused Rust and TypeScript proof.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix only; no new user-facing discovery surface.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A. This is a storage and remote-runtime routing fix with no visible UI layout change. Machine proof is listed above.


🔄 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/1941 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1927-managed-gallery-files` --- ### 📝 Commits (4) - [`f0443d3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f0443d3837b87a601cd29a0b7795763f34a4f2b8) Fix gallery media managed files - [`f074b6b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f074b6bdd2b81150c3b9b9aaae38a105f4eff409) Clean up gallery files on create failure - [`8c5875f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8c5875fde94fb9d67162b5ba2e99653d76e595c6) Merge upstream refactor into gallery media fix - [`a9d29dc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a9d29dcb6bbb60fb56833c8180b790a4aabf1510) Trigger review after base sync ### 📊 Changes **7 files changed** (+289 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+117 -3) 📝 `src-tauri/src/commands/storage/shared.rs` (+85 -6) 📝 `src-tauri/src/http_dispatch.rs` (+12 -2) 📝 `src-tauri/src/http_server.rs` (+44 -11) 📝 `src/features/catalog/characters/hooks/use-characters.ts` (+8 -4) 📝 `src/features/catalog/gallery/hooks/use-gallery.ts` (+6 -6) 📝 `src/shared/api/local-file-api.ts` (+17 -1) </details> ### 📄 Description ## Linked issue Closes #1927 ## Why this change - Gallery uploads and generated gallery images were persisted with inline `data:image` URLs in storage rows. That bloats storage records and leaves remote runtime without a managed gallery asset route. ## What changed - Persist fresh chat and character gallery uploads under `data/gallery` and store managed `filePath` / `filename` metadata instead of inline image data. - Normalize generic `storage_create` writes for `gallery` and `character-gallery` so generated illustrations, selfies, and regenerations are also persisted as managed gallery files. - Add `/api/assets/gallery/<filename>` routing for remote runtime with filename-only path validation. - Resolve gallery rows from managed metadata in chat and character gallery queries, while keeping legacy inline `url` rows as fallback. - Updated focused Rust tests for generic create, upload, remote dispatch, remote asset routing, delete cleanup, and legacy gallery import rendering. ## Refactor impact Primary owner: - Rust storage Impact areas reviewed: - Catalog gallery - Character gallery - Runtime generation gallery rows - Remote runtime managed asset routing - Managed media delete cleanup - Legacy gallery import compatibility Boundary notes: - Engine callers continue to use storage capability APIs; the managed-file conversion lives at the Rust storage boundary. - Feature code uses the shared API gallery resolver rather than raw remote-runtime fetches. - Remote runtime now treats `gallery` as a managed asset kind alongside avatar/background/font/game/lorebook. Pressure points touched: - `src-tauri/src/commands/storage/commands/entities.rs` - `src-tauri/src/commands/storage/shared.rs` - `src-tauri/src/http_server.rs` - `src-tauri/src/http_dispatch.rs` - `src/shared/api/local-file-api.ts` - `src/features/catalog/gallery/hooks/use-gallery.ts` - `src/features/catalog/characters/hooks/use-characters.ts` ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Before-fix repro: `cargo test --manifest-path src-tauri\Cargo.toml gallery_create_persists_data_url_as_managed_file` failed because the gallery row kept an inline `data:image` URL. - After-fix targeted proof: `cargo test --manifest-path src-tauri\Cargo.toml gallery` passed, covering generic generated-row create, chat/character upload dispatch, managed delete cleanup, legacy gallery import rendering, and gallery route positive/negative controls. - Baseline: `pnpm check` passed after the final diff. - Proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed locally. - No human-only verification blocker. This is a storage/remote-runtime contract fix with focused Rust and TypeScript proof. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix only; no new user-facing discovery surface. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A. This is a storage and remote-runtime routing fix with no visible UI layout change. Machine proof is listed above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:30 +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#5352
No description provided.