feat(m1): TUI load-on-mount state persistence from SaveExchange#21
Merged
Conversation
PRD M1 deliverable: "Close/reopen preserves all state." Previously MainApp.on_mount called refresh_panels() but never loaded from the save exchange, so every reopen started from scratch. Save-on-exit was already implemented in action_quit (via bridge_loop.save_exchange). Implementation: - Add MainApp._load_from_save_exchange() — checks bridge_loop.save_exchange, reads the payload, and replaces self.session_state, bridge_loop.state, and hook_listener.state with the loaded state so all three references are consistent after the swap. - Call _load_from_save_exchange() at the top of on_mount() before refresh. Tests (5 Pilot + 4 unit = 9 new tests): Pilot (test_app_pilot.py): - test_app_loads_kingdom_name_from_save_on_mount - test_app_restores_session_count_and_attributes_from_save - test_app_with_no_save_file_starts_fresh - test_save_on_quit_then_reload_round_trip - test_hook_listener_uses_loaded_state_after_mount Unit (test_app.py — TestLoadFromSaveExchange): - test_returns_false_when_no_bridge_loop - test_returns_false_when_no_save_exchange_on_loop - test_returns_false_when_save_file_does_not_exist - test_returns_true_and_replaces_state_when_save_exists (also verifies bridge_loop.state and hook_listener.state are updated) +9 tests, 149 total passing. https://claude.ai/code/session_01NpeAv65eF3PeVd91JoTNJs
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the last M1 deliverable: "Close/reopen preserves all state."
Previously
MainApp.on_mountcalledrefresh_panels()but never loaded from the save exchange — every reopen started from scratch. Save-on-exit was already wired inaction_quit.Implementation (
tui/app.py)MainApp._load_from_save_exchange()— ifbridge_loop.save_exchangeexists and has a file, reads the payload and replaces:self.session_state(TUI state)self.bridge_loop.state(loop's state reference)self.bridge_loop.hook_listener.state(so post-mount injections land on the loaded session)on_mount()beforerefresh_panels()Tests (+9 tests)
Pilot tests (
test_app_pilot.py):test_app_loads_kingdom_name_from_save_on_mounttest_app_restores_session_count_and_attributes_from_savetest_app_with_no_save_file_starts_freshtest_save_on_quit_then_reload_round_trips→ new app → loads statetest_hook_listener_uses_loaded_state_after_mountgkey increments loaded session, not stale stateUnit tests (
test_app.py—TestLoadFromSaveExchange):Falsewhen no bridge loop / no exchange / no fileTrueand updatesstate,bridge_loop.state, andhook_listener.statewhen save existsToward kanban
Toward kanban: t_cefabee5 (M1 Vertical Slice) — all M1 deliverables now complete including close/reopen
Test plan
pytest tui/tests/ -q→ 48 passedpytest -q→ 149 passedhttps://claude.ai/code/session_01NpeAv65eF3PeVd91JoTNJs
Generated by Claude Code