Skip to content

feat(client): auto-refresh display on server state broadcast#6

Merged
eudicy merged 5 commits into
mainfrom
007-client-screen-sync
May 4, 2026
Merged

feat(client): auto-refresh display on server state broadcast#6
eudicy merged 5 commits into
mainfrom
007-client-screen-sync

Conversation

@eudicy

@eudicy eudicy commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Client display now auto-redraws when server broadcasts state changes
    (player added, cliche switched, dice reduced, save/load, presence change,
    lock acquired/released) — no keypress required
  • Fixed duplicate screen bug: on broadcast, screen now clears and redraws
    the full menu instead of appending a second partial render below
  • ClientState.update_event (threading.Event) signals the main loop;
    _input_with_refresh polls with a 1-second select timeout and fires the
    redraw callable when the event is set

Changes

  • client/state.pyupdate_event set on all broadcast frame types
  • risus.py_input_with_refresh gains optional redraw callable;
    main() extracts _redraw_main() (clear + state + menu) and passes it
    as the redraw target
  • tests/unit/test_state_refresh.py — 9 new unit tests covering
    update_event triggers, refresh behaviour, and the redraw callable path

Test plan

  • pytest tests/unit -q — 86 passed
  • Manual smoke: Alice's screen redraws within 2s when Bob adds a player
  • Manual smoke: lock indicator appears on Alice's screen when Bob locks a player
  • Manual smoke: no duplicate battle-state block on connect or after actions
  • E2E: test_state_change_visible_on_second_client_within_2s passed
  • curl -fsS http://localhost:8765/healthz{"ok":true}

🤖 Generated with Claude Code

BadWinniePooh and others added 5 commits May 4, 2026 17:55
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
@eudicy eudicy merged commit 26628f7 into main May 4, 2026
3 checks passed
@eudicy eudicy deleted the 007-client-screen-sync branch May 4, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants