[GH-ISSUE #1842] [Issue]: Character avatars missing in chat when connected to remote server #892

Closed
opened 2026-10-21 05:23:03 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @cha1latte on GitHub.

Summary

Character avatars fail to render in chat messages when connected to a remote Marinara server with Basic Auth. The browser's broken image icon appears instead. Avatars render correctly in the character library, cards, and all other catalog surfaces — only the chat transcript is affected.

Expected behavior

Character avatars appear in chat messages when connected to a remote runtime, consistent with how they render everywhere else in the app.

Actual behavior

Chat messages show the browser's broken image icon. DevTools Network shows the browser attempting to load a local macOS path (/Users/philipp/Library/Application Support/.../uuid.png) as a URL, resulting in 404 or net::ERR_FILE_NOT_FOUND.

Expression sprites continue to work correctly because they are returned as inline base64 data URLs and require no HTTP fetch.

Root cause

Two compounding issues:

1. Stale avatarFilePath in the database.
Character records store the original upload machine's absolute path. On the remote Linux server the file is physically present at /data/avatars/characters/<uuid>.png and the /api/assets/avatar/<filename> endpoint returns 200 — but the DB field still points to the Mac path.

2. ChatMessage.tsx bypasses the authenticated async image pipeline.
characterAvatarUrl() → avatarFileUrlFromPath() → remoteManagedAssetUrl() returns null for authenticated remote targets (by design — a plain <img> can't send auth headers), then falls through to filePathToAssetUrl() which returns the broken local path string. All other avatar surfaces use CharacterAvatarImage, which calls resolveAvatarFileUrl() asynchronously, fetches the image with Basic Auth headers, and returns a blob: URL. There are at least 11 raw <img src={avatarUrl}> sites in ChatMessage.tsx that bypass this working pattern.

Steps to reproduce

  1. Configure a remote runtime URL with Basic Auth in Settings.
  2. Open any chat with a character that has an avatar.
  3. Observe broken image icon instead of the character avatar.
  4. Open the Character Library — the same character's avatar renders correctly.
  5. DevTools → Network: observe requests to local macOS paths failing.

Environment

  • Marinara Engine version: refactor branch (2026-06-01)
  • Install type: source (client) / Docker (server)
  • OS + version: macOS client, Ubuntu LXC server
  • Browser or app shell: Tauri / web shell

Logs, screenshots, or video

DB record queried directly from the remote server:

{
  "avatarFilePath": "/Users/philipp/Library/Application Support/com.marinara-engine.app/avatars/90765724-6d34-4ff3-8c4c-2d5f4cfa9ded.png",
  "avatarFilename": "90765724-6d34-4ff3-8c4c-2d5f4cfa9ded.png"
}

The file exists on the server and the asset endpoint returns 200. The problem is entirely client-side.

Additional context

Recommended fix: Replace raw <img src={avatarUrl}> tags in ChatMessage.tsx with CharacterAvatarImage (or an equivalent async component). avatarFilePath and avatarFilename need to be surfaced through useChatSurfaceData → characterMap so the component can call resolveAvatarFileUrl() and get a blob URL via authenticated fetch. This is already the pattern used by every other avatar surface in the app.

A DB-only fix (rewriting avatarFilePath values) is not sufficient — local clients will re-introduce local paths on any new avatar upload.

Key files:

  • src/features/modes/shared/chat-ui/components/ChatMessage.tsx — all raw <img> avatar sites
  • src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts — characterMap missing avatarFilePath/avatarFilename
  • src/features/catalog/characters/components/CharacterAvatarImage.tsx — reference implementation
  • src/shared/api/local-file-api.ts — sync remoteManagedAssetUrl vs. async resolveAvatarFileUrl

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Gunterlie on GitHub (Jun 1, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1842 Originally assigned to: @cha1latte on GitHub. ## Summary Character avatars fail to render in chat messages when connected to a remote Marinara server with Basic Auth. The browser's broken image icon appears instead. Avatars render correctly in the character library, cards, and all other catalog surfaces — only the chat transcript is affected. ## Expected behavior Character avatars appear in chat messages when connected to a remote runtime, consistent with how they render everywhere else in the app. ## Actual behavior Chat messages show the browser's broken image icon. DevTools Network shows the browser attempting to load a local macOS path (`/Users/philipp/Library/Application Support/.../uuid.png`) as a URL, resulting in 404 or `net::ERR_FILE_NOT_FOUND`. Expression sprites continue to work correctly because they are returned as inline base64 data URLs and require no HTTP fetch. ## Root cause Two compounding issues: **1. Stale `avatarFilePath` in the database.** Character records store the original upload machine's absolute path. On the remote Linux server the file is physically present at `/data/avatars/characters/<uuid>.png` and the `/api/assets/avatar/<filename>` endpoint returns 200 — but the DB field still points to the Mac path. **2. `ChatMessage.tsx` bypasses the authenticated async image pipeline.** `characterAvatarUrl()` → `avatarFileUrlFromPath()` → `remoteManagedAssetUrl()` returns `null` for authenticated remote targets (by design — a plain `<img>` can't send auth headers), then falls through to `filePathToAssetUrl()` which returns the broken local path string. All other avatar surfaces use `CharacterAvatarImage`, which calls `resolveAvatarFileUrl()` asynchronously, fetches the image with Basic Auth headers, and returns a `blob:` URL. There are at least 11 raw `<img src={avatarUrl}>` sites in `ChatMessage.tsx` that bypass this working pattern. ## Steps to reproduce 1. Configure a remote runtime URL with Basic Auth in Settings. 2. Open any chat with a character that has an avatar. 3. Observe broken image icon instead of the character avatar. 4. Open the Character Library — the same character's avatar renders correctly. 5. DevTools → Network: observe requests to local macOS paths failing. ## Environment - Marinara Engine version: `refactor` branch (2026-06-01) - Install type: source (client) / Docker (server) - OS + version: macOS client, Ubuntu LXC server - Browser or app shell: Tauri / web shell ## Logs, screenshots, or video DB record queried directly from the remote server: ```json { "avatarFilePath": "/Users/philipp/Library/Application Support/com.marinara-engine.app/avatars/90765724-6d34-4ff3-8c4c-2d5f4cfa9ded.png", "avatarFilename": "90765724-6d34-4ff3-8c4c-2d5f4cfa9ded.png" } ``` The file exists on the server and the asset endpoint returns 200. The problem is entirely client-side. ## Additional context **Recommended fix:** Replace raw `<img src={avatarUrl}>` tags in `ChatMessage.tsx` with `CharacterAvatarImage` (or an equivalent async component). `avatarFilePath` and `avatarFilename` need to be surfaced through `useChatSurfaceData` → `characterMap` so the component can call `resolveAvatarFileUrl()` and get a blob URL via authenticated fetch. This is already the pattern used by every other avatar surface in the app. A DB-only fix (rewriting `avatarFilePath` values) is not sufficient — local clients will re-introduce local paths on any new avatar upload. Key files: - `src/features/modes/shared/chat-ui/components/ChatMessage.tsx` — all raw `<img>` avatar sites - `src/features/modes/shared/chat-ui/hooks/use-chat-surface-data.ts` — `characterMap` missing `avatarFilePath`/`avatarFilename` - `src/features/catalog/characters/components/CharacterAvatarImage.tsx` — reference implementation - `src/shared/api/local-file-api.ts` — sync `remoteManagedAssetUrl` vs. async `resolveAvatarFileUrl` ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:23:03 +07:00
Author
Owner

@cha1latte commented on GitHub (Jun 1, 2026):

Closed in #1846

<!-- gh-comment-id:4596691336 --> @cha1latte commented on GitHub (Jun 1, 2026): Closed in #1846
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#892
No description provided.