[PR #544] [MERGED] Fix game scene time drift #4665

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/544
Author: @cha1latte
Created: 5/8/2026
Status: ✅ Merged
Merged: 5/8/2026
Merged by: @cha1latte

Base: main ← Head: fix/issue-516-gm-state-drift


📝 Commits (1)

  • ab73888 Fix game scene time drift

📊 Changes

5 files changed (+85 additions, -20 deletions)

View changed files

📝 packages/server/src/routes/game.routes.ts (+14 -18)
📝 packages/server/src/services/game/gm-prompts.ts (+3 -1)
📝 packages/server/src/services/game/time.service.ts (+20 -1)
📝 packages/server/test/game-session-prompts.test.ts (+23 -0)
➕ packages/server/test/game-time.test.ts (+25 -0)

📄 Description

Linked issue

Closes #516

Why this change

  • Scene analysis was treating repeated time-of-day observations as clock commands. When the scene analyzer kept returning the same label such as night, the HUD day counter advanced by one day per turn even if the narration had not moved forward.
  • The GM widget prompt also did not clearly separate visual HUD widget mirroring from durable player/party stat storage, which made widget/stat ownership easier for the model to blur.

What changed

  • Added setTimeOfDay() so scene-analysis labels preserve the current day when the label already matches the current phase, advance within the same day for later phases, and roll over only for true earlier-phase transitions.
  • Updated /game/time/advance to use the new scene-label helper instead of directly incrementing the day whenever the target hour was less than or equal to the current hour.
  • Hardened the GM format reminder so HUD widgets are updated consistently as visible UI state while durable player/party facts remain in their canonical systems.
  • Added server regression coverage for repeated scene labels and the widget/stat prompt boundary.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Machine verification: node scratch\issue-516-time-repro.mjs

    Issue #516 time repro
    Input labels: night, night, night, night, night
    Before fix: {"day":6,"hour":21,"minute":0}
    After fix: {"day":1,"hour":21,"minute":0}
    
  • Machine verification: pnpm --filter @marinara-engine/server exec tsx --test test/game-time.test.ts test/game-session-prompts.test.ts

    • 13 tests passed.
  • Machine verification: pnpm check

    • Passed: impeccable context check, lint/type checks, shared/server/client builds.
  • Manual follow-up worth doing before merge: run a short real Game mode session with a configured scene-analysis model and confirm the HUD day no longer increments when the scene remains in the same time-of-day phase.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No docs or release metadata changed.

UI evidence (if applicable)

N/A - backend/game-state logic and GM prompt behavior. The raw command proof above captures the before/after state transition.


🔄 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/544 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/8/2026 **Status:** ✅ Merged **Merged:** 5/8/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-516-gm-state-drift` --- ### 📝 Commits (1) - [`ab73888`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ab7388840bcf7a76a8ab9e4633bb8441fad62f62) Fix game scene time drift ### 📊 Changes **5 files changed** (+85 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/game.routes.ts` (+14 -18) 📝 `packages/server/src/services/game/gm-prompts.ts` (+3 -1) 📝 `packages/server/src/services/game/time.service.ts` (+20 -1) 📝 `packages/server/test/game-session-prompts.test.ts` (+23 -0) ➕ `packages/server/test/game-time.test.ts` (+25 -0) </details> ### 📄 Description ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #516 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Scene analysis was treating repeated time-of-day observations as clock commands. When the scene analyzer kept returning the same label such as `night`, the HUD day counter advanced by one day per turn even if the narration had not moved forward. - The GM widget prompt also did not clearly separate visual HUD widget mirroring from durable player/party stat storage, which made widget/stat ownership easier for the model to blur. ## What changed <!-- List the key changes in this PR --> - Added `setTimeOfDay()` so scene-analysis labels preserve the current day when the label already matches the current phase, advance within the same day for later phases, and roll over only for true earlier-phase transitions. - Updated `/game/time/advance` to use the new scene-label helper instead of directly incrementing the day whenever the target hour was less than or equal to the current hour. - Hardened the GM format reminder so HUD widgets are updated consistently as visible UI state while durable player/party facts remain in their canonical systems. - Added server regression coverage for repeated scene labels and the widget/stat prompt boundary. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Machine verification: `node scratch\issue-516-time-repro.mjs` ```text Issue #516 time repro Input labels: night, night, night, night, night Before fix: {"day":6,"hour":21,"minute":0} After fix: {"day":1,"hour":21,"minute":0} ``` - Machine verification: `pnpm --filter @marinara-engine/server exec tsx --test test/game-time.test.ts test/game-session-prompts.test.ts` - 13 tests passed. - Machine verification: `pnpm check` - Passed: impeccable context check, lint/type checks, shared/server/client builds. - Manual follow-up worth doing before merge: run a short real Game mode session with a configured scene-analysis model and confirm the HUD day no longer increments when the scene remains in the same time-of-day phase. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No docs or release metadata changed. ## UI evidence (if applicable) N/A - backend/game-state logic and GM prompt behavior. The raw command proof above captures the before/after state transition. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:09:36 +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#4665
No description provided.