You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(playback): report whether the player received an admin message - #4621
Closes#4617
Related issue: N/A
Validation tasks: none (reaches #1206 C1 and #1207 C1 for the message command; both not run yet)
Other clients: Apple N/A (players already answer messages; no admin UI); Android N/A (same); Roku N/A (no live control socket)
When an administrator sends a message to a playing session, the server answered 202 with delivery: "dispatched" as soon as it wrote the message to the player's realtime socket. If the player's connection had died without closing, for example from a dropped network or a frozen device, the write still succeeded. The admin saw "Message sent" and the player saw nothing. The server keeps such a socket for about 30 seconds, until its ping times out.
Now a message waits up to 3 seconds for the player's answer. The receipt says acknowledged when the player answered and stays dispatched otherwise. dispatched is now documented as written to the socket but not confirmed by the player. The web admin keeps "Message sent" for an acknowledged message. Otherwise it warns that the player didn’t confirm the message and that it may show up late or not at all.
Approach
Web, Android and Apple players already send a result for a message, and the server receives it but never matched it to the request. The message command now registers for that result before writing the frame, keyed by session and command. It writes the frame and records the receipt under the ledger lock as before. It then releases the lock before waiting, so one unresponsive player doesn't hold up commands for other sessions. The wait's outcome lives on the receipt and is recorded without the lock, so an answered message never queues behind another session's socket write. A completed result within 3 seconds makes it acknowledged. A rejection ends the wait at once and leaves it dispatched, and so does no answer. A replay of the same identity reports the same outcome; one that arrives during the wait waits for it. Android answers before it shows the notice, so acknowledged means the player received the message.
Pause, resume, stop and terminate are unchanged. Each already carries a deadline after which the server ends the session if the player doesn't answer, so the admin's intent holds even when the player is gone. Message is the only command with no fallback, so dispatched was the last thing the admin heard about it. Stop handling is also being changed in #4616.
A message relayed from another API replica gets 3 more seconds of reply wait (11 instead of 8) for the player's answer, through ControlRelay.ForwardWaiting. Every other relayed command keeps 8 seconds. The receipt schema gains the acknowledged value. Since #5095 the contract check treats a new response enum value as additive, so no breaking approval is needed. Only the web admin calls these operations. The new warning string comes from Silo-Server/silo-translations#106 and #107, and this branch pins their release.
Validation
Reproduced on a sandbox at origin/main: with one web player's packets dropped, a message to it answered 202 dispatched in 4 ms and nothing appeared.
Same steps on this branch, one API replica:
healthy player: acknowledged in 5 ms, and the notice showed
dropped player: dispatched after 3.0 s, and nothing showed
a second session messaged during that wait: acknowledged in 6 ms, so it wasn't delayed
Two API replicas sharing the database and Redis, players on one and messages sent to the other: the same three results, through the relay.
Web admin Activity page at desktop and phone width: "Message sent" for the healthy player, and the warning after about 3.5 s for the dropped one.
Review fixes, on a sandbox from 3e85a1c with a scripted player:
answers at once: acknowledged in 22 ms
never answers: dispatched after 3.02 s, and a retry of the same identity sent at 0.5 s returned dispatched with it
rejects: dispatched in 18 ms
answers after 1.5 s: acknowledged, and the retry sent at 0.5 s also returned acknowledged
Four handler tests, including the relayed case, fail on main and pass here with -race. The three review tests (lock contention, a retry during the wait, a rejection) fail on 3b72712, before the review fixes, and pass here. Handler, apiv2, playback and contractspec packages pass.
make lint-changed reports 0 issues. The contract checks (verify-apiv2-contract, -openapi, -web-types), verify-local-paths, web ESLint, Prettier and the admin command tests pass.
Web typecheck passes.
After merging current main (0d53d06): build, the focused Go tests with -race, make lint-changed, the contract and route-inventory checks, the web typecheck and the message dialog test pass.
A relayed message now waits up to 11 seconds instead of 8 before a no-reply 503. Other relayed commands, and a terminate's local revocation fallback when the owning replica has died, keep 8 seconds.
An admin message request that gets no answer holds its HTTP request for 3 seconds. Other sessions' commands don't wait on it.
dispatched is the honest answer even when the player shows the message late. If the connection recovers, TCP can still deliver the frame after the wait, and the player then shows it. A player that reconnects to another replica during the wait also answers on a lane this request isn't watching. The warning says the message may show up late or not at all.
During a rolling upgrade, an older replica's message receipts stay dispatched, so the new web admin warns for those. An older replica that relays a message to an upgraded one still waits only 8 seconds, so a silent player there can return a 503; a retry replays the recorded receipt.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
Council review
Rounds: 3, last reviewed 3e85a1c (the head since adds merges of main, a comment and a test assertion)
Visual review: 1 round, captures from 4d86256 (same code as afeb04a)
Member
Round 1
Sol
better, 9/10
Opus
better, 7.5/10
Gemini
better, 8/10
Fixed in the maintainer review:
An answered message no longer takes the ledger lock again.
A retry during the wait reports the player's answer.
A rejection ends the wait.
Only a relayed message gets the longer reply wait.
Main's emptied approvals file is merged in.
Earlier fixes: the warning says a late arrival is possible, an unconfirmed replay closes the dialog, and a web test covers the receipt cases.
Left as follow-ups: a command id a client reuses after the ledger evicted it; mixed-version relays during a rolling upgrade; a spurious log line on cross-session command id reuse; and a handler-level relay test for the message's extra wait.
AI Disclosure
Harness: Claude Code in T3 Code
Tool(s): GitHub CLI, headless Chromium (Playwright), a dev-builder sandbox
Model(s): claude-opus-5-5; plan and visual reviews by gpt-6.2-sol, claude-opus-5-5 and gemini-4-neon
Involvement: Fully AI-generated, human verified
Adversarial review: before this PR opened, a plan round by the three models cut the plan to one new enum value and per-session waiter keys, and a code-review pass found a tie between the answer and the deadline (fixed). The background review and the maintainer review's rounds are in Council review above; the maintainer review's fixes were written by claude-opus-5-5.
Add acknowledged delivery value for admin playback messages
Admin message commands now wait up to 3 seconds for the player's realtime result. A completed result changes the receipt's delivery from dispatched to acknowledged; a timeout or rejection stays dispatched.
PlaybackHandler gains waiter registration for session-command pairs, and realtime result frames in session_ws.go signal the matching waiter.
Message requests and matching replays wait outside the command-ledger lock, on a shared completion channel, so replays report the same outcome without dispatching a second frame.
Relayed display-message commands use ForwardWaiting in control_relay.go to add 3 seconds to the owner reply wait (documented owner-reply wait rises to 11 seconds).
The admin UI in AdminSessionActions.tsx shows success only for acknowledged; other deliveries show a warning, and an acknowledged replay keeps the message text for resend.
Behavioral Change: dispatched no longer implies player confirmation; API consumers of the delivery enum (OpenAPI contract and generated schema) now see acknowledged as a third value, and unanswered messages add up to a 3-second wait before responding.
Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).
Message commands now wait briefly for player results and report acknowledged only when the player completes the command. The API contract and admin interface distinguish acknowledgement from dispatch. Relay requests for messages allow additional time for the result.
The receipt schemas add acknowledged. The API documentation describes the three-second message wait, player confirmation, and shared replay results.
Server result coordination internal/api/handlers/playback.go, internal/api/handlers/playback_realtime.go, internal/api/handlers/session_ws.go, internal/api/handlers/admin_playback_commands.go, internal/api/handlers/admin_playback_commands_test.go, internal/api/handlers/admin_playback_control_test.go
The handler registers result waiters by session and command, records receipts before waiting, and shares the final delivery result with retries. Completed results produce acknowledged; rejection or timeout leaves delivery as dispatched. Tests cover result timing, replay behavior, and concurrent commands.
ForwardWaiting extends the relay deadline for message commands. Other commands use no added wait. Tests and architecture documentation cover the extended deadline.
sequenceDiagram
participant Admin as Admin API
participant Handler as Playback command handler
participant Player as Player
participant Results as Realtime result handler
Admin->>Handler: Submit message command
Handler->>Player: Dispatch command
Player->>Results: Report command result
Results->>Handler: Signal matching session and command
Handler-->>Admin: Return acknowledged or dispatched receipt
Loading
Suggested reviewers:rhainland, coffeeknyte
Merge Risk: Low · previous review 0d53d
Admin message receipts now report whether the player answered within a short wait, and the web admin warns when delivery is unconfirmed. The remaining open point is a minor admin UI case where a draft edited during a pending replay may be cleared. It is bounded and recoverable, so the change is mergeable with owner awareness.
Security architecture risk: Minimal · up to 0d53d
The inspected change improves delivery reporting without establishing an introduced security or failure-containment risk. Player responses remain session-scoped, message waits do not hold the shared command lock, and acknowledgement does not grant authority or prove that a message was displayed.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — On the inspected result path, a player can report completion for its own session's pending message. That self-report can affect the corresponding receipt, but session-scoped correlation does not let it acknowledge another session's waiter or acquire additional authority. It is not proof of human-visible display.
Trust Boundaries and Controls
observed — The result is validated and its session must equal the socket-bound session before notification. Although notification precedes the existing command-record ownership check, its lookup includes both session and command, so a foreign-session command ID alone cannot wake the intended victim's waiter. Accepted result statuses are limited to completed and rejected.
Resilience and Maintainability Implications
observed — The relay retains its containment rule for uncertain execution: publish failure or reply timeout returns an unknown remote outcome rather than blindly executing again. Only an explicit owner decline allows a changed-owner retry, bounded by the original deadline. Owner execution remains off the bus reader, so a player's acknowledgement wait does not block receipt of other relay traffic.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(playback): report whether the player received an admin message" matches the main change. The PR makes admin message receipts report acknowledged when the player answers within a 3-sec…
Linked Issues check
Directly linked issue #4617 asks that the admin learn whether a player received a message, or that delivery is unconfirmed. At head 0d53d06, internal/api/handlers/admin_playback_commands.go implements…
Out of Scope Changes check
All changed areas relate to #4617. The handler, playback_realtime.go, session_ws.go and playback.go changes add the per-session result waiter that the acknowledgement requires. The control_relay.go an…
Description check
The description is specific and related to the changeset. It explains the problem (admin message receipts report dispatched after a socket write even when the player never receives the message), the…
Full details: Title check
Explanation
The title "fix(playback): report whether the player received an admin message" matches the main change. The PR makes admin message receipts report acknowledged when the player answers within a 3-second wait, and otherwise keeps dispatched. The title is specific and concise, and it uses a conventional commit prefix.
Full details: Linked Issues check
Explanation
Directly linked issue #4617 asks that the admin learn whether a player received a message, or that delivery is unconfirmed. At head 0d53d06, internal/api/handlers/admin_playback_commands.go implements this for message commands. commandLocal registers a result waiter (awaitRealtimeResult) before dispatchSequenced writes the frame, and records the receipt under commandMu. It then releases the lock before awaitMessageResult, which waits up to adminPlaybackMessageResultWait (3s). A completed result sets delivery to acknowledged. A rejection ends the wait and keeps dispatched. No answer keeps dispatched. Replays of the same command_id wait on the shared answer channel outside the lock and do not redispatch. The wait is outside commandMu, as the issue requires. The receipt enum adds acknowledged in internal/apiv2, openapi.json and web schema.ts, and the docs define dispatched as unconfirmed. The relay reply window for messages grows to 11s through ControlRelay.ForwardWaiting, so it covers the owner write plus the wait. The web admin warns for unconfirmed messages. Tests cover completion during and after the write, no answer, rejection, replay during the wait, and the relayed case. Limitation: the incremental diff from aecc742 could not be read (diff metadata too large, then changed blobs missing). The verdict rests on the whole-PR summary and the head source of admin_playback_commands.go. The relay and web changes were not re-read at head.
Full details: Out of Scope Changes check
Explanation
All changed areas relate to #4617. The handler, playback_realtime.go, session_ws.go and playback.go changes add the per-session result waiter that the acknowledgement requires. The control_relay.go and admin_playback_relay.go changes extend only the message relay wait, and their tests cover that scope. The contract, apiv2, schema.ts and docs changes record the new acknowledged value. The AdminSessionActions web changes add the required warning wording. The locale and .silo-translations pin supply that warning text. Pause, resume, stop and terminate keep their behavior, as the head code shows (only the message path is changed in commandLocal and dispatchSequenced). The PR does not change Apple or Android clients, which the issue says already send results. I found no demonstrated unrelated change. The incremental diff from aecc742 was not readable, so this verdict rests on the whole-PR summary and head source reads.
Full details: Description check
Explanation
The description is specific and related to the changeset. It explains the problem (admin message receipts report dispatched after a socket write even when the player never receives the message), the approach (message commands wait up to 3 seconds for the player's realtime result, record acknowledged on completion, release the ledger lock while waiting, and extend the relayed reply window to 11 seconds through ControlRelay.ForwardWaiting), the web admin warning change, the added acknowledged enum value, validation evidence, and risks. This matches the files in the raw summary, including the OpenAPI contract, the handlers, the relay, the web schema and dialog, and the tests.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
An admin message answered 202 "dispatched" once the frame was written to
the session's realtime socket, even when the player's connection had died
without closing. Waiting up to 3 seconds for the player's result, outside
the ledger lock, lets the receipt say "acknowledged" when the player
answered; otherwise it stays "dispatched", now documented as written but
unconfirmed. The relay reply timeout grows to cover the wait, and the web
admin warns when a message wasn't confirmed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
A rejected cross-session result can falsely acknowledge a message
An unrelated result can make an administrator's message appear acknowledged even though the player never received it. Check the recorded command's session before calling h.signalRealtimeResult.
Prompt for LLM
File internal/api/handlers/session_ws.go, lines 97-99:
A rejected cross-session result can falsely acknowledge a message
A completed result wakes the message waiter before the existing ownership check rejects a command ID belonging to another session, so an unrelated result can make an administrator's message appear acknowledged even though the player did not receive it. Check the recorded command's session before signaling the waiter.
The reason will be displayed to describe this comment to others. Learn more.
Leaving this as it is. The waiter is keyed by the socket's own session and the command ID (realtimeResultKey), and sessionID here is the session whose socket delivered the result, already checked against result.SessionID above. A result arriving on session S can only wake a message that was sent to S under that command ID. S's player learns that ID only from S's own frame, so a result from another session's player can't acknowledge it.
Moving the signal below the ownership check would make it worse. Command IDs are chosen per session (the ledger only requires uniqueness within a session), while getRealtimeCommand is keyed by command ID alone. If the same ID was used on two sessions, the record can name the other session, and S's genuine answer would then be dropped as unacknowledged.
The reason will be displayed to describe this comment to others. Learn more.
Agreed—the original suggestion is incorrect. I withdraw it.
The result’s session ID is checked against the socket’s session before signaling (internal/api/handlers/session_ws.go:89–98), and the waiter is keyed by both session and command ID (internal/api/handlers/playback_realtime.go:351–353, 379–386). A result from another session therefore cannot wake this session’s waiter just by using the same command ID.
Also, the command record is keyed by command ID alone (internal/api/handlers/playback_realtime.go:328–333, 389–396). Moving the signal below that ownership check could suppress a genuine result if another session’s record has overwritten it.
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 4 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
The reason will be displayed to describe this comment to others. Learn more.
[P3] S3 — Start the concurrency check independently of the ledger lock
If a regression keeps commandMu held through the message waits, commandLedgerState can block behind both sends. It checks latest before checking the deadline, so the helper can return successfully after both waits end. The pause timer then starts against an idle lock and the test can pass. Signal the first message write from the fake socket and assert that the pause completes while that message is still awaiting its result.
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
Covered in bd246b7 by TestAnsweredMessageDoesNotQueueBehindOtherCommands. The test holds the ledger lock itself while the player answers. So a regression that kept commandMu through the wait, or took it again afterwards, fails it regardless of when waitForPendingMessages returns.
One low-severity finding, inline. I found no correctness defects.
What I checked and found sound:
Lock order: realtimeCommandMu is only ever taken inside commandMu (the waiter is registered under it, and rememberRealtimeCommand already ran under it). signalRealtimeResult and release take realtimeCommandMu alone. Nothing takes commandMu while holding realtimeCommandMu.
Waiter lifecycle: release is deferred on every exit after registration, including stale, conflict and dispatch errors. It runs before the deferred unlock, so the lock order holds. It removes only its own channel, so a re-registration under the same key is safe.
Timer race: the inner select in the timer branch catches an answer that lands with the deadline. A late signal after release finds nothing.
Ledger during the wait: the upgrade checks that the ledger and receipt still exist and that the sequence matches, and never recreates a dropped ledger.
Result routing: the only reader of player frames (PlaybackControlSocketV2) checks lane ownership before handleRealtimeClientMessage. The waiter key includes the session, so a result from another session cannot wake it.
Relay budget: owner lookup (1 s) + lane write (5 s) + wait (3 s) fits inside 11 s with about the same margin the old 8 s had over 6 s. Web writes have no client deadline.
Client claims: Android sends completed before applying ShowMessage. Apple sends it after showNotice returns, and showNotice does not block. The web video and audiobook players handle display_message synchronously. Neither the Android nor the Apple app calls the v2 command routes, so the widened enum reaches only the web admin.
The documented 30 s figure matches wsPingInterval + wsPongTimeout.
This review was written by an AI model (Claude Opus 5.5).
Checked factual claims and edge cases across the server, web admin/players, Android, and Apple clients, plus contracts, docs, lock ordering, waiter lifecycle, relay timing, and test coverage.
Verified: Web video and audiobook players, Android phone/TV (before showing the notice), and Apple (after showing the notice) all emit type: "result" with status: "completed" for display_message. Neither Apple nor Android calls the admin session command operations. Lock ordering (commandMu -> realtimeCommandMu leaf lock, commandMu -> lane.mu -> writeMu), waiter cleanup on error/timeout/ack paths, 11 s relay reply timeout math, docs, and the 8 pre-lock breaking-approvals.json entries all match the code.
Findings (posted inline):
G1 (low):web/src/components/AdminSessionActions.tsx:213 — a replayed unconfirmed (dispatched) message shows the same unconfirmed toast as a first send but leaves the dialog open with the draft after the command identity has already been settled.
G2 (medium):internal/api/handlers/admin_playback_commands_test.go:435 — all positive acknowledgement tests answer synchronously inside WriteJSON, leaving the async wait path, waiter lifetime past dispatchSequenced, cross-session command_id isolation on completed, and mid-wait ledger drop untested.
The reason will be displayed to describe this comment to others. Learn more.
G2 (medium): Positive acknowledgement tests answer synchronously inside WriteJSON and do not exercise the async wait, session isolation, or mid-wait ledger drop
Trigger / gap: Both adminPlaybackControlTestConn.WriteJSON (internal/api/handlers/admin_playback_control_test.go:17-23) and relayTestConn.WriteJSON (internal/api/handlers/admin_playback_relay_test.go:78-91) invoke c.answer(env) synchronously before returning. Every test that checks delivery == "acknowledged" (TestSequencedCommandValidationAndSessionState, TestMessageIsAcknowledgedWhenThePlayerAnswers, TestAdminCommandRelaysToTheLaneOwner) therefore calls signalRealtimeResult while commandMu is still held and before dispatchSequenced even returns.
Impact: Three key parts of the production behavior would regress without failing any test:
Async wait & waiter lifetime: Calling release() immediately after dispatchSequenced (before awaitMessageResult) would break every real network player, yet all tests would still pass because answered is already closed before dispatchSequenced returns.
Cross-session (sessionID, commandID) waiter scoping: In TestUnansweredMessageStaysDispatchedWithoutDelayingOtherSessions, silent and refusing share sequencedCommandA (but refusing returns rejected, which never calls signalRealtimeResult), while healthy uses sequencedCommandB for a pause. Dropping sessionID from realtimeResultKey would allow another session's completed result for sequencedCommandA to falsely acknowledge silent without failing any test.
Mid-wait ledger drop/trim: The ledger != nil and receipt.sequence == in.Sequence guards in awaitMessageResult (internal/api/handlers/admin_playback_commands.go:313-319) are never hit because no completed result arrives after commandMu is released.
Suggested repair: Add async tests that wait via waitForPendingMessages until commandLocal has released commandMu and entered awaitMessageResult, then deliver handleRealtimeClientMessage: (1) a completed result from the same session upgrades both the 202 response and a subsequent replay to acknowledged, (2) a completed result for the same command_id from a different session does not wake the waiting session, and (3) dropping the session/ledger mid-wait before completed arrives returns acknowledged without panicking or recreating the ledger.
The "during the wait" case of TestMessageIsAcknowledgedWhenThePlayerAnswers answers after the sender released the lock.
TestReplayDuringTheWaitReportsThePlayersAnswer and TestAnsweredMessageDoesNotQueueBehindOtherCommands (bd246b7) answer from outside the write.
Dropping the ledger mid-wait no longer matters: the answer lives on the receipt, so there's no ledger lookup left to exercise.
Still not covered: a test where another session's completed result reuses the same command id. The key includes the socket's own session, so I've left that as is.
…rmed
A replayed message that came back unconfirmed showed the warning but kept
the dialog open with its text, so a second Send made a new command and the
viewer could see the message twice. Only an acknowledged replay keeps the
text for a deliberate resend now.
Also:
- test a player answer that arrives during the unlocked wait, not only
inside the write;
- test which toast and dialog state each receipt produces;
- stop describing `dispatched` as "not confirmed": a pause or resume the
player confirms after its receipt was recorded still reads `dispatched`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 4 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
Preserve durable media identity and share identity-evidence precedence
Bound decoder throughput trades and share direct-play eligibility
203-204: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve edits made while the message request is pending.
If the administrator sends A and then edits the textarea to B during the acknowledgment wait, a dispatched replay now reaches setMessage("") and discards the unsent B. Previously, the replay returned without clearing the draft. The textarea remains enabled while the request is pending.
Disable editing during the request, or clear the draft only if it still matches the submitted value. Add a deferred-response test that edits the draft before resolving a dispatched replay.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 6b4f5b9a-b2dc-4270-b51b-6e47714c48b1
Commits
Reviewing files that changed from the base of the PR and between 2c2dc7c and aecc742.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…ions
A message whose player answered took the ledger lock again to record the
answer. Another session's lane write can hold that lock for up to its 5 second
write deadline, so a relayed message the player had confirmed could pass the
relay's reply wait and come back as no reply. The answer now lives on the
receipt itself and is recorded without the lock.
A retry that arrived while the first request still waited replayed the
provisional "dispatched", so the web admin warned even when the player then
answered. A replay now waits for the same answer, outside the lock.
Only a relayed message gets the extra 3 seconds of reply wait. Pause, resume,
stop and terminate keep 8 seconds, so a terminate whose owning replica died
starts its local fallback on the usual schedule.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A player that rejected a message still held the administrator's request for
the whole 3 second wait, though its answer had already arrived. The waiter
now receives the result's status: a rejection ends the wait at once and the
receipt stays "dispatched".
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
Review of 3b72712, which is this branch with main merged in. Main had moved the translation pin, keys.ts and breaking-approvals.json. The pin now follows main, whose catalog release already has the warning key. The approvals file keeps only this PR's eight entries, because the contract check rejects older ones as stale against the new merge base.
The approach holds. Registering the waiter before the write, keyed by session and command id, is the right boundary. All three players (web video and audiobooks, Apple, Android phone and TV) send a completed result for a message, so a healthy player reads acknowledged.
Four findings, each inline except the first. I'm fixing all four in commits on this branch, so there's no need to change anything yourself:
Medium: the answer takes the ledger lock again before the request returns. This is the existing CodeRabbit thread on line 306; I'm replying there.
Medium: a retry during the wait reports dispatched early.
Low: the longer relay wait applies to every command, including terminate's fallback.
Low: a rejection holds the request for the full 3 seconds.
The reason will be displayed to describe this comment to others. Learn more.
Shortened relay timeout can reject successful remote terminates
The watch-state publish and socket write can each take five seconds, so a successful stop may exceed the eight-second relay deadline. Increase controlRelayReplyTimeout to cover both operations and the relay margin, or give terminate a longer deadline.
Prompt for LLM
File internal/playback/control_relay.go, line 72:
Shortened relay timeout can reject successful remote terminates
A relayed terminate can time out after eight seconds while its owner is still completing a successful stop: the new watch-state publish alone can take five seconds, followed by a socket write with another five-second deadline. Preserve a timeout that covers both bounded operations and the relay margin, or assign terminate its own longer deadline.
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code (claude-opus-5-5)
This PR doesn't shorten the terminate deadline. controlRelayReplyTimeout has been 8 seconds since #2349, and git diff origin/main shows the constant unchanged here. An earlier commit on this branch gave every relayed command 11 seconds. bd246b7 limited the extra 3 seconds to messages, which is the change this comment compares against. Terminate keeps main's deadline, so a slow terminate behaves the same as it does on main.
I also found no 5-second watch-state publish on the terminate path, in the realtime and admin command handlers or in internal/playback and internal/watchstate. I'm leaving the timeout as it is.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking. Given that the terminate timeout is unchanged from main, and the claimed five-second watch-state publish is not on that path, my suggestion does not establish a regression in this PR. Keeping the existing timeout is reasonable.
Reviewed head: 45439ef, which is afbc6be with current main merged in (0d53d06) plus a test-timing fix. The council's last round reviewed 3e85a1c. Since then the branch has only merges of main, a comment fix and a stronger test assertion.
Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)
Fit. The fix stops the web admin from saying "Message sent" when the player never got the message. Silo's 1.0 milestone lists that "admin can … send a message clients surface", so this closes a gap in a release item. The added surface is one value on an existing receipt field. There's no new setting, and nothing runs in the background. The default is the honest answer.
Readiness. The behavior is shown live and by tests that fail on the base, and the validation-board check has now run with no passed case affected. The open items below are low severity and none blocks the merge.
Test timing (45439ef): the replay and relay tests now wait on a hook and a gate instead of fixed sleeps, as CodeRabbit pointed out. Both still fail when their behavior breaks.
Main merged twice before that.
The translation pin and keys.ts follow main. Main's catalog release already has the warning key, so no catalog PR was needed.
An answered message no longer takes the ledger lock again before returning, so it can't turn into a relay no-reply behind another session's socket write (bd246b7).
A retry during the 3-second wait waits for the player's answer instead of reporting dispatched early (bd246b7).
Only a relayed message gets the extra 3 seconds of reply wait. Terminate's fallback keeps 8 seconds (bd246b7).
Older review threads: I replied in each one. The dialog behavior, the web test and the dispatched wording were already handled by the author's later commits.
never answers: dispatched after 3.02 s, and a retry sent at 0.5 s returned dispatched with it
rejects: dispatched in 18 ms
answers after 1.5 s: acknowledged, and the retry also returned acknowledged
Tests that fail on 3b72712, before the fixes:TestAnsweredMessageDoesNotQueueBehindOtherCommands, TestReplayDuringTheWaitReportsThePlayersAnswer, and the updated TestUnansweredMessageStaysDispatchedWithoutDelayingOtherSessions. The author's four handler tests fail on main.
Other checks: lint, the contract checks and the web message test pass.
After merging main (0d53d06): build, the handler, playback, apiv2 and contractspec tests with -race, make lint-changed (0 issues), the route inventory, the apiv2 contract, OpenAPI and web-type checks, verify-local-paths, the web typecheck and the message dialog test pass. The two checks that failed on afbc6be were a Go build-cache miss in the route-inventory step and TestStartupMigrationsStopWhenALockSessionEndsDB, neither in code this PR touches; CI reruns both on the new head.
Command id reuse after eviction: a client that reuses a command id after 256 newer receipts pushed it out of the ledger could have a late answer acknowledge the newer message. The web admin always sends a fresh id.
Rolling upgrade: an older replica relaying a message to an upgraded one waits only 8 seconds, and it passes acknowledged through a schema that lacks it. A retry recovers, and this ends once every replica is upgraded.
Spurious log line: a message result whose command id matches another session's tracked command still reaches the existing ownership check and logs an invalid payload. That path predates this PR.
Missing test: nothing tests relayCommand choosing the longer wait for a message. The relay method itself is tested.
Validated features
Checked against the v1.0 board. No passed case reaches the changed code. The message command's cases, #1206 C1 and #1207 C1, are both not run yet, so validators will see the new receipt and warning when they run them. The passed node cases (#1177 C3, #1178 C1–C3) cover node failover and monitoring, which this PR doesn't change.
User manual
running-a-server/active-playback.md says to "watch the session's state or ask the viewer" to see whether a command worked. With this PR a message reports whether the player confirmed it. I recommend a siloserver.org issue to add one sentence about the confirmation and the warning there. None exists yet.
Apple and Android
No change needed. Both apps already answer messages, and neither calls these admin endpoints.
Synchronize the replay with the pending-answer branch.
The replay goroutine can remain unscheduled during the 100 ms wait. If it starts after the player answers, this test passes without exercising a pending replay. A regression that returns provisional dispatched only during the wait can therefore pass.
Add a synchronization hook at the replay's pending-answer branch. Wait for that signal before checking that the replay remains blocked and sending the player result. Keep a timeout only as a failure bound.
Based on learnings, “Fixed delays do not synchronize with background completion.”
The test separates the deadlines with a 50 ms timeout and a 150 ms sleep. This makes the result depend on scheduler timing.
Start ForwardWaiting first and wait for its handler-entry signal. Then start Forward. After Forward returns ControlRelayNoReply, release the gated handlers and assert that ForwardWaiting returns ControlRelayHandled. Release the gate during cleanup as well.
Based on learnings: “In tests, wait on observable state — job status, health endpoints, channel receipts — not fixed sleeps.”
Source: Learnings
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 1f893f08-1777-4dde-ae42-666f69993cb9
Commits
Reviewing files that changed from the base of the PR and between aecc742 and 0d53d06.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
The replay test now waits for a hook that fires when the replay starts
waiting for the player's answer, so it always exercises a pending replay.
The relay test holds the owner's handler on a gate instead of sleeping
past a 50 ms reply timeout.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code Review Completed, but its comments could not be posted ⚠️
The review produced 1 comment(s), but none could be posted to this pull request (for example, the platform rejected them with a rate limit). This is not a clean review: comment @kody review on this PR to run it again.
Kody Guide: Usage and ConfigurationInteracting with Kody
Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.
Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.
Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.
Current Kody ConfigurationReview Options
The following review options are enabled or disabled:
TestReplayDuringTheWaitReportsThePlayersAnswer now waits for a hook that fires when the replay starts waiting for the player's answer, instead of sleeping 100 ms. It always tests a replay that is still waiting.
TestControlRelayWaitsLongerOnlyForARequestThatWaitsForThePlayer holds the owner's handler on a gate. The waiting request goes first, the plain request gets no reply, then the gate opens and the waiting request is handled. No sleeps.
Both pass 20 runs with -race. Each still fails when its behavior breaks: a replay that skips the wait, and a relay that ignores the extra time.
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
bugSomething isn't workingpriority: P2Limited scope, workaround exists, or polishsize/XL500–999 added + deleted lines (all files); change volume, not priority.
1 participant
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.
Problem
Closes #4617
Related issue: N/A
Validation tasks: none (reaches #1206 C1 and #1207 C1 for the message command; both not run yet)
Other clients: Apple N/A (players already answer messages; no admin UI); Android N/A (same); Roku N/A (no live control socket)
When an administrator sends a message to a playing session, the server answered
202withdelivery: "dispatched"as soon as it wrote the message to the player's realtime socket. If the player's connection had died without closing, for example from a dropped network or a frozen device, the write still succeeded. The admin saw "Message sent" and the player saw nothing. The server keeps such a socket for about 30 seconds, until its ping times out.Now a message waits up to 3 seconds for the player's answer. The receipt says
acknowledgedwhen the player answered and staysdispatchedotherwise.dispatchedis now documented as written to the socket but not confirmed by the player. The web admin keeps "Message sent" for an acknowledged message. Otherwise it warns that the player didn’t confirm the message and that it may show up late or not at all.Approach
Web, Android and Apple players already send a
resultfor a message, and the server receives it but never matched it to the request. The message command now registers for that result before writing the frame, keyed by session and command. It writes the frame and records the receipt under the ledger lock as before. It then releases the lock before waiting, so one unresponsive player doesn't hold up commands for other sessions. The wait's outcome lives on the receipt and is recorded without the lock, so an answered message never queues behind another session's socket write. Acompletedresult within 3 seconds makes itacknowledged. A rejection ends the wait at once and leaves itdispatched, and so does no answer. A replay of the same identity reports the same outcome; one that arrives during the wait waits for it. Android answers before it shows the notice, soacknowledgedmeans the player received the message.Pause, resume, stop and terminate are unchanged. Each already carries a deadline after which the server ends the session if the player doesn't answer, so the admin's intent holds even when the player is gone. Message is the only command with no fallback, so
dispatchedwas the last thing the admin heard about it. Stop handling is also being changed in #4616.A message relayed from another API replica gets 3 more seconds of reply wait (11 instead of 8) for the player's answer, through
ControlRelay.ForwardWaiting. Every other relayed command keeps 8 seconds. The receipt schema gains theacknowledgedvalue. Since #5095 the contract check treats a new response enum value as additive, so no breaking approval is needed. Only the web admin calls these operations. The new warning string comes from Silo-Server/silo-translations#106 and #107, and this branch pins their release.Validation
origin/main: with one web player's packets dropped, a message to it answered202 dispatchedin 4 ms and nothing appeared.acknowledgedin 5 ms, and the notice showeddispatchedafter 3.0 s, and nothing showedacknowledgedin 6 ms, so it wasn't delayed3e85a1cwith a scripted player:acknowledgedin 22 msdispatchedafter 3.02 s, and a retry of the same identity sent at 0.5 s returneddispatchedwith itdispatchedin 18 msacknowledged, and the retry sent at 0.5 s also returnedacknowledgedmainand pass here with-race. The three review tests (lock contention, a retry during the wait, a rejection) fail on3b72712, before the review fixes, and pass here. Handler, apiv2, playback and contractspec packages pass.make lint-changedreports 0 issues. The contract checks (verify-apiv2-contract,-openapi,-web-types),verify-local-paths, web ESLint, Prettier and the admin command tests pass.-race,make lint-changed, the contract and route-inventory checks, the web typecheck and the message dialog test pass.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/issue-4617/ (the review fixes' timings and tests are in that site's
pr-4621-reviewpage)Risks
503. Other relayed commands, and a terminate's local revocation fallback when the owning replica has died, keep 8 seconds.dispatchedis the honest answer even when the player shows the message late. If the connection recovers, TCP can still deliver the frame after the wait, and the player then shows it. A player that reconnects to another replica during the wait also answers on a lane this request isn't watching. The warning says the message may show up late or not at all.dispatched, so the new web admin warns for those. An older replica that relays a message to an upgraded one still waits only 8 seconds, so a silent player there can return a503; a retry replays the recorded receipt.Checklist
Council review
Rounds: 3, last reviewed 3e85a1c (the head since adds merges of main, a comment and a test assertion)
Visual review: 1 round, captures from 4d86256 (same code as afeb04a)
Fixed in the maintainer review:
Earlier fixes: the warning says a late arrival is possible, an unconfirmed replay closes the dialog, and a web test covers the receipt cases.
Left as follow-ups: a command id a client reuses after the ledger evicted it; mixed-version relays during a rolling upgrade; a spurious log line on cross-session command id reuse; and a handler-level relay test for the message's extra wait.
AI Disclosure
🤖 Generated with Claude Code
Note
Add
acknowledgeddelivery value for admin playback messagesdispatchedtoacknowledged; a timeout or rejection staysdispatched.PlaybackHandlergains waiter registration for session-command pairs, and realtime result frames in session_ws.go signal the matching waiter.ForwardWaitingin control_relay.go to add 3 seconds to the owner reply wait (documented owner-reply wait rises to 11 seconds).acknowledged; other deliveries show a warning, and an acknowledged replay keeps the message text for resend.dispatchedno longer implies player confirmation; API consumers of the delivery enum (OpenAPI contract and generated schema) now seeacknowledgedas a third value, and unanswered messages add up to a 3-second wait before responding.Macroscope summarized 45439ef.