Skip to content

feat(watch-together): make vote rooms actually vote - #486

Closed
RXWatcher wants to merge 3 commits into
Silo-Server:mainfrom
RXWatcher:feat/watch-together-voting
Closed

RXWatcher wants to merge 3 commits into
Silo-Server:mainfrom
RXWatcher:feat/watch-together-voting

Conversation

@RXWatcher

@RXWatcher RXWatcher commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem

selection_mode has been stored, normalized and published on every room snapshot since Watch Together landed, and nothing has ever read it. A vote room behaved exactly like a host_pick one: members could suggest and vote, the tally was recorded and broadcast to everyone, and then the host promoted whatever they liked regardless of it.

So the mode was a label on an unimplemented feature, and the vote counts on everyone's screen were decoration.

What a vote room does now

The host starts the winner rather than choosing it. Promoting anything other than the leading suggestion is refused (409 not_vote_winner), because a host who can overrule the tally makes the mode host_pick with extra steps.

The winner is the head of the repository's existing ordering — vote_count DESC, created_at ASC. Most votes; ties to whoever suggested first. Deterministic, and re-suggesting a title cannot jump the queue.

A room where nobody has voted has no winner and says so (409 no_votes_cast), rather than quietly promoting the oldest suggestion as though a vote had happened.

host_pick rooms are untouched: the host still promotes freely.

Both doors, not one

PromoteSuggestion is not the only way into a room's selection. SelectItem (PUT /rooms/{room_id}/selection) is host-only but was not gated by mode at all, so a host could set any title directly and bypass the vote entirely. Enforcing the tally on one path and not the other is the same as not enforcing it. A vote room now refuses a direct selection (409 vote_room_selection).

I got this wrong in the first commit here and caught it while working through the host's options — worth a look in review, since "is that every path into this state?" is exactly the question this change lives or dies on.

Testing

The winner rule is split out from the database (winnerFrom) and unit tested: most-voted wins, ties go to the earlier suggestion, and an unvoted room yields ErrNoVotesCast rather than a default. internal/watchtogether and internal/api/handlers green; make lint clean for the touched files.

Running on my server. Not yet exercised with real participants — the rule has tests on both sides, but nobody has had two devices in a room voting against each other.

Client side

Silo-Server/silo-android#106 carries the client half: hosting offers a vote room, the lobby marks the leader WINNING, and the host gets a single "Start winner" action. The client mirrors this winner rule exactly so its idea of who is leading cannot drift from the server's.

Note the clients also had to stop pre-selecting a title when creating a vote room — doing so set the room playing immediately and the vote never happened.

AI-use disclosure

Written by Claude Opus 5 (Claude Code) working with @RXWatcher, who specified the semantics (anyone suggests and votes, host starts the winner, host cannot override) and whose question about the host's options surfaced the SelectItem gap.

Summary by CodeRabbit

  • New Features

    • Added vote-winner selection for watch-together rooms, including promotion based on the current vote winner.
  • Bug Fixes

    • When promoting before any votes are cast, the app now returns a clear 409 Conflict error (“Nobody has voted yet”).
    • Deterministic tie-breaking ensures consistent winner selection when vote counts are equal.
  • Tests

    • Added unit tests covering winner selection rules and the no-votes error case.

RXWatcher and others added 2 commits July 26, 2026 16:58
selection_mode has been stored, normalized and published since the
feature landed, and nothing has ever read it. A "vote" room behaved
exactly like a host_pick one: members could suggest and vote, the tally
was recorded and broadcast, and then the host promoted whatever they
liked regardless of it.

In a vote room the host now starts the winner rather than choosing it.
Promoting anything other than the leading suggestion is refused, because
being able to overrule the tally makes the mode host_pick with extra
steps and turns the vote counts on everyone else's screen into
decoration.

The winner is the head of the repository's existing ordering
(vote_count DESC, created_at ASC): most votes, ties to whoever suggested
first — deterministic, and re-suggesting a title cannot jump the queue.

A room where nobody has voted has no winner and says so, rather than
quietly promoting the oldest suggestion as though a vote had happened.

host_pick rooms are untouched: the host still promotes freely.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
Gating PromoteSuggestion left SelectItem wide open: it is host-only but
was not gated by selection mode, so the host of a vote room could set any
title directly and bypass the vote entirely. Enforcing the tally on one
path and not the other makes the vote counts on everyone else's screen
decoration.

A vote room now refuses a direct selection outright. The winner is the
only way in.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7b6f2179-6b74-4f40-8891-3316a79c9719

📥 Commits

Reviewing files that changed from the base of the PR and between 77c7d6a and 200cd4f.

📒 Files selected for processing (2)
  • internal/api/handlers/watch_together.go
  • internal/watchtogether/service.go
💤 Files with no reviewable changes (1)
  • internal/api/handlers/watch_together.go

📝 Walkthrough

Walkthrough

Vote-mode winner selection now returns a dedicated no-vote error, computes the ordered winner, tests tie and no-vote behavior, and maps the error to an HTTP 409 response.

Changes

Vote winner selection

Layer / File(s) Summary
Vote winner calculation
internal/watchtogether/service.go, internal/watchtogether/vote_winner_test.go
Adds ErrNoVotesCast and VoteWinner, selects the head of the ordered suggestions, and tests ordering, no-vote handling, and ties.
No-vote HTTP response
internal/api/handlers/watch_together.go
Maps ErrNoVotesCast to HTTP 409 with code no_votes_cast and message “Nobody has voted yet”.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: rhainland

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: adding real voting behavior for watch-together rooms.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/watchtogether/service.go`:
- Around line 1910-1912: The winner-promotion path in
VoteWinner/HandlePromoteSuggestion must not call the public SelectItem method,
because its vote-room guard rejects every promotion. After validating the
winning suggestion, route promotion through a private selection-finalization
method that bypasses the direct-selection guard, while preserving SelectItem’s
existing protection; add a regression test confirming promotion of the current
winner succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: be689586-5748-4cdc-863e-d1ef435b4378

📥 Commits

Reviewing files that changed from the base of the PR and between 99d2056 and 77c7d6a.

📒 Files selected for processing (3)
  • internal/api/handlers/watch_together.go
  • internal/watchtogether/service.go
  • internal/watchtogether/vote_winner_test.go

Comment on lines 1910 to 1912
return s.SelectItem(ctx, roomID, userID, profileID, SelectItemInput{
ContentID: suggestion.ContentID,
})

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Winner promotion is unconditionally rejected.

VoteWinner can successfully return the requested suggestion, but this then calls SelectItem, whose new vote-mode guard returns ErrVoteRoomSelection for every vote room. Consequently, no vote-room suggestion can be promoted; HandlePromoteSuggestion falls through to a 500 for this unexpected error. Route promotion through a private selection-finalization method after winner validation, while retaining the public direct-selection guard. Add a regression test that promoting the current winner succeeds.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/watchtogether/service.go` around lines 1910 - 1912, The
winner-promotion path in VoteWinner/HandlePromoteSuggestion must not call the
public SelectItem method, because its vote-room guard rejects every promotion.
After validating the winning suggestion, route promotion through a private
selection-finalization method that bypasses the direct-selection guard, while
preserving SelectItem’s existing protection; add a regression test confirming
promotion of the current winner succeeds.

Reverses the winner-only restriction. The tally is advisory now: the host
may promote any suggestion, and may set the room's selection directly.

Both gates go — promotion and the raw selection path — because leaving
either one would produce a room where the host can override through one
door and not the other, which is harder to explain than either rule on
its own.

VoteWinner stays and keeps its tests. It is still the room's answer, and
both clients use it for the WINNING badge and the one-press "Start
winner" action; it simply no longer binds the host.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Db4dSxN9tH8yN7uUP549tK
@RXWatcher

Copy link
Copy Markdown
Contributor Author

Semantics changed on review of the actual UX: the host can now override the vote.

The original rule here was that the host starts the winner but cannot choose something else — the reasoning being that a host who can ignore the tally makes the vote decoration. On reflection that is too rigid for a living room: the person hosting is usually the one holding the remote, and a room can perfectly well vote and then have someone say "actually, let's watch the other one".

So the tally is advisory now. Concretely, on top of the two commits already here:

  • PromoteSuggestion no longer refuses a non-winner
  • SelectItem no longer refuses a direct selection in a vote room
  • Both associated error paths are gone with them

I removed both gates rather than one, because leaving either would produce a room where the host can override through one door and not the other — harder to explain than either rule on its own.

VoteWinner stays, with its tests. It is still the room's answer and both clients use it for the WINNING badge and the one-press "Start winner" action; it simply no longer binds the host.

Client side follows in Silo-Server/silo-android#106 — the per-row "Pick" returns in vote rooms, where it had been hidden precisely because the server used to refuse it.

Note this also makes the PR title slightly overstated: vote rooms do now vote, and the tally drives the default action, but it is a recommendation rather than a constraint.

@Quick104

Copy link
Copy Markdown
Contributor

Closing because this branch has been superseded by the binding vote-room implementation now on main. The final commit changes the semantics to advisory voting with a host override, while the PR title and body still describe winner-only enforcement; resolving the conflicts would therefore silently reverse the current behavior. If advisory voting is still desired, please open a fresh, focused PR against current main with the updated rationale and tests. Thanks for the work here.

@Quick104 Quick104 closed this Jul 29, 2026
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