[PR #1676] [MERGED] Fix game metadata save retry #5204

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1676
Author: @cha1latte
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1537-game-metadata-persistence


📝 Commits (1)

  • f8f1e8f Fix game metadata save retry

📊 Changes

5 files changed (+581 additions, -54 deletions)

View changed files

📝 src/features/modes/game/components/GameSurface.tsx (+49 -35)
➕ src/features/modes/game/lib/game-metadata-persistence.test.ts (+101 -0)
➕ src/features/modes/game/lib/game-metadata-persistence.ts (+277 -0)
📝 src/features/modes/game/stores/game-mode.store.test.ts (+137 -10)
📝 src/features/modes/game/stores/game-mode.store.ts (+17 -9)

📄 Description

Linked issue

Closes #1537

Why this change

  • Game mode had several automatic metadata writes that updated visible state first and then saved in the background with silent catches. If a metadata write failed, inventory/widgets/scene/combat/segment UI could appear durable but disappear after refresh or chat switch.

What changed

  • Added a focused Game metadata persistence helper that coalesces per-chat metadata patches, keeps failed patches retryable in localStorage, reports persistence failures with toast/console feedback, and publishes successful saved sessionChat responses back into cache.
  • Routed GameSurface automatic metadata writes for scene assets, narration progress, segment edits/deletes, combat snapshots, map command persistence, recent tracks, stale combat cleanup, and segment-driven inventory persistence through the retryable helper.
  • Updated HUD widget auto-persistence so failed saves keep the pending signature active until a retry succeeds, and stale incoming metadata does not clobber locally pending widgets.
  • Added regression coverage for failed retry retention, patch coalescing, durable retry clearing, invalid retry payload handling, widget retry state, and stale widget metadata protection.

Refactor impact

Primary owner:

Game mode metadata persistence in src/features/modes/game.

Impact areas reviewed:

  • GameSurface metadata-backed UI state for inventory, widgets, scenes, narration progress, segment edits/deletes, combat snapshots, map command state, and recent tracks.
  • Game mode widget store persistence and incoming metadata hydration.

Boundary notes:

  • Kept the fix in src/features/modes/game; no schema, engine, Rust, Tauri storage, shared runtime adapter, dependency, or prompt assembly changes.
  • The helper continues to use the existing storageApi.patchChatMetadata wrapper instead of adding a new storage fallback.

Pressure points touched:

  • GameSurface
  • Game mode widget store
  • Game metadata persistence helper

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

  • Codex proof run:
  • pnpm test -- src/features/modes/game/lib/game-metadata-persistence.test.ts src/features/modes/game/stores/game-mode.store.test.ts
  • pnpm test -- src/features/modes/game src/features/runtime/world-state
  • pnpm typecheck
  • pnpm check:architecture
  • pnpm check
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json
  • Visual evidence is not applicable: this is a persistence-contract bug proven with forced storage failure tests rather than a visible layout state.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs or release-note changes were made; this PR does not restore old staging/package-workspace/release claims.

UI evidence

N/A. The fix is covered by forced metadata persistence failure tests and store retry-state tests.


🔄 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/1676 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1537-game-metadata-persistence` --- ### 📝 Commits (1) - [`f8f1e8f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f8f1e8fe3b6a30e4c4db3b185be849965020a730) Fix game metadata save retry ### 📊 Changes **5 files changed** (+581 additions, -54 deletions) <details> <summary>View changed files</summary> 📝 `src/features/modes/game/components/GameSurface.tsx` (+49 -35) ➕ `src/features/modes/game/lib/game-metadata-persistence.test.ts` (+101 -0) ➕ `src/features/modes/game/lib/game-metadata-persistence.ts` (+277 -0) 📝 `src/features/modes/game/stores/game-mode.store.test.ts` (+137 -10) 📝 `src/features/modes/game/stores/game-mode.store.ts` (+17 -9) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #1537 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Game mode had several automatic metadata writes that updated visible state first and then saved in the background with silent catches. If a metadata write failed, inventory/widgets/scene/combat/segment UI could appear durable but disappear after refresh or chat switch. ## What changed <!-- List the key changes in this PR. --> - Added a focused Game metadata persistence helper that coalesces per-chat metadata patches, keeps failed patches retryable in `localStorage`, reports persistence failures with toast/console feedback, and publishes successful saved `sessionChat` responses back into cache. - Routed GameSurface automatic metadata writes for scene assets, narration progress, segment edits/deletes, combat snapshots, map command persistence, recent tracks, stale combat cleanup, and segment-driven inventory persistence through the retryable helper. - Updated HUD widget auto-persistence so failed saves keep the pending signature active until a retry succeeds, and stale incoming metadata does not clobber locally pending widgets. - Added regression coverage for failed retry retention, patch coalescing, durable retry clearing, invalid retry payload handling, widget retry state, and stale widget metadata protection. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Game mode metadata persistence in `src/features/modes/game`. Impact areas reviewed: - GameSurface metadata-backed UI state for inventory, widgets, scenes, narration progress, segment edits/deletes, combat snapshots, map command state, and recent tracks. - Game mode widget store persistence and incoming metadata hydration. Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Kept the fix in `src/features/modes/game`; no schema, engine, Rust, Tauri storage, shared runtime adapter, dependency, or prompt assembly changes. - The helper continues to use the existing `storageApi.patchChatMetadata` wrapper instead of adding a new storage fallback. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `GameSurface` - Game mode widget store - Game metadata persistence helper ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex proof run: - `pnpm test -- src/features/modes/game/lib/game-metadata-persistence.test.ts src/features/modes/game/stores/game-mode.store.test.ts` - `pnpm test -- src/features/modes/game src/features/runtime/world-state` - `pnpm typecheck` - `pnpm check:architecture` - `pnpm check` - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` - Visual evidence is not applicable: this is a persistence-contract bug proven with forced storage failure tests rather than a visible layout state. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs or release-note changes were made; this PR does not restore old staging/package-workspace/release claims. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A. The fix is covered by forced metadata persistence failure tests and store retry-state tests. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:11 +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#5204
No description provided.