[PR #2196] [MERGED] Preserve managed image references #5462

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2196
Author: @Xelvanis
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/inline-image-followups


📝 Commits (3)

  • 7521f15 Preserve managed image references
  • f2b1916 Address image reference review findings
  • 4b640f1 Keep avatar gallery ids paired

📊 Changes

17 files changed (+273 additions, -78 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+4 -4)
📝 src-tauri/src/commands/storage/imports/marinara_assets.rs (+2 -2)
📝 src-tauri/src/commands/storage/imports/marinara_helpers.rs (+1 -1)
📝 src-tauri/src/commands/storage/imports/payloads.rs (+1 -1)
📝 src-tauri/src/commands/storage/imports/service.rs (+3 -3)
📝 src-tauri/src/commands/storage/imports/service_tests.rs (+43 -0)
📝 src-tauri/src/commands/storage/media_uploads.rs (+26 -3)
📝 src-tauri/src/commands/storage/startup_migrations.rs (+2 -9)
📝 src/engine/contracts/types/game.ts (+2 -0)
📝 src/engine/contracts/types/scene.ts (+1 -1)
📝 src/engine/generation/connected-commands.ts (+3 -2)
📝 src/engine/generation/start-generation.ts (+3 -2)
📝 src/features/modes/game/api/game-api.ts (+96 -5)
📝 src/features/modes/game/components/GameSurface.tsx (+1 -1)
📝 src/features/modes/game/stores/game-mode.store.ts (+43 -13)
📝 src/features/modes/shared/chat-ui/components/ChatMessage.tsx (+36 -31)
📝 src/features/modes/shared/chat-ui/components/ResolvedAvatarImage.tsx (+6 -0)

📄 Description

Linked issue

N/A

Why this change

  • Inline image handling was still split across a few lowercase-only checks, so mixed-case data URL headers could be skipped or left inline instead of being materialized as managed image files.
  • Generated images were persisted through gallery storage, but some downstream message and game paths still kept the original image data URL or could not reuse the managed gallery/local asset URL as a future provider reference.

What changed

  • Centralized inline image detection on the shared Rust storage helper across gallery create, startup migration, Marinara import, ST import, and charx asset paths.
  • Made image payload decoding accept case-variant data URL headers and added Rust regression coverage for mixed-case ST avatar imports.
  • Stored managed gallery URLs on generated selfie, illustration, and game NPC portrait outputs instead of keeping the transient generated data URL.
  • Threaded optional avatarGalleryId through game NPC contracts, generation results, and the game mode store so generated NPC portraits remain linked to their gallery rows.
  • Resolved managed gallery/local asset URLs back into data URLs when loading game illustration reference subjects.
  • Updated shared chat avatar lightbox handling to resolve managed avatar file URLs lazily and reuse cached resolved sources.

Refactor impact

Primary owner:

Rust storage/imports, engine generation, game mode assets, and shared chat UI.

Impact areas reviewed:

  • Gallery create and startup inline-image migration paths.
  • ST, Marinara, and charx character/persona avatar import paths.
  • Generated image attachment metadata for selfie and illustration commands.
  • Game NPC portrait generation, game NPC metadata, and future illustration reference loading.
  • Shared transcript avatar rendering and lightbox source resolution.

Boundary notes:

  • Feature code continues through focused shared API wrappers (storageApi, urlBinaryApi, and local file helpers); no raw Tauri invoke or raw remote-runtime fetch was added.
  • Engine generation continues to use injected storage/generation ports and now records the managed gallery URL returned by that port.
  • Rust changes stay inside storage, imports, media helpers, and tests; no command registry or HTTP dispatch changes.

Pressure points touched:

  • src/features/modes/game/api/game-api.ts and the game mode store for NPC portrait metadata.
  • Shared mode UI avatar components for lightbox source resolution.
  • src-tauri storage/import modules for inline image detection and decoding.

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

  • pnpm typecheck passed.
  • cargo test --manifest-path src-tauri/Cargo.toml import_st_character_materializes_mixed_case_inline_avatar passed.
  • cargo check --manifest-path src-tauri/Cargo.toml passed.
  • pnpm check passed.
  • Native Tauri/provider image-generation flow was not run locally; this remains the main manual verification gap.

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 and compatibility follow-up only; no new discoverable workflow, setting, mode, panel, or advanced tool was added.

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

No docs changes were made because this preserves existing image/import behavior rather than adding a documented command, setting, workflow, or architecture rule.

UI evidence

No screenshots or recordings captured. The UI-adjacent change is avatar lightbox source resolution, not layout or visual styling.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed handling of inline image data URLs with mixed-case prefixes.
  • New Features

    • NPC avatars now tracked with gallery references for improved asset management.
    • Added support for resolving managed local avatar images.
  • Performance

    • Avatar URLs now load lazily on-demand with improved caching instead of pre-loading.

🔄 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/2196 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/inline-image-followups` --- ### 📝 Commits (3) - [`7521f15`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7521f159218357be8d61bdfbda3f39401742d025) Preserve managed image references - [`f2b1916`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f2b19166f99ebf50fbaf7f46b556bf2bacd36f21) Address image reference review findings - [`4b640f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4b640f192a40192cac685812fed217bfc6997205) Keep avatar gallery ids paired ### 📊 Changes **17 files changed** (+273 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+4 -4) 📝 `src-tauri/src/commands/storage/imports/marinara_assets.rs` (+2 -2) 📝 `src-tauri/src/commands/storage/imports/marinara_helpers.rs` (+1 -1) 📝 `src-tauri/src/commands/storage/imports/payloads.rs` (+1 -1) 📝 `src-tauri/src/commands/storage/imports/service.rs` (+3 -3) 📝 `src-tauri/src/commands/storage/imports/service_tests.rs` (+43 -0) 📝 `src-tauri/src/commands/storage/media_uploads.rs` (+26 -3) 📝 `src-tauri/src/commands/storage/startup_migrations.rs` (+2 -9) 📝 `src/engine/contracts/types/game.ts` (+2 -0) 📝 `src/engine/contracts/types/scene.ts` (+1 -1) 📝 `src/engine/generation/connected-commands.ts` (+3 -2) 📝 `src/engine/generation/start-generation.ts` (+3 -2) 📝 `src/features/modes/game/api/game-api.ts` (+96 -5) 📝 `src/features/modes/game/components/GameSurface.tsx` (+1 -1) 📝 `src/features/modes/game/stores/game-mode.store.ts` (+43 -13) 📝 `src/features/modes/shared/chat-ui/components/ChatMessage.tsx` (+36 -31) 📝 `src/features/modes/shared/chat-ui/components/ResolvedAvatarImage.tsx` (+6 -0) </details> ### 📄 Description ## Linked issue N/A ## Why this change - Inline image handling was still split across a few lowercase-only checks, so mixed-case data URL headers could be skipped or left inline instead of being materialized as managed image files. - Generated images were persisted through gallery storage, but some downstream message and game paths still kept the original image data URL or could not reuse the managed gallery/local asset URL as a future provider reference. ## What changed - Centralized inline image detection on the shared Rust storage helper across gallery create, startup migration, Marinara import, ST import, and charx asset paths. - Made image payload decoding accept case-variant data URL headers and added Rust regression coverage for mixed-case ST avatar imports. - Stored managed gallery URLs on generated selfie, illustration, and game NPC portrait outputs instead of keeping the transient generated data URL. - Threaded optional `avatarGalleryId` through game NPC contracts, generation results, and the game mode store so generated NPC portraits remain linked to their gallery rows. - Resolved managed gallery/local asset URLs back into data URLs when loading game illustration reference subjects. - Updated shared chat avatar lightbox handling to resolve managed avatar file URLs lazily and reuse cached resolved sources. ## Refactor impact Primary owner: Rust storage/imports, engine generation, game mode assets, and shared chat UI. Impact areas reviewed: - Gallery create and startup inline-image migration paths. - ST, Marinara, and charx character/persona avatar import paths. - Generated image attachment metadata for selfie and illustration commands. - Game NPC portrait generation, game NPC metadata, and future illustration reference loading. - Shared transcript avatar rendering and lightbox source resolution. Boundary notes: - Feature code continues through focused shared API wrappers (`storageApi`, `urlBinaryApi`, and local file helpers); no raw Tauri invoke or raw remote-runtime fetch was added. - Engine generation continues to use injected storage/generation ports and now records the managed gallery URL returned by that port. - Rust changes stay inside storage, imports, media helpers, and tests; no command registry or HTTP dispatch changes. Pressure points touched: - `src/features/modes/game/api/game-api.ts` and the game mode store for NPC portrait metadata. - Shared mode UI avatar components for lightbox source resolution. - `src-tauri` storage/import modules for inline image detection and decoding. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm typecheck` passed. - `cargo test --manifest-path src-tauri/Cargo.toml import_st_character_materializes_mixed_case_inline_avatar` passed. - `cargo check --manifest-path src-tauri/Cargo.toml` passed. - `pnpm check` passed. - Native Tauri/provider image-generation flow was not run locally; this remains the main manual verification gap. ## 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 and compatibility follow-up only; no new discoverable workflow, setting, mode, panel, or advanced tool was added. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims No docs changes were made because this preserves existing image/import behavior rather than adding a documented command, setting, workflow, or architecture rule. ## UI evidence No screenshots or recordings captured. The UI-adjacent change is avatar lightbox source resolution, not layout or visual styling. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed handling of inline image data URLs with mixed-case prefixes. * **New Features** * NPC avatars now tracked with gallery references for improved asset management. * Added support for resolving managed local avatar images. * **Performance** * Avatar URLs now load lazily on-demand with improved caching instead of pre-loading. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:33 +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#5462
No description provided.