[PR #2430] [MERGED] Keep just-completed quests on tracker re-run #5605

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/2430
Author: @Romuromylus
Created: 6/6/2026
Status: ✅ Merged
Merged: 6/6/2026
Merged by: @Romuromylus

Base: refactor ← Head: fix/quest-rerun-keep-completed


📝 Commits (2)

  • a4d85bf Keep just-completed quests on tracker re-run
  • 032b937 Thread quest auto-remove through the client so per-turn callers keep removing

📊 Changes

4 files changed (+33 additions, -11 deletions)

View changed files

📝 src/engine/generation/start-generation.ts (+3 -0)
📝 src/engine/generation/tracker-snapshots.ts (+13 -2)
📝 src/engine/shared/game-state/player-stats.ts (+10 -7)
📝 src/features/runtime/generation/hooks/use-generate.ts (+7 -2)

📄 Description

Linked issue

Closes #2373

Why this change

  • Regression vs main. The refactor's port of applyQuestUpdatesToPlayerStats dropped main's autoRemoveFullyCompleted opt-out, so the fully-completed-quest splice ran unconditionally. Clicking the quest-refresh / re-run tracker button silently removed quests the user had just completed, whereas main keeps them visible until the next normal turn.

What changed

  • src/engine/shared/game-state/player-stats.ts: re-added an options?: { autoRemoveFullyCompleted?: boolean } param to applyQuestUpdatesToPlayerStats and gated the fully-completed splice behind it (default = keep).
  • src/engine/generation/tracker-snapshots.ts + src/engine/generation/start-generation.ts: threaded an autoRemoveFullyCompletedQuests flag through persistTrackerSnapshotSafely → persistTrackerSnapshotForTurn → gameStatePatchFromAgentResult → the engine fn. The per-turn persist site passes true (remove — unchanged normal-turn behavior); the single-tracker re-run persist site keeps the default false (keep), restoring main's two-route split.
  • The two engine persist call sites are physically distinct (per-turn vs re-run), so the distinction is preserved without a flag on the client path.

Refactor impact

Primary owner: engine generation (world-state / game-state)

Impact areas reviewed:

  • src/engine/shared/game-state/player-stats.ts (applyQuestUpdatesToPlayerStats)
  • src/engine/generation/tracker-snapshots.ts, src/engine/generation/start-generation.ts (persist threading)

Boundary notes:

  • None. Engine-layer only; the pure function stays pure (no feature/React imports). Verified exactly two persistTrackerSnapshotSafely callers — per-turn (passes true) and re-run (default false).

Pressure points touched:

  • Runtime generation, world-state.

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 — local-only tests confirmed applyQuestUpdatesToPlayerStats keeps a fully-completed quest by default and with { autoRemoveFullyCompleted: false }, and removes it with true. tracker-snapshots.test.ts — 4 passed (no persist-path regression).
  • pnpm exec tsc -b — 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/2430 **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/quest-rerun-keep-completed` --- ### 📝 Commits (2) - [`a4d85bf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4d85bfe331223f5699a94340599ccf79690ca5d) Keep just-completed quests on tracker re-run - [`032b937`](https://github.com/Pasta-Devs/Marinara-Engine/commit/032b937757b366f3fda575cc30aa9e4518ae8205) Thread quest auto-remove through the client so per-turn callers keep removing ### 📊 Changes **4 files changed** (+33 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src/engine/generation/start-generation.ts` (+3 -0) 📝 `src/engine/generation/tracker-snapshots.ts` (+13 -2) 📝 `src/engine/shared/game-state/player-stats.ts` (+10 -7) 📝 `src/features/runtime/generation/hooks/use-generate.ts` (+7 -2) </details> ### 📄 Description ## Linked issue Closes #2373 ## Why this change - Regression vs main. The refactor's port of `applyQuestUpdatesToPlayerStats` dropped main's `autoRemoveFullyCompleted` opt-out, so the fully-completed-quest splice ran unconditionally. Clicking the quest-refresh / re-run tracker button silently removed quests the user had just completed, whereas main keeps them visible until the next normal turn. ## What changed - `src/engine/shared/game-state/player-stats.ts`: re-added an `options?: { autoRemoveFullyCompleted?: boolean }` param to `applyQuestUpdatesToPlayerStats` and gated the fully-completed splice behind it (default = keep). - `src/engine/generation/tracker-snapshots.ts` + `src/engine/generation/start-generation.ts`: threaded an `autoRemoveFullyCompletedQuests` flag through `persistTrackerSnapshotSafely` → `persistTrackerSnapshotForTurn` → `gameStatePatchFromAgentResult` → the engine fn. The per-turn persist site passes `true` (remove — unchanged normal-turn behavior); the single-tracker re-run persist site keeps the default `false` (keep), restoring main's two-route split. - The two engine persist call sites are physically distinct (per-turn vs re-run), so the distinction is preserved without a flag on the client path. ## Refactor impact Primary owner: engine generation (world-state / game-state) Impact areas reviewed: - `src/engine/shared/game-state/player-stats.ts` (`applyQuestUpdatesToPlayerStats`) - `src/engine/generation/tracker-snapshots.ts`, `src/engine/generation/start-generation.ts` (persist threading) Boundary notes: - None. Engine-layer only; the pure function stays pure (no feature/React imports). Verified exactly two `persistTrackerSnapshotSafely` callers — per-turn (passes `true`) and re-run (default `false`). Pressure points touched: - Runtime generation, world-state. ## 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` — local-only tests confirmed `applyQuestUpdatesToPlayerStats` keeps a fully-completed quest by default and with `{ autoRemoveFullyCompleted: false }`, and removes it with `true`. `tracker-snapshots.test.ts` — 4 passed (no persist-path regression). - `pnpm exec tsc -b` — 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#5605
No description provided.