[PR #2721] [MERGED] feat(turn-games): playable UNO in conversation mode + extensible turn-game framework #5718

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2721
Author: @Romuromylus
Created: 6/21/2026
Status: ✅ Merged
Merged: 6/21/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/turn-games-uno


📝 Commits (10+)

  • 69cc0de feat(turn-games): add UNO playable in conversation mode
  • de1366c fix(turn-games): support game_engine_state on the file-storage backend
  • 9414142 feat(turn-games): natural in-character bot turns + board polish
  • 455c349 fix(turn-games): start the bot loop when the opening turn is a bot's
  • 58e3168 feat(turn-games): make conversation bots aware of an in-progress game
  • 79711a4 feat(turn-games): trigger UNO via /uno + natural language, drop the button
  • 628a584 Connect UNO board + free-chat to game state
  • c91c873 Fix duplicate UNO setup modal
  • e3e71be fix(uno): order the board seat row by live turn order
  • 26b0e6f feat(uno): AI-driven UNO start via an in-character agreement command

📊 Changes

36 files changed (+3809 additions, -12 deletions)

View changed files

📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+5 -0)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+1 -0)
📝 packages/client/src/components/chat/ConversationInput.tsx (+11 -0)
📝 packages/client/src/components/chat/ConversationView.tsx (+16 -2)
➕ packages/client/src/components/chat/UnoBoard.tsx (+409 -0)
➕ packages/client/src/components/chat/UnoSetup.tsx (+189 -0)
📝 packages/client/src/hooks/use-generate.ts (+14 -0)
➕ packages/client/src/hooks/use-uno.ts (+135 -0)
📝 packages/client/src/lib/slash-commands.ts (+14 -0)
➕ packages/client/src/stores/uno-game.store.ts (+35 -0)
📝 packages/server/src/db/file-backed-store.ts (+2 -0)
📝 packages/server/src/db/migrate.ts (+17 -0)
➕ packages/server/src/db/schema/game-engine-state.ts (+28 -0)
📝 packages/server/src/db/schema/index.ts (+1 -0)
📝 packages/server/src/routes/conversation.routes.ts (+8 -0)
📝 packages/server/src/routes/generate.routes.ts (+140 -3)
📝 packages/server/src/routes/index.ts (+2 -0)
➕ packages/server/src/routes/turn-games.routes.ts (+94 -0)
📝 packages/server/src/services/conversation/character-commands.ts (+16 -0)
📝 packages/server/src/services/storage/chats.storage.ts (+17 -0)

...and 16 more files

📄 Description

Linked issue

No issue is linked yet, since this is a self-initiated feature. Per the template guidance I am happy to open a feature request to gather opinions and link it here before this leaves draft.

Closes #

Why this change

  • Conversation-mode characters could talk about games but there was no way to actually play one together.
  • UNO is a clean first target for a turn-based, server-authoritative engine, and building it as a small framework (rather than a one-off) means the next game is mostly "one folder plus an engine that satisfies the contract."
  • The aim was a game that lives inside the conversation rather than taking it over: chat continues mid-game, characters react in their own voice, and a character can even start a game when the user proposes one. The board is a real React component (no model-emitted HTML), and the engine is the single source of truth for legality, turn order, and win conditions.

What changed

  • Extensible turn-game framework: a pure-function engine contract plus a codegen registry under packages/shared/src/features/turn-games/. On the server/engine side a new game is a new folder plus a manifest, and the runner, persistence, REST routes, and the generic turn_game_state_patch SSE event stay game-agnostic; each game additionally ships its own client board and store.
  • UNO engine: deterministic with a seeded RNG (deals replay identically; message edits and regenerations rewind the game), server-authoritative legality / turn order / win, a redacted per-viewer publicView for the board, and a hand-free spectatorSummary for free-chat awareness.
  • Server runner and REST (turn-game-runner.service.ts, turn-games.routes.ts) backed by a new game_engine_state table, registered in BOTH storage backends: migrate.ts (libsql) and file-backed-store.ts (the file-native store used in production). A table registered in only one would 500 at runtime.
  • Bot turns run inside a client-opened generate request gated by a new turnGameBots flag that short-circuits the normal conversation pipeline. The model proposes a move via a restricted, per-turn tool call (validated by the engine, with a deterministic fallback so a bot can never stall) and then narrates the engine-confirmed result in character. Move tools are injected per turn rather than added to the global tool registry.
  • Live board (UnoBoard.tsx) driven by a Zustand store fed by an initial fetch plus a new uno_state_patch SSE event. Cards are pure CSS/SVG. The seat row renders in live turn order (current player first, in the play direction, so a Reverse visibly flips the queue) and includes the human in their real slot.
  • Triggering a game: /uno, a natural-language phrase, or a new in-character [uno] conversation command. A character emits [uno] only when the user proposes a game and they are willing to play; declining is simply not emitting it. Defaults on and is toggleable like the other conversation commands (CONVERSATION_COMMAND_KEYS).
  • Schedule and scene integration: the [scene] guidance now excludes card / board games (so "let's play uno" no longer starts a roleplay scene by mistake); characters seated at an active game are treated as present at the table (their schedule offline-skip and dnd/idle typing delay are bypassed for that chat); and autonomous messaging is suppressed while a game is active so it cannot seize the chat's single generation lock and stall a bot turn.

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

