feat(client): auto-refresh display on server state broadcast#6
Merged
Conversation
Spec, plan, tasks, research, data model, contracts, and checklist for automatic client screen refresh when server broadcasts state changes. Amends constitution v1.1.1 to permit synchronous stdlib-only polling wrappers as a replacement for input() when required for display refresh. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add threading.Event dirty-flag to ClientState.apply() and a select.select-based polling wrapper (_input_with_refresh) at the top-level menu prompt in risus.py. The display redraws within 2s of any state/presence/lock_acquired/lock_released broadcast without operator input. Falls back to plain input() when stdin lacks fileno() (test environments). Adds 8 unit tests covering all FR/SC. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_input_with_refresh now accepts a redraw callable. main() passes _redraw_main which calls clear() + show_state() + full menu, so server-broadcast updates replace the screen instead of appending below. Closes risus-cli-r9j Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(client): clear screen on state broadcast refresh
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
(player added, cliche switched, dice reduced, save/load, presence change,
lock acquired/released) — no keypress required
the full menu instead of appending a second partial render below
ClientState.update_event(threading.Event) signals the main loop;_input_with_refreshpolls with a 1-second select timeout and fires theredraw callable when the event is set
Changes
client/state.py—update_eventset on all broadcast frame typesrisus.py—_input_with_refreshgains optionalredrawcallable;main()extracts_redraw_main()(clear + state + menu) and passes itas the redraw target
tests/unit/test_state_refresh.py— 9 new unit tests coveringupdate_event triggers, refresh behaviour, and the redraw callable path
Test plan
pytest tests/unit -q— 86 passedtest_state_change_visible_on_second_client_within_2spassedcurl -fsS http://localhost:8765/healthz→{"ok":true}🤖 Generated with Claude Code