[PR #2048] [MERGED] Store uploaded avatars as managed assets #5413

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/avatar-upload-managed-assets


📝 Commits (1)

  • 6a6576f storage: store uploaded avatars as managed assets

📊 Changes

15 files changed (+562 additions, -56 deletions)

View changed files

📝 src-tauri/src/commands/storage/avatars.rs (+452 -10)
📝 src-tauri/src/commands/storage/commands/entities.rs (+2 -1)
📝 src-tauri/src/commands/storage/media_uploads.rs (+2 -18)
📝 src/engine/contracts/types/chat.ts (+2 -0)
📝 src/engine/generation/persona-snapshot.ts (+2 -0)
📝 src/features/catalog/personas/hooks/use-personas.ts (+33 -10)
📝 src/features/catalog/personas/query-keys.ts (+1 -1)
📝 src/features/modes/conversation/components/ConversationInput.tsx (+8 -3)
📝 src/features/modes/conversation/components/ConversationMessage.tsx (+24 -3)
📝 src/features/modes/shared/chat-ui/components/ChatMessage.tsx (+20 -4)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx (+3 -0)
📝 src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts (+9 -5)
📝 src/features/modes/shared/chat-ui/index.ts (+1 -0)
📝 src/features/runtime/generation/hooks/use-generate.ts (+1 -1)
📝 src/features/runtime/visuals/types.ts (+2 -0)

📄 Description

Linked issue

N/A

Why this change

  • Avatar uploads decoded and wrote managed files, but then kept inline data:image/... payloads in live avatar and avatarPath fields. That made character, persona, NPC, chat, and game hot paths carry large base64 strings.

What changed

  • Store uploaded character, persona, and NPC avatars as managed asset URLs in avatar/avatarPath while preserving avatarFilePath and avatarFilename metadata.
  • Added Rust coverage for character, persona, and NPC avatar upload return/storage shape.
  • Switched chat/conversation character and persona reads to projected summary records so managed avatars do not force full inline avatar payload reads.
  • Removed the stale full active-persona cache path and pointed generation's cached persona snapshot lookup at the projected active summary cache.

Refactor impact

Primary owner:

Rust storage, catalog persona hooks, and shared chat/conversation hot-path reads.

Impact areas reviewed:

  • Character avatar upload storage
  • Persona avatar upload storage
  • NPC avatar upload response shape used by game/tracker callers
  • Chat surface character and persona lookup paths
  • Conversation input persona status lookup
  • Generation optimistic persona snapshot cache lookup

Boundary notes:

  • Rust storage owns the upload persistence contract.
  • Feature code continues to use catalog hooks and storageApi; no new raw Tauri or remote-runtime calls were added.
  • Engine code was not coupled to feature or shared API adapters.
  • Existing character version/export paths still inline avatar data only for compatibility snapshots/exports.

Pressure points touched:

  • Shared chat UI hook and conversation input were touched for projected reads.
  • No ModeSurface, GameSurface, src-tauri/src/lib.rs, or import module changes.

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

  • cargo test --manifest-path src-tauri/Cargo.toml avatar_upload passed.
  • cargo test --manifest-path src-tauri/Cargo.toml character_avatar_update_snapshot_does_not_restore_deleted_file_metadata passed.
  • pnpm typecheck passed.
  • pnpm check passed.

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 for persisted avatar payload shape; no new discoverable feature.

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 or release-note update was made because this is an internal storage payload-shape bugfix and the repo has no changelog/release-notes file to update.

UI evidence

N/A. No visual layout change; verification is storage contract and type/check proof.

Remaining risk

  • Existing records that already contain inline avatar data are not migrated in this PR.
  • Generated assistant image attachments and generated NPC portrait persistence are separate follow-up work.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Avatar files are now intelligently preserved when referenced within message history and persona snapshots, preventing unintended deletion
    • Avatar metadata is now properly stored and retrieved for consistent display
  • Improvements

    • Optimized avatar data handling and file management across the application
    • Enhanced avatar resolution for improved consistency in conversation displays

🔄 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/2048 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/3/2026 **Status:** ✅ Merged **Merged:** 6/3/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/avatar-upload-managed-assets` --- ### 📝 Commits (1) - [`6a6576f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a6576fd975798a1b3d9e8bba83f742481770d87) storage: store uploaded avatars as managed assets ### 📊 Changes **15 files changed** (+562 additions, -56 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/avatars.rs` (+452 -10) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+2 -1) 📝 `src-tauri/src/commands/storage/media_uploads.rs` (+2 -18) 📝 `src/engine/contracts/types/chat.ts` (+2 -0) 📝 `src/engine/generation/persona-snapshot.ts` (+2 -0) 📝 `src/features/catalog/personas/hooks/use-personas.ts` (+33 -10) 📝 `src/features/catalog/personas/query-keys.ts` (+1 -1) 📝 `src/features/modes/conversation/components/ConversationInput.tsx` (+8 -3) 📝 `src/features/modes/conversation/components/ConversationMessage.tsx` (+24 -3) 📝 `src/features/modes/shared/chat-ui/components/ChatMessage.tsx` (+20 -4) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.test.tsx` (+3 -0) 📝 `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts` (+9 -5) 📝 `src/features/modes/shared/chat-ui/index.ts` (+1 -0) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+1 -1) 📝 `src/features/runtime/visuals/types.ts` (+2 -0) </details> ### 📄 Description ## Linked issue N/A ## Why this change - Avatar uploads decoded and wrote managed files, but then kept inline `data:image/...` payloads in live `avatar` and `avatarPath` fields. That made character, persona, NPC, chat, and game hot paths carry large base64 strings. ## What changed - Store uploaded character, persona, and NPC avatars as managed asset URLs in `avatar`/`avatarPath` while preserving `avatarFilePath` and `avatarFilename` metadata. - Added Rust coverage for character, persona, and NPC avatar upload return/storage shape. - Switched chat/conversation character and persona reads to projected summary records so managed avatars do not force full inline avatar payload reads. - Removed the stale full active-persona cache path and pointed generation's cached persona snapshot lookup at the projected active summary cache. ## Refactor impact Primary owner: Rust storage, catalog persona hooks, and shared chat/conversation hot-path reads. Impact areas reviewed: - Character avatar upload storage - Persona avatar upload storage - NPC avatar upload response shape used by game/tracker callers - Chat surface character and persona lookup paths - Conversation input persona status lookup - Generation optimistic persona snapshot cache lookup Boundary notes: - Rust storage owns the upload persistence contract. - Feature code continues to use catalog hooks and `storageApi`; no new raw Tauri or remote-runtime calls were added. - Engine code was not coupled to feature or shared API adapters. - Existing character version/export paths still inline avatar data only for compatibility snapshots/exports. Pressure points touched: - Shared chat UI hook and conversation input were touched for projected reads. - No `ModeSurface`, `GameSurface`, `src-tauri/src/lib.rs`, or import module changes. ## 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 - `cargo test --manifest-path src-tauri/Cargo.toml avatar_upload` passed. - `cargo test --manifest-path src-tauri/Cargo.toml character_avatar_update_snapshot_does_not_restore_deleted_file_metadata` passed. - `pnpm typecheck` passed. - `pnpm check` passed. ## 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 for persisted avatar payload shape; no new discoverable feature. ## 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 or release-note update was made because this is an internal storage payload-shape bugfix and the repo has no changelog/release-notes file to update. ## UI evidence N/A. No visual layout change; verification is storage contract and type/check proof. ## Remaining risk - Existing records that already contain inline avatar data are not migrated in this PR. - Generated assistant image attachments and generated NPC portrait persistence are separate follow-up work. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Bug Fixes** * Avatar files are now intelligently preserved when referenced within message history and persona snapshots, preventing unintended deletion * Avatar metadata is now properly stored and retrieved for consistent display * **Improvements** * Optimized avatar data handling and file management across the application * Enhanced avatar resolution for improved consistency in conversation displays <!-- 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:05 +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#5413
No description provided.