[PR #5703] [MERGED] fix(game): stop claiming the Game Master is writing after the tokens stop #6893

Closed
opened 2026-10-23 04:14:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5703
Author: @Gunterlie
Created: 8/31/2026
Status: ✅ Merged
Merged: 8/31/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/game-mode-writing-status-5692


📝 Commits (8)

  • 2d765c3 fix(game): stop claiming the Game Master is writing after the tokens stop
  • fefcb8f fix(game): drive the narration status from message_saved, not a token-idle timer
  • bdb5216 Merge branch 'staging' into fix/game-mode-writing-status-5692
  • 2274611 Merge branch 'staging' into fix/game-mode-writing-status-5692
  • 6076791 fix(game): scope the narration phase flag to the live stream and each group turn
  • 0e73094 Merge branch 'staging' into fix/game-mode-writing-status-5692
  • 0b03189 Merge branch 'staging' into fix/game-mode-writing-status-5692
  • 580e65a fix(game): guard the group-turn phase reset by stream ownership

📊 Changes

4 files changed (+108 additions, -7 deletions)

View changed files

📝 packages/client/src/components/game/GameNarration.tsx (+26 -6)
📝 packages/client/src/hooks/use-generate.ts (+20 -0)
📝 packages/client/src/stores/chat.store.ts (+24 -1)
➕ scripts/regressions/game-narration-phase.regression.ts (+38 -0)

📄 Description

Closes #5692

Why

In Game Mode the status line said "The Game Master is writing the next segment..." for the whole generation request. But the request stays open well past the last narration token: the server saves the assistant message, then post-processing agents run, the client refreshes messages, and only then does sidecar scene analysis start. With a fast local model that gap is most of the turn, so users watched an idle CPU while the UI insisted text was being generated.

Unlike Roleplay, Game Mode cannot release isStreaming on assistant_message_ready — the segment-by-segment narration reveal depends on the stream staying live — so isStreaming alone cannot tell "the model is writing" apart from "the model is done and the turn is being assembled".

What

The server already sends the exact signal: message_saved fires the moment the narration row is durable. Game generations now record that in a per-chat narrationSavedChatIds flag on the chat store, and the status line reads it — writing label before, the existing "Preparing scene…" label after.

The flag follows the same lifecycle as the neighbouring backgroundIllustrationChatIds: cleared when a new generation takes the chat's abort controller, and cleared by clearPerChatState on teardown.

No new locale keys.

Scope note

This makes the status truthful. It does not shorten the gap itself — reducing the post-generation latency means reordering the server-side post-processing and scene-analysis handoff, which is a separate change.

Test plan

  • pnpm check
  • node scripts/run-regressions.mjs (adds game-narration-phase, pinning that every teardown path clears the flag — a missed clear would strand the next turn on "Preparing scene…")
  • Manually run a Game Mode turn with a fast model and scene analysis enabled; verify the label switches to "Preparing scene…" the moment the narration completes
  • Manually verify the label stays "The Game Master is writing the next segment..." while tokens are still arriving
  • Manually verify with streaming disabled that the writing label shows until the message is saved
  • Manually run two turns in a row and verify the second turn starts on the writing label
  • Manually verify the narration segment reveal and the input bar timing are unchanged

Summary by CodeRabbit

  • New Features

    • Added clearer game narration status updates while the Game Master prepares and writes the next segment.
    • Narration now indicates when text has been saved, even while additional game processing continues.
  • Bug Fixes

    • Improved per-chat narration status tracking and cleanup when starting or ending generation.
  • Tests

    • Added regression coverage for narration status transitions, chat isolation, and reset behavior.

🔄 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/5703 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/31/2026 **Status:** ✅ Merged **Merged:** 8/31/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/game-mode-writing-status-5692` --- ### 📝 Commits (8) - [`2d765c3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d765c3270dce3dd24d2df19b1f8419a672d7626) fix(game): stop claiming the Game Master is writing after the tokens stop - [`fefcb8f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fefcb8f5abebe5df850e1cb1d3e9543355bf3a9c) fix(game): drive the narration status from message_saved, not a token-idle timer - [`bdb5216`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bdb52160c3b00982dd2e76f85f9d079f85f788e1) Merge branch 'staging' into fix/game-mode-writing-status-5692 - [`2274611`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2274611cad09d49c331698c2cfe49fa4c2e3ba29) Merge branch 'staging' into fix/game-mode-writing-status-5692 - [`6076791`](https://github.com/Pasta-Devs/Marinara-Engine/commit/60767914acc702beb83b60db20592cfe3450c1c8) fix(game): scope the narration phase flag to the live stream and each group turn - [`0e73094`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0e7309437d6d16e9330168a99da129df87221a1c) Merge branch 'staging' into fix/game-mode-writing-status-5692 - [`0b03189`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b03189624a01e46eedb6603938a03efa10ea3e3) Merge branch 'staging' into fix/game-mode-writing-status-5692 - [`580e65a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/580e65a923f0428798ed47e8e319d9220266e42d) fix(game): guard the group-turn phase reset by stream ownership ### 📊 Changes **4 files changed** (+108 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameNarration.tsx` (+26 -6) 📝 `packages/client/src/hooks/use-generate.ts` (+20 -0) 📝 `packages/client/src/stores/chat.store.ts` (+24 -1) ➕ `scripts/regressions/game-narration-phase.regression.ts` (+38 -0) </details> ### 📄 Description Closes #5692 ## Why In Game Mode the status line said "The Game Master is writing the next segment..." for the whole generation request. But the request stays open well past the last narration token: the server saves the assistant message, then post-processing agents run, the client refreshes messages, and only then does sidecar scene analysis start. With a fast local model that gap is most of the turn, so users watched an idle CPU while the UI insisted text was being generated. Unlike Roleplay, Game Mode cannot release `isStreaming` on `assistant_message_ready` — the segment-by-segment narration reveal depends on the stream staying live — so `isStreaming` alone cannot tell "the model is writing" apart from "the model is done and the turn is being assembled". ## What The server already sends the exact signal: `message_saved` fires the moment the narration row is durable. Game generations now record that in a per-chat `narrationSavedChatIds` flag on the chat store, and the status line reads it — writing label before, the existing "Preparing scene…" label after. The flag follows the same lifecycle as the neighbouring `backgroundIllustrationChatIds`: cleared when a new generation takes the chat's abort controller, and cleared by `clearPerChatState` on teardown. No new locale keys. ## Scope note This makes the status truthful. It does not shorten the gap itself — reducing the post-generation latency means reordering the server-side post-processing and scene-analysis handoff, which is a separate change. ## Test plan - [ ] `pnpm check` - [ ] `node scripts/run-regressions.mjs` (adds `game-narration-phase`, pinning that every teardown path clears the flag — a missed clear would strand the next turn on "Preparing scene…") - [ ] Manually run a Game Mode turn with a fast model and scene analysis enabled; verify the label switches to "Preparing scene…" the moment the narration completes - [ ] Manually verify the label stays "The Game Master is writing the next segment..." while tokens are still arriving - [ ] Manually verify with streaming disabled that the writing label shows until the message is saved - [ ] Manually run two turns in a row and verify the second turn starts on the writing label - [ ] Manually verify the narration segment reveal and the input bar timing are unchanged <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added clearer game narration status updates while the Game Master prepares and writes the next segment. * Narration now indicates when text has been saved, even while additional game processing continues. * **Bug Fixes** * Improved per-chat narration status tracking and cleanup when starting or ending generation. * **Tests** * Added regression coverage for narration status transitions, chat isolation, and reset behavior. <!-- 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-23 04:14:39 +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#6893
No description provided.