[PR #1028] [MERGED] Fix Quest Board state reversion after tracker updates #4892

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1028
Author: @Xelvanis
Created: 5/20/2026
Status: ✅ Merged
Merged: 5/20/2026
Merged by: @Xelvanis

Base: staging ← Head: fix/quest-board-state-reversion


📝 Commits (2)

  • b627083 fix: normalize quest tracker state merges
  • a64feb1 fix: remove completed empty-objective quests

📊 Changes

5 files changed (+321 additions, -127 deletions)

View changed files

📝 packages/client/src/hooks/use-generate.ts (+10 -44)
📝 packages/server/src/routes/generate.routes.ts (+13 -54)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+8 -29)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/utils/quest-state.ts (+289 -0)

📄 Description

Linked issue

Closes #1033

Why this change

  • The Quest Board HUD could briefly show the quest tracker agent's newest updates, then revert at the end of the turn when the authoritative game-state patch arrived.
  • The original report in #1002 suspected sampling/JSON adherence, but investigation found a state merge bug: client optimistic updates and server persistence handled legacy/grouped quest shapes differently.
  • Fixing the merge path reduces the need to solve this specific Quest Board reversion by changing agent sampling settings.

What changed

  • Added a shared quest-state merge helper for client and server quest tracker updates.
  • Normalized legacy/grouped activeQuests shapes, keyed quest maps, grouped objective containers, and object-shaped objective payloads before writing playerStats.activeQuests.
  • Updated normal generation, retry-agent persistence, and client optimistic Quest Board updates to use the same shared merge behavior.
  • Preserved server-side completed-quest auto-removal for normal generation while keeping client optimistic updates immediate.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Focused tsx smokes passed for keyed quest maps, nested keyed maps, object-shaped objectives, grouped arrays, and completed quest auto-removal.
  • pnpm --filter @marinara-engine/shared lint passed.
  • pnpm --filter @marinara-engine/client lint passed.
  • pnpm --filter @marinara-engine/server lint passed.
  • pnpm --filter @marinara-engine/client build passed.
  • git diff --check passed with line-ending warnings only.
  • Browser smoke pass used a disposable RP chat and confirmed Quest Board counts stayed aligned with /game-state; no browser console warnings/errors were observed.
  • Still needs human verification during a real RP generation with more than three objectives/groups before marking ready.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

Not attached yet. A human RP verification pass should add screenshot/recording evidence before this draft is marked ready.

Summary by CodeRabbit

  • Refactor
    • Improved quest state handling to use shared utilities for consistent processing across the application.
    • Enhanced quest tracking with automatic removal of fully completed quests.
    • Added improved error handling for quest update persistence with clearer logging.
    • Standardized quest data normalization for better internal consistency.

Review Change Stack


🔄 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/1028 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/20/2026 **Status:** ✅ Merged **Merged:** 5/20/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `staging` ← **Head:** `fix/quest-board-state-reversion` --- ### 📝 Commits (2) - [`b627083`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b627083094beda454844fb5363b565305cf97e3f) fix: normalize quest tracker state merges - [`a64feb1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a64feb136f15a9ffcdc491e153f5e1c5bef16b16) fix: remove completed empty-objective quests ### 📊 Changes **5 files changed** (+321 additions, -127 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/hooks/use-generate.ts` (+10 -44) 📝 `packages/server/src/routes/generate.routes.ts` (+13 -54) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+8 -29) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/utils/quest-state.ts` (+289 -0) </details> ### 📄 Description ## Linked issue Closes #1033 ## Why this change - The Quest Board HUD could briefly show the quest tracker agent's newest updates, then revert at the end of the turn when the authoritative game-state patch arrived. - The original report in #1002 suspected sampling/JSON adherence, but investigation found a state merge bug: client optimistic updates and server persistence handled legacy/grouped quest shapes differently. - Fixing the merge path reduces the need to solve this specific Quest Board reversion by changing agent sampling settings. ## What changed - Added a shared quest-state merge helper for client and server quest tracker updates. - Normalized legacy/grouped `activeQuests` shapes, keyed quest maps, grouped objective containers, and object-shaped objective payloads before writing `playerStats.activeQuests`. - Updated normal generation, retry-agent persistence, and client optimistic Quest Board updates to use the same shared merge behavior. - Preserved server-side completed-quest auto-removal for normal generation while keeping client optimistic updates immediate. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Focused `tsx` smokes passed for keyed quest maps, nested keyed maps, object-shaped objectives, grouped arrays, and completed quest auto-removal. - `pnpm --filter @marinara-engine/shared lint` passed. - `pnpm --filter @marinara-engine/client lint` passed. - `pnpm --filter @marinara-engine/server lint` passed. - `pnpm --filter @marinara-engine/client build` passed. - `git diff --check` passed with line-ending warnings only. - Browser smoke pass used a disposable RP chat and confirmed Quest Board counts stayed aligned with `/game-state`; no browser console warnings/errors were observed. - Still needs human verification during a real RP generation with more than three objectives/groups before marking ready. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) Not attached yet. A human RP verification pass should add screenshot/recording evidence before this draft is marked ready. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved quest state handling to use shared utilities for consistent processing across the application. * Enhanced quest tracking with automatic removal of fully completed quests. * Added improved error handling for quest update persistence with clearer logging. * Standardized quest data normalization for better internal consistency. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1028?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:11:30 +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#4892
No description provided.