[PR #306] [MERGED] feat(game): Interrupt button with risky/force confirmation flow #4552

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

📋 Pull Request Information

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

Base: main ← Head: feat/interrupt-button


📝 Commits (2)

  • 2d4ea4c feat(game): add Interrupt button with risky/force confirmation flow
  • 08d280a Address interrupt review feedback

📊 Changes

3 files changed (+609 additions, -41 deletions)

View changed files

📝 packages/client/src/components/game/GameInput.tsx (+60 -3)
📝 packages/client/src/components/game/GameNarration.tsx (+339 -35)
📝 packages/client/src/components/game/GameSurface.tsx (+210 -3)

📄 Description

Summary

Adds an Interrupt! button to game-mode narration so the player can stop the GM mid-action and write back early. Click → confirmation modal → soft-pause → type → send. Nothing is mutated server-side until the player actually sends, so backing out (Resume / No) is a true undo.

The confirmation modal exposes three options:

  • No — close, narration resumes from where it paused.
  • Yes (red) — risky in-fiction interrupt; the GM is told via a one-line system message and may resist or fail the attempt. The input bar paints red, the dice button glows, and a using dice recommended hint appears next to it.
  • Force Interrupt (#20C20E hacker green) — cuts in cleanly. The GM's last message is truncated at the segment the player saw, but no system message is added, so the GM has no idea anything was cut. Input bar gets a matching green ring + force interrupting label.

The truncation reuses the same line-based emission logic as parseNarrationSegments, so the prior assistant message is shortened to end at the segment the player was reading. On send, the truncation PATCH is awaited before /generate reads from the DB, so prompt construction sees the cut.

Auto-play state is snapshotted on pause and restored on Resume — if it was off, it stays off. A stale interrupt anchor self-clears on chat switch or when a new GM turn arrives, so it can never be applied to the wrong message.

Screenshots

Desktop

image image image

Mobile

WhatsApp Image 2026-04-28 at 10 46 32 PM WhatsApp Image 2026-04-28 at 10 46 31 PM WhatsApp Image 2026-04-28 at 10 46 31 PM (1)

Test plan

  • Click Interrupt! mid-narration — modal appears, narration pauses, input bar does NOT appear behind the modal, auto-play stops.
  • Click No — modal closes, narration resumes, auto-play returns to its prior state.
  • Click Yes — modal closes, input bar appears with red ring, dice button glows, using dice recommended label visible (>=640px).
  • Click Force Interrupt — modal closes, input bar appears with green ring, force interrupting label visible, dice not glowing.
  • Click Resume in either committed mode — pending interrupt is discarded, narration resumes, auto-play returns to its prior state, no server-side mutation occurred.
  • In Yes (risky) mode, send a turn — verify the GM message in chat history was truncated at the segment you saw AND a [Interrupt] … system message appears just before your user turn. Next AI response acknowledges the interrupt.
  • In Force mode, send a turn — verify the GM message is truncated but NO system message is added. Next AI response continues without knowing it was interrupted.
  • Queue a dice roll in Yes mode and send — verify the dice tag is appended to your user message and the GM treats the result as the interrupt's success/failure.
  • Switch chats while an interrupt is pending — pending state clears.
  • Wait for a new GM turn while an interrupt is pending — pending state clears.
  • Test on mobile (<640px): all narration-card controls fit on one row (Logs/Inventory/Interrupt collapse to icons).
  • Confirm `pnpm check` passes.

Summary by CodeRabbit

  • New Features
    • Interrupt flow: players can request, confirm, force, or resume narration interruptions with a confirmation modal.
    • Two interrupt modes: "risky" (dice-recommended hint + red styling) and "force" (green highlight, no cost).
    • Inline input now appears appropriately during/after interrupts; narration auto-play pauses and restores around interrupt actions.
    • Input focus behavior improved and buttons/tooltips updated to reflect interrupt state.

🔄 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/306 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/29/2026 **Status:** ✅ Merged **Merged:** 4/29/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `feat/interrupt-button` --- ### 📝 Commits (2) - [`2d4ea4c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d4ea4ce4d62ac9c7b4d29fc620d67b22a8aa190) feat(game): add Interrupt button with risky/force confirmation flow - [`08d280a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/08d280a5feaa39976aaf942332493dabb8ed232b) Address interrupt review feedback ### 📊 Changes **3 files changed** (+609 additions, -41 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/game/GameInput.tsx` (+60 -3) 📝 `packages/client/src/components/game/GameNarration.tsx` (+339 -35) 📝 `packages/client/src/components/game/GameSurface.tsx` (+210 -3) </details> ### 📄 Description ## Summary Adds an **Interrupt!** button to game-mode narration so the player can stop the GM mid-action and write back early. Click → confirmation modal → soft-pause → type → send. Nothing is mutated server-side until the player actually sends, so backing out (Resume / No) is a true undo. The confirmation modal exposes three options: - **No** — close, narration resumes from where it paused. - **Yes** (red) — *risky* in-fiction interrupt; the GM is told via a one-line system message and may resist or fail the attempt. The input bar paints red, the dice button glows, and a `using dice recommended` hint appears next to it. - **Force Interrupt** (`#20C20E` hacker green) — cuts in cleanly. The GM's last message is truncated at the segment the player saw, but no system message is added, so the GM has no idea anything was cut. Input bar gets a matching green ring + `force interrupting` label. The truncation reuses the same line-based emission logic as `parseNarrationSegments`, so the prior assistant message is shortened to end at the segment the player was reading. On send, the truncation `PATCH` is awaited before `/generate` reads from the DB, so prompt construction sees the cut. Auto-play state is snapshotted on pause and restored on Resume — if it was off, it stays off. A stale interrupt anchor self-clears on chat switch or when a new GM turn arrives, so it can never be applied to the wrong message. ## Screenshots ### Desktop <img width="1907" height="861" alt="image" src="https://github.com/user-attachments/assets/5937acc1-e585-45c0-8cbd-c2e223a008ea" /> <img width="1038" height="728" alt="image" src="https://github.com/user-attachments/assets/10e9cd3f-568b-4a17-91b5-90831107f59d" /> <img width="1908" height="863" alt="image" src="https://github.com/user-attachments/assets/b561b235-226d-409b-8b48-6e0e1ee9f63c" /> ### Mobile <img width="945" height="2048" alt="WhatsApp Image 2026-04-28 at 10 46 32 PM" src="https://github.com/user-attachments/assets/e04df026-4ac7-4fba-8f5d-dcd5a333f6af" /> <img width="945" height="2048" alt="WhatsApp Image 2026-04-28 at 10 46 31 PM" src="https://github.com/user-attachments/assets/3ebd21c5-6d2d-41b7-a829-225db52eadfc" /> <img width="945" height="2048" alt="WhatsApp Image 2026-04-28 at 10 46 31 PM (1)" src="https://github.com/user-attachments/assets/8fba3d65-0034-420c-a357-8e1e6b44042b" /> ## Test plan - [x] Click **Interrupt!** mid-narration — modal appears, narration pauses, input bar does NOT appear behind the modal, auto-play stops. - [x] Click **No** — modal closes, narration resumes, auto-play returns to its prior state. - [x] Click **Yes** — modal closes, input bar appears with red ring, dice button glows, `using dice recommended` label visible (>=640px). - [x] Click **Force Interrupt** — modal closes, input bar appears with green ring, `force interrupting` label visible, dice not glowing. - [x] Click **Resume** in either committed mode — pending interrupt is discarded, narration resumes, auto-play returns to its prior state, no server-side mutation occurred. - [x] In Yes (risky) mode, send a turn — verify the GM message in chat history was truncated at the segment you saw AND a `[Interrupt] …` system message appears just before your user turn. Next AI response acknowledges the interrupt. - [x] In Force mode, send a turn — verify the GM message is truncated but NO system message is added. Next AI response continues without knowing it was interrupted. - [x] Queue a dice roll in Yes mode and send — verify the dice tag is appended to your user message and the GM treats the result as the interrupt's success/failure. - [x] Switch chats while an interrupt is pending — pending state clears. - [x] Wait for a new GM turn while an interrupt is pending — pending state clears. - [x] Test on mobile (<640px): all narration-card controls fit on one row (Logs/Inventory/Interrupt collapse to icons). - [x] Confirm \`pnpm check\` passes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Interrupt flow: players can request, confirm, force, or resume narration interruptions with a confirmation modal. * Two interrupt modes: "risky" (dice-recommended hint + red styling) and "force" (green highlight, no cost). * Inline input now appears appropriately during/after interrupts; narration auto-play pauses and restores around interrupt actions. * Input focus behavior improved and buttons/tooltips updated to reflect interrupt state. <!-- 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: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#4552
No description provided.