[PR #5098] [MERGED] feat(game): Experience combat seam — combatActive, combatStyle, requestCombat (Capability API 1.11) #6628

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

📋 Pull Request Information

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

Base: staging ← Head: feat/5094-experience-combat-signal


📝 Commits (5)

  • e2b76c2 feat(game): Experience combat seam — combatActive/combatStyle/requestCombat (Capability API 1.11, #5094)
  • 8f98ed9 fix(game): scope combat-generation in-flight lock to the active chat (#5094)
  • 1ab0134 fix(game): scope combat error + visuals + toast to the request (#5094)
  • e6d2c4d fix(game): invalidate combat requests by monotonic id, not just chat (#5094)
  • af29c34 fix(game): gate combat visual apply on request being current

📊 Changes

5 files changed (+267 additions, -81 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 docs/development/optional-agent-packages.md (+22 -0)
📝 packages/client/src/components/game/GameSurface.tsx (+236 -75)
📝 packages/shared/src/schemas/capability-package.schema.ts (+3 -1)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+5 -5)

📄 Description

Closes #5094

Why

A game-surface Experience has no trustworthy combat signal: the only thing a package can watch is chatMeta.gameActiveState, the GM's narrative scene state — it lags the actual combat-UI flip (written by a separate metadata transition) and can say "combat" when no encounter was generated at all. And an Experience with its own world (an encounter tile in a pixel RPG) cannot request a fight without the player re-confirming through a modal that duplicates the intent they just expressed in the Experience's own UI.

What changed (Capability API 1.11 — client-only, additive, zero combat mechanics touched)

packages/client/src/components/game/GameSurface.tsx:

  • experienceSurfaceProps gains combatActive (the already-computed combatUiActive — true the instant the combat UI actually mounts), combatStyle (the effective style, classic/tactical), and requestCombat().
  • The manual Start Combat handler is refactored so the confirm dialog wraps a shared core (startCombatGeneration), and requestCombat calls that same core — one path into the vanilla generateCombatStateForMessage pass, so a package can never trigger side effects the button would not. The confirm dialog is skipped on the package path because the Experience's own interface already expressed the intent; the guards (combat already active, generation pending, no turn yet) still apply.
  • Deliberately absent: startCombat(party, enemies) or any way to inject combat state — the vanilla LLM pass still decides what the encounter is. Combat stays Engine-owned.
  • The experienceSurfaceProps memo moved below the combat declarations it now consumes (its only consumer is the surface mount further down; nothing between the old and new positions referenced it). The Classic-game guard is untouched: the props are still not built at all unless the surface is active.
  • requestCombat() is identity-stable (reads current state through refs, matching the stability contract of every other function in the props — a package may safely cache it), silent on the package path (returns "started" | "combat-active" | "pending" | "no-turn" | "unavailable" instead of painting Engine toasts over the package UI), and gated: concluded sessions and replay refuse with "unavailable", mirroring the sendMessage seam.
  • A synchronous in-flight ref guards the generation alongside the async React state, so same-frame double calls (a package spamming requestCombat) cannot fan out concurrent /encounter/init generations.
  • combatPending/combatError mirror generation progress and failure, so a package is never left waiting on combatActive after a failed generation.
  • The manual button keeps its pre-dialog guards (including the no-turn check, which the first review round caught moving behind the confirm).

packages/shared/src/schemas/capability-package.schema.ts: supportedCapabilityApi → {1, 11} (a package requiring the seam declares 1.11 and older engines refuse it with the versioned message; packages that feature-detect keep working everywhere). Lifecycle-regression pins updated.

Docs: Capability API 1.11 section in docs/development/optional-agent-packages.md; CHANGELOG entry under Unreleased.

Note on requestCombat(opts): the issue sketched a hint parameter; it is deferred — the encounter generator (/encounter/init) takes no steering context today, so accepting-and-ignoring a hint would be dishonest. If steering lands server-side later, the callback can grow the option compatibly.

Validation

  • pnpm check
  • capability-package-lifecycle + capability-package-cache regressions (1.11 pins)
  • pnpm version:check
  • Manually verify a Classic game: Start Combat button shows the confirm, generates, enters and exits combat exactly as before.
  • Manually verify an Experience game: the package sees combatActive flip the instant combat mounts, and requestCombat() generates an encounter through the same vanilla pass (no confirm dialog).
  • Manually verify a Classic game still builds no experienceSurfaceProps at all.

Docs note: the docs/development/optional-agent-packages.md edit needs a docs-i18n mirror — batched with the pending round-8 catch-up.

Summary by CodeRabbit

  • New Features

    • Game-surface experiences can display live combat activity and style information.
    • Experiences can request Engine-generated combat encounters and receive pending, success, and error status updates.
    • Combat controls prevent duplicate or invalid encounter requests.
    • Experiences that manage their own combat can hide the standard combat controls.
    • Tactical combat can automatically generate battlefield backgrounds.
    • Updated support for Capability API version 1.11.
  • Documentation

    • Added guidance for integrating combat capabilities into optional game-surface packages.

🔄 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/5098 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/5094-experience-combat-signal` --- ### 📝 Commits (5) - [`e2b76c2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e2b76c2eb68351675031931a4e4a36a76da2cdcc) feat(game): Experience combat seam — combatActive/combatStyle/requestCombat (Capability API 1.11, #5094) - [`8f98ed9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8f98ed97ba1ab9cca3221d206a0dbc30163fcb08) fix(game): scope combat-generation in-flight lock to the active chat (#5094) - [`1ab0134`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ab0134e2299cda9d6d6b035299268f67f0108ba) fix(game): scope combat error + visuals + toast to the request (#5094) - [`e6d2c4d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e6d2c4d754d9b8ced5109af7073b40908eac1ac1) fix(game): invalidate combat requests by monotonic id, not just chat (#5094) - [`af29c34`](https://github.com/Pasta-Devs/Marinara-Engine/commit/af29c34fb9388d92cc09cf4acf73fb5f2d65b58a) fix(game): gate combat visual apply on request being current ### 📊 Changes **5 files changed** (+267 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `docs/development/optional-agent-packages.md` (+22 -0) 📝 `packages/client/src/components/game/GameSurface.tsx` (+236 -75) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+3 -1) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+5 -5) </details> ### 📄 Description Closes #5094 ## Why A `game-surface` Experience has no trustworthy combat signal: the only thing a package can watch is `chatMeta.gameActiveState`, the GM's *narrative* scene state — it lags the actual combat-UI flip (written by a separate metadata transition) and can say "combat" when no encounter was generated at all. And an Experience with its own world (an encounter tile in a pixel RPG) cannot request a fight without the player re-confirming through a modal that duplicates the intent they just expressed in the Experience's own UI. ## What changed (Capability API 1.11 — client-only, additive, zero combat mechanics touched) `packages/client/src/components/game/GameSurface.tsx`: - `experienceSurfaceProps` gains **`combatActive`** (the already-computed `combatUiActive` — true the instant the combat UI actually mounts), **`combatStyle`** (the effective style, `classic`/`tactical`), and **`requestCombat()`**. - The manual Start Combat handler is refactored so the confirm dialog wraps a shared core (`startCombatGeneration`), and `requestCombat` calls that **same core** — one path into the vanilla `generateCombatStateForMessage` pass, so a package can never trigger side effects the button would not. The confirm dialog is skipped on the package path because the Experience's own interface already expressed the intent; the guards (combat already active, generation pending, no turn yet) still apply. - **Deliberately absent:** `startCombat(party, enemies)` or any way to inject combat state — the vanilla LLM pass still decides what the encounter is. Combat stays Engine-owned. - The `experienceSurfaceProps` memo moved below the combat declarations it now consumes (its only consumer is the surface mount further down; nothing between the old and new positions referenced it). The Classic-game guard is untouched: the props are still not built at all unless the surface is active. - `requestCombat()` is **identity-stable** (reads current state through refs, matching the stability contract of every other function in the props — a package may safely cache it), **silent on the package path** (returns `"started" | "combat-active" | "pending" | "no-turn" | "unavailable"` instead of painting Engine toasts over the package UI), and **gated**: concluded sessions and replay refuse with `"unavailable"`, mirroring the sendMessage seam. - A synchronous in-flight ref guards the generation alongside the async React state, so same-frame double calls (a package spamming `requestCombat`) cannot fan out concurrent `/encounter/init` generations. - `combatPending`/`combatError` mirror generation progress and failure, so a package is never left waiting on `combatActive` after a failed generation. - The manual button keeps its pre-dialog guards (including the no-turn check, which the first review round caught moving behind the confirm). `packages/shared/src/schemas/capability-package.schema.ts`: `supportedCapabilityApi` → `{1, 11}` (a package *requiring* the seam declares 1.11 and older engines refuse it with the versioned message; packages that feature-detect keep working everywhere). Lifecycle-regression pins updated. Docs: Capability API 1.11 section in `docs/development/optional-agent-packages.md`; CHANGELOG entry under Unreleased. Note on `requestCombat(opts)`: the issue sketched a `hint` parameter; it is deferred — the encounter generator (`/encounter/init`) takes no steering context today, so accepting-and-ignoring a hint would be dishonest. If steering lands server-side later, the callback can grow the option compatibly. ## Validation - [x] `pnpm check` - [x] capability-package-lifecycle + capability-package-cache regressions (1.11 pins) - [x] `pnpm version:check` - [x] Manually verify a Classic game: Start Combat button shows the confirm, generates, enters and exits combat exactly as before. - [x] Manually verify an Experience game: the package sees `combatActive` flip the instant combat mounts, and `requestCombat()` generates an encounter through the same vanilla pass (no confirm dialog). - [x] Manually verify a Classic game still builds no `experienceSurfaceProps` at all. Docs note: the `docs/development/optional-agent-packages.md` edit needs a docs-i18n mirror — batched with the pending round-8 catch-up. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Game-surface experiences can display live combat activity and style information. * Experiences can request Engine-generated combat encounters and receive pending, success, and error status updates. * Combat controls prevent duplicate or invalid encounter requests. * Experiences that manage their own combat can hide the standard combat controls. * Tactical combat can automatically generate battlefield backgrounds. * Updated support for Capability API version 1.11. * **Documentation** * Added guidance for integrating combat capabilities into optional game-surface packages. <!-- 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:12 +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#6628
No description provided.