Repository navigation
fix(startup): surface load-failure notices at the cold menu (issue #520) - #541
Conversation
_load_failed() pushed its message into a state that, at a true cold start, has no events array, so sim.push_event dropped it and the drawer never redrew: clicking Load Game with no (or an incompatible) save gave no feedback. Seed the events array, push, and redraw the drawer -- the same three steps the #516 no-colony save notice uses. The seeded bare state still fails has_persistable_colony(), so it can never reach disk. Flow 10 in tests/test_save_failure_surfaced.gd pins the notice landing in state.events and on the drawer label from a cold {} state, with zero writes.
There was a problem hiding this comment.
{"schema":"review-handoff/v1","review_id":"2dce14f35984e309","head_sha":"a2afdf5cd50caef969af5343ee59c4602e65f7da","verdict":"approve","review_result":"findings","required_checks":"none","items":[{"id":"f3b730d10cec3e2446ad2b2484bf12d12b9600a3e1e2bc2228274328316cc075","severity":"minor","category":"style","path":"scripts/main.gd","line":1005,"message":"The seed → push → redraw notice sequence is now duplicated in `save_game()` and `_load_failed()`; the issue suggested extracting a shared helper next to them."},{"id":"2adf5a4e142d033ca882971712862d8086df2c72e86b14a836f51f82b644bc0b","severity":"info","category":"verification","path":"tests/test_save_failure_surfaced.gd","line":474,"message":"The `_save_call_count == 0` assertion is only meaningful if the hooked `root.get_node(\"GameState\")` is the instance `main.gd` persists through; it mirrors Flow 6/8 and passes either way."}],"items_total":2,"items_truncated":false,"unresolved_requirement_ids":[],"unresolved_requirement_ids_total":0,"unresolved_requirement_ids_truncated":false,"unresolved_requirement_ids_source_total":0,"unresolved_required_checks":[],"unresolved_required_checks_total":0,"unresolved_required_checks_truncated":false,"unresolved_required_checks_source_total":0,"unresolved_review_obligations":[],"unresolved_review_obligations_total":0,"unresolved_review_obligations_truncated":false,"derived_obligation_state":null}AI Automated Review
✅ Automated recommendation: APPROVE
Full PR review.
Analysis engine: MiniMax-M3.1-Flash (anthropic) — primary route · pr-reviewer-action v3.10.0
Findings (1 minor, 1 info)
| Severity | Location | Finding |
|---|---|---|
| Minor | scripts/main.gd:1005 |
The seed → push → redraw notice sequence is now duplicated in `save_game()` and `_load_failed()`; the issue suggested extracting a shared helper next to them. |
| Info | tests/test_save_failure_surfaced.gd:474 |
The `_save_call_count == 0` assertion is only meaningful if the hooked `root.get_node("GameState")` is the instance `main.gd` persists through; it mirrors Flow 6/8 and passes either way. |
Recommendation
Approve — the fix is the minimal seed → push → redraw mirror of PR 516, and the new Flow 10 exercises it against the real scene.
Findings
No blocker or major issues. Two minor/info items are in the findings array.
Requirement Coverage
- req-82dc1b4c58b2 (colony render paths must not read the seeded bare state, PR 529): satisfied.
toggle_menu(main.gd:939),open_build_popup(960),render_all(1542),render_tile(1636) and_on_dock_side_selected(1111) all gate onhas_persistable_colony(), which requires aresourcesDictionary; the seed adds onlyevents, so every gate still rejects it, and_on_tickstill short-circuits onnot game_active(1405).
Claims
Held: 5/5 items. Claim 1 (Flow 10 asserts notice in state.events, drawer label text, has_persistable_colony() false, zero writes) is present in the diff. Claim 2: persist() (main.gd:2214/2234) is the only GameState.save_game call site and gates on has_persistable_colony(); exit_game, the WM_CLOSE flush, _flush_save_on_unload and the tick path all route through it. Claim 3: verified the five gates above. Claim 4: Flow 8 pins the _on_tick proxy on the seeded state. Claim 5: grep shows _load_failed's only callers are load_saved_game's two gate rejections and _revert_failed_restore; all now seed and redraw, which is a benign extension of the restore-revert notices.
Linked Issue Fit
Issue PR 520 asks to make _load_failed() show its message at the cold startup menu by seeding the events array and redrawing the event drawer, and names scripts/main.gd plus a regression assertion in tests/test_save_failure_surfaced.gd (cold state = {}, call _load_failed(...), assert the notice lands in state.events). All three are met, with both startup-menu message strings pinned. The restore-confirmation notices left out of scope are already tracked as PR 540.
Tool Harness Findings
40 read-only calls over 22 rounds (budget exhausted). Verified colony_sim.gd:190 drops push_event without an events key (the root cause), render_event_drawer()'s event_rev gate, has_persistable_colony(), the cold render gates, and the main.tscn drawer nodes. All CI checks on a2afdf5 are green, including the script test suite, which corroborates the local-validation claim in the PR body.
Unknowns or Needs Verification
One item could not be settled with the reads available: whether Flow 10's hooked root.get_node("GameState") is the same instance main.gd's persist() writes through, which decides whether the zero-write assertion is meaningful. It mirrors Flow 6/8 exactly, so it passes either way and does not affect the verdict.
Closes #520
What changed
_load_failed()inscripts/main.gdnow uses the same three steps the #516 no-colony save notice uses: seedstate["events"] = []when the state has none, push the notice, then redraw the event drawer. At a true cold start the state is{}, andColonySim.push_event(scripts/colony_sim.gd:190) drops messages when there is noeventskey — so clicking Load Game at the startup menu with no (or an incompatible) save previously gave no feedback at all. The drawer redraw runs in both branches; mid-game (game_active) the existingrender_sidebar()call is unchanged, and the drawer'sevent_revcache makes the extra call a no-op when nothing changed.tests/test_save_failure_surfaced.gdgains Flow 10: real scene, coldstate = {}, both startup-menu load-failure messages, asserting the notice lands instate.events, the drawer label shows it, the seeded state still failshas_persistable_colony(), and no save write happens (save hook intercepts every write).Invariants this change must keep, and every other path enforcing each
persist()(the onlyGameState.save_gamecall site) gates onhas_persistable_colony(), which requires aresourcesDictionary; every forced write (exit_game, theWM_CLOSEflush,_flush_save_on_unload, the tick path) goes throughpersist(). Kept: this PR does not touch the gate; the seeded state has noresources, and Flow 10 assertshas_persistable_colony()stays false and the save-hook write count stays 0 (same reasoning as Flow 8).save_game()'s no-colony skip (fix(save): never persist an unstarted colony so startup exits keep the save (issue #513) #516,scripts/main.gd:985-988). Kept: unchanged; this PR mirrors it rather than refactoring it.toggle_menu,open_build_popup,render_all,render_tile,_on_dock_side_selectedgate onhas_persistable_colony(), and_on_tickshort-circuits onnot game_active. Kept: the seed keeps the state non-persistable, so every gate still rejects it; Flow 8 pins the_on_tickproxy.render_event_drawer()returns early while_drawer_event_rev == sim.event_rev;push_eventbumpsevent_rev. Kept: the unconditional call is a no-op unless this push changed the rev; no other renderer is affected._load_failed. Enforcers:load_saved_game's gate rejections and_revert_failed_restoreare its only callers. Kept: unchanged call sites; both notices now seed-and-redraw through the fixed function.Local validation (receipts)
mise exec -- just --justfile .justfile validate(cwd/workspace, heada2afdf5, pinned.tools/Godot_v4.7.1-stable_linux.x86_64verified againstgodot-toolchain.jsonsha256): exit 0, 40/40 suites ok, noSCRIPT ERROR, noParse Error.tests/test_save_failure_surfaced.gd→ 57 passed, 0 failed (includes the 6 new Flow 10 assertions).CI on this branch is not yet observed (expected green per the identical local matrix).
Follow-up found during review
The restore-confirmation rejection notices (
scripts/main.gd:432,scripts/main.gd:436) drop at the cold menu through the same mechanism. Filed as #540; out of scope here.