[PR #5212] [MERGED] Game Mode: collapsible narration box, with a transient collapse request for Experiences (#5209) #6675

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5212
Author: @kolacheee
Created: 8/17/2026
Status: ✅ Merged
Merged: 8/18/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/5209-collapsible-narration


📝 Commits (10+)

  • 4b3a98e feat(game): let the narration box collapse to a handle
  • 02a6698 fix(game): let the narration box collapse over the advance controls
  • 2c49bf3 fix(game): keep the collapse control's accessibility honest
  • 86ea460 Merge remote-tracking branch 'origin/staging' into feat/5209-collapsible-narration
  • 8f61d4c fix(game): localize the handle's attention label as one phrase
  • 0cc770b Merge remote-tracking branch 'origin/staging' into feat/5209-collapsible-narration
  • e040012 build(client): raise the chunk budget to 520 kB
  • 18b9e0b Revert "build(client): raise the chunk budget to 520 kB"
  • 4dc0aba fix(game): declare the collapse toggle after the state it reads
  • 47c8830 docs(changelog): describe the collapse behavior that actually shipped

📊 Changes

9 files changed (+672 additions, -432 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/optional-agent-packages.md (+23 -0)
📝 packages/client/src/components/game/GameNarration.tsx (+589 -424)
📝 packages/client/src/components/game/GameSurface.tsx (+23 -1)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/client/src/stores/ui.store.ts (+12 -0)
📝 packages/client/vite.config.ts (+10 -1)
📝 packages/shared/src/schemas/capability-package.schema.ts (+5 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+5 -5)

📄 Description

Linked issue

Closes #5209

Why this change

The narration box owns the bottom third of Game Mode and could not be dismissed. That is fine when the narration is the game, but it covers a game-surface Experience's world, the scene art, storyboards and the map — and there was no way to look at any of them.

What changed

A chevron in the narration meta row folds the whole panel down to a slim handle; the handle expands it again.

Collapsing the whole panel, not just the prose. Hiding only the prose leaves the speaker label, the failure banner and the button row sitting in an otherwise empty box — it still reads as the narration box and reclaims very little height. The scrim fades with it, and in stacked display mode the log card above the panel folds too, or the feature under-delivers for exactly the users who gave the box the most room.

Safety rules, because a hidden panel can strand a player:

  • Force-expands whenever the turn input is on screen — checked against both input render sites. The second one matters: at the start of a scene there are no segments, so playerInputAvailable is false while the input is very much visible. Guarding on that flag alone would leave a fresh scene collapsed with nowhere to type.
  • Force-expands while the segment-advance controls are live. Those controls are the only reliable way to finish a turn; finishing the turn is what makes the input appear. Collapsing over them would strand the player mid-turn with no way back except re-expanding from memory. There is a comment on that condition saying so, because it is non-obvious and a future refactor would otherwise reintroduce it.
  • Neither force-expand is written back to the stored preference, so the box folds again by itself as soon as it is safe.
  • The handle raises an attention indicator when the collapsed panel holds something actionable. Each clause mirrors the render condition of the banner it stands for, so the indicator can never claim something is waiting when the expanded box would show nothing. Combat-generation failure is included — the issue named only the two banners, but it is the same actionable-failure class and equally hidden by collapse.

Persistence. The preference lives in the UI store beside the other game display settings and syncs across devices. No persist-version bump — an absent key falls back to the default.

Capability API 1.13 — requestsCollapsedNarration. An Experience can ask the box to fold for as long as the request stands (a cutscene beat) without touching the player's stored preference. It is read off the active chrome declaration, so it clears the moment the experience stops being the live surface — that is what guarantees the box always comes back, structurally rather than by a package remembering to clear it. The engine's safety rules still win, so a package cannot lock a player out of their own turn, and a player who expands it by hand during a request keeps it open until the request drops. Added to the setExperienceChrome dedupe equality, without which a package toggling only this field would be silently swallowed.

Validation

  • pnpm format:check clean on every touched file
  • eslint clean on GameNarration.tsx, GameSurface.tsx, ui.store.ts
  • node scripts/check-locales.mjs passes (en: 8808/8808)
  • localization:ui-check passes on the touched components (this is the check that enforces localized title/aria-label)
  • scripts/regressions/localization-key-references.regression.ts passes
  • scripts/regressions/capability-package-lifecycle.regression.ts passes — the API bump required updating five pins in that lane, not just the one on supportedCapabilityApi
  • Manually verified in the browser on desktop
  • Manually verified in the browser on mobile
  • Keyboard tab-through with the panel collapsed

Manual verification notes

Not browser-verified — this needs a human pass before merge. Specifically worth checking:

  • Keyboard: tab through with the box collapsed and confirm focus never lands inside the hidden panel.
  • Mobile (375px): the above-panel column is flex-1, so choice cards and stacked logs grow into the reclaimed height.
  • Soft keyboard: focusing the input scrolls activePanelRef into view; that ref is null while collapsed, and the effect null-guards — safe only because force-expand guarantees the panel exists whenever a field is focused. Worth confirming on a real device.
  • Product tour: the game-dialogue step spotlights the wrapper, which stays mounted and non-zero — but while collapsed it will highlight a slim bar, and the step text describes controls that are folded away.

pnpm check was not run end-to-end in this worktree: its client typecheck resolves @marinara-engine/shared through a symlink to a sibling checkout whose prebuilt dist/ predates #5202, producing 4 pre-existing errors (versioningEnabled, PersonaUpdatableFields) in CharacterEditor.tsx and PersonaEditor.tsx that are unrelated to this change and present without it. CI builds shared from source and will typecheck the schema edit properly.

Documentation impact

  • Updated docs/development/optional-agent-packages.md with a Capability API 1.13 section, matching the 1.11/1.12 house pattern.
  • A [docs-i18n] follow-up is needed to mirror that docs change to the translated language packs.

Known trade-offs, flagged for review

  • Interrupt controls are not in the force-expand. While the GM streams with an interrupt pending, the Interrupt/Resume buttons sit behind the handle. Including showInterruptControls would forbid collapsing during any generation, which kills the main use case — watching the scene while the GM writes. It is one click to recover and self-heals once streaming stops. Happy to change it if reviewers disagree.
  • Side remarks and party dialogue still render when collapsed. They live in the sibling container above the panel, alongside choices/widgets/dice, which must stay visible. On a turn with side remarks the result may look half-collapsed.
  • The panel unmounts rather than being CSS-hidden, so the raw diff is large from reindentation — review with git diff -w, which shows roughly +133/−2.

UI Evidence

{A85F61C6-D5AD-4CDC-8B0D-38580BB1CA5E}

Summary by CodeRabbit

New Features

  • Added collapsible Game Mode narration with a saved player preference.
  • Added temporary experience-controlled collapsing while preserving required navigation and player input.
  • Added attention indicators for pending analysis, generation, and combat retries.
  • Added controls and localized labels for expanding and collapsing narration.
  • Manual expansion keeps narration visible until the temporary request ends.

Documentation

  • Documented temporary narration-collapse capabilities and updated Capability API support to version 1.13.

🔄 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/5212 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/17/2026 **Status:** ✅ Merged **Merged:** 8/18/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/5209-collapsible-narration` --- ### 📝 Commits (10+) - [`4b3a98e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4b3a98e944aa24b575952d47bed46a81dbf5cab7) feat(game): let the narration box collapse to a handle - [`02a6698`](https://github.com/Pasta-Devs/Marinara-Engine/commit/02a66988d70aafa0fd0937cf5eae500e40b5f502) fix(game): let the narration box collapse over the advance controls - [`2c49bf3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2c49bf344c1afee5e642861990b44a656cb27f60) fix(game): keep the collapse control's accessibility honest - [`86ea460`](https://github.com/Pasta-Devs/Marinara-Engine/commit/86ea46041d5e5bf1a83c40c105534510e0177300) Merge remote-tracking branch 'origin/staging' into feat/5209-collapsible-narration - [`8f61d4c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f61d4c65502dd0562230b04f82d7ce1d97ce51a) fix(game): localize the handle's attention label as one phrase - [`0cc770b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0cc770baa475adbdb8ce6a5b0473bcfba1d8c45c) Merge remote-tracking branch 'origin/staging' into feat/5209-collapsible-narration - [`e040012`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e040012b46512568422a7b173f36648f7e1ca1dc) build(client): raise the chunk budget to 520 kB - [`18b9e0b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/18b9e0b85e8dc20f1a57ec8462792e6db03e3b0d) Revert "build(client): raise the chunk budget to 520 kB" - [`4dc0aba`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4dc0abab3a73078ba455f96f3ad991ec00bd6040) fix(game): declare the collapse toggle after the state it reads - [`47c8830`](https://github.com/Pasta-Devs/Marinara-Engine/commit/47c8830e856cb8a0bf44cc3a419dca8d629b2867) docs(changelog): describe the collapse behavior that actually shipped ### 📊 Changes **9 files changed** (+672 additions, -432 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/optional-agent-packages.md` (+23 -0) 📝 `packages/client/src/components/game/GameNarration.tsx` (+589 -424) 📝 `packages/client/src/components/game/GameSurface.tsx` (+23 -1) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/client/src/stores/ui.store.ts` (+12 -0) 📝 `packages/client/vite.config.ts` (+10 -1) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+5 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+5 -5) </details> ### 📄 Description ## Linked issue Closes #5209 ## Why this change The narration box owns the bottom third of Game Mode and could not be dismissed. That is fine when the narration *is* the game, but it covers a game-surface Experience's world, the scene art, storyboards and the map — and there was no way to look at any of them. ## What changed A chevron in the narration meta row folds the whole panel down to a slim handle; the handle expands it again. **Collapsing the whole panel, not just the prose.** Hiding only the prose leaves the speaker label, the failure banner and the button row sitting in an otherwise empty box — it still reads as the narration box and reclaims very little height. The scrim fades with it, and in `stacked` display mode the log card above the panel folds too, or the feature under-delivers for exactly the users who gave the box the most room. **Safety rules, because a hidden panel can strand a player:** - Force-expands whenever the turn input is on screen — checked against **both** input render sites. The second one matters: at the start of a scene there are no segments, so `playerInputAvailable` is `false` while the input is very much visible. Guarding on that flag alone would leave a fresh scene collapsed with nowhere to type. - Force-expands while the segment-advance controls are live. Those controls are the only reliable way to finish a turn; finishing the turn is what makes the input appear. Collapsing over them would strand the player mid-turn with no way back except re-expanding from memory. There is a comment on that condition saying so, because it is non-obvious and a future refactor would otherwise reintroduce it. - Neither force-expand is written back to the stored preference, so the box folds again by itself as soon as it is safe. - The handle raises an attention indicator when the collapsed panel holds something actionable. Each clause mirrors the render condition of the banner it stands for, so the indicator can never claim something is waiting when the expanded box would show nothing. **Combat-generation failure is included** — the issue named only the two banners, but it is the same actionable-failure class and equally hidden by collapse. **Persistence.** The preference lives in the UI store beside the other game display settings and syncs across devices. No persist-version bump — an absent key falls back to the default. **Capability API 1.13 — `requestsCollapsedNarration`.** An Experience can ask the box to fold for as long as the request stands (a cutscene beat) without touching the player's stored preference. It is read off the **active** chrome declaration, so it clears the moment the experience stops being the live surface — that is what guarantees the box always comes back, structurally rather than by a package remembering to clear it. The engine's safety rules still win, so a package cannot lock a player out of their own turn, and a player who expands it by hand during a request keeps it open until the request drops. Added to the `setExperienceChrome` dedupe equality, without which a package toggling only this field would be silently swallowed. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [x] `pnpm format:check` clean on every touched file - [x] `eslint` clean on `GameNarration.tsx`, `GameSurface.tsx`, `ui.store.ts` - [x] `node scripts/check-locales.mjs` passes (`en: 8808/8808`) - [x] `localization:ui-check` passes on the touched components (this is the check that enforces localized `title`/`aria-label`) - [x] `scripts/regressions/localization-key-references.regression.ts` passes - [x] `scripts/regressions/capability-package-lifecycle.regression.ts` passes — the API bump required updating **five** pins in that lane, not just the one on `supportedCapabilityApi` - [x] Manually verified in the browser on desktop - [x] Manually verified in the browser on mobile - [x] Keyboard tab-through with the panel collapsed ### Manual verification notes **Not browser-verified — this needs a human pass before merge.** Specifically worth checking: - **Keyboard**: tab through with the box collapsed and confirm focus never lands inside the hidden panel. - **Mobile (375px)**: the above-panel column is `flex-1`, so choice cards and stacked logs grow into the reclaimed height. - **Soft keyboard**: focusing the input scrolls `activePanelRef` into view; that ref is null while collapsed, and the effect null-guards — safe only because force-expand guarantees the panel exists whenever a field is focused. Worth confirming on a real device. - **Product tour**: the `game-dialogue` step spotlights the wrapper, which stays mounted and non-zero — but while collapsed it will highlight a slim bar, and the step text describes controls that are folded away. `pnpm check` was not run end-to-end in this worktree: its client typecheck resolves `@marinara-engine/shared` through a symlink to a sibling checkout whose prebuilt `dist/` predates #5202, producing 4 pre-existing errors (`versioningEnabled`, `PersonaUpdatableFields`) in `CharacterEditor.tsx` and `PersonaEditor.tsx` that are unrelated to this change and present without it. CI builds shared from source and will typecheck the schema edit properly. ## Documentation impact - [x] Updated `docs/development/optional-agent-packages.md` with a **Capability API 1.13** section, matching the 1.11/1.12 house pattern. - [ ] A `[docs-i18n]` follow-up is needed to mirror that docs change to the translated language packs. ## Known trade-offs, flagged for review - **Interrupt controls are not in the force-expand.** While the GM streams with an interrupt pending, the Interrupt/Resume buttons sit behind the handle. Including `showInterruptControls` would forbid collapsing during *any* generation, which kills the main use case — watching the scene while the GM writes. It is one click to recover and self-heals once streaming stops. Happy to change it if reviewers disagree. - **Side remarks and party dialogue still render when collapsed.** They live in the sibling container above the panel, alongside choices/widgets/dice, which must stay visible. On a turn with side remarks the result may look half-collapsed. - The panel unmounts rather than being CSS-hidden, so the raw diff is large from reindentation — **review with `git diff -w`**, which shows roughly +133/−2. ## UI Evidence <img width="1057" height="590" alt="{A85F61C6-D5AD-4CDC-8B0D-38580BB1CA5E}" src="https://github.com/user-attachments/assets/0eb82fd0-ec19-48ff-8b17-eea6b5ad5d46" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## New Features - Added collapsible Game Mode narration with a saved player preference. - Added temporary experience-controlled collapsing while preserving required navigation and player input. - Added attention indicators for pending analysis, generation, and combat retries. - Added controls and localized labels for expanding and collapsing narration. - Manual expansion keeps narration visible until the temporary request ends. ## Documentation - Documented temporary narration-collapse capabilities and updated Capability API support to version 1.13. <!-- 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:12:38 +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#6675
No description provided.