[PR #326] [MERGED] feat(game): middle-mouse + click navigation through chat history for game mode #4562

Closed
opened 2026-10-22 04:08:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/326
Author: @LukaTheHero
Created: 4/30/2026
Status: ✅ Merged
Merged: 4/30/2026
Merged by: @LukaTheHero

Base: main ← Head: feat/game-middle-mouse-nav


📝 Commits (1)

  • c04b418 feat(game): middle-mouse + click navigation through chat history

📊 Changes

6 files changed (+374 additions, -27 deletions)

View changed files

📝 packages/client/src/components/game/GameMap.tsx (+1 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+246 -27)
📝 packages/client/src/components/game/GameSurface.tsx (+104 -0)
📝 packages/client/src/components/game/GameWidgetPanel.tsx (+2 -0)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+9 -0)
📝 packages/client/src/stores/ui.store.ts (+12 -0)

📄 Description

Summary

Adds an opt-in "Mouse-wheel + click navigation" setting under Settings → General (right below "Instantly reveal game text"). When enabled, the player can scroll back through past chat entries with the mouse wheel and step forward with click — without leaving the game scene.

Behavior

wheel up wheel down left click / Next Return button
At present back 1 entry no-op advance segment in current GM turn (hidden)
Reviewing past back 1 forward 1 forward 1 jump home in one shot
  • Each step = one log entry (one parsed narration segment, one dialogue line, or one player input — same granularity as the Logs panel).
  • Wheel-up goes through your own messages too — the chronology matches what you'd see scrolling the Logs.
  • Reviewing past freezes auto-play, hides the chat input, and reveals a yellow Return button next to the Next button. Return jumps straight home; Next / wheel-down / bg-click step forward one entry at a time.
  • Auto-play state is snapshotted when review starts and restored on Return (if it was off, it stays off).
  • Wheel-up clamp comes from the actual flat-log size — no overshoot into "random text" land.

UI immunity

Events that originate inside any of the following are skipped — the offset doesn't move and native UI behavior is unaffected:

  • Native interactive elements: button, a, input, textarea, select, label.
  • ARIA roles: button, link, dialog, menu, menuitem, tab, tablist, slider, checkbox, switch, combobox, listbox, option.
  • Radix popovers: [data-radix-popper-content-wrapper].
  • Explicit opt-out marker [data-game-skip-bg-nav="true"] was added to:
    • The Logs modal (also tagged role="dialog").
    • HUD widget cards (Bonds, Whispers, etc.) — desktop and mobile.
    • The Map widget.

So clicking inside any of those, or wheeling inside the Logs modal, does what you'd expect (scroll, button click, dismiss) without bumping the offset.

Implementation

  • useUIStore.gameMiddleMouseNav — new persisted boolean.
  • GameSurface owns messageOffset/nextActionToken/wheelNavMaxOffset state and a window-level wheel + click listener attached when the toggle is on. Capture phase so nothing can stopPropagation us out of the loop.
  • GameNarration builds a flatLogEntries list (chronological, one entry per visible segment) and resolves the current review entry via flatLogEntries[length - 1 - offset]. Reports the clamp upward via onMaxNavOffsetChange.
  • Step-forward (onStepForward) decrements the offset by one; jump-home (onJumpToLatest) zeroes it. Both wired through GameSurface.
  • DirectionEngine is unmodified — no DOM-stacking gymnastics.

Test plan

  • Toggle off (default): wheel + click behave as before — no nav, no console output.
  • Toggle on with multiple GM turns + your replies in the chat: wheel up walks back through the log one entry at a time, in reverse chronological order. Includes player messages.
  • At review depth N, click on the bare scene area or press Next: offset decreases by 1 each time. After N clicks you land back at the present where you were reading.
  • At review depth N, click Return: offset goes to 0 immediately, narration card returns to the segment you were on before scrolling back.
  • Wheel down at present (offset 0): no-op.
  • Wheel up to the oldest log entry, then keep wheeling: clamp holds, no further back, no overshoot.
  • Click a Bonds/Whispers/HUD widget card or a button inside it: nav does NOT bump.
  • Click the map widget or a location pin inside it: nav does NOT bump.
  • Open Logs modal, scroll inside it, click X to close: nav does NOT bump on any of those.
  • Open Settings panel, scroll inside it, toggle other checkboxes: nav does NOT bump.
  • Auto-play snapshot/restore: enable auto-play, wheel up to review, click Return → auto-play resumes; same with auto-play off (stays off).
  • New GM turn arrives while reviewing past: nothing breaks; clamp updates.
  • Switch chats while reviewing past: offset resets to 0.
  • pnpm check passes.

