[GH-ISSUE #2106] 4. Media and assets #1028

Closed
opened 2026-10-21 05:25:20 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2106

Originally assigned to: @Promansis on GitHub.

Target 4: Media And Assets

target: 4
name: Media and assets
scan_status: reported
parity_verdict: on_par
proof_level: focused_test
scan_refactor: refactor, 2026-06-04
legacy_ref: main branch
report: https://github.com/Pasta-Devs/Marinara-Engine/issues/1904#issuecomment-4602089938
foundation_rescan: 2026-06-04
background_game_assets_rescan: 2026-06-04
catalog_media_edges_rescan: 2026-06-04
defer_cross_target_dependencies: 2026-06-04
last_refreshed: 2026-06-04
closure_rescan: 2026-06-04

Scope

Included:

  • Managed assets for avatars, backgrounds, fonts, game assets, lorebook images, thumbnails, and gallery images.
  • Remote asset routing and remote-safe managed asset URLs.
  • Chat gallery and character gallery storage.
  • Settings background picker and game-mode background resolution.
  • Gallery orphan recovery.
  • Sprite library list payloads, sprite CRUD, sprite owner namespacing, and runtime sprite consumers.
  • Game asset manifest, seeded defaults, browser/file operations, and public/default assets.

Not checked:

  • Full native/browser render sweep for every rendered media consumer; this closure pass used static/code proof and focused tests rather than a full app/Tauri media walkthrough.
  • Adjacent/cross-target media surfaces stay dependency notes unless their owning targets pull them in.
  • Profile import/export media round-trip, bot-browser avatar proxies, tracker/journal portraits, chat attachment lightboxes, and shell/static Mari assets are inventoried as adjacent/later surfaces only, with explicit routing in the deferred dependency pass below.

Closure Rescan 2026-06-04

Audit gate:

  • Mode: full target refresh focused on the remaining Target 4 blockers after #2107, #2109, #2110, #2111, and #2112 closed.
  • Refactor checkout: origin/refactor at 089e1d72.
  • Legacy reference: origin/main.
  • Proof target: static legacy/refactor trace plus focused Rust tests for Google Fonts safety, backgrounds, asset-manifest bridge behavior, and sprite storage. No full native/browser media render sweep was run.

Verdict:

  • Target 4 is on_par for the scanned media/assets contract. No open Target 4 blocker remains.
  • #2107 is resolved: GameSurface now scopes runtime reset, media reset, scene restore, intro presentation, and last resolved background cache by activeChatId:gameId, matching the legacy sceneRuntimeScopeKey.
  • #2111 is resolved: the five legacy nested music paths and two exploration SFX files are restored in the default game assets bundle and manifest.
  • #2112 is resolved: Google Fonts downloads now have per-family in-flight guarding, CSS2 plus legacy endpoint fallback/richer face selection, and temp/backup metadata replacement with rollback.
  • #2109 and #2110 are closed with code/static coverage: character sprite download failure feedback is now guarded like persona downloads, and runtime sprite resolution prefers expression sprites unless fullBodyOnly is set. Rendered browser/native proof for every sprite flow was not rerun in this closure pass.

Evidence:

  • Refactor src/features/modes/game/components/GameSurface.tsx defines sceneRuntimeScopeKey from chatMeta.gameId and uses it for reset/cache refs; legacy origin/main:packages/client/src/components/game/GameSurface.tsx uses the same chat-plus-game scope.
  • Refactor src-tauri/resources/default-data/game-assets/manifest.json and bundled files contain the restored legacy music paths plus sfx/exploration/bed-creak.wav and sfx/exploration/wet-squelch.wav; legacy origin/main:packages/server/src/assets/default-game-assets contains the same paths.
  • Refactor src-tauri/src/commands/storage/fonts.rs now has GoogleFontDownloadGuard, CSS2 plus legacy CSS probing, managed Google font file replacement with backup/rollback, and temp-file metadata replacement.
  • Refactor src/features/catalog/characters/components/CharacterSpritesTab.tsx now catches sprite download failures and shows the visible error toast already present in PersonaSpritesTab.
  • Refactor src/features/runtime/visuals/components/SpriteOverlay.tsx uses expression sprite pools before full-body pools for normal overlays and keeps fullBodyOnly overlays restricted to full-body sprites.

Focused proof commands passed:

  • cargo test --manifest-path src-tauri/Cargo.toml google_font - 5 passed, 0 failed.
  • cargo test --manifest-path src-tauri/Cargo.toml background - 7 passed, 0 failed.
  • cargo test --manifest-path src-tauri/crates/assets/Cargo.toml managed_background_bridge_does_not_overwrite_explicit_game_asset_tags - 1 passed, 0 failed.
  • cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests - 8 passed, 0 failed.

Coverage notes:

  • cargo test --manifest-path src-tauri/Cargo.toml manifest passed 6 tests, but that filter did not include a default-game-asset inventory test; default asset closure is backed by static file/manifest inventory and #2121 proof notes.
  • The deferred media rows for profile import/export, bot-browser avatar proxies, tracker/journal portraits, chat attachment lightboxes, and static shell assets remain routed to targets 20, 21, 19, 14, and 9. They are not Target 4 blockers.
  • A future full native/browser media walkthrough can still raise UI-only regressions, but this scan found no current Target 4 gap from the known blocker list.

Deferred Cross-Target Dependency Pass 2026-06-04

Audit gate:

  • Rows: 04-MA-COMPAT-profile-import-export-assets, 04-MA-REMOTE-bot-browser-avatar-proxies, 04-MA-UI-tracker-journal-portraits, 04-MA-UI-chat-attachment-images, 04-MA-UI-static-shell-assets.
  • Goal: keep target 4 focused on managed media/assets while recording adjacent media dependencies for targets 20, 21, 19, 14, and shared chat UI.
  • Proof target: static refactor-vs-legacy trace only; no app/Tauri/browser proof and no blocker filing from this pass.

Verdict:

  • These rows should remain dependency notes, not target 4 blockers, and should not expand target 4 rescan scope.
  • Profile import/export media round-trip belongs to target 20 (Import, export, and backup). Refactor has managed profile asset manifests/backups for avatars, sprites, backgrounds, gallery, game assets, fonts, knowledge sources, and lorebook images, but full destructive import/export/backup round-trip proof is owned by target 20.
  • Bot-browser avatar proxies belong to target 21 (Shell and integrations), with an avatar-import dependency if the importer path is being rescanned. Refactor and legacy both proxy external provider avatar URLs and convert downloaded avatars during import.
  • Tracker/journal portraits belong to target 19 (Tracker, world state, and visuals) plus shared chat UI where quick switchers or message avatars consume the same avatar data.
  • Chat attachment lightboxes belong to target 14 (Shared chat UI) and may also inform target 9 message attachment storage/payload checks; they are media UI consumers outside the managed gallery asset foundation.
  • Static shell assets belong to target 21 and app/shell discovery/onboarding surfaces. Public Mari/tutorial/Spotify/player sprites are static bundle assets, not managed user media.

Evidence:

  • Refactor profile assets include managed directories in src-tauri/src/commands/storage/profile/assets.rs; backups copy the same media directories and include restore notes in src-tauri/src/commands/storage/backup.rs.
  • Legacy profile import/export UI and server routes are under main:packages/client/src/components/panels/SettingsPanel.tsx and main:packages/server/src/routes/import.routes.ts; target 20 should prove round-trip semantics rather than target 4.
  • Refactor bot-browser avatar routes are built in src/features/shell/bot-browser/components/BotBrowserView.tsx and proxied through src-tauri/src/commands/storage/bot_browser.rs; legacy used /api/bot-browser/*/avatar/* in main:packages/client/src/components/bot-browser/BotBrowserView.tsx.
  • Refactor tracker/game portrait consumers are in src/features/runtime/tracker/hooks/use-tracker-panel-model.ts, src/features/runtime/tracker/components/FeaturedCharacterPortrait.tsx, and src/features/modes/game/components/GameJournal.tsx; legacy counterparts are tracker-panel and game journal surfaces under main:packages/client/src/features/tracker-panel and main:packages/client/src/components/game/GameJournal.tsx.
  • Refactor chat attachment and image lightbox handling is in src/features/modes/shared/chat-ui/components/ChatMessage.tsx, src/features/modes/conversation/components/ConversationMessage.tsx, and src/features/runtime/visuals/components/PinnedImageOverlay.tsx; legacy equivalents live under main:packages/client/src/components/chat/ChatMessage.tsx, ConversationMessage.tsx, and PinnedImageOverlay.tsx.
  • Refactor static shell assets are referenced by src/features/shell/mari/components/ProfessorMariSurface.tsx, src/features/shell/onboarding/components/OnboardingTutorial.tsx, src/features/modes/game/components/GameTutorial.tsx, and src/features/shell/spotify/components/SpotifyMiniPlayer.tsx; legacy equivalents are in main:packages/client/src/components/onboarding, main:packages/client/src/components/game/GameTutorial.tsx, and main:packages/client/src/components/spotify/SpotifyMiniPlayer.tsx.

Routing:

  • Target 20: profile import/export media and backup archive proof.
  • Target 21: bot-browser avatar proxies and static shell/Mari/tutorial/Spotify assets.
  • Target 19: tracker/world-state/game journal portraits.
  • Target 14: shared chat attachment lightboxes and message image rendering.
  • Target 9: only if attachment storage/payload shape becomes part of chats/messages parity.

Coverage note:

  • Open issue search found no separate current duplicate for these deferred dependency rows beyond this target detail issue.

Catalog Media Edges Rescan 2026-06-04

Audit gate:

  • Rows: 04-MA-ASSET-avatar-managed-files, 04-MA-ASSET-font-files, 04-MA-ASSET-lorebook-images, 04-MA-ASSET-public-default-assets.
  • Refactor owner: src-tauri/src/commands/storage/avatars.rs, src-tauri/src/commands/storage/fonts.rs, src-tauri/src/commands/storage/lorebook_images.rs, src-tauri/src/http_server.rs, src/shared/api/local-file-api.ts, src/shared/api/settings-assets-api.ts, src/shared/api/lorebook-command-api.ts, src/features/catalog/characters, src/features/catalog/personas, src/features/catalog/lorebooks, public, src-tauri/resources/default-data, src-tauri/src/state.rs, src-tauri/tauri.conf.json.
  • Legacy owner: main:packages/server/src/routes/avatars.routes.ts, main:packages/server/src/routes/characters.routes.ts, main:packages/server/src/routes/fonts.routes.ts, main:packages/server/src/routes/lorebooks.routes.ts, main:packages/client/src/App.tsx, main:packages/client/src/components/characters, main:packages/client/src/components/personas, main:packages/client/src/hooks/use-lorebooks.ts, main:packages/client/public, main:packages/server/src/assets/default-*, main:packages/server/src/db/seed-*.
  • Risk: medium for catalog media edges; user-owned avatar/font/lorebook/default media must remain file-backed, routable, and compatible with legacy data.
  • Proof target: static legacy/refactor trace plus focused Rust tests where filters exist; no app/browser/Tauri render proof.

Verdict:

  • No confirmed regression found for avatar managed files or lorebook images. Avatar handling is refactor-better because current rows store managed file metadata and generate/cache safe thumbnails while preserving crop paths.
  • Font files are on par after the closure rescan: refactor keeps list/serve/register/open-folder/Google-download behavior, and #2123 restored Google Fonts duplicate/concurrent download guard, CSS2 plus legacy CSS fallback for richer shard coverage, and atomic replace/rollback for managed Google font files.
  • Public/static Mari sprites and default backgrounds match legacy by filename, and refactor bundles/seeds resources/default-data. #2121 restored the default game asset legacy nested music paths/tags and the two exploration SFX files, so the public/default asset row is on par for this scan.
  • Lorebook images are statically on par/refactor-better for upload, managed metadata, managed serving, thumbnail use, and stale image cleanup on replacement; delete-time cleanup was not separately app-proven.

Evidence:

  • Refactor avatar uploads persist avatar, avatarPath, avatarFilePath, avatarFilename, and avatarUpdatedAt, clear avatar crop on removal, remove stale managed files/thumbnails, and preserve persona avatar files referenced by message snapshots in src-tauri/src/commands/storage/avatars.rs.
  • Refactor avatar thumbnails validate allowed sizes, reject sources outside managed avatar roots, cache resized thumbnails under .avatar-thumbnails, support inline fallback thumbnails, and route through /api/assets/avatar-thumbnail/... in src-tauri/src/commands/storage/avatars.rs and src-tauri/src/http_server.rs.
  • Refactor character/persona catalog avatar components prefer managed file URLs and thumbnails while preserving crop styling in src/features/catalog/characters/components/CharacterAvatarImage.tsx and src/features/catalog/personas/components/PersonaAvatarImage.tsx.
  • Legacy avatar routes served /api/avatars/file/:filename, uploaded NPC avatars under /api/avatars/npc/:chatId, and character/persona avatar writes stored /api/avatars/file/<filename> in main:packages/server/src/routes/avatars.routes.ts and main:packages/server/src/routes/characters.routes.ts.
  • Refactor fonts list data/fonts, serves supported font files through managed asset routes, opens the fonts folder, downloads Google Font woff2 shards, stores font-metadata.json, registers app fonts from src/app/App.tsx, and now has the legacy concurrent/atomic/fallback handling in src-tauri/src/commands/storage/fonts.rs.
  • Refactor lorebook image upload stores marinara-lorebook-image:<filename>, imageFilePath, imageFilename, and imageUpdatedAt, removes the previous managed file, serves through /api/assets/lorebook/..., and renders panel thumbnails via managed thumbnail resolution. Legacy uploaded to /api/lorebooks/:id/image and stored /api/lorebooks/images/file/<filename>.
  • Static inventory found current public/sprites/mari filenames match legacy packages/client/public/sprites/mari. Current src-tauri/resources/default-data/backgrounds matches legacy default-background filenames, with current-only meta.json.
  • Closure rescan inventory found current default game assets restored the legacy mood/theme music subfolders (music/combat/fantasy/intense/battle-epic.mp3, etc.) and restored sfx/exploration/bed-creak.wav plus sfx/exploration/wet-squelch.wav.

Focused proof commands passed:

  • cargo test --manifest-path src-tauri/Cargo.toml avatar - 33 passed, 0 failed.
  • cargo test --manifest-path src-tauri/Cargo.toml seed - 4 passed, 0 failed.
  • cargo test --manifest-path src-tauri/Cargo.toml background - 7 passed, 0 failed.

Coverage notes:

  • cargo test --manifest-path src-tauri/Cargo.toml font, cargo test --manifest-path src-tauri/Cargo.toml lorebook_image, and cargo test --manifest-path src-tauri/Cargo.toml game_assets matched 0 tests.
  • No browser/native render proof was run for avatar thumbnails, font application, lorebook thumbnails, static shell sprites, or default game asset runtime resolution.

Suggested follow-ups:

  • Closed by #2123: legacy Google Font safety around concurrent downloads, dual CSS endpoint fallback, and atomic replacement/rollback is restored.
  • Closed by #2121: legacy default music paths/tags and the two exploration SFX files are restored.

Background And Game Assets Rescan 2026-06-04

Audit gate:

  • Rows: 04-MA-UI-settings-background-picker, 04-MA-RUNTIME-chat-background-persistence, 04-MA-ASSET-game-asset-manifest, 04-MA-RUNTIME-game-background-resolution, 04-MA-UI-game-assets-browser-ops.
  • Refactor owner: src/features/shell/settings/components/SettingsPanel.tsx, src/shared/lib/backgrounds.ts, src/features/runtime/generation/hooks/use-generate.ts, src/features/modes/game/stores/game-asset.store.ts, src/features/modes/game/components/GameSurface.tsx, src/features/modes/game-assets, src/shared/api/assets-api.ts, src/shared/api/remote-runtime.ts, src-tauri/src/commands/storage/backgrounds.rs, src-tauri/src/commands/storage/game_assets.rs, src-tauri/crates/assets/src/lib.rs, src-tauri/src/http_dispatch.rs.
  • Legacy owner: main:packages/client/src/components/panels/SettingsPanel.tsx, main:packages/client/src/lib/backgrounds.ts, main:packages/client/src/components/game/GameSurface.tsx, main:packages/client/src/components/game-assets, main:packages/client/src/hooks/use-game-assets.ts, main:packages/server/src/routes/backgrounds.routes.ts, main:packages/server/src/routes/game-assets.routes.ts, main:packages/server/src/services/game/asset-manifest.service.ts.
  • Risk: high for settings/game/runtime/storage bridge; same asset state feeds game prompts, scene display, and persisted chat metadata.
  • Proof target: static legacy/refactor trace plus focused Rust tests for game-asset backgrounds in the picker and the managed user-background manifest bridge.

Verdict:

  • #1928 is validated for the Settings picker row: current refactor lists game asset backgrounds, marks them non-editable/non-deletable, resolves thumbnails through game managed assets, and preserves user background controls.
  • Chat background metadata conversion is statically on par for user backgrounds and gameAsset: metadata.
  • Game asset manifest and browser ops are statically on par with refactor-better remote/embedded routing through typed wrappers and explicit dispatch.
  • Closure rescan update: #2107 is fixed by #2120. Current refactor now scopes runtime media reset and last resolved background cache by activeChatId:gameId, matching legacy.

Evidence:

  • Refactor backgrounds_list merges state.game_assets.manifest().byCategory.backgrounds into picker rows and labels game asset rows as source: "game_asset", editable: false, deletable: false, renameable: false in src-tauri/src/commands/storage/backgrounds.rs.
  • Refactor Settings picker maps background rows, preserves source, uses gameAssetFileUrlFromPath and managed game thumbnails for game asset backgrounds, and keeps user upload/delete/tag/rename paths in src/features/shell/settings/components/SettingsPanel.tsx.
  • Refactor chat background helpers convert marinara-background: and marinara-game-asset: URLs to stored metadata and back, including gameAsset:<path>, in src/shared/lib/backgrounds.ts.
  • Refactor game asset manifest returns live manifest_with_backgrounds, including user backgrounds under backgrounds:user:*, in src-tauri/src/commands/storage/game_assets.rs and src-tauri/crates/assets/src/lib.rs.
  • Refactor game asset browser hooks cover tree, folder create/delete, upload, rescan, folder descriptions, file info, text read/write, single move/copy/delete, and bulk move/copy/delete through src/shared/api/assets-api.ts; remote-capable commands are allowlisted in src/shared/api/remote-runtime.ts and handled in src-tauri/src/http_dispatch.rs. OS folder open remains intentionally non-remote.
  • Legacy /api/backgrounds merged getAssetManifest().byCategory.backgrounds, legacy backgrounds.ts used the same gameAsset: metadata concept, legacy game assets routes exposed equivalent browser operations, and legacy GameSurface scoped scene media/background cache by sceneRuntimeScopeKey = activeChatId:activeGameMetaId.
  • Current refactor GameSurface reset/cache checks now use sceneRuntimeScopeKey for runtime state and lastResolvedBackgroundRef, so the same-chat new/replaced game boundary clears stale scene media/background state like legacy.

Focused proof commands passed:

  • cargo test --manifest-path src-tauri/Cargo.toml list_backgrounds_includes_non_editable_game_asset_backgrounds
  • cargo test --manifest-path src-tauri/crates/assets/Cargo.toml managed_background_bridge_does_not_overwrite_explicit_game_asset_tags

Suggested follow-up:

  • Closed by #2120: game media/background runtime scoping now includes the current gameId; closure rescan marks 04-MA-RUNTIME-game-background-resolution on par.

Audit gate:

  • Rows: 04-MA-STORAGE-chat-gallery-file-backed, 04-MA-STORAGE-character-gallery, 04-MA-ERROR-gallery-orphan-recovery.
  • Refactor owner: src-tauri/src/commands/storage/shared.rs, src-tauri/src/commands/storage/commands/entities.rs, src-tauri/src/commands/storage/commands/media.rs, src-tauri/src/commands/storage/chats.rs, src-tauri/src/state.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.
  • Legacy owner: main:packages/server/src/routes/gallery.routes.ts, main:packages/server/src/routes/characters.routes.ts, main:packages/server/src/services/storage/gallery-recovery.ts, main:packages/server/src/app.ts, main:packages/server/src/services/image/image-generation.ts.
  • Risk: highest data-loss/storage risk for gallery media, managed file cleanup, and orphan recovery.
  • Proof target: static legacy/refactor trace plus focused Rust tests for upload/create conversion, remote dispatch, managed route safety, delete cleanup, and startup recovery.

Verdict:

  • No confirmed regression and no likely parity gap found in these three gallery data-safety rows.
  • 04-MA-STORAGE-chat-gallery-file-backed, 04-MA-STORAGE-character-gallery, and 04-MA-ERROR-gallery-orphan-recovery are clean on current refactor for the rescanned behavior.
  • This validates closed #1927 and #1929 for the requested rows, but does not upgrade the whole target to on_par; #1930 and broader media/UI/runtime rows still need their own rescan, and the game background runtime-scope defect remains open.

Evidence:

  • Refactor gallery upload persists bytes into the managed gallery directory and records filePath, filename, and a non-inline asset URL in src-tauri/src/commands/storage/shared.rs.
  • Refactor storage_create for gallery and character-gallery converts inline data:image payloads from generated/regenerated images into managed gallery files in src-tauri/src/commands/storage/commands/entities.rs.
  • Refactor serves managed gallery files through /api/assets/gallery/* in src-tauri/src/http_server.rs and supports chat/character gallery upload over remote dispatch in src-tauri/src/http_dispatch.rs.
  • Refactor gallery delete, chat delete, and character delete remove managed gallery files through registered media cleanup in src-tauri/src/commands/storage/commands/entities.rs and src-tauri/src/commands/storage/chats.rs.
  • Refactor startup recovery scans legacy data_dir/gallery/<chatId> orphan files, creates gallery rows, removes recovered source files, and is idempotent in src-tauri/src/state.rs.
  • Legacy stored chat gallery files under data/gallery/<chatId>, character gallery files under data/gallery/characters/<id>, served direct file routes, and ran recoverGalleryImages(db) on startup.

Focused proof command passed:

  • cargo test --manifest-path src-tauri/Cargo.toml gallery - 13 passed, 0 failed.

Adjacent note:

  • Profile import/export media round-trip remains routed to target 20. This pass did not treat profile import's renderable-data-URL compatibility path as a target-4 blocker.

Foundation Rescan 2026-06-04

Audit gate:

  • Rows: 04-MA-API-media-route-registration, 04-MA-REMOTE-managed-asset-routing, 04-MA-REMOTE-raw-path-denial, 04-MA-ASSET-managed-thumbnails.
  • Refactor owner: src/shared/api/local-file-api.ts, src/shared/api/remote-runtime.ts, src-tauri/src/http_server.rs, src-tauri/src/http_dispatch.rs, src-tauri/src/commands/storage/managed_thumbnails.rs, src-tauri/src/commands/storage/commands/profile.rs.
  • Legacy owner: main:packages/server/src/routes/index.ts, main:packages/server/src/app.ts, direct main:packages/server/src/routes/*/file media routes.
  • Risk: high for raw local path denial; medium for URL resolution foundation rows.
  • Proof target: static code trace plus focused Rust tests for positive managed URL resolution and negative raw/local path controls.

Verdict:

  • No confirmed regression and no likely parity gap found in these four foundation rows.
  • Refactor is on par for route registration and managed asset routing, and refactor is better for raw path denial plus managed thumbnail support.
  • This does not upgrade the whole target to on_par; later UI/runtime media consumers still need their own rescan/proof.

Evidence:

  • Refactor registers /api/assets/:kind/*path in src-tauri/src/http_server.rs and maps managed kinds for avatar, avatar-thumbnail, background, font, gallery, game, lorebook, thumbnail, and sprite in managed_asset_path.
  • Refactor URL helpers build remote-safe /api/assets/<kind>/<path> URLs in src/shared/api/local-file-api.ts; embedded mode still falls back to shell-local file URL conversion where appropriate.
  • Refactor keeps raw local path commands out of remote /api/invoke: background_file_path, game_assets_file_path, and lorebook_image_file_path are listed as non-remote in src-tauri/src/http_dispatch.rs, and the dispatch test proves they return unsupported_command.
  • Refactor load_url_binary accepts managed asset URLs only after canonicalizing under the app data directory, restricting to allowed media dirs, rejecting symlinks, and applying a size cap in src-tauri/src/commands/storage/commands/profile.rs.
  • Refactor managed thumbnails are implemented in src-tauri/src/commands/storage/managed_thumbnails.rs, support background/gallery/game/lorebook sources, validate supported sizes, reject sources outside managed assets, and route through /api/assets/thumbnail/....
  • Legacy registered separate media route prefixes in main:packages/server/src/routes/index.ts and served files through direct routes such as main:packages/server/src/routes/avatars.routes.ts, backgrounds.routes.ts, gallery.routes.ts, game-assets.routes.ts, lorebooks.routes.ts, and sprites.routes.ts.

Focused proof commands passed:

  • cargo test --manifest-path src-tauri/Cargo.toml dispatch_rejects_remote_raw_server_path_commands
  • cargo test --manifest-path src-tauri/Cargo.toml managed_thumbnail
  • cargo test --manifest-path src-tauri/Cargo.toml asset_path_routes
  • cargo test --manifest-path src-tauri/Cargo.toml gallery_asset_path_rejects_path_tokens
  • cargo test --manifest-path src-tauri/Cargo.toml sprite_asset_path_rejects_path_tokens
  • cargo test --manifest-path src-tauri/Cargo.toml local_asset_binary

Sprite Rescan 2026-06-04

Audit gate:

  • Rows: 04-MA-PERF-sprite-list-metadata-urls, 04-MA-ASSET-sprite-editor-crud, 04-MA-ASSET-sprite-owner-namespace, 04-MA-RUNTIME-runtime-sprite-consumers.
  • Refactor owner: src-tauri/src/commands/storage/sprites.rs, src/shared/api/image-generation-api.ts, src/shared/api/local-file-api.ts, src/features/catalog/sprites/hooks/use-sprites.ts, src/features/catalog/characters/components/CharacterSpritesTab.tsx, src/features/catalog/personas/components/sprites/PersonaSpritesTab.tsx, src/features/runtime/visuals/components/SpriteOverlay.tsx, src/features/runtime/tracker/components/tracker-sprite.helpers.ts.
  • Legacy owner: main:packages/server/src/routes/sprites.routes.ts, main:packages/client/src/hooks/use-characters.ts, main:packages/client/src/components/chat/SpriteOverlay.tsx, main:packages/client/src/features/tracker-panel.
  • Risk: medium-high for media payload size, owner compatibility, and runtime sprite visibility.
  • Proof target: static legacy/refactor trace plus focused Rust tests for non-inline list payloads, CRUD backend paths, owner namespace separation, legacy persona migration, and negative controls.

Verdict:

  • No confirmed regression and no likely parity gap found in the requested sprite rows.
  • #1930 is validated: current refactor sprite list responses return metadata and resolvable managed URLs instead of eager base64 image bytes.
  • Character/persona sprite editor CRUD is statically covered through shared hooks and editor wiring, with focused backend proof for upload/bulk-upload/delete/list behavior. Download/framing/wand-cleanup remain UI-wired but not browser-proven.
  • Sprite owner namespace is on par/refactor-better: persona sprites use a separate namespace, unambiguous legacy persona dirs migrate, and conflicts fail without overwriting.
  • Runtime sprite consumers are statically covered in roleplay/game/tracker paths, but not upgraded beyond static proof because rendered app/browser proof was not run.

Evidence:

  • Refactor sprite_info_from_path returns expression, filename, absolutePath, ownerId, ownerType, size, cacheKey, and a cache-busted file-backed asset URL in src-tauri/src/commands/storage/sprites.rs; it does not encode sprite bytes into the list response.
  • Refactor sprite API wrapper resolves sprite records through resolveSpriteFileUrl, which maps owner type/id/filename to remote-safe /api/assets/sprite/<ownerType>/<ownerId>/<filename> URLs or embedded file URLs in src/shared/api/image-generation-api.ts and src/shared/api/local-file-api.ts.
  • Refactor hooks cover list, upload, bulk upload, delete, cleanup saved sprites, and cleanup restore for both character and persona owners in src/features/catalog/sprites/hooks/use-sprites.ts.
  • Refactor character and persona sprite tabs wire list/upload/delete/download/framing/wand-cleanup/saved-cleanup flows through the shared sprite hooks in src/features/catalog/characters/components/CharacterSpritesTab.tsx and src/features/catalog/personas/components/sprites/PersonaSpritesTab.tsx.
  • Refactor SpriteOwnerKind accepts character and persona, defaults omitted owner type to character, rejects blank/invalid owner types, stores personas under sprites/personas/<id>, and migrates unambiguous legacy persona dirs in src-tauri/src/commands/storage/sprites.rs.
  • Refactor runtime SpriteOverlay consumes owner-aware sprite hooks, maps agent and saved expressions through owner keys, chooses expression/full-body sprite pools, and renders resolved URLs; tracker portrait helpers resolve sprite expressions and sprite URLs for character/persona tracker surfaces.
  • Legacy sprite list returned /api/sprites/<characterId>/file/<filename>?v=<mtime> from main:packages/server/src/routes/sprites.routes.ts, and legacy useCharacterSprites/SpriteOverlay consumed that URL list from main:packages/client/src/hooks/use-characters.ts and main:packages/client/src/components/chat/SpriteOverlay.tsx.

Focused proof command passed:

  • cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests - 8 passed, 0 failed.

Coverage note:

  • This validates closed #1930 and the owner-namespace backend behavior. It does not provide native/browser visual proof that roleplay/game/tracker rendered sprites are visible in-app.

Surface Inventory

Surface ID Surface Bucket Source Legacy owner Refactor owner In scope Notes
04-MA-API-media-route-registration Media and asset route/command registration for backgrounds, avatars, sprites, fonts, gallery, and game assets. API both legacy packages/server/src/routes/index.ts, packages/server/src/app.ts src/shared/api/remote-runtime.ts, src-tauri/src/http_dispatch.rs, src-tauri/src/http_server.rs yes Baseline entrypoint map for every target-4 media command/route. Foundation rescan 2026-06-04 found no gap.
04-MA-REMOTE-managed-asset-routing Managed asset URL resolution and remote HTTP serving for background, gallery, avatar, font, game, lorebook, thumbnail, and sprite files. REMOTE both legacy direct /api/*/file routes src/shared/api/local-file-api.ts, src-tauri/src/http_server.rs, src-tauri/src/http_dispatch.rs yes Refactor uses marinara-* schemes plus /api/assets; legacy used server file routes. Foundation rescan 2026-06-04 found refactor better.
04-MA-REMOTE-raw-path-denial Remote runtime rejects raw local file path commands while allowing managed asset routes. ERROR refactor_only not found src-tauri/src/http_dispatch.rs, src/shared/api/local-file-api.ts yes Refactor-only safety surface for hostable runtime. Foundation rescan 2026-06-04 has focused negative-control proof.
04-MA-ASSET-avatar-managed-files Character, persona, and NPC avatars store/serve managed files with crop/thumbnail metadata. ASSET both legacy packages/server/src/routes/avatars.routes.ts, packages/server/src/routes/characters.routes.ts, packages/shared/src/types src-tauri/src/commands/storage/avatars.rs, src/shared/api/avatar-api.ts, src/shared/api/local-file-api.ts, src/features/catalog/*/*AvatarImage.tsx yes Catalog media edges rescan 2026-06-04 found refactor-better managed metadata, thumbnail cache, cleanup, and focused avatar tests.
04-MA-ASSET-font-files Custom fonts and Google Font downloads are stored, served, listed, registered, concurrency-guarded, endpoint-fallback aware, and atomically replaced. ASSET both legacy packages/server/src/routes/fonts.routes.ts, packages/client/src/App.tsx, packages/client/src/components/panels/SettingsPanel.tsx src-tauri/src/commands/storage/fonts.rs, src/shared/api/settings-assets-api.ts, src/features/shell/settings/components/SettingsPanel.tsx yes Closure rescan 2026-06-04 found Google Fonts safety parity restored by #2123: duplicate download guard, CSS2/legacy fallback, and temp/backup rollback proof.
04-MA-UI-settings-background-picker Settings background picker lists user backgrounds and game asset backgrounds, with upload/delete/rename/tag controls. UI both legacy packages/server/src/routes/backgrounds.routes.ts, packages/client/src/components/panels/SettingsPanel.tsx, packages/client/src/lib/backgrounds.ts src-tauri/src/commands/storage/backgrounds.rs, src/features/shell/settings/components/SettingsPanel.tsx, src/shared/api/settings-assets-api.ts, src/shared/lib/backgrounds.ts yes Background/game assets rescan 2026-06-04 clean for #1928 picker listing and non-editable game asset rows.
04-MA-RUNTIME-chat-background-persistence Chat background metadata restores, persists, resolves, and renders for roleplay/game surfaces. RUNTIME both legacy packages/client/src/components/chat/ChatArea.tsx, packages/client/src/components/chat/ChatRoleplaySurface.tsx src/features/modes/*, src/features/runtime/generation/hooks/use-generate.ts, src/shared/lib/backgrounds.ts, src/shared/stores/ui.store.ts yes Background/game assets rescan 2026-06-04 found metadata conversion on par for user and game asset backgrounds; app render proof still belongs to mode rows.
04-MA-STORAGE-chat-gallery-file-backed Chat gallery rows use managed files/URLs instead of inline image data. STORAGE both legacy packages/server/src/routes/gallery.routes.ts, packages/server/src/services/storage/gallery.storage.ts, packages/client/src/hooks/use-gallery.ts src-tauri/src/commands/storage/shared.rs, src-tauri/src/commands/storage/commands/entities.rs, src/features/catalog/gallery/hooks/use-gallery.ts, src/features/modes/shared/chat-ui/components/ChatGallery.tsx yes Gallery data safety rescan 2026-06-04 clean; validates #1927 for this row.
04-MA-ERROR-gallery-orphan-recovery Startup recovery re-creates gallery records for orphaned gallery files. ERROR both legacy packages/server/src/services/storage/gallery-recovery.ts, packages/server/src/app.ts src-tauri/src/state.rs yes Gallery data safety rescan 2026-06-04 clean; validates #1929 for this row.
04-MA-STORAGE-character-gallery Character-specific gallery stores reference art separately from chat gallery. STORAGE both legacy packages/server/src/routes/characters.routes.ts, packages/server/src/services/storage/character-gallery.storage.ts, packages/server/src/db/schema/gallery.ts src/features/catalog/characters/components/CharacterGalleryTab.tsx, src/features/catalog/characters/hooks/use-characters.ts, src-tauri/src/commands/storage/commands/media.rs, src-tauri/src/commands/storage/commands/entities.rs yes Gallery data safety rescan 2026-06-04 clean for managed storage, URL resolution, and delete cleanup.
04-MA-ASSET-managed-thumbnails Managed thumbnail API/cache covers background, gallery, game, and lorebook assets. ASSET refactor_only not found src-tauri/src/commands/storage/managed_thumbnails.rs, src/shared/api/local-file-api.ts yes Refactor-better surface; foundation rescan 2026-06-04 has focused command/path proof. UI consumers still need proof in their own rows.
04-MA-ASSET-lorebook-images Lorebook images upload, store, serve, thumbnail, and update image path metadata. ASSET both legacy packages/shared/src/types/lorebook.ts, packages/server/src/routes/lorebooks.routes.ts, packages/client/src/hooks/use-lorebooks.ts src/engine/contracts/types/lorebook.ts, src/engine/contracts/schemas/lorebook.schema.ts, src-tauri/src/commands/storage/lorebook_images.rs, src/features/catalog/lorebooks yes Catalog media edges rescan 2026-06-04 found static parity/refactor-better managed metadata and stale replacement cleanup; delete-time cleanup not app-proven.
04-MA-ASSET-game-asset-manifest Game asset manifest, default seed, categories, and user-background bridge are exposed to game/background flows. ASSET both legacy packages/server/src/services/game/asset-manifest.service.ts, packages/server/src/db/seed-game-assets.ts src-tauri/crates/assets/src/lib.rs, src-tauri/src/commands/storage/game_assets.rs, src-tauri/resources/default-data/game-assets yes Background/game assets rescan 2026-06-04 clean; focused proof covers user-background bridge collision behavior.
04-MA-UI-game-assets-browser-ops Game assets browser supports tree/list, upload, rescan, folder descriptions, file info, text edit, bulk move/copy/delete. UI both legacy packages/server/src/routes/game-assets.routes.ts, packages/client/src/hooks/use-game-assets.ts, packages/client/src/components/game-assets/GameAssetsBrowserView.tsx src/features/modes/game-assets, src/shared/api/assets-api.ts, src-tauri/crates/assets/src/lib.rs, src-tauri/src/http_dispatch.rs yes Background/game assets rescan 2026-06-04 found static parity; remote-capable ops use typed wrappers and explicit dispatch.
04-MA-RUNTIME-game-background-resolution Game runtime resolves selected/generated scene backgrounds from scoped game assets and persists current background metadata. RUNTIME both legacy packages/client/src/stores/game-asset.store.ts, packages/client/src/components/game/GameSurface.tsx src/features/modes/game/stores/game-asset.store.ts, src/features/modes/game/components/GameSurface.tsx, src/features/modes/game/lib/game-asset-selection.ts yes Closure rescan 2026-06-04 found #2107 fixed by #2120: runtime media reset and last-resolved background cache now use chat-plus-game scope.
04-MA-PERF-sprite-list-metadata-urls Sprite list payload returns metadata and asset URLs, not eager base64 image bytes. PERF both legacy packages/server/src/routes/sprites.routes.ts, packages/client/src/hooks/use-characters.ts src-tauri/src/commands/storage/sprites.rs, src/shared/api/image-generation-api.ts, src/features/catalog/sprites/hooks/use-sprites.ts yes Sprite rescan 2026-06-04 clean with focused proof; validates #1930.
04-MA-ASSET-sprite-editor-crud Character and persona sprite editors support list/upload/delete/download/framing/cleanup flows. ASSET both legacy packages/server/src/routes/sprites.routes.ts, packages/client/src/components/chat/SpriteOverlay.tsx, packages/client/src/components/ui/SpriteGenerationModal.tsx src/features/catalog/characters/components/*Sprite*, src/features/catalog/personas/components/sprites, src-tauri/src/commands/storage/sprites.rs yes Static UI wiring plus focused backend CRUD proof remain valid; #2109 closed by #2117 after character sprite download failures gained visible error feedback. Full rendered editor pass was not rerun in this closure scan.
04-MA-ASSET-sprite-owner-namespace Sprite owner type separates character/persona sprite folders and migrates unambiguous legacy persona sprite dirs. COMPAT refactor_only legacy has character-id sprite dirs src-tauri/src/commands/storage/sprites.rs, src/features/catalog/sprites/hooks/use-sprites.ts yes Sprite rescan 2026-06-04 clean/refactor-better with focused namespace and migration tests.
04-MA-RUNTIME-runtime-sprite-consumers Roleplay/game/tracker runtime surfaces consume sprite library data for expression and full-body sprites. RUNTIME both legacy packages/client/src/components/chat/SpriteOverlay.tsx, packages/client/src/components/chat/SpriteSidebar.tsx, packages/client/src/features/tracker-panel src/features/runtime/visuals, src/features/modes/roleplay, src/features/modes/game, src/features/runtime/tracker yes Static runtime wiring remains covered; #2110 closed by #2118 after normal overlays were changed to prefer expression sprites while full-body overlays stay gated by fullBodyOnly. Full rendered runtime sprite pass was not rerun in this closure scan.
04-MA-ASSET-public-default-assets Public sprites, tutorial images, default backgrounds, and default game assets are bundled/seeded. ASSET both legacy packages/client/public, packages/server/src/assets/default-*, packages/server/src/db/seed-* public, src-tauri/resources/default-data, src-tauri/src/state.rs, src-tauri/tauri.conf.json yes Closure rescan 2026-06-04 found #2111 fixed by #2121: legacy nested default music paths and the two exploration SFX files are restored in the bundle and manifest.
04-MA-COMPAT-profile-import-export-assets Profile export/import and backups include managed assets for avatars, sprites, backgrounds, gallery, game assets, fonts, and lorebook images. COMPAT both legacy packages/server/src/routes/characters.routes.ts, packages/server/src/services/import/marinara.importer.ts, packages/server/src/routes/import.routes.ts src-tauri/src/commands/storage/profile/assets.rs, src-tauri/src/commands/storage/backup.rs, src/shared/api/profile-api.ts, src/shared/api/import-api.ts later Route to target 20 for full import/export proof; keep as target-4 dependency.
04-MA-UI-chat-attachment-images Chat message attachments, markdown image rendering, pinned images, and lightbox surfaces render media outside gallery. UI unclear legacy likely packages/client/src/components/chat/ChatMessage.tsx src/features/modes/shared/chat-ui/components/ChatMessage.tsx, src/features/runtime/visuals/components/PinnedImageOverlay.tsx later Adjacent media UI, not part of existing target scope.
04-MA-REMOTE-bot-browser-avatar-proxies External bot-browser avatar proxies and import-time avatar download/conversion. REMOTE both legacy packages/server/src/routes/bot-browser*.routes.ts, packages/client/src/components/bot-browser/BotBrowserView.tsx src/features/shell/bot-browser, src-tauri/src/commands/storage/bot_browser* later Better fit for shell/integration target unless avatar import parity is being rescanned.
04-MA-UI-tracker-journal-portraits Tracker/world-state portraits, NPC journal images, and quick switcher/avatar thumbnails. UI both legacy tracker/game UI paths src/features/runtime/tracker, src/features/modes/game/components/GameJournal.tsx, src/features/modes/shared/chat-ui later Better fit for target 19 and shared chat UI target.
04-MA-UI-static-shell-assets Static Mari/tutorial/Spotify/player sprites and shell avatars outside managed asset pipeline. UI both legacy public/client UI assets public/sprites, src/features/shell/mari, src/features/shell/discovery later Static assets should be noted, not used to decide managed asset parity.

Coverage Matrix

Surface ID Status Proof Follow-up
04-MA-API-media-route-registration covered_static static trace, 2026-06-04
04-MA-REMOTE-managed-asset-routing refactor_better static trace plus focused asset-path tests, 2026-06-04
04-MA-REMOTE-raw-path-denial refactor_better focused negative-control tests, 2026-06-04
04-MA-ASSET-avatar-managed-files refactor_better static trace plus focused avatar tests, 2026-06-04
04-MA-ASSET-font-files on_par static trace plus focused Google Fonts safety tests, 2026-06-04 #2112 CLOSED
04-MA-UI-settings-background-picker on_par static trace plus focused background-picker test, 2026-06-04 #1928
04-MA-RUNTIME-chat-background-persistence covered_static static trace, 2026-06-04
04-MA-STORAGE-chat-gallery-file-backed on_par static trace plus focused gallery tests, 2026-06-04 #1927
04-MA-ERROR-gallery-orphan-recovery on_par static trace plus focused gallery tests, 2026-06-04 #1929
04-MA-STORAGE-character-gallery on_par static trace plus focused gallery tests, 2026-06-04
04-MA-ASSET-managed-thumbnails refactor_better focused thumbnail tests, 2026-06-04
04-MA-ASSET-lorebook-images on_par static trace, 2026-06-04
04-MA-ASSET-game-asset-manifest on_par static trace plus focused manifest bridge test, 2026-06-04
04-MA-UI-game-assets-browser-ops covered_static static trace, 2026-06-04
04-MA-RUNTIME-game-background-resolution on_par static trace after #2120 plus scope-key rescan, 2026-06-04 #2107 CLOSED
04-MA-PERF-sprite-list-metadata-urls on_par static trace plus focused sprite tests, 2026-06-04 #1930
04-MA-ASSET-sprite-editor-crud covered_static static UI trace, focused backend sprite tests, and #2117 download failure feedback, 2026-06-04 #2109 CLOSED
04-MA-ASSET-sprite-owner-namespace refactor_better focused namespace/migration/negative-control tests, 2026-06-04
04-MA-RUNTIME-runtime-sprite-consumers covered_static static trace plus #2118 expression-priority fix, 2026-06-04 #2110 CLOSED
04-MA-ASSET-public-default-assets on_par static inventory after #2121 plus focused background/asset bridge tests, 2026-06-04 #2111 CLOSED

Follow-Ups

Issue State Why it matters
#1927 CLOSED Gallery images were inline data URLs instead of managed files. Gallery data safety rescan clean on 2026-06-04.
#1928 CLOSED Settings picker did not show game asset backgrounds. Background/game assets rescan clean for picker listing on 2026-06-04.
#1929 CLOSED Gallery orphan-file recovery was missing. Gallery data safety rescan clean on 2026-06-04.
#1930 CLOSED Sprite listing eagerly returned base64 payloads. Sprite rescan clean on 2026-06-04.
#2107 CLOSED Fixed by #2120; closure rescan confirmed game media/background scope now includes game id.
#2111 CLOSED Fixed by #2121; closure rescan confirmed legacy default game asset paths and exploration SFX are restored.
#2112 CLOSED Fixed by #2123; closure rescan confirmed Google Fonts guard/fallback/rollback behavior and focused tests.
#2109 CLOSED Closed by #2117; character sprite download failure handling now matches persona visible error feedback. No full rendered editor pass was run in this closure rescan.
#2110 CLOSED Closed by #2118; runtime overlay selection now prefers expression sprites unless fullBodyOnly is set. No full rendered runtime sprite pass was run in this closure rescan.

Rescan Criteria

  • Target 4 closure rescan passed on current origin/refactor at 089e1d72; no open Target 4 blockers remain.
  • Keep deferred cross-target media rows routed to targets 20, 21, 19, 14, or target 9 instead of expanding Target 4.
  • Reopen or rescan Target 4 if media route topology, raw-path command exposure, managed asset URL resolution, thumbnail generation, Google Fonts download safety, default game asset inventory, game runtime media scoping, or sprite URL/runtime selection changes.
  • Full native/browser media render sweeps remain useful manual proof, but the known Target 4 blocker list is closed by this scan.
Originally created by @Promansis on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2106 Originally assigned to: @Promansis on GitHub. # Target 4: Media And Assets ```yaml target: 4 name: Media and assets scan_status: reported parity_verdict: on_par proof_level: focused_test scan_refactor: refactor, 2026-06-04 legacy_ref: main branch report: https://github.com/Pasta-Devs/Marinara-Engine/issues/1904#issuecomment-4602089938 foundation_rescan: 2026-06-04 background_game_assets_rescan: 2026-06-04 catalog_media_edges_rescan: 2026-06-04 defer_cross_target_dependencies: 2026-06-04 last_refreshed: 2026-06-04 closure_rescan: 2026-06-04 ``` ## Scope Included: - Managed assets for avatars, backgrounds, fonts, game assets, lorebook images, thumbnails, and gallery images. - Remote asset routing and remote-safe managed asset URLs. - Chat gallery and character gallery storage. - Settings background picker and game-mode background resolution. - Gallery orphan recovery. - Sprite library list payloads, sprite CRUD, sprite owner namespacing, and runtime sprite consumers. - Game asset manifest, seeded defaults, browser/file operations, and public/default assets. Not checked: - Full native/browser render sweep for every rendered media consumer; this closure pass used static/code proof and focused tests rather than a full app/Tauri media walkthrough. - Adjacent/cross-target media surfaces stay dependency notes unless their owning targets pull them in. - Profile import/export media round-trip, bot-browser avatar proxies, tracker/journal portraits, chat attachment lightboxes, and shell/static Mari assets are inventoried as adjacent/later surfaces only, with explicit routing in the deferred dependency pass below. ## Closure Rescan 2026-06-04 Audit gate: - Mode: full target refresh focused on the remaining Target 4 blockers after #2107, #2109, #2110, #2111, and #2112 closed. - Refactor checkout: `origin/refactor` at `089e1d72`. - Legacy reference: `origin/main`. - Proof target: static legacy/refactor trace plus focused Rust tests for Google Fonts safety, backgrounds, asset-manifest bridge behavior, and sprite storage. No full native/browser media render sweep was run. Verdict: - Target 4 is `on_par` for the scanned media/assets contract. No open Target 4 blocker remains. - #2107 is resolved: `GameSurface` now scopes runtime reset, media reset, scene restore, intro presentation, and last resolved background cache by `activeChatId:gameId`, matching the legacy `sceneRuntimeScopeKey`. - #2111 is resolved: the five legacy nested music paths and two exploration SFX files are restored in the default game assets bundle and manifest. - #2112 is resolved: Google Fonts downloads now have per-family in-flight guarding, CSS2 plus legacy endpoint fallback/richer face selection, and temp/backup metadata replacement with rollback. - #2109 and #2110 are closed with code/static coverage: character sprite download failure feedback is now guarded like persona downloads, and runtime sprite resolution prefers expression sprites unless `fullBodyOnly` is set. Rendered browser/native proof for every sprite flow was not rerun in this closure pass. Evidence: - Refactor `src/features/modes/game/components/GameSurface.tsx` defines `sceneRuntimeScopeKey` from `chatMeta.gameId` and uses it for reset/cache refs; legacy `origin/main:packages/client/src/components/game/GameSurface.tsx` uses the same chat-plus-game scope. - Refactor `src-tauri/resources/default-data/game-assets/manifest.json` and bundled files contain the restored legacy music paths plus `sfx/exploration/bed-creak.wav` and `sfx/exploration/wet-squelch.wav`; legacy `origin/main:packages/server/src/assets/default-game-assets` contains the same paths. - Refactor `src-tauri/src/commands/storage/fonts.rs` now has `GoogleFontDownloadGuard`, CSS2 plus legacy CSS probing, managed Google font file replacement with backup/rollback, and temp-file metadata replacement. - Refactor `src/features/catalog/characters/components/CharacterSpritesTab.tsx` now catches sprite download failures and shows the visible error toast already present in `PersonaSpritesTab`. - Refactor `src/features/runtime/visuals/components/SpriteOverlay.tsx` uses expression sprite pools before full-body pools for normal overlays and keeps `fullBodyOnly` overlays restricted to full-body sprites. Focused proof commands passed: - `cargo test --manifest-path src-tauri/Cargo.toml google_font` - 5 passed, 0 failed. - `cargo test --manifest-path src-tauri/Cargo.toml background` - 7 passed, 0 failed. - `cargo test --manifest-path src-tauri/crates/assets/Cargo.toml managed_background_bridge_does_not_overwrite_explicit_game_asset_tags` - 1 passed, 0 failed. - `cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests` - 8 passed, 0 failed. Coverage notes: - `cargo test --manifest-path src-tauri/Cargo.toml manifest` passed 6 tests, but that filter did not include a default-game-asset inventory test; default asset closure is backed by static file/manifest inventory and #2121 proof notes. - The deferred media rows for profile import/export, bot-browser avatar proxies, tracker/journal portraits, chat attachment lightboxes, and static shell assets remain routed to targets 20, 21, 19, 14, and 9. They are not Target 4 blockers. - A future full native/browser media walkthrough can still raise UI-only regressions, but this scan found no current Target 4 gap from the known blocker list. ## Deferred Cross-Target Dependency Pass 2026-06-04 Audit gate: - Rows: `04-MA-COMPAT-profile-import-export-assets`, `04-MA-REMOTE-bot-browser-avatar-proxies`, `04-MA-UI-tracker-journal-portraits`, `04-MA-UI-chat-attachment-images`, `04-MA-UI-static-shell-assets`. - Goal: keep target 4 focused on managed media/assets while recording adjacent media dependencies for targets 20, 21, 19, 14, and shared chat UI. - Proof target: static refactor-vs-legacy trace only; no app/Tauri/browser proof and no blocker filing from this pass. Verdict: - These rows should remain dependency notes, not target 4 blockers, and should not expand target 4 rescan scope. - Profile import/export media round-trip belongs to target 20 (Import, export, and backup). Refactor has managed profile asset manifests/backups for avatars, sprites, backgrounds, gallery, game assets, fonts, knowledge sources, and lorebook images, but full destructive import/export/backup round-trip proof is owned by target 20. - Bot-browser avatar proxies belong to target 21 (Shell and integrations), with an avatar-import dependency if the importer path is being rescanned. Refactor and legacy both proxy external provider avatar URLs and convert downloaded avatars during import. - Tracker/journal portraits belong to target 19 (Tracker, world state, and visuals) plus shared chat UI where quick switchers or message avatars consume the same avatar data. - Chat attachment lightboxes belong to target 14 (Shared chat UI) and may also inform target 9 message attachment storage/payload checks; they are media UI consumers outside the managed gallery asset foundation. - Static shell assets belong to target 21 and app/shell discovery/onboarding surfaces. Public Mari/tutorial/Spotify/player sprites are static bundle assets, not managed user media. Evidence: - Refactor profile assets include managed directories in `src-tauri/src/commands/storage/profile/assets.rs`; backups copy the same media directories and include restore notes in `src-tauri/src/commands/storage/backup.rs`. - Legacy profile import/export UI and server routes are under `main:packages/client/src/components/panels/SettingsPanel.tsx` and `main:packages/server/src/routes/import.routes.ts`; target 20 should prove round-trip semantics rather than target 4. - Refactor bot-browser avatar routes are built in `src/features/shell/bot-browser/components/BotBrowserView.tsx` and proxied through `src-tauri/src/commands/storage/bot_browser.rs`; legacy used `/api/bot-browser/*/avatar/*` in `main:packages/client/src/components/bot-browser/BotBrowserView.tsx`. - Refactor tracker/game portrait consumers are in `src/features/runtime/tracker/hooks/use-tracker-panel-model.ts`, `src/features/runtime/tracker/components/FeaturedCharacterPortrait.tsx`, and `src/features/modes/game/components/GameJournal.tsx`; legacy counterparts are tracker-panel and game journal surfaces under `main:packages/client/src/features/tracker-panel` and `main:packages/client/src/components/game/GameJournal.tsx`. - Refactor chat attachment and image lightbox handling is in `src/features/modes/shared/chat-ui/components/ChatMessage.tsx`, `src/features/modes/conversation/components/ConversationMessage.tsx`, and `src/features/runtime/visuals/components/PinnedImageOverlay.tsx`; legacy equivalents live under `main:packages/client/src/components/chat/ChatMessage.tsx`, `ConversationMessage.tsx`, and `PinnedImageOverlay.tsx`. - Refactor static shell assets are referenced by `src/features/shell/mari/components/ProfessorMariSurface.tsx`, `src/features/shell/onboarding/components/OnboardingTutorial.tsx`, `src/features/modes/game/components/GameTutorial.tsx`, and `src/features/shell/spotify/components/SpotifyMiniPlayer.tsx`; legacy equivalents are in `main:packages/client/src/components/onboarding`, `main:packages/client/src/components/game/GameTutorial.tsx`, and `main:packages/client/src/components/spotify/SpotifyMiniPlayer.tsx`. Routing: - Target 20: profile import/export media and backup archive proof. - Target 21: bot-browser avatar proxies and static shell/Mari/tutorial/Spotify assets. - Target 19: tracker/world-state/game journal portraits. - Target 14: shared chat attachment lightboxes and message image rendering. - Target 9: only if attachment storage/payload shape becomes part of chats/messages parity. Coverage note: - Open issue search found no separate current duplicate for these deferred dependency rows beyond this target detail issue. ## Catalog Media Edges Rescan 2026-06-04 Audit gate: - Rows: `04-MA-ASSET-avatar-managed-files`, `04-MA-ASSET-font-files`, `04-MA-ASSET-lorebook-images`, `04-MA-ASSET-public-default-assets`. - Refactor owner: `src-tauri/src/commands/storage/avatars.rs`, `src-tauri/src/commands/storage/fonts.rs`, `src-tauri/src/commands/storage/lorebook_images.rs`, `src-tauri/src/http_server.rs`, `src/shared/api/local-file-api.ts`, `src/shared/api/settings-assets-api.ts`, `src/shared/api/lorebook-command-api.ts`, `src/features/catalog/characters`, `src/features/catalog/personas`, `src/features/catalog/lorebooks`, `public`, `src-tauri/resources/default-data`, `src-tauri/src/state.rs`, `src-tauri/tauri.conf.json`. - Legacy owner: `main:packages/server/src/routes/avatars.routes.ts`, `main:packages/server/src/routes/characters.routes.ts`, `main:packages/server/src/routes/fonts.routes.ts`, `main:packages/server/src/routes/lorebooks.routes.ts`, `main:packages/client/src/App.tsx`, `main:packages/client/src/components/characters`, `main:packages/client/src/components/personas`, `main:packages/client/src/hooks/use-lorebooks.ts`, `main:packages/client/public`, `main:packages/server/src/assets/default-*`, `main:packages/server/src/db/seed-*`. - Risk: medium for catalog media edges; user-owned avatar/font/lorebook/default media must remain file-backed, routable, and compatible with legacy data. - Proof target: static legacy/refactor trace plus focused Rust tests where filters exist; no app/browser/Tauri render proof. Verdict: - No confirmed regression found for avatar managed files or lorebook images. Avatar handling is refactor-better because current rows store managed file metadata and generate/cache safe thumbnails while preserving crop paths. - Font files are on par after the closure rescan: refactor keeps list/serve/register/open-folder/Google-download behavior, and #2123 restored Google Fonts duplicate/concurrent download guard, CSS2 plus legacy CSS fallback for richer shard coverage, and atomic replace/rollback for managed Google font files. - Public/static Mari sprites and default backgrounds match legacy by filename, and refactor bundles/seeds `resources/default-data`. #2121 restored the default game asset legacy nested music paths/tags and the two exploration SFX files, so the public/default asset row is on par for this scan. - Lorebook images are statically on par/refactor-better for upload, managed metadata, managed serving, thumbnail use, and stale image cleanup on replacement; delete-time cleanup was not separately app-proven. Evidence: - Refactor avatar uploads persist `avatar`, `avatarPath`, `avatarFilePath`, `avatarFilename`, and `avatarUpdatedAt`, clear avatar crop on removal, remove stale managed files/thumbnails, and preserve persona avatar files referenced by message snapshots in `src-tauri/src/commands/storage/avatars.rs`. - Refactor avatar thumbnails validate allowed sizes, reject sources outside managed avatar roots, cache resized thumbnails under `.avatar-thumbnails`, support inline fallback thumbnails, and route through `/api/assets/avatar-thumbnail/...` in `src-tauri/src/commands/storage/avatars.rs` and `src-tauri/src/http_server.rs`. - Refactor character/persona catalog avatar components prefer managed file URLs and thumbnails while preserving crop styling in `src/features/catalog/characters/components/CharacterAvatarImage.tsx` and `src/features/catalog/personas/components/PersonaAvatarImage.tsx`. - Legacy avatar routes served `/api/avatars/file/:filename`, uploaded NPC avatars under `/api/avatars/npc/:chatId`, and character/persona avatar writes stored `/api/avatars/file/<filename>` in `main:packages/server/src/routes/avatars.routes.ts` and `main:packages/server/src/routes/characters.routes.ts`. - Refactor fonts list `data/fonts`, serves supported font files through managed asset routes, opens the fonts folder, downloads Google Font `woff2` shards, stores `font-metadata.json`, registers app fonts from `src/app/App.tsx`, and now has the legacy concurrent/atomic/fallback handling in `src-tauri/src/commands/storage/fonts.rs`. - Refactor lorebook image upload stores `marinara-lorebook-image:<filename>`, `imageFilePath`, `imageFilename`, and `imageUpdatedAt`, removes the previous managed file, serves through `/api/assets/lorebook/...`, and renders panel thumbnails via managed thumbnail resolution. Legacy uploaded to `/api/lorebooks/:id/image` and stored `/api/lorebooks/images/file/<filename>`. - Static inventory found current `public/sprites/mari` filenames match legacy `packages/client/public/sprites/mari`. Current `src-tauri/resources/default-data/backgrounds` matches legacy default-background filenames, with current-only `meta.json`. - Closure rescan inventory found current default game assets restored the legacy mood/theme music subfolders (`music/combat/fantasy/intense/battle-epic.mp3`, etc.) and restored `sfx/exploration/bed-creak.wav` plus `sfx/exploration/wet-squelch.wav`. Focused proof commands passed: - `cargo test --manifest-path src-tauri/Cargo.toml avatar` - 33 passed, 0 failed. - `cargo test --manifest-path src-tauri/Cargo.toml seed` - 4 passed, 0 failed. - `cargo test --manifest-path src-tauri/Cargo.toml background` - 7 passed, 0 failed. Coverage notes: - `cargo test --manifest-path src-tauri/Cargo.toml font`, `cargo test --manifest-path src-tauri/Cargo.toml lorebook_image`, and `cargo test --manifest-path src-tauri/Cargo.toml game_assets` matched 0 tests. - No browser/native render proof was run for avatar thumbnails, font application, lorebook thumbnails, static shell sprites, or default game asset runtime resolution. Suggested follow-ups: - Closed by #2123: legacy Google Font safety around concurrent downloads, dual CSS endpoint fallback, and atomic replacement/rollback is restored. - Closed by #2121: legacy default music paths/tags and the two exploration SFX files are restored. ## Background And Game Assets Rescan 2026-06-04 Audit gate: - Rows: `04-MA-UI-settings-background-picker`, `04-MA-RUNTIME-chat-background-persistence`, `04-MA-ASSET-game-asset-manifest`, `04-MA-RUNTIME-game-background-resolution`, `04-MA-UI-game-assets-browser-ops`. - Refactor owner: `src/features/shell/settings/components/SettingsPanel.tsx`, `src/shared/lib/backgrounds.ts`, `src/features/runtime/generation/hooks/use-generate.ts`, `src/features/modes/game/stores/game-asset.store.ts`, `src/features/modes/game/components/GameSurface.tsx`, `src/features/modes/game-assets`, `src/shared/api/assets-api.ts`, `src/shared/api/remote-runtime.ts`, `src-tauri/src/commands/storage/backgrounds.rs`, `src-tauri/src/commands/storage/game_assets.rs`, `src-tauri/crates/assets/src/lib.rs`, `src-tauri/src/http_dispatch.rs`. - Legacy owner: `main:packages/client/src/components/panels/SettingsPanel.tsx`, `main:packages/client/src/lib/backgrounds.ts`, `main:packages/client/src/components/game/GameSurface.tsx`, `main:packages/client/src/components/game-assets`, `main:packages/client/src/hooks/use-game-assets.ts`, `main:packages/server/src/routes/backgrounds.routes.ts`, `main:packages/server/src/routes/game-assets.routes.ts`, `main:packages/server/src/services/game/asset-manifest.service.ts`. - Risk: high for settings/game/runtime/storage bridge; same asset state feeds game prompts, scene display, and persisted chat metadata. - Proof target: static legacy/refactor trace plus focused Rust tests for game-asset backgrounds in the picker and the managed user-background manifest bridge. Verdict: - #1928 is validated for the Settings picker row: current refactor lists game asset backgrounds, marks them non-editable/non-deletable, resolves thumbnails through game managed assets, and preserves user background controls. - Chat background metadata conversion is statically on par for user backgrounds and `gameAsset:` metadata. - Game asset manifest and browser ops are statically on par with refactor-better remote/embedded routing through typed wrappers and explicit dispatch. - Closure rescan update: #2107 is fixed by #2120. Current refactor now scopes runtime media reset and last resolved background cache by `activeChatId:gameId`, matching legacy. Evidence: - Refactor `backgrounds_list` merges `state.game_assets.manifest().byCategory.backgrounds` into picker rows and labels game asset rows as `source: "game_asset"`, `editable: false`, `deletable: false`, `renameable: false` in `src-tauri/src/commands/storage/backgrounds.rs`. - Refactor Settings picker maps background rows, preserves `source`, uses `gameAssetFileUrlFromPath` and managed game thumbnails for game asset backgrounds, and keeps user upload/delete/tag/rename paths in `src/features/shell/settings/components/SettingsPanel.tsx`. - Refactor chat background helpers convert `marinara-background:` and `marinara-game-asset:` URLs to stored metadata and back, including `gameAsset:<path>`, in `src/shared/lib/backgrounds.ts`. - Refactor game asset manifest returns live `manifest_with_backgrounds`, including user backgrounds under `backgrounds:user:*`, in `src-tauri/src/commands/storage/game_assets.rs` and `src-tauri/crates/assets/src/lib.rs`. - Refactor game asset browser hooks cover tree, folder create/delete, upload, rescan, folder descriptions, file info, text read/write, single move/copy/delete, and bulk move/copy/delete through `src/shared/api/assets-api.ts`; remote-capable commands are allowlisted in `src/shared/api/remote-runtime.ts` and handled in `src-tauri/src/http_dispatch.rs`. OS folder open remains intentionally non-remote. - Legacy `/api/backgrounds` merged `getAssetManifest().byCategory.backgrounds`, legacy `backgrounds.ts` used the same `gameAsset:` metadata concept, legacy game assets routes exposed equivalent browser operations, and legacy `GameSurface` scoped scene media/background cache by `sceneRuntimeScopeKey = activeChatId:activeGameMetaId`. - Current refactor `GameSurface` reset/cache checks now use `sceneRuntimeScopeKey` for runtime state and `lastResolvedBackgroundRef`, so the same-chat new/replaced game boundary clears stale scene media/background state like legacy. Focused proof commands passed: - `cargo test --manifest-path src-tauri/Cargo.toml list_backgrounds_includes_non_editable_game_asset_backgrounds` - `cargo test --manifest-path src-tauri/crates/assets/Cargo.toml managed_background_bridge_does_not_overwrite_explicit_game_asset_tags` Suggested follow-up: - Closed by #2120: game media/background runtime scoping now includes the current `gameId`; closure rescan marks `04-MA-RUNTIME-game-background-resolution` on par. ## Gallery Data Safety Rescan 2026-06-04 Audit gate: - Rows: `04-MA-STORAGE-chat-gallery-file-backed`, `04-MA-STORAGE-character-gallery`, `04-MA-ERROR-gallery-orphan-recovery`. - Refactor owner: `src-tauri/src/commands/storage/shared.rs`, `src-tauri/src/commands/storage/commands/entities.rs`, `src-tauri/src/commands/storage/commands/media.rs`, `src-tauri/src/commands/storage/chats.rs`, `src-tauri/src/state.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`. - Legacy owner: `main:packages/server/src/routes/gallery.routes.ts`, `main:packages/server/src/routes/characters.routes.ts`, `main:packages/server/src/services/storage/gallery-recovery.ts`, `main:packages/server/src/app.ts`, `main:packages/server/src/services/image/image-generation.ts`. - Risk: highest data-loss/storage risk for gallery media, managed file cleanup, and orphan recovery. - Proof target: static legacy/refactor trace plus focused Rust tests for upload/create conversion, remote dispatch, managed route safety, delete cleanup, and startup recovery. Verdict: - No confirmed regression and no likely parity gap found in these three gallery data-safety rows. - `04-MA-STORAGE-chat-gallery-file-backed`, `04-MA-STORAGE-character-gallery`, and `04-MA-ERROR-gallery-orphan-recovery` are clean on current `refactor` for the rescanned behavior. - This validates closed #1927 and #1929 for the requested rows, but does not upgrade the whole target to `on_par`; #1930 and broader media/UI/runtime rows still need their own rescan, and the game background runtime-scope defect remains open. Evidence: - Refactor gallery upload persists bytes into the managed `gallery` directory and records `filePath`, `filename`, and a non-inline asset URL in `src-tauri/src/commands/storage/shared.rs`. - Refactor `storage_create` for `gallery` and `character-gallery` converts inline `data:image` payloads from generated/regenerated images into managed gallery files in `src-tauri/src/commands/storage/commands/entities.rs`. - Refactor serves managed gallery files through `/api/assets/gallery/*` in `src-tauri/src/http_server.rs` and supports chat/character gallery upload over remote dispatch in `src-tauri/src/http_dispatch.rs`. - Refactor gallery delete, chat delete, and character delete remove managed gallery files through registered media cleanup in `src-tauri/src/commands/storage/commands/entities.rs` and `src-tauri/src/commands/storage/chats.rs`. - Refactor startup recovery scans legacy `data_dir/gallery/<chatId>` orphan files, creates `gallery` rows, removes recovered source files, and is idempotent in `src-tauri/src/state.rs`. - Legacy stored chat gallery files under `data/gallery/<chatId>`, character gallery files under `data/gallery/characters/<id>`, served direct file routes, and ran `recoverGalleryImages(db)` on startup. Focused proof command passed: - `cargo test --manifest-path src-tauri/Cargo.toml gallery` - 13 passed, 0 failed. Adjacent note: - Profile import/export media round-trip remains routed to target 20. This pass did not treat profile import's renderable-data-URL compatibility path as a target-4 blocker. ## Foundation Rescan 2026-06-04 Audit gate: - Rows: `04-MA-API-media-route-registration`, `04-MA-REMOTE-managed-asset-routing`, `04-MA-REMOTE-raw-path-denial`, `04-MA-ASSET-managed-thumbnails`. - Refactor owner: `src/shared/api/local-file-api.ts`, `src/shared/api/remote-runtime.ts`, `src-tauri/src/http_server.rs`, `src-tauri/src/http_dispatch.rs`, `src-tauri/src/commands/storage/managed_thumbnails.rs`, `src-tauri/src/commands/storage/commands/profile.rs`. - Legacy owner: `main:packages/server/src/routes/index.ts`, `main:packages/server/src/app.ts`, direct `main:packages/server/src/routes/*/file` media routes. - Risk: high for raw local path denial; medium for URL resolution foundation rows. - Proof target: static code trace plus focused Rust tests for positive managed URL resolution and negative raw/local path controls. Verdict: - No confirmed regression and no likely parity gap found in these four foundation rows. - Refactor is on par for route registration and managed asset routing, and refactor is better for raw path denial plus managed thumbnail support. - This does not upgrade the whole target to `on_par`; later UI/runtime media consumers still need their own rescan/proof. Evidence: - Refactor registers `/api/assets/:kind/*path` in `src-tauri/src/http_server.rs` and maps managed kinds for avatar, avatar-thumbnail, background, font, gallery, game, lorebook, thumbnail, and sprite in `managed_asset_path`. - Refactor URL helpers build remote-safe `/api/assets/<kind>/<path>` URLs in `src/shared/api/local-file-api.ts`; embedded mode still falls back to shell-local file URL conversion where appropriate. - Refactor keeps raw local path commands out of remote `/api/invoke`: `background_file_path`, `game_assets_file_path`, and `lorebook_image_file_path` are listed as non-remote in `src-tauri/src/http_dispatch.rs`, and the dispatch test proves they return `unsupported_command`. - Refactor `load_url_binary` accepts managed asset URLs only after canonicalizing under the app data directory, restricting to allowed media dirs, rejecting symlinks, and applying a size cap in `src-tauri/src/commands/storage/commands/profile.rs`. - Refactor managed thumbnails are implemented in `src-tauri/src/commands/storage/managed_thumbnails.rs`, support background/gallery/game/lorebook sources, validate supported sizes, reject sources outside managed assets, and route through `/api/assets/thumbnail/...`. - Legacy registered separate media route prefixes in `main:packages/server/src/routes/index.ts` and served files through direct routes such as `main:packages/server/src/routes/avatars.routes.ts`, `backgrounds.routes.ts`, `gallery.routes.ts`, `game-assets.routes.ts`, `lorebooks.routes.ts`, and `sprites.routes.ts`. Focused proof commands passed: - `cargo test --manifest-path src-tauri/Cargo.toml dispatch_rejects_remote_raw_server_path_commands` - `cargo test --manifest-path src-tauri/Cargo.toml managed_thumbnail` - `cargo test --manifest-path src-tauri/Cargo.toml asset_path_routes` - `cargo test --manifest-path src-tauri/Cargo.toml gallery_asset_path_rejects_path_tokens` - `cargo test --manifest-path src-tauri/Cargo.toml sprite_asset_path_rejects_path_tokens` - `cargo test --manifest-path src-tauri/Cargo.toml local_asset_binary` ## Sprite Rescan 2026-06-04 Audit gate: - Rows: `04-MA-PERF-sprite-list-metadata-urls`, `04-MA-ASSET-sprite-editor-crud`, `04-MA-ASSET-sprite-owner-namespace`, `04-MA-RUNTIME-runtime-sprite-consumers`. - Refactor owner: `src-tauri/src/commands/storage/sprites.rs`, `src/shared/api/image-generation-api.ts`, `src/shared/api/local-file-api.ts`, `src/features/catalog/sprites/hooks/use-sprites.ts`, `src/features/catalog/characters/components/CharacterSpritesTab.tsx`, `src/features/catalog/personas/components/sprites/PersonaSpritesTab.tsx`, `src/features/runtime/visuals/components/SpriteOverlay.tsx`, `src/features/runtime/tracker/components/tracker-sprite.helpers.ts`. - Legacy owner: `main:packages/server/src/routes/sprites.routes.ts`, `main:packages/client/src/hooks/use-characters.ts`, `main:packages/client/src/components/chat/SpriteOverlay.tsx`, `main:packages/client/src/features/tracker-panel`. - Risk: medium-high for media payload size, owner compatibility, and runtime sprite visibility. - Proof target: static legacy/refactor trace plus focused Rust tests for non-inline list payloads, CRUD backend paths, owner namespace separation, legacy persona migration, and negative controls. Verdict: - No confirmed regression and no likely parity gap found in the requested sprite rows. - #1930 is validated: current refactor sprite list responses return metadata and resolvable managed URLs instead of eager base64 image bytes. - Character/persona sprite editor CRUD is statically covered through shared hooks and editor wiring, with focused backend proof for upload/bulk-upload/delete/list behavior. Download/framing/wand-cleanup remain UI-wired but not browser-proven. - Sprite owner namespace is on par/refactor-better: persona sprites use a separate namespace, unambiguous legacy persona dirs migrate, and conflicts fail without overwriting. - Runtime sprite consumers are statically covered in roleplay/game/tracker paths, but not upgraded beyond static proof because rendered app/browser proof was not run. Evidence: - Refactor `sprite_info_from_path` returns `expression`, `filename`, `absolutePath`, `ownerId`, `ownerType`, `size`, `cacheKey`, and a cache-busted file-backed asset URL in `src-tauri/src/commands/storage/sprites.rs`; it does not encode sprite bytes into the list response. - Refactor sprite API wrapper resolves sprite records through `resolveSpriteFileUrl`, which maps owner type/id/filename to remote-safe `/api/assets/sprite/<ownerType>/<ownerId>/<filename>` URLs or embedded file URLs in `src/shared/api/image-generation-api.ts` and `src/shared/api/local-file-api.ts`. - Refactor hooks cover list, upload, bulk upload, delete, cleanup saved sprites, and cleanup restore for both character and persona owners in `src/features/catalog/sprites/hooks/use-sprites.ts`. - Refactor character and persona sprite tabs wire list/upload/delete/download/framing/wand-cleanup/saved-cleanup flows through the shared sprite hooks in `src/features/catalog/characters/components/CharacterSpritesTab.tsx` and `src/features/catalog/personas/components/sprites/PersonaSpritesTab.tsx`. - Refactor `SpriteOwnerKind` accepts `character` and `persona`, defaults omitted owner type to `character`, rejects blank/invalid owner types, stores personas under `sprites/personas/<id>`, and migrates unambiguous legacy persona dirs in `src-tauri/src/commands/storage/sprites.rs`. - Refactor runtime `SpriteOverlay` consumes owner-aware sprite hooks, maps agent and saved expressions through owner keys, chooses expression/full-body sprite pools, and renders resolved URLs; tracker portrait helpers resolve sprite expressions and sprite URLs for character/persona tracker surfaces. - Legacy sprite list returned `/api/sprites/<characterId>/file/<filename>?v=<mtime>` from `main:packages/server/src/routes/sprites.routes.ts`, and legacy `useCharacterSprites`/`SpriteOverlay` consumed that URL list from `main:packages/client/src/hooks/use-characters.ts` and `main:packages/client/src/components/chat/SpriteOverlay.tsx`. Focused proof command passed: - `cargo test --manifest-path src-tauri/Cargo.toml sprite_upload_tests` - 8 passed, 0 failed. Coverage note: - This validates closed #1930 and the owner-namespace backend behavior. It does not provide native/browser visual proof that roleplay/game/tracker rendered sprites are visible in-app. ## Surface Inventory | Surface ID | Surface | Bucket | Source | Legacy owner | Refactor owner | In scope | Notes | | --- | --- | --- | --- | --- | --- | --- | --- | | 04-MA-API-media-route-registration | Media and asset route/command registration for backgrounds, avatars, sprites, fonts, gallery, and game assets. | API | both | legacy `packages/server/src/routes/index.ts`, `packages/server/src/app.ts` | `src/shared/api/remote-runtime.ts`, `src-tauri/src/http_dispatch.rs`, `src-tauri/src/http_server.rs` | yes | Baseline entrypoint map for every target-4 media command/route. Foundation rescan 2026-06-04 found no gap. | | 04-MA-REMOTE-managed-asset-routing | Managed asset URL resolution and remote HTTP serving for background, gallery, avatar, font, game, lorebook, thumbnail, and sprite files. | REMOTE | both | legacy direct `/api/*/file` routes | `src/shared/api/local-file-api.ts`, `src-tauri/src/http_server.rs`, `src-tauri/src/http_dispatch.rs` | yes | Refactor uses `marinara-*` schemes plus `/api/assets`; legacy used server file routes. Foundation rescan 2026-06-04 found refactor better. | | 04-MA-REMOTE-raw-path-denial | Remote runtime rejects raw local file path commands while allowing managed asset routes. | ERROR | refactor_only | not found | `src-tauri/src/http_dispatch.rs`, `src/shared/api/local-file-api.ts` | yes | Refactor-only safety surface for hostable runtime. Foundation rescan 2026-06-04 has focused negative-control proof. | | 04-MA-ASSET-avatar-managed-files | Character, persona, and NPC avatars store/serve managed files with crop/thumbnail metadata. | ASSET | both | legacy `packages/server/src/routes/avatars.routes.ts`, `packages/server/src/routes/characters.routes.ts`, `packages/shared/src/types` | `src-tauri/src/commands/storage/avatars.rs`, `src/shared/api/avatar-api.ts`, `src/shared/api/local-file-api.ts`, `src/features/catalog/*/*AvatarImage.tsx` | yes | Catalog media edges rescan 2026-06-04 found refactor-better managed metadata, thumbnail cache, cleanup, and focused avatar tests. | | 04-MA-ASSET-font-files | Custom fonts and Google Font downloads are stored, served, listed, registered, concurrency-guarded, endpoint-fallback aware, and atomically replaced. | ASSET | both | legacy `packages/server/src/routes/fonts.routes.ts`, `packages/client/src/App.tsx`, `packages/client/src/components/panels/SettingsPanel.tsx` | `src-tauri/src/commands/storage/fonts.rs`, `src/shared/api/settings-assets-api.ts`, `src/features/shell/settings/components/SettingsPanel.tsx` | yes | Closure rescan 2026-06-04 found Google Fonts safety parity restored by #2123: duplicate download guard, CSS2/legacy fallback, and temp/backup rollback proof. | | 04-MA-UI-settings-background-picker | Settings background picker lists user backgrounds and game asset backgrounds, with upload/delete/rename/tag controls. | UI | both | legacy `packages/server/src/routes/backgrounds.routes.ts`, `packages/client/src/components/panels/SettingsPanel.tsx`, `packages/client/src/lib/backgrounds.ts` | `src-tauri/src/commands/storage/backgrounds.rs`, `src/features/shell/settings/components/SettingsPanel.tsx`, `src/shared/api/settings-assets-api.ts`, `src/shared/lib/backgrounds.ts` | yes | Background/game assets rescan 2026-06-04 clean for #1928 picker listing and non-editable game asset rows. | | 04-MA-RUNTIME-chat-background-persistence | Chat background metadata restores, persists, resolves, and renders for roleplay/game surfaces. | RUNTIME | both | legacy `packages/client/src/components/chat/ChatArea.tsx`, `packages/client/src/components/chat/ChatRoleplaySurface.tsx` | `src/features/modes/*`, `src/features/runtime/generation/hooks/use-generate.ts`, `src/shared/lib/backgrounds.ts`, `src/shared/stores/ui.store.ts` | yes | Background/game assets rescan 2026-06-04 found metadata conversion on par for user and game asset backgrounds; app render proof still belongs to mode rows. | | 04-MA-STORAGE-chat-gallery-file-backed | Chat gallery rows use managed files/URLs instead of inline image data. | STORAGE | both | legacy `packages/server/src/routes/gallery.routes.ts`, `packages/server/src/services/storage/gallery.storage.ts`, `packages/client/src/hooks/use-gallery.ts` | `src-tauri/src/commands/storage/shared.rs`, `src-tauri/src/commands/storage/commands/entities.rs`, `src/features/catalog/gallery/hooks/use-gallery.ts`, `src/features/modes/shared/chat-ui/components/ChatGallery.tsx` | yes | Gallery data safety rescan 2026-06-04 clean; validates #1927 for this row. | | 04-MA-ERROR-gallery-orphan-recovery | Startup recovery re-creates gallery records for orphaned gallery files. | ERROR | both | legacy `packages/server/src/services/storage/gallery-recovery.ts`, `packages/server/src/app.ts` | `src-tauri/src/state.rs` | yes | Gallery data safety rescan 2026-06-04 clean; validates #1929 for this row. | | 04-MA-STORAGE-character-gallery | Character-specific gallery stores reference art separately from chat gallery. | STORAGE | both | legacy `packages/server/src/routes/characters.routes.ts`, `packages/server/src/services/storage/character-gallery.storage.ts`, `packages/server/src/db/schema/gallery.ts` | `src/features/catalog/characters/components/CharacterGalleryTab.tsx`, `src/features/catalog/characters/hooks/use-characters.ts`, `src-tauri/src/commands/storage/commands/media.rs`, `src-tauri/src/commands/storage/commands/entities.rs` | yes | Gallery data safety rescan 2026-06-04 clean for managed storage, URL resolution, and delete cleanup. | | 04-MA-ASSET-managed-thumbnails | Managed thumbnail API/cache covers background, gallery, game, and lorebook assets. | ASSET | refactor_only | not found | `src-tauri/src/commands/storage/managed_thumbnails.rs`, `src/shared/api/local-file-api.ts` | yes | Refactor-better surface; foundation rescan 2026-06-04 has focused command/path proof. UI consumers still need proof in their own rows. | | 04-MA-ASSET-lorebook-images | Lorebook images upload, store, serve, thumbnail, and update image path metadata. | ASSET | both | legacy `packages/shared/src/types/lorebook.ts`, `packages/server/src/routes/lorebooks.routes.ts`, `packages/client/src/hooks/use-lorebooks.ts` | `src/engine/contracts/types/lorebook.ts`, `src/engine/contracts/schemas/lorebook.schema.ts`, `src-tauri/src/commands/storage/lorebook_images.rs`, `src/features/catalog/lorebooks` | yes | Catalog media edges rescan 2026-06-04 found static parity/refactor-better managed metadata and stale replacement cleanup; delete-time cleanup not app-proven. | | 04-MA-ASSET-game-asset-manifest | Game asset manifest, default seed, categories, and user-background bridge are exposed to game/background flows. | ASSET | both | legacy `packages/server/src/services/game/asset-manifest.service.ts`, `packages/server/src/db/seed-game-assets.ts` | `src-tauri/crates/assets/src/lib.rs`, `src-tauri/src/commands/storage/game_assets.rs`, `src-tauri/resources/default-data/game-assets` | yes | Background/game assets rescan 2026-06-04 clean; focused proof covers user-background bridge collision behavior. | | 04-MA-UI-game-assets-browser-ops | Game assets browser supports tree/list, upload, rescan, folder descriptions, file info, text edit, bulk move/copy/delete. | UI | both | legacy `packages/server/src/routes/game-assets.routes.ts`, `packages/client/src/hooks/use-game-assets.ts`, `packages/client/src/components/game-assets/GameAssetsBrowserView.tsx` | `src/features/modes/game-assets`, `src/shared/api/assets-api.ts`, `src-tauri/crates/assets/src/lib.rs`, `src-tauri/src/http_dispatch.rs` | yes | Background/game assets rescan 2026-06-04 found static parity; remote-capable ops use typed wrappers and explicit dispatch. | | 04-MA-RUNTIME-game-background-resolution | Game runtime resolves selected/generated scene backgrounds from scoped game assets and persists current background metadata. | RUNTIME | both | legacy `packages/client/src/stores/game-asset.store.ts`, `packages/client/src/components/game/GameSurface.tsx` | `src/features/modes/game/stores/game-asset.store.ts`, `src/features/modes/game/components/GameSurface.tsx`, `src/features/modes/game/lib/game-asset-selection.ts` | yes | Closure rescan 2026-06-04 found #2107 fixed by #2120: runtime media reset and last-resolved background cache now use chat-plus-game scope. | | 04-MA-PERF-sprite-list-metadata-urls | Sprite list payload returns metadata and asset URLs, not eager base64 image bytes. | PERF | both | legacy `packages/server/src/routes/sprites.routes.ts`, `packages/client/src/hooks/use-characters.ts` | `src-tauri/src/commands/storage/sprites.rs`, `src/shared/api/image-generation-api.ts`, `src/features/catalog/sprites/hooks/use-sprites.ts` | yes | Sprite rescan 2026-06-04 clean with focused proof; validates #1930. | | 04-MA-ASSET-sprite-editor-crud | Character and persona sprite editors support list/upload/delete/download/framing/cleanup flows. | ASSET | both | legacy `packages/server/src/routes/sprites.routes.ts`, `packages/client/src/components/chat/SpriteOverlay.tsx`, `packages/client/src/components/ui/SpriteGenerationModal.tsx` | `src/features/catalog/characters/components/*Sprite*`, `src/features/catalog/personas/components/sprites`, `src-tauri/src/commands/storage/sprites.rs` | yes | Static UI wiring plus focused backend CRUD proof remain valid; #2109 closed by #2117 after character sprite download failures gained visible error feedback. Full rendered editor pass was not rerun in this closure scan. | | 04-MA-ASSET-sprite-owner-namespace | Sprite owner type separates character/persona sprite folders and migrates unambiguous legacy persona sprite dirs. | COMPAT | refactor_only | legacy has character-id sprite dirs | `src-tauri/src/commands/storage/sprites.rs`, `src/features/catalog/sprites/hooks/use-sprites.ts` | yes | Sprite rescan 2026-06-04 clean/refactor-better with focused namespace and migration tests. | | 04-MA-RUNTIME-runtime-sprite-consumers | Roleplay/game/tracker runtime surfaces consume sprite library data for expression and full-body sprites. | RUNTIME | both | legacy `packages/client/src/components/chat/SpriteOverlay.tsx`, `packages/client/src/components/chat/SpriteSidebar.tsx`, `packages/client/src/features/tracker-panel` | `src/features/runtime/visuals`, `src/features/modes/roleplay`, `src/features/modes/game`, `src/features/runtime/tracker` | yes | Static runtime wiring remains covered; #2110 closed by #2118 after normal overlays were changed to prefer expression sprites while full-body overlays stay gated by `fullBodyOnly`. Full rendered runtime sprite pass was not rerun in this closure scan. | | 04-MA-ASSET-public-default-assets | Public sprites, tutorial images, default backgrounds, and default game assets are bundled/seeded. | ASSET | both | legacy `packages/client/public`, `packages/server/src/assets/default-*`, `packages/server/src/db/seed-*` | `public`, `src-tauri/resources/default-data`, `src-tauri/src/state.rs`, `src-tauri/tauri.conf.json` | yes | Closure rescan 2026-06-04 found #2111 fixed by #2121: legacy nested default music paths and the two exploration SFX files are restored in the bundle and manifest. | | 04-MA-COMPAT-profile-import-export-assets | Profile export/import and backups include managed assets for avatars, sprites, backgrounds, gallery, game assets, fonts, and lorebook images. | COMPAT | both | legacy `packages/server/src/routes/characters.routes.ts`, `packages/server/src/services/import/marinara.importer.ts`, `packages/server/src/routes/import.routes.ts` | `src-tauri/src/commands/storage/profile/assets.rs`, `src-tauri/src/commands/storage/backup.rs`, `src/shared/api/profile-api.ts`, `src/shared/api/import-api.ts` | later | Route to target 20 for full import/export proof; keep as target-4 dependency. | | 04-MA-UI-chat-attachment-images | Chat message attachments, markdown image rendering, pinned images, and lightbox surfaces render media outside gallery. | UI | unclear | legacy likely `packages/client/src/components/chat/ChatMessage.tsx` | `src/features/modes/shared/chat-ui/components/ChatMessage.tsx`, `src/features/runtime/visuals/components/PinnedImageOverlay.tsx` | later | Adjacent media UI, not part of existing target scope. | | 04-MA-REMOTE-bot-browser-avatar-proxies | External bot-browser avatar proxies and import-time avatar download/conversion. | REMOTE | both | legacy `packages/server/src/routes/bot-browser*.routes.ts`, `packages/client/src/components/bot-browser/BotBrowserView.tsx` | `src/features/shell/bot-browser`, `src-tauri/src/commands/storage/bot_browser*` | later | Better fit for shell/integration target unless avatar import parity is being rescanned. | | 04-MA-UI-tracker-journal-portraits | Tracker/world-state portraits, NPC journal images, and quick switcher/avatar thumbnails. | UI | both | legacy tracker/game UI paths | `src/features/runtime/tracker`, `src/features/modes/game/components/GameJournal.tsx`, `src/features/modes/shared/chat-ui` | later | Better fit for target 19 and shared chat UI target. | | 04-MA-UI-static-shell-assets | Static Mari/tutorial/Spotify/player sprites and shell avatars outside managed asset pipeline. | UI | both | legacy public/client UI assets | `public/sprites`, `src/features/shell/mari`, `src/features/shell/discovery` | later | Static assets should be noted, not used to decide managed asset parity. | ## Coverage Matrix | Surface ID | Status | Proof | Follow-up | | --- | --- | --- | --- | | 04-MA-API-media-route-registration | covered_static | static trace, 2026-06-04 | | | 04-MA-REMOTE-managed-asset-routing | refactor_better | static trace plus focused asset-path tests, 2026-06-04 | | | 04-MA-REMOTE-raw-path-denial | refactor_better | focused negative-control tests, 2026-06-04 | | | 04-MA-ASSET-avatar-managed-files | refactor_better | static trace plus focused avatar tests, 2026-06-04 | | | 04-MA-ASSET-font-files | on_par | static trace plus focused Google Fonts safety tests, 2026-06-04 | #2112 CLOSED | | 04-MA-UI-settings-background-picker | on_par | static trace plus focused background-picker test, 2026-06-04 | #1928 | | 04-MA-RUNTIME-chat-background-persistence | covered_static | static trace, 2026-06-04 | | | 04-MA-STORAGE-chat-gallery-file-backed | on_par | static trace plus focused gallery tests, 2026-06-04 | #1927 | | 04-MA-ERROR-gallery-orphan-recovery | on_par | static trace plus focused gallery tests, 2026-06-04 | #1929 | | 04-MA-STORAGE-character-gallery | on_par | static trace plus focused gallery tests, 2026-06-04 | | | 04-MA-ASSET-managed-thumbnails | refactor_better | focused thumbnail tests, 2026-06-04 | | | 04-MA-ASSET-lorebook-images | on_par | static trace, 2026-06-04 | | | 04-MA-ASSET-game-asset-manifest | on_par | static trace plus focused manifest bridge test, 2026-06-04 | | | 04-MA-UI-game-assets-browser-ops | covered_static | static trace, 2026-06-04 | | | 04-MA-RUNTIME-game-background-resolution | on_par | static trace after #2120 plus scope-key rescan, 2026-06-04 | #2107 CLOSED | | 04-MA-PERF-sprite-list-metadata-urls | on_par | static trace plus focused sprite tests, 2026-06-04 | #1930 | | 04-MA-ASSET-sprite-editor-crud | covered_static | static UI trace, focused backend sprite tests, and #2117 download failure feedback, 2026-06-04 | #2109 CLOSED | | 04-MA-ASSET-sprite-owner-namespace | refactor_better | focused namespace/migration/negative-control tests, 2026-06-04 | | | 04-MA-RUNTIME-runtime-sprite-consumers | covered_static | static trace plus #2118 expression-priority fix, 2026-06-04 | #2110 CLOSED | | 04-MA-ASSET-public-default-assets | on_par | static inventory after #2121 plus focused background/asset bridge tests, 2026-06-04 | #2111 CLOSED | ## Follow-Ups | Issue | State | Why it matters | | --- | --- | --- | | #1927 | CLOSED | Gallery images were inline data URLs instead of managed files. Gallery data safety rescan clean on 2026-06-04. | | #1928 | CLOSED | Settings picker did not show game asset backgrounds. Background/game assets rescan clean for picker listing on 2026-06-04. | | #1929 | CLOSED | Gallery orphan-file recovery was missing. Gallery data safety rescan clean on 2026-06-04. | | #1930 | CLOSED | Sprite listing eagerly returned base64 payloads. Sprite rescan clean on 2026-06-04. | | #2107 | CLOSED | Fixed by #2120; closure rescan confirmed game media/background scope now includes game id. | | #2111 | CLOSED | Fixed by #2121; closure rescan confirmed legacy default game asset paths and exploration SFX are restored. | | #2112 | CLOSED | Fixed by #2123; closure rescan confirmed Google Fonts guard/fallback/rollback behavior and focused tests. | | #2109 | CLOSED | Closed by #2117; character sprite download failure handling now matches persona visible error feedback. No full rendered editor pass was run in this closure rescan. | | #2110 | CLOSED | Closed by #2118; runtime overlay selection now prefers expression sprites unless `fullBodyOnly` is set. No full rendered runtime sprite pass was run in this closure rescan. | ## Rescan Criteria - Target 4 closure rescan passed on current `origin/refactor` at `089e1d72`; no open Target 4 blockers remain. - Keep deferred cross-target media rows routed to targets 20, 21, 19, 14, or target 9 instead of expanding Target 4. - Reopen or rescan Target 4 if media route topology, raw-path command exposure, managed asset URL resolution, thumbnail generation, Google Fonts download safety, default game asset inventory, game runtime media scoping, or sprite URL/runtime selection changes. - Full native/browser media render sweeps remain useful manual proof, but the known Target 4 blocker list is closed by this scan.
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#1028
No description provided.