Automated checks already run locally: pnpm check (TypeScript + ESLint + production build across all packages) passes, and the turn-game / UNO engine test suite (node:test, gitignored and run locally, so not part of this diff) passes 30/30, including a full game played through the runner with DB round-trips, a 40-game fallback fuzz, and reverse-flips-direction / persona-name / finished-game-context regression guards.

The checkboxes above are intentionally left unticked: per this template's note, an agent should not tick them. The following are the in-browser checks a reviewer should confirm:

  • Start a game via /uno: the setup modal opens, deal works, the board renders for 1vN.
  • Start a game via natural language ("let's play uno") and via a character agreeing in-character ([uno]); a game starts and no roleplay scene is created.
  • Play a full game: Skip / Reverse / Draw Two / Wild / Wild Draw Four, the optional house rules (stacking, draw-to-match, 7-0, jump-in), Call UNO and Catch.
  • Reverse re-orders the seat-row turn display and the play direction.
  • With schedules enabled: a seated character replies promptly mid-game (no dnd delay), offline characters are not seated, and a busy character can still decline a game.
  • Regenerate / branch a message mid-game and confirm the board rewinds correctly.
  • Sanity check the other modes (Roleplay, Game, Visual Novel) for regressions, since this touches generate.routes.ts.

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 version/release-metadata files are touched by this PR.

UI evidence (if applicable)

image image

🔄 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/2721 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/21/2026 **Status:** ✅ Merged **Merged:** 6/21/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/turn-games-uno` --- ### 📝 Commits (10+) - [`69cc0de`](https://github.com/Pasta-Devs/Marinara-Engine/commit/69cc0deb7d76fd7fa7bfee7329148fa3c6ebf6dc) feat(turn-games): add UNO playable in conversation mode - [`de1366c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/de1366c37af6107fe76c4d697db9784bc78d5694) fix(turn-games): support game_engine_state on the file-storage backend - [`9414142`](https://github.com/Pasta-Devs/Marinara-Engine/commit/941414270bf684321c72270206a33c3a07eb660f) feat(turn-games): natural in-character bot turns + board polish - [`455c349`](https://github.com/Pasta-Devs/Marinara-Engine/commit/455c3493603a3c60a9c3a298a5ccecf786196c9f) fix(turn-games): start the bot loop when the opening turn is a bot's - [`58e3168`](https://github.com/Pasta-Devs/Marinara-Engine/commit/58e31684afd43dcce5d0ca6e3507482d0961cbf9) feat(turn-games): make conversation bots aware of an in-progress game - [`79711a4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/79711a4d0b0b7d7dda2cba13276a8ec13809035e) feat(turn-games): trigger UNO via /uno + natural language, drop the button - [`628a584`](https://github.com/Pasta-Devs/Marinara-Engine/commit/628a5843bd31e1f777dcaa87c14d5ee5db4b795e) Connect UNO board + free-chat to game state - [`c91c873`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c91c873fbdc5fce2198751325783a00394329976) Fix duplicate UNO setup modal - [`e3e71be`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e3e71be6830cfb8acb0e92329d9a8e8260d665df) fix(uno): order the board seat row by live turn order - [`26b0e6f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/26b0e6f5a91cc47c34130a48a98bff464d072dd6) feat(uno): AI-driven UNO start via an in-character agreement command ### 📊 Changes **36 files changed** (+3809 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+5 -0) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+1 -0) 📝 `packages/client/src/components/chat/ConversationInput.tsx` (+11 -0) 📝 `packages/client/src/components/chat/ConversationView.tsx` (+16 -2) ➕ `packages/client/src/components/chat/UnoBoard.tsx` (+409 -0) ➕ `packages/client/src/components/chat/UnoSetup.tsx` (+189 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+14 -0) ➕ `packages/client/src/hooks/use-uno.ts` (+135 -0) 📝 `packages/client/src/lib/slash-commands.ts` (+14 -0) ➕ `packages/client/src/stores/uno-game.store.ts` (+35 -0) 📝 `packages/server/src/db/file-backed-store.ts` (+2 -0) 📝 `packages/server/src/db/migrate.ts` (+17 -0) ➕ `packages/server/src/db/schema/game-engine-state.ts` (+28 -0) 📝 `packages/server/src/db/schema/index.ts` (+1 -0) 📝 `packages/server/src/routes/conversation.routes.ts` (+8 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+140 -3) 📝 `packages/server/src/routes/index.ts` (+2 -0) ➕ `packages/server/src/routes/turn-games.routes.ts` (+94 -0) 📝 `packages/server/src/services/conversation/character-commands.ts` (+16 -0) 📝 `packages/server/src/services/storage/chats.storage.ts` (+17 -0) _...and 16 more files_ </details> ### 📄 Description ## Linked issue No issue is linked yet, since this is a self-initiated feature. Per the template guidance I am happy to open a feature request to gather opinions and link it here before this leaves draft. Closes # ## Why this change - Conversation-mode characters could talk *about* games but there was no way to actually play one together. - UNO is a clean first target for a turn-based, server-authoritative engine, and building it as a small framework (rather than a one-off) means the next game is mostly "one folder plus an engine that satisfies the contract." - The aim was a game that lives *inside* the conversation rather than taking it over: chat continues mid-game, characters react in their own voice, and a character can even start a game when the user proposes one. The board is a real React component (no model-emitted HTML), and the engine is the single source of truth for legality, turn order, and win conditions. ## What changed - **Extensible turn-game framework**: a pure-function engine contract plus a codegen registry under `packages/shared/src/features/turn-games/`. On the server/engine side a new game is a new folder plus a manifest, and the runner, persistence, REST routes, and the generic `turn_game_state_patch` SSE event stay game-agnostic; each game additionally ships its own client board and store. - **UNO engine**: deterministic with a seeded RNG (deals replay identically; message edits and regenerations rewind the game), server-authoritative legality / turn order / win, a redacted per-viewer `publicView` for the board, and a hand-free `spectatorSummary` for free-chat awareness. - **Server runner and REST** (`turn-game-runner.service.ts`, `turn-games.routes.ts`) backed by a new `game_engine_state` table, registered in BOTH storage backends: `migrate.ts` (libsql) and `file-backed-store.ts` (the file-native store used in production). A table registered in only one would 500 at runtime. - **Bot turns** run inside a client-opened generate request gated by a new `turnGameBots` flag that short-circuits the normal conversation pipeline. The model proposes a move via a restricted, per-turn tool call (validated by the engine, with a deterministic fallback so a bot can never stall) and then narrates the engine-confirmed result in character. Move tools are injected per turn rather than added to the global tool registry. - **Live board** (`UnoBoard.tsx`) driven by a Zustand store fed by an initial fetch plus a new `uno_state_patch` SSE event. Cards are pure CSS/SVG. The seat row renders in live turn order (current player first, in the play direction, so a Reverse visibly flips the queue) and includes the human in their real slot. - **Triggering a game**: `/uno`, a natural-language phrase, or a new in-character `[uno]` conversation command. A character emits `[uno]` only when the user proposes a game and they are willing to play; declining is simply not emitting it. Defaults on and is toggleable like the other conversation commands (`CONVERSATION_COMMAND_KEYS`). - **Schedule and scene integration**: the `[scene]` guidance now excludes card / board games (so "let's play uno" no longer starts a roleplay scene by mistake); characters seated at an active game are treated as present at the table (their schedule offline-skip and dnd/idle typing delay are bypassed for that chat); and autonomous messaging is suppressed while a game is active so it cannot seize the chat's single generation lock and stall a bot turn. ## 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 Automated checks already run locally: `pnpm check` (TypeScript + ESLint + production build across all packages) passes, and the turn-game / UNO engine test suite (node:test, gitignored and run locally, so not part of this diff) passes 30/30, including a full game played through the runner with DB round-trips, a 40-game fallback fuzz, and reverse-flips-direction / persona-name / finished-game-context regression guards. The checkboxes above are intentionally left unticked: per this template's note, an agent should not tick them. The following are the in-browser checks a reviewer should confirm: - Start a game via `/uno`: the setup modal opens, deal works, the board renders for 1vN. - Start a game via natural language ("let's play uno") and via a character agreeing in-character (`[uno]`); a game starts and no roleplay scene is created. - Play a full game: Skip / Reverse / Draw Two / Wild / Wild Draw Four, the optional house rules (stacking, draw-to-match, 7-0, jump-in), Call UNO and Catch. - Reverse re-orders the seat-row turn display and the play direction. - With schedules enabled: a seated character replies promptly mid-game (no dnd delay), offline characters are not seated, and a busy character can still decline a game. - Regenerate / branch a message mid-game and confirm the board rewinds correctly. - Sanity check the other modes (Roleplay, Game, Visual Novel) for regressions, since this touches `generate.routes.ts`. ## 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 version/release-metadata files are touched by this PR. ## UI evidence (if applicable) <img width="2064" height="1255" alt="image" src="https://github.com/user-attachments/assets/cda2ca80-329c-423d-8308-dc4486b9c050" /> <img width="2061" height="1327" alt="image" src="https://github.com/user-attachments/assets/81c6c511-f121-44ef-b586-910ad146fb27" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:48 +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#5718
No description provided.