[GH-ISSUE #1503] Roleplay weather effects can leak world state across chats #755

Closed
opened 2026-10-20 17:32:56 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Roleplay weather effects read the global world-state store directly instead of the chat-scoped tracker controller, so weather/time visuals can leak from another chat.

This came out of the Roleplay smoke/audit work for #1486.

Evidence

  • src/features/modes/roleplay/components/ChatRoleplaySurface.tsx defines WeatherEffectsConnected as:
    • const gs = useGameStateStore((s) => s.current);
    • then renders <WeatherEffects weather={gs?.weather ?? null} timeOfDay={gs?.time ?? null} />.
  • The normal tracker path uses useTrackerStateController(chatId, ...), which guards reads with s.current?.chatId === activeChatId and loads the target chat's world state.
  • WeatherEffectsConnected receives no chatId and does not verify that useGameStateStore.current.chatId matches the active Roleplay chat.
  • ChatRoleplaySurface renders weather effects independently of tracker widgets: {weatherEffects && addonsReady && <WeatherEffectsConnected />}.

Expected

Weather/time visuals should be scoped to the active Roleplay chat. Switching to a chat with no tracker state should clear weather effects instead of showing the previous chat's weather.

Actual

The weather overlay can render whatever happens to be in the global world-state store, even if that state belongs to a different chat. This is especially likely when weather effects are enabled but tracker widgets/controller are disabled or still loading for the active chat.

Suggested Fix

Route weather effects through the same chat-scoped state contract as the HUD/tracker panel. Options:

  • pass chatId into WeatherEffectsConnected and only use current when current.chatId === chatId, or
  • derive weather/time from useTrackerStateController(chatId, ...) or an equivalent scoped world-state hook.

Avoid a UI-only fallback that keeps stale global state visible.

  • #1486
  • #1502 tracks a separate Roleplay agent output persistence issue.
Originally created by @Xelvanis on GitHub (May 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1503 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Roleplay weather effects read the global world-state store directly instead of the chat-scoped tracker controller, so weather/time visuals can leak from another chat. This came out of the Roleplay smoke/audit work for #1486. ## Evidence - `src/features/modes/roleplay/components/ChatRoleplaySurface.tsx` defines `WeatherEffectsConnected` as: - `const gs = useGameStateStore((s) => s.current);` - then renders `<WeatherEffects weather={gs?.weather ?? null} timeOfDay={gs?.time ?? null} />`. - The normal tracker path uses `useTrackerStateController(chatId, ...)`, which guards reads with `s.current?.chatId === activeChatId` and loads the target chat's world state. - `WeatherEffectsConnected` receives no `chatId` and does not verify that `useGameStateStore.current.chatId` matches the active Roleplay chat. - `ChatRoleplaySurface` renders weather effects independently of tracker widgets: `{weatherEffects && addonsReady && <WeatherEffectsConnected />}`. ## Expected Weather/time visuals should be scoped to the active Roleplay chat. Switching to a chat with no tracker state should clear weather effects instead of showing the previous chat's weather. ## Actual The weather overlay can render whatever happens to be in the global world-state store, even if that state belongs to a different chat. This is especially likely when weather effects are enabled but tracker widgets/controller are disabled or still loading for the active chat. ## Suggested Fix Route weather effects through the same chat-scoped state contract as the HUD/tracker panel. Options: - pass `chatId` into `WeatherEffectsConnected` and only use `current` when `current.chatId === chatId`, or - derive weather/time from `useTrackerStateController(chatId, ...)` or an equivalent scoped world-state hook. Avoid a UI-only fallback that keeps stale global state visible. ## Related - #1486 - #1502 tracks a separate Roleplay agent output persistence issue.
Author
Owner

@SpicyMarinara commented on GitHub (May 29, 2026):

Addressed in b2cebc28 on refactor. Weather effects now receive the active Roleplay chat id and only read world-state data when the store's current chat id matches, so switching chats clears stale weather/time visuals instead of leaking another chat's tracker state. Added the Graphify refresh for the changed files.

<!-- gh-comment-id:4572042670 --> @SpicyMarinara commented on GitHub (May 29, 2026): Addressed in b2cebc28 on refactor. Weather effects now receive the active Roleplay chat id and only read world-state data when the store's current chat id matches, so switching chats clears stale weather/time visuals instead of leaking another chat's tracker state. Added the Graphify refresh for the changed files.
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#755
No description provided.