[GH-ISSUE #1508] [Issue]: Roleplay background persists after switching to a chat with no background #757

Closed
opened 2026-10-20 17:32:59 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Xelvanis on GitHub (May 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1508

Originally assigned to: @Xelvanis on GitHub.

Summary

Roleplay can keep showing the previous chat's background after switching to a different Roleplay chat/branch whose metadata has no background configured.

Expected behavior

Switching from a Roleplay chat with a configured background to a Roleplay chat with metadata.background: null should clear the visible background immediately, without requiring a reload.

Actual behavior

The sprite overlay and pinned image overlay clear correctly on chat switch, but the old background remains visible. Reloading while the no-background chat is active clears it, so the persisted metadata is correct and the stale state appears to be in the live chat-switch path.

Steps to reproduce

  1. Launch the refactor desktop app through the native Tauri path.
  2. In Roleplay mode, use a chat with a configured background. In QA I used http://localhost:1420/logo.png as disposable local media.
  3. Ensure a related Roleplay branch/chat has metadata.background: null.
  4. Switch from the background chat to the no-background branch/chat from the sidebar.
  5. Observe that the previous background remains visible until the app is reloaded.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: origin/refactor at 229e7d89 (Fix PR 1499 review follow-ups)
  • Run mode: Tauri desktop
  • OS + version: Windows NT 10.0.26200.0
  • Node + pnpm versions: Node v24.16.0, pnpm 10.33.2
  • Rust version, if relevant: rustc 1.95.0, cargo 1.95.0
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: LM Studio localhost was available during QA, but this repro does not depend on provider output.

Logs, screenshots, or video

Local QA screenshots captured during the audit:

  • scratch/roleplay-audit-a10-original-background-sprite.png: source Roleplay chat with background and sprite visible.
  • scratch/roleplay-audit-a10-branch-after-media-switch.png: branch/no-background chat after sidebar switch; old background still visible while sprite and pinned overlay are gone.

Observed DOM/computed-state evidence:

  • Source chat background layer included url("http://localhost:1420/logo.png").
  • After switching to the branch, the active chat id changed to the branch id and branch metadata confirmed background: null.
  • After the switch, sprite and pinned-image queries returned empty results, but the background layer still included url("http://localhost:1420/logo.png").
  • After reloading on the branch, background layers became none, confirming persisted metadata was not the source of the stale visible background.

Regression notes

Found during the 2026-05-29 Roleplay mode audit on latest origin/refactor. No earlier known-good commit identified.

Additional context

Likely area to inspect: src/features/modes/shared/chat-ui/hooks/use-chat-metadata-sync.ts. The restore effect appears to run on chat?.id while reading metadata values that may hydrate after the chat id changes; if the first render for the new chat still has the previous background value, the background store can be restored with stale data and not rerun when the new metadata arrives.

Related code paths inspected during the audit:

  • src/features/modes/shared/chat-ui/ChatRoleplaySurface.tsx
  • src/features/modes/shared/chat-ui/hooks/use-chat-metadata-sync.ts
  • src/features/modes/shared/chat-ui/components/CrossfadeBackground.tsx

Duplicate check:

  • gh issue list --repo Pasta-Devs/Marinara-Engine --state all --search "Roleplay background persists after switching chat background" returned no matches.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1508 Originally assigned to: @Xelvanis on GitHub. ## Summary Roleplay can keep showing the previous chat's background after switching to a different Roleplay chat/branch whose metadata has no background configured. ## Expected behavior Switching from a Roleplay chat with a configured background to a Roleplay chat with `metadata.background: null` should clear the visible background immediately, without requiring a reload. ## Actual behavior The sprite overlay and pinned image overlay clear correctly on chat switch, but the old background remains visible. Reloading while the no-background chat is active clears it, so the persisted metadata is correct and the stale state appears to be in the live chat-switch path. ## Steps to reproduce 1. Launch the refactor desktop app through the native Tauri path. 2. In Roleplay mode, use a chat with a configured background. In QA I used `http://localhost:1420/logo.png` as disposable local media. 3. Ensure a related Roleplay branch/chat has `metadata.background: null`. 4. Switch from the background chat to the no-background branch/chat from the sidebar. 5. Observe that the previous background remains visible until the app is reloaded. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [x] Roleplay mode - [ ] Game mode - [x] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [ ] Shared API wrapper or remote runtime routing - [ ] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `origin/refactor` at `229e7d89` (`Fix PR 1499 review follow-ups`) - Run mode: Tauri desktop - OS + version: Windows NT 10.0.26200.0 - Node + pnpm versions: Node `v24.16.0`, pnpm `10.33.2` - Rust version, if relevant: rustc `1.95.0`, cargo `1.95.0` - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: LM Studio localhost was available during QA, but this repro does not depend on provider output. ## Logs, screenshots, or video Local QA screenshots captured during the audit: - `scratch/roleplay-audit-a10-original-background-sprite.png`: source Roleplay chat with background and sprite visible. - `scratch/roleplay-audit-a10-branch-after-media-switch.png`: branch/no-background chat after sidebar switch; old background still visible while sprite and pinned overlay are gone. Observed DOM/computed-state evidence: - Source chat background layer included `url("http://localhost:1420/logo.png")`. - After switching to the branch, the active chat id changed to the branch id and branch metadata confirmed `background: null`. - After the switch, sprite and pinned-image queries returned empty results, but the background layer still included `url("http://localhost:1420/logo.png")`. - After reloading on the branch, background layers became `none`, confirming persisted metadata was not the source of the stale visible background. ## Regression notes Found during the 2026-05-29 Roleplay mode audit on latest `origin/refactor`. No earlier known-good commit identified. ## Additional context Likely area to inspect: `src/features/modes/shared/chat-ui/hooks/use-chat-metadata-sync.ts`. The restore effect appears to run on `chat?.id` while reading metadata values that may hydrate after the chat id changes; if the first render for the new chat still has the previous background value, the background store can be restored with stale data and not rerun when the new metadata arrives. Related code paths inspected during the audit: - `src/features/modes/shared/chat-ui/ChatRoleplaySurface.tsx` - `src/features/modes/shared/chat-ui/hooks/use-chat-metadata-sync.ts` - `src/features/modes/shared/chat-ui/components/CrossfadeBackground.tsx` Duplicate check: - `gh issue list --repo Pasta-Devs/Marinara-Engine --state all --search "Roleplay background persists after switching chat background"` returned no matches. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-20 17:32:59 +07:00
  • closed this issue
  • added the
    bug
    label
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#757
No description provided.