[GH-ISSUE #2107] Game background runtime media state should be scoped by game id #1027

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/2107

Originally assigned to: @Promansis on GitHub.

Summary

Game runtime media state is scoped by activeChatId only in the refactor UI. Legacy scoped scene media/background state by activeChatId:gameId, so replacing or starting a different game under the same chat could clear stale scene media correctly.

Expected behavior

When a game is replaced or a different game/session identity is active under the same chat, scene background/media runtime state should reset or restore against the current game identity. Last resolved backgrounds, current scene background, music/ambient state, pending scene readiness, and restored-scene flags should not leak across game identities.

Actual behavior

Current refactor GameSurface resets runtime media/background state and caches the last resolved background by activeChatId only. A same-chat game replacement can keep stale scene media/background state longer than legacy because the game id/session boundary is not part of the scope key.

Steps to reproduce

  1. Start or restore a game in a chat and allow scene background/media state to resolve.
  2. Replace/start a different game identity in the same chat so gameId changes while activeChatId stays the same.
  3. Observe that runtime media/background reset paths do not run for the game boundary, and the last resolved background cache is still keyed only by the chat id.

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: refactor, parityscan on 2026-06-04
  • Run mode: Static code audit; likely affects Tauri desktop and remote runtime UI
  • OS + version: Not relevant
  • Node + pnpm versions: Not relevant
  • Rust version, if relevant: Not relevant
  • Remote Runtime URL configured? Not relevant
  • Provider, model, or integration, if relevant: Game assets/backgrounds

Logs, screenshots, or video

No runtime logs or screenshots. Static parity evidence only.

Refactor evidence:

  • src/features/modes/game/components/GameSurface.tsx uses prevActiveChatRef and resets runtime state only when activeChatId changes.
  • src/features/modes/game/components/GameSurface.tsx stores lastResolvedBackgroundRef as { chatId, url } and updates/clears it against activeChatId.

Legacy evidence:

  • main:packages/client/src/components/game/GameSurface.tsx defines activeGameMetaId from chatMeta.gameId.
  • main:packages/client/src/components/game/GameSurface.tsx defines sceneRuntimeScopeKey = ${activeChatId}:${activeGameMetaId}.
  • Legacy reset/restoration/background-cache refs use sceneRuntimeScopeKey, including runtime reset, media reset, restored-scene reset, and last resolved background cache.

Regression notes

Legacy main scoped game scene media/background runtime state by both chat id and game id. Refactor currently scopes this part by chat id only, so this is a parity regression found during target 4 media/assets rescan.

Additional context

Related tracker: #2106, 04-MA-RUNTIME-game-background-resolution.

Suggested fix path:

  • Restore a game-scoped media/runtime key in refactor GameSurface, such as ${activeChatId}:${chatMeta.gameId ?? ""} or another explicit per-game/session identity.
  • Use that key for runtime state reset, media reset, restored-scene reset, and last resolved background cache.
  • Rescan 04-MA-RUNTIME-game-background-resolution after the fix.

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 @Promansis on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2107 Originally assigned to: @Promansis on GitHub. ## Summary Game runtime media state is scoped by `activeChatId` only in the refactor UI. Legacy scoped scene media/background state by `activeChatId:gameId`, so replacing or starting a different game under the same chat could clear stale scene media correctly. ## Expected behavior When a game is replaced or a different game/session identity is active under the same chat, scene background/media runtime state should reset or restore against the current game identity. Last resolved backgrounds, current scene background, music/ambient state, pending scene readiness, and restored-scene flags should not leak across game identities. ## Actual behavior Current refactor `GameSurface` resets runtime media/background state and caches the last resolved background by `activeChatId` only. A same-chat game replacement can keep stale scene media/background state longer than legacy because the game id/session boundary is not part of the scope key. ## Steps to reproduce 1. Start or restore a game in a chat and allow scene background/media state to resolve. 2. Replace/start a different game identity in the same chat so `gameId` changes while `activeChatId` stays the same. 3. Observe that runtime media/background reset paths do not run for the game boundary, and the last resolved background cache is still keyed only by the chat id. ## Impact area - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [x] Game mode - [ ] 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: `refactor`, parityscan on 2026-06-04 - Run mode: Static code audit; likely affects Tauri desktop and remote runtime UI - OS + version: Not relevant - Node + pnpm versions: Not relevant - Rust version, if relevant: Not relevant - Remote Runtime URL configured? Not relevant - Provider, model, or integration, if relevant: Game assets/backgrounds ## Logs, screenshots, or video No runtime logs or screenshots. Static parity evidence only. Refactor evidence: - `src/features/modes/game/components/GameSurface.tsx` uses `prevActiveChatRef` and resets runtime state only when `activeChatId` changes. - `src/features/modes/game/components/GameSurface.tsx` stores `lastResolvedBackgroundRef` as `{ chatId, url }` and updates/clears it against `activeChatId`. Legacy evidence: - `main:packages/client/src/components/game/GameSurface.tsx` defines `activeGameMetaId` from `chatMeta.gameId`. - `main:packages/client/src/components/game/GameSurface.tsx` defines `sceneRuntimeScopeKey = ${activeChatId}:${activeGameMetaId}`. - Legacy reset/restoration/background-cache refs use `sceneRuntimeScopeKey`, including runtime reset, media reset, restored-scene reset, and last resolved background cache. ## Regression notes Legacy `main` scoped game scene media/background runtime state by both chat id and game id. Refactor currently scopes this part by chat id only, so this is a parity regression found during target 4 media/assets rescan. ## Additional context Related tracker: #2106, `04-MA-RUNTIME-game-background-resolution`. Suggested fix path: - Restore a game-scoped media/runtime key in refactor `GameSurface`, such as `${activeChatId}:${chatMeta.gameId ?? ""}` or another explicit per-game/session identity. - Use that key for runtime state reset, media reset, restored-scene reset, and last resolved background cache. - Rescan `04-MA-RUNTIME-game-background-resolution` after the fix. ## 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-21 05:25:20 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1027
No description provided.