Summary by CodeRabbit

  • New Features
    • Added the ability to review past narration and turns using mouse-wheel and click navigation while in game mode.
    • Added a new "Game Mode Navigation" toggle in Settings to enable/disable this feature.
    • Navigation state syncs across devices via cloud settings.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/326 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/30/2026 **Status:** ✅ Merged **Merged:** 4/30/2026 **Merged by:** [@LukaTheHero](https://github.com/LukaTheHero) **Base:** `main` ← **Head:** `feat/game-middle-mouse-nav` --- ### 📝 Commits (1) - [`c04b418`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c04b418bd1ebc5829d6389f330ee78bf608f98ef) feat(game): middle-mouse + click navigation through chat history ### 📊 Changes **6 files changed** (+374 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameMap.tsx` (+1 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+246 -27) 📝 `packages/client/src/components/game/GameSurface.tsx` (+104 -0) 📝 `packages/client/src/components/game/GameWidgetPanel.tsx` (+2 -0) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+9 -0) 📝 `packages/client/src/stores/ui.store.ts` (+12 -0) </details> ### 📄 Description ## Summary Adds an opt-in **"Mouse-wheel + click navigation"** setting under Settings → General (right below "Instantly reveal game text"). When enabled, the player can scroll back through past chat entries with the mouse wheel and step forward with click — without leaving the game scene. ## Behavior | | wheel up | wheel down | left click / Next | Return button | |---|---|---|---|---| | **At present** | back 1 entry | no-op | advance segment in current GM turn | (hidden) | | **Reviewing past** | back 1 | forward 1 | forward 1 | jump home in one shot | - Each step = one **log entry** (one parsed narration segment, one dialogue line, or one player input — same granularity as the Logs panel). - Wheel-up goes through your own messages too — the chronology matches what you'd see scrolling the Logs. - Reviewing past freezes auto-play, hides the chat input, and reveals a yellow **Return** button next to the **Next** button. Return jumps straight home; Next / wheel-down / bg-click step forward one entry at a time. - Auto-play state is snapshotted when review starts and restored on Return (if it was off, it stays off). - Wheel-up clamp comes from the actual flat-log size — no overshoot into "random text" land. ## UI immunity Events that originate inside any of the following are skipped — the offset doesn't move and native UI behavior is unaffected: - Native interactive elements: `button, a, input, textarea, select, label`. - ARIA roles: `button, link, dialog, menu, menuitem, tab, tablist, slider, checkbox, switch, combobox, listbox, option`. - Radix popovers: `[data-radix-popper-content-wrapper]`. - Explicit opt-out marker `[data-game-skip-bg-nav="true"]` was added to: - The Logs modal (also tagged `role="dialog"`). - HUD widget cards (Bonds, Whispers, etc.) — desktop and mobile. - The Map widget. So clicking inside any of those, or wheeling inside the Logs modal, does what you'd expect (scroll, button click, dismiss) without bumping the offset. ## Implementation - `useUIStore.gameMiddleMouseNav` — new persisted boolean. - `GameSurface` owns `messageOffset`/`nextActionToken`/`wheelNavMaxOffset` state and a window-level wheel + click listener attached when the toggle is on. Capture phase so nothing can stopPropagation us out of the loop. - `GameNarration` builds a `flatLogEntries` list (chronological, one entry per visible segment) and resolves the current review entry via `flatLogEntries[length - 1 - offset]`. Reports the clamp upward via `onMaxNavOffsetChange`. - Step-forward (`onStepForward`) decrements the offset by one; jump-home (`onJumpToLatest`) zeroes it. Both wired through GameSurface. - `DirectionEngine` is unmodified — no DOM-stacking gymnastics. ## Test plan - [x] Toggle off (default): wheel + click behave as before — no nav, no console output. - [x] Toggle on with multiple GM turns + your replies in the chat: wheel up walks back through the log one entry at a time, in reverse chronological order. Includes player messages. - [x] At review depth N, click on the bare scene area or press Next: offset decreases by 1 each time. After N clicks you land back at the present where you were reading. - [x] At review depth N, click Return: offset goes to 0 immediately, narration card returns to the segment you were on before scrolling back. - [x] Wheel down at present (offset 0): no-op. - [x] Wheel up to the oldest log entry, then keep wheeling: clamp holds, no further back, no overshoot. - [x] Click a Bonds/Whispers/HUD widget card or a button inside it: nav does NOT bump. - [x] Click the map widget or a location pin inside it: nav does NOT bump. - [x] Open Logs modal, scroll inside it, click X to close: nav does NOT bump on any of those. - [x] Open Settings panel, scroll inside it, toggle other checkboxes: nav does NOT bump. - [x] Auto-play snapshot/restore: enable auto-play, wheel up to review, click Return → auto-play resumes; same with auto-play off (stays off). - [x] New GM turn arrives while reviewing past: nothing breaks; clamp updates. - [x] Switch chats while reviewing past: offset resets to 0. - [x] `pnpm check` passes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added the ability to review past narration and turns using mouse-wheel and click navigation while in game mode. * Added a new "Game Mode Navigation" toggle in Settings to enable/disable this feature. * Navigation state syncs across devices via cloud settings. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:08:45 +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#4562
No description provided.