[PR #1642] [MERGED] Surface game journal load and save failures with retry #5174

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/game-journal-error-state


📝 Commits (2)

  • 1782f0a Surface game journal load and save failures with retry
  • 29b1af3 Clear stale journal save error on edit and seed the retry ref

📊 Changes

2 files changed (+278 additions, -11 deletions)

View changed files

➕ src/features/modes/game/components/GameJournal.test.tsx (+183 -0)
📝 src/features/modes/game/components/GameJournal.tsx (+95 -11)

📄 Description

Why this change

GameJournal swallowed both of its async failures in empty .catch(() => {}) blocks:

  • When getJournal rejected, setJournal never ran, so the panel stayed stuck on the "Loading journal..." spinner forever, with no error and no way out.
  • When updateNotes rejected, setNotesSaved(true) never ran, so the notes status pill stayed on the amber "Saving..." indefinitely, implying an in-flight save that had actually failed.

(Note: the issue body references a useGameJournal hook, but no such hook exists. The component uses local state, so the fix uses local state.)

What changed

src/features/modes/game/components/GameJournal.tsx:

  • Track loadError / saveError in local state.
  • The load runs through a loadJournal callback so it can be retried; on failure it records the error.
  • The render guard now shows a retryable error panel (underlying message + a Retry that re-runs the load + a Close) before falling through to the plain loading state.
  • saveNotes records its failure and clears it on success; NotesView shows a red "Save failed" with a Retry control instead of a stuck "Saving...".

Verification

  • pnpm exec tsc -b clean.
  • New jsdom component test (GameJournal.test.tsx) covers: the load-error panel renders (not a stuck spinner), a successful load retry shows the journal, and a save failure surfaces "Save failed" + Retry.

Risk / note

This is Game-mode-owned UI; the underlying gameApi.getJournal/updateNotes are unchanged. The unmount-flush effect still calls saveNotes on unmount; on failure it sets error state on an unmounting component (benign React warning at most). The error panel's exact styling is verified by render, not pixel comparison.

Linked issue

Closes #1536.


🔄 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/1642 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/game-journal-error-state` --- ### 📝 Commits (2) - [`1782f0a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1782f0a3bd990aae40b610ba7e65c27ed11eb442) Surface game journal load and save failures with retry - [`29b1af3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/29b1af3217488e75f352f4343363391a1a56e498) Clear stale journal save error on edit and seed the retry ref ### 📊 Changes **2 files changed** (+278 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `src/features/modes/game/components/GameJournal.test.tsx` (+183 -0) 📝 `src/features/modes/game/components/GameJournal.tsx` (+95 -11) </details> ### 📄 Description ## Why this change `GameJournal` swallowed both of its async failures in empty `.catch(() => {})` blocks: - When `getJournal` rejected, `setJournal` never ran, so the panel stayed stuck on the **"Loading journal..."** spinner forever, with no error and no way out. - When `updateNotes` rejected, `setNotesSaved(true)` never ran, so the notes status pill stayed on the amber **"Saving..."** indefinitely, implying an in-flight save that had actually failed. (Note: the issue body references a `useGameJournal` hook, but no such hook exists. The component uses local state, so the fix uses local state.) ## What changed `src/features/modes/game/components/GameJournal.tsx`: - Track `loadError` / `saveError` in local state. - The load runs through a `loadJournal` callback so it can be retried; on failure it records the error. - The render guard now shows a retryable error panel (underlying message + a **Retry** that re-runs the load + a **Close**) before falling through to the plain loading state. - `saveNotes` records its failure and clears it on success; `NotesView` shows a red **"Save failed"** with a **Retry** control instead of a stuck "Saving...". ## Verification - `pnpm exec tsc -b` clean. - New jsdom component test (`GameJournal.test.tsx`) covers: the load-error panel renders (not a stuck spinner), a successful load retry shows the journal, and a save failure surfaces "Save failed" + Retry. ## Risk / note This is Game-mode-owned UI; the underlying `gameApi.getJournal`/`updateNotes` are unchanged. The unmount-flush effect still calls `saveNotes` on unmount; on failure it sets error state on an unmounting component (benign React warning at most). The error panel's exact styling is verified by render, not pixel comparison. ## Linked issue Closes #1536. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:13:56 +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#5174
No description provided.