Skip to content

Decide a client's availability and its join in the session - #98

Merged
kahrendt merged 1 commit into
mainfrom
issue-26-visualizer-available-join
Oct 16, 2026
Merged

kahrendt merged 1 commit into
mainfrom
issue-26-visualizer-available-join

Conversation

@kahrendt

Copy link
Copy Markdown
Contributor

Summary

A client's available and the join a turn to available: true makes for its stream roles lived in PlayerStream, whatever roles the client had, and ServerCore read them as session().player().available(). That placement made a visualizer-only client's join look missing. It was not: PlayerStream set the join for every client, and Session applies the kind to both stream roles. This moves the decision to the session, where it belongs. Behavior is unchanged.

Change

  • Session::on_client_state decides the join: a report of available: true that is the first or follows false. Session::available() exposes the latest report.
  • PlayerStream drops its state_received_, its availability join and its available() accessor. Its on_client_state returns a kind only for the role's first object since its activation, as VisualizerStream's does.
  • PlayerStream and VisualizerStream each keep their copy of available for eligibility, as ArtworkStream and SourceStream do.
  • ServerCore::on_client_state reads session().available().
  • Left as is: the two streams' near-identical on_activation_written() bodies. The visualizer's also resets its offset_.

Tests

  • SessionTest.MakesATurnToAvailableAJoin: a table over Session with no I/O, on a visualizer-only client. Each row's last client/state carries no role object, so any join is availability's. It covers true after false (Control), a first true, true after true, false after true and a first false. The "true after true" row covers the old rule, which had no test.
  • ServerVisualizer.JoinsAPlayingGroupOnceItTurnsAvailable: a visualizer-only client whose first client/state reports available: false stays in the playing group it joined. Once it reports true, its stream starts the group lead past its stream/start. The check of the first message against the lead is shared with StartsAJoinerTheGroupLeadPastItsStart.
  • Known gap: the raw-client test guards the join rule only weakly. The first state's own join (the role's first object) may still be pending when available: true arrives, so the Session test holds the rule.

Closes #26

A client's `available` and the join a turn to `available: true` makes for
its stream roles were tracked in PlayerStream, whatever the client's roles,
and ServerCore read them as the player's. Session now tracks them and sets
the join for both stream roles; PlayerStream and VisualizerStream keep only
their own copy for eligibility, and ServerCore reads the session's.

A Session test covers which reports are a join, and a raw-client test has a
visualizer-only client that starts unavailable in a playing group join it
at the group lead once it reports available.
@kahrendt
kahrendt marked this pull request as ready for review October 16, 2026 16:52
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused refactor preserves existing semantics, updates the affected caller, and adds regression coverage with no identified blocking issues.

0 open findings

What changed in this PR

Moves client availability and availability-triggered joins into Session, preserving behavior while clarifying ownership for visualizer-only clients.

Changes:

  • Centralizes availability tracking and join decisions in Session.
  • Removes session-wide availability responsibilities from PlayerStream.
  • Adds session regression coverage and a visualizer integration test.
File Description
tests/​test_session.cpp Tests availability transitions and join decisions.
tests/​test_server_visualizer.cpp Tests availability-driven startup and shares timing assertions.
src/​session.h Adds session availability state and accessor.
src/​session.cpp Decides availability-triggered joins.
src/​server_core.cpp Reads availability directly from the session.
src/​player_stream.h Removes the availability accessor and redundant tracking field.
src/​player_stream.cpp Limits join decisions to the role’s first state object.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@kahrendt
kahrendt merged commit a88fc9d into main Oct 16, 2026
14 checks passed
@kahrendt
kahrendt deleted the issue-26-visualizer-available-join branch October 16, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide whether a visualizer that turns available again gets a join trigger

2 participants