mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #6216] [MERGED] feat(game): finish rolled turns in one request #7095
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7095
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6216
Author: @kolacheee
Created: 9/14/2026
Status: ✅ Merged
Merged: 9/15/2026
Merged by: @kolacheee
Base:
staging← Head:feat/one-request-dice📝 Commits (10+)
29e9d99feat(game): add the one-request dice pass, wrapper and narration gate0c9f0d5feat(game): roll and substitute one-request dice placeholdersfc3fba5feat(game): hide streaming dice placeholders and mark the rolled number86050adfeat(game): keep the half a one-request dice roll selects6b915c6feat(game): teach the one-request dice forms in the GM reminder577e1b7feat(game): add the one-request dice switch, its notices and docs0db91d3feat(game): add the sighted dice pool as a one-request dice sub-optiondb052c3test(game): close the mobile actions menu the one-request dice proof opens35a39a8fix(game): correct one-request dice offsets, holds and continuation records15e6409fix(game): hold the inline dice marker until the typewriter has revealed the segment📊 Changes
51 files changed (+7973 additions, -126 deletions)
View changed files
📝
CHANGELOG.md(+5 -0)📝
docs/game/dice-and-skill-checks.md(+44 -0)📝
docs/game/getting-started.md(+2 -0)➕
e2e/game-one-request-dice.e2e.ts(+574 -0)📝
packages/client/src/components/chat/ChatSettingsDrawer.tsx(+27 -1)📝
packages/client/src/components/game/AnimatedText.tsx(+2 -2)📝
packages/client/src/components/game/GameNarration.tsx(+162 -15)📝
packages/client/src/components/game/GameSurface.tsx(+12 -1)📝
packages/client/src/components/game/game-narration-format.ts(+3 -1)📝
packages/client/src/features/chat-settings/sections/FunctionCallingSection.tsx(+102 -1)📝
packages/client/src/hooks/use-generate.ts(+17 -0)➕
packages/client/src/lib/game-dice-markers.ts(+197 -0)📝
packages/client/src/lib/game-tag-parser.ts(+15 -0)📝
packages/client/src/localization/locales/en.json(+21 -0)📝
packages/client/src/styles/globals.css(+11 -0)📝
packages/server/src/db/file-backed-store.ts(+9 -0)➕
packages/server/src/db/schema/game-dice-pools.ts(+38 -0)📝
packages/server/src/db/schema/index.ts(+1 -0)📝
packages/server/src/routes/generate.routes.ts(+250 -15)➕
packages/server/src/services/game/chance-stream-filter.ts(+204 -0)...and 31 more files
📄 Description
Linked issue
Closes #6215
Why this change
roll_diceis still in the resolved tool set, and a call to it is a full extra round. A Game tool connection other than Same as narrator always makes its own planning request. Neither is the rewrite this PR removes. The switch withdraws only the mode default that auto-attachedroll_dice; a tool the user turned on is honoured as-is.branch=andpool=are unknown attributes to every existing reader, the substituted number is saved bare, and the marker and notice ride on the message extra. With the switch off every touched path renders the bytes it renders today, and the lanes pin that. The one exception worth knowing: the display strippers on both sides now remove the four branch delimiter strings wherever they appear, keeping the prose between them, so a historical turn that happened to contain the literal text[on success]or[/branch]would render without it.What changed
gameOneRequestDiceon chat metadata, rendered in Function Calling directly above Narrate dice outcomes immediately. While it is on, the narration toggle is shown disabled with a note and its stored value is never written, so turning the switch back off gives the player their old setting back. With a separate Game tool connection set, a line says the planning request still applies.generate.routes.ts: the branch arm runs before spatial extraction and the package-verb strip, so a discarded half's commands are never collected; the placeholder arm runs right after the verb strip, so a placeholder inside a verb argument goes away with the verb. A throw-safe wrapper implements the failure contract. The narration-rewrite gate reads throughshouldNarrateGameDiceOutcome, which returns false while the switch is on. Logic lives inpackages/server/src/services/game/one-request-dice.tsso the lanes can drive it without HTTP.packages/shared/src/utils/dice-placeholder.ts). An opener walk over[[roll:, not a bounded regex: every opener produces a bounded span, and every span is either rolled or replaced with the notice, so no raw span survives for a downstream stripper to half-eat. One NdM term, at most one flat number and at most one sheet name (2d6+3,1d8+STR,2d6+STR+3); an attribute name adds the attribute modifier, a skill name adds the skill bonus plus its governing attribute, exactly as a check does. Rolled withcrypto.randomIntat parse time. Each roll is recorded in the dice history, the session log's dice line, and an audit record on the message extra.packages/shared/src/utils/dice-branch.ts).[skill_check ... branch="label"]followed by[branch: label] [on success] ... [on failure] ... [/branch]. Matching is by label and must be one-to-one; a nested block, a check tag inside a block, a missing or duplicated half, or an unmatched label drops the block and re-emits any check tag that sat inside it, so the ask is never lost. The matched check is rolled through the shipped resolver with the session's crypto roller and written back resolved, never left sparse for the client to roll a second time. Closer offsets are taken on the original string, not a lowercased copy. One stated cost: a block that wrote a half marker and never closed runs to the end of the turn and is dropped whole, because keeping one unrolled half would invent the outcome and keeping both would save two contradictory ones. The raw block is logged.chance-stream-filter.ts). A placeholder or branch block is held back from the token stream and the finished sentence arrives throughcontent_replace. A malformed candidate releases only its own bounded prefix and the rest is re-scanned, so the output does not depend on how the provider chunks tokens.titleis added to the narration sanitizer's allowed attributes. The session log gains one plain line per thing the engine could not roll, and a toast fires only when something was declined.gm-prompts.ts). With the switch on, the DICE block is replaced by the case-by-case rule: branch block for a two-way outcome, placeholder for a bare number, sparse tag for a three-way outcome. The sheet-modifier sentence renders only when the chat has names to resolve, theroll_diceline only when the tool is actually in the resolved set, and the "stop at the attempt" line is dropped because it is the instruction the second request exists to serve. With the switch off the block is byte-identical to today.rollreserved.roll,branchandonjoinRESERVED_GM_TAG_NAMESso a package verb cannot shadow the placeholder's inner tag or the block opener.dice-pool.ts,dice-pool.service.ts,game_dice_pools). Six values per size for d4 through d20 and two for d100, thrown withcrypto.randomInt. The prompt shows the next value of each size (window 1 by default). The engine spends from the head in reading order, re-derives every number in the record from the queue and the sheet, bounds the DC to 1 to 40, records any disagreement with what the model wrote inpool=orrolls=without obeying it, and refills once per accepted turn so a swipe, a regenerate and a continuation all face the same queue. A size that goes three accepted turns unspent is rethrown (gameDicePoolAgeTurns, 0 turns it off). Overflow leaves the tag sparse with every number dropped; the client's own skill-check fallback is gated off in pool mode so an overflowed check cannot be rolled live.game_dice_poolstable, one row per chat, message and swipe, registered in the schema, the built-in table list, the shard key map, the lazy-unit set, both cascades and the launcher's sharded-table list, and deleted with the chat and on rewind. NoSTORAGE_VERSIONbump: the table is additive and an older build simply does not read it, which is how the last five table additions were handled.one-request-dice-gate,-placeholders,-branch,-rendering,-prompt,-pool) over the switch gate, the scanner cases, the branch matching and ordering proof, the marker matching, the prompt on and off, and the pool's consumption, refill, window, aging, overflow, mismatch and rewind rules. A new e2e,e2e/game-one-request-dice.e2e.ts, drives a scripted Game Master through a fake provider and asserts one request, one half kept, both numbers substituted, the markers, the dice history and the log, then the pool spending six values in order and leaving the seventh check unrolled with no live roll issued.docs/game/dice-and-skill-checks.mdgains the one-request section with all three forms, the caveats and the pool's trade-off;docs/game/getting-started.mdgains a paragraph in the AI-calls section;CHANGELOG.mdcarries the entries under[Unreleased].Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Run before opening: every piece of
pnpm checkseparately,pnpm version:check,git diff --check, the six new lanes plusgame-text-dice,capability-gm-verbs,capability-gm-verb-runtime,game-mode-dice-tool,gm-skill-check-resolution,message-sharding,prompt,experience-setup-configand the launcher format guard,e2e/game-one-request-dice.e2e.tson desktop and mobile Chromium,e2e/game-native-dice.e2e.tson desktop Chromium as a regression guard, and a local CodeRabbit sweep. Mobile WebKit cannot launch on the author's Fedora host, so CI proves that lane.Still to verify by hand:
]]) saves "(roll unavailable)" in its place, shows the warning toast once, and adds the log line.roll_diceis still offered and that a call to it still works.<dice_pool>, six d20 checks in one reply spend slots 1 to 6 in order, and a seventh is left sparse with the log line.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/game/dice-and-skill-checks.mdanddocs/game/getting-started.mdchanged andCHANGELOG.mdgained entries under[Unreleased]. The[docs-i18n]follow-up for both pages is batched with the other pending pages rather than filed per PR. No version bump. Nostorage-format.jsonchange, for the reason under Storage above.UI evidence (if applicable)
Screenshots of the Function Calling section with the switch and the pool block, an underlined substituted number with its hover, and the session log with the dice lines, to be added by the author.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.