[PR #2429] [MERGED] Flush pending game-state edits before retrying agents #5604

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/retry-agents-flush-patch


📝 Commits (1)

  • 4410b81 Flush pending game-state edits before retrying agents

📊 Changes

3 files changed (+12 additions, -10 deletions)

View changed files

📝 src/features/runtime/generation/hooks/use-generate.ts (+11 -0)
📝 src/features/runtime/tracker/components/TrackerSectionList.tsx (+0 -2)
📝 src/features/runtime/tracker/hooks/use-tracker-rerun.ts (+1 -8)

📄 Description

Linked issue

Closes #2371

Why this change

  • retryAgents re-ran the tracker/agent engine without first flushing pending debounced game-state edits, so the engine re-read a stale storage snapshot and the regenerated output clobbered the user's just-made manual HUD tracker edit (data loss). This is a regression vs main, where the pre-retry flush was centralized. All four roleplay-HUD handlers (Re-run Trackers / Re-run Single Tracker / Retry Failed Agents / Retry Agent) funnel through retryAgents.

What changed

  • src/features/runtime/generation/hooks/use-generate.ts: retryAgents now flushes useGameStateStore.flushPatch() after setProcessing(true) and before retryGenerationAgents, mirroring the in-repo guard. A single site covers all four HUD handlers plus the other callers. A flush failure now aborts the retry (throws, surfaced via the existing error toast) instead of silently corrupting state.
  • src/features/runtime/tracker/hooks/use-tracker-rerun.ts + TrackerSectionList.tsx: removed the now-redundant per-call flushPatch() (superseded by the centralized flush) and tidied the dead flushPatch prop.

Refactor impact

Primary owner: runtime generation / world-state

Impact areas reviewed:

  • src/features/runtime/generation/hooks/use-generate.ts (retryAgents)
  • src/features/runtime/tracker/hooks/use-tracker-rerun.ts, src/features/runtime/tracker/components/TrackerSectionList.tsx (redundant flush + prop cleanup)

Boundary notes:

  • None. flushPatch is a no-op when no patcher is registered (buildFlushPatch returns null) and idempotent on an empty buffer, so the added await is negligible. No conflict with #2373 quest logic (flush-only). No Rust touched.

Pressure points touched:

  • Runtime generation, world-state, shared mode UI (tracker section).

Validation

  • Matching validation command passes locally
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • pnpm vitest run — a local-only test against the real useGameStateStore flush seam confirmed the flush runs BEFORE retryGenerationAgents (via invocationCallOrder), a flush rejection throws and retryGenerationAgents is never called, and a no-patcher flush is a safe no-op.
  • pnpm exec tsc -b, pnpm lint:eslint, pnpm check:architecture — all clean.

Feature Discoverability

  • Updated src/features/shell/discovery/
  • N/A because this PR is a data-loss regression fix.

Reason:

  • No new discoverable surface.

Docs and release impact

  • No docs changes needed

🔄 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/2429 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/retry-agents-flush-patch` --- ### 📝 Commits (1) - [`4410b81`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4410b81b120b5711880df2fa6f452550274cb9a0) Flush pending game-state edits before retrying agents ### 📊 Changes **3 files changed** (+12 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+11 -0) 📝 `src/features/runtime/tracker/components/TrackerSectionList.tsx` (+0 -2) 📝 `src/features/runtime/tracker/hooks/use-tracker-rerun.ts` (+1 -8) </details> ### 📄 Description ## Linked issue Closes #2371 ## Why this change - `retryAgents` re-ran the tracker/agent engine without first flushing pending debounced game-state edits, so the engine re-read a stale storage snapshot and the regenerated output clobbered the user's just-made manual HUD tracker edit (data loss). This is a regression vs main, where the pre-retry flush was centralized. All four roleplay-HUD handlers (Re-run Trackers / Re-run Single Tracker / Retry Failed Agents / Retry Agent) funnel through `retryAgents`. ## What changed - `src/features/runtime/generation/hooks/use-generate.ts`: `retryAgents` now flushes `useGameStateStore.flushPatch()` after `setProcessing(true)` and before `retryGenerationAgents`, mirroring the in-repo guard. A single site covers all four HUD handlers plus the other callers. A flush failure now aborts the retry (throws, surfaced via the existing error toast) instead of silently corrupting state. - `src/features/runtime/tracker/hooks/use-tracker-rerun.ts` + `TrackerSectionList.tsx`: removed the now-redundant per-call `flushPatch()` (superseded by the centralized flush) and tidied the dead `flushPatch` prop. ## Refactor impact Primary owner: runtime generation / world-state Impact areas reviewed: - `src/features/runtime/generation/hooks/use-generate.ts` (`retryAgents`) - `src/features/runtime/tracker/hooks/use-tracker-rerun.ts`, `src/features/runtime/tracker/components/TrackerSectionList.tsx` (redundant flush + prop cleanup) Boundary notes: - None. `flushPatch` is a no-op when no patcher is registered (`buildFlushPatch` returns `null`) and idempotent on an empty buffer, so the added await is negligible. No conflict with #2373 quest logic (flush-only). No Rust touched. Pressure points touched: - Runtime generation, world-state, shared mode UI (tracker section). ## Validation - [x] Matching validation command passes locally - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `pnpm vitest run` — a local-only test against the real `useGameStateStore` flush seam confirmed the flush runs BEFORE `retryGenerationAgents` (via `invocationCallOrder`), a flush rejection throws and `retryGenerationAgents` is never called, and a no-patcher flush is a safe no-op. - `pnpm exec tsc -b`, `pnpm lint:eslint`, `pnpm check:architecture` — all clean. ## Feature Discoverability - [ ] Updated `src/features/shell/discovery/` - [x] N/A because this PR is a data-loss regression fix. Reason: - No new discoverable surface. ## Docs and release impact - [x] No docs changes needed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:45 +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#5604
No description provided.