[PR #1658] [MERGED] Fix character avatar path normalization #5189

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1658
Author: @Xelvanis
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/avatar-path-panel-crash


📝 Commits (1)

  • 60582fe Fix character avatar path normalization

📊 Changes

8 files changed (+708 additions, -29 deletions)

View changed files

📝 src-tauri/Cargo.lock (+1 -0)
📝 src-tauri/Cargo.toml (+1 -0)
📝 src-tauri/src/commands/storage/commands/profile.rs (+344 -7)
📝 src-tauri/src/http_dispatch.rs (+42 -5)
📝 src/features/catalog/characters/hooks/use-characters.test.ts (+253 -8)
📝 src/features/catalog/characters/hooks/use-characters.ts (+43 -8)
📝 src/features/catalog/personas/hooks/use-personas.test.tsx (+21 -0)
📝 src/features/catalog/personas/hooks/use-personas.ts (+3 -1)

📄 Description

Summary

  • Normalize character avatar records through the catalog/characters hook layer.
  • Request avatarPath in character list projections so legacy inline-only avatars are still available to panels, while managed avatars continue to prefer avatarFilePath/avatarFilename.
  • Keep character and persona normalized rows consistent by writing avatarPath: null when no avatar fields are present.
  • Allow managed local avatar/media asset URLs to be converted through load_url_binary in both desktop Tauri and remote-runtime dispatch paths, while restricting local binary reads to managed media roots and reading through a no-follow file handle.
  • Cover summary, list, detail, by-id, cache-write, legacy list-avatar, remote-runtime avatar URL, null-avatar normalization, dispatcher parity, and local asset binary failure paths with targeted tests.

Root Cause

The persona fix normalized avatar data at the persona hook boundary, but character hooks could still return either a missing avatarPath for projected managed-avatar rows or the raw embedded avatar payload from detail/by-id reads. Panels that directly used character.avatarPath could still render the unsafe payload or miss the managed URL.

The first character-list patch also omitted avatarPath from the list projection. That kept managed avatars small, but it meant legacy inline-only character rows had no display avatar in list consumers. The list projection now requests avatarPath; the existing storage projection keeps legacy avatarPath while omitting redundant managed embedded payloads when managed avatar file fields are present.

After character avatar paths were normalized, workflows that convert the current avatar URL into a data URL, such as avatar generation references and import-as-persona paths, could receive managed local asset URLs. The existing binary loader only supported remote HTTP(S) URLs, and the remote runtime dispatcher still bypassed the new local loader, so those local managed assets still failed until load_url_binary shared one implementation across desktop and remote dispatch.

Validation

  • cargo test --manifest-path src-tauri/Cargo.toml local_asset_binary --lib
  • cargo test --manifest-path src-tauri/Cargo.toml dispatch_load_url_binary --lib
  • cargo check --manifest-path src-tauri/Cargo.toml
  • pnpm test -- src/features/catalog/characters/hooks/use-characters.test.ts src/features/catalog/personas/hooks/use-personas.test.tsx
  • pnpm test -- src/features/catalog/characters/hooks/use-characters.test.ts src/features/catalog/personas/hooks/use-personas.test.tsx src/shared/lib/url-blob.test.ts src/shared/api/url-binary-api.test.ts
  • pnpm typecheck
  • pnpm check:architecture
  • pnpm build

Notes

  • No changelog entry: no changelog, changeset, or release-notes file was found in the repo.
  • Native Tauri panel click-through with real profile data is still useful manual QA.

🔄 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/1658 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/avatar-path-panel-crash` --- ### 📝 Commits (1) - [`60582fe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/60582fe35a6064e78bc2345b602daa578561628a) Fix character avatar path normalization ### 📊 Changes **8 files changed** (+708 additions, -29 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/Cargo.lock` (+1 -0) 📝 `src-tauri/Cargo.toml` (+1 -0) 📝 `src-tauri/src/commands/storage/commands/profile.rs` (+344 -7) 📝 `src-tauri/src/http_dispatch.rs` (+42 -5) 📝 `src/features/catalog/characters/hooks/use-characters.test.ts` (+253 -8) 📝 `src/features/catalog/characters/hooks/use-characters.ts` (+43 -8) 📝 `src/features/catalog/personas/hooks/use-personas.test.tsx` (+21 -0) 📝 `src/features/catalog/personas/hooks/use-personas.ts` (+3 -1) </details> ### 📄 Description ## Summary - Normalize character avatar records through the catalog/characters hook layer. - Request `avatarPath` in character list projections so legacy inline-only avatars are still available to panels, while managed avatars continue to prefer `avatarFilePath`/`avatarFilename`. - Keep character and persona normalized rows consistent by writing `avatarPath: null` when no avatar fields are present. - Allow managed local avatar/media asset URLs to be converted through `load_url_binary` in both desktop Tauri and remote-runtime dispatch paths, while restricting local binary reads to managed media roots and reading through a no-follow file handle. - Cover summary, list, detail, by-id, cache-write, legacy list-avatar, remote-runtime avatar URL, null-avatar normalization, dispatcher parity, and local asset binary failure paths with targeted tests. ## Root Cause The persona fix normalized avatar data at the persona hook boundary, but character hooks could still return either a missing `avatarPath` for projected managed-avatar rows or the raw embedded avatar payload from detail/by-id reads. Panels that directly used `character.avatarPath` could still render the unsafe payload or miss the managed URL. The first character-list patch also omitted `avatarPath` from the list projection. That kept managed avatars small, but it meant legacy inline-only character rows had no display avatar in list consumers. The list projection now requests `avatarPath`; the existing storage projection keeps legacy `avatarPath` while omitting redundant managed embedded payloads when managed avatar file fields are present. After character avatar paths were normalized, workflows that convert the current avatar URL into a data URL, such as avatar generation references and import-as-persona paths, could receive managed local asset URLs. The existing binary loader only supported remote HTTP(S) URLs, and the remote runtime dispatcher still bypassed the new local loader, so those local managed assets still failed until `load_url_binary` shared one implementation across desktop and remote dispatch. ## Validation - `cargo test --manifest-path src-tauri/Cargo.toml local_asset_binary --lib` - `cargo test --manifest-path src-tauri/Cargo.toml dispatch_load_url_binary --lib` - `cargo check --manifest-path src-tauri/Cargo.toml` - `pnpm test -- src/features/catalog/characters/hooks/use-characters.test.ts src/features/catalog/personas/hooks/use-personas.test.tsx` - `pnpm test -- src/features/catalog/characters/hooks/use-characters.test.ts src/features/catalog/personas/hooks/use-personas.test.tsx src/shared/lib/url-blob.test.ts src/shared/api/url-binary-api.test.ts` - `pnpm typecheck` - `pnpm check:architecture` - `pnpm build` ## Notes - No changelog entry: no changelog, changeset, or release-notes file was found in the repo. - Native Tauri panel click-through with real profile data is still useful manual QA. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:04 +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#5189
No description provided.