Unassign a device from a playlist #209

Closed
opened 2026-11-15 09:02:08 +00:00 by vivy · 5 comments
Owner

Product owner, 2026-11-15 (GRI-2051): "I want to be able to unassign a device (so uncheck the check box)."

Today. AssignToDeviceForm in PlaylistEditorScreen.tsx renders an already-assigned device as checked and the user cannot clear it. The server has only POST /api/v1/devices/{device_id}/playlist (crates/server/src/playlists/mod.rs:36); there is no route that removes an assignment.

Wanted.

  • Server: DELETE /api/v1/devices/{device_id}/playlist removes the row from device_playlist_assignments, writes the audit entry, and pushes the change to the device if it is connected (same path as an assignment push). Same campus-scoping rules as assign.
  • Panel: the device list on the playlist shows the current state; checking and unchecking, then Save, applies the difference (assign the new ones, unassign the cleared ones). The live rollout status updates for both.
  • Also from the Devices screen: a device's playlist can be set to "none".

Decide first — what does an unassigned device show? Fallback content (#56) is not built yet. Proposed for now: the device shows the existing idle/"no playlist" screen and keeps no old content on screen. Write the choice in plan/ and test it.

Acceptance. Unchecking a device and saving makes that device stop playing the playlist within the normal push time, and the panel shows it as unassigned.

Product owner, 2026-11-15 (GRI-2051): *"I want to be able to unassign a device (so uncheck the check box)."* **Today.** `AssignToDeviceForm` in `PlaylistEditorScreen.tsx` renders an already-assigned device as `checked` and the user cannot clear it. The server has only `POST /api/v1/devices/{device_id}/playlist` (`crates/server/src/playlists/mod.rs:36`); there is no route that removes an assignment. **Wanted.** - Server: `DELETE /api/v1/devices/{device_id}/playlist` removes the row from `device_playlist_assignments`, writes the audit entry, and pushes the change to the device if it is connected (same path as an assignment push). Same campus-scoping rules as assign. - Panel: the device list on the playlist shows the current state; checking and unchecking, then **Save**, applies the difference (assign the new ones, unassign the cleared ones). The live rollout status updates for both. - Also from the **Devices** screen: a device's playlist can be set to "none". **Decide first — what does an unassigned device show?** Fallback content (#56) is not built yet. Proposed for now: the device shows the existing idle/"no playlist" screen and keeps no old content on screen. Write the choice in `plan/` and test it. **Acceptance.** Unchecking a device and saving makes that device stop playing the playlist within the normal push time, and the panel shows it as unassigned.
Author
Owner

Panel side lives in the Devices tab of #210.

Panel side lives in the Devices tab of #210.
Member

Implemented the server side (and the protocol + client support needed for the push to actually clear the screen), on feature/GRI-2073-unassign-device-playlist.

Server

  • DELETE /api/v1/devices/{device_id}/playlist (crates/server/src/playlists/{mod,handlers,store}.rs): same ContentAssign permission and campus-visibility check as POST .../playlist. An unknown or not-visible device is 404. Otherwise idempotent: 204 whether or not the device had an assignment to remove. Pushes PlaylistCleared to the device's live connection if it has one (same DeviceConnections::push, false ignored, same reasoning as assign).
  • plan/server/rest-api.md: documented the new route.

Protocol

  • New ServerControl::PlaylistCleared (crates/shared/src/protocol.rs), additive per the envelope's #[serde(other)] rule — an old client reads it as Unknown and ignores it rather than failing to parse.
  • plan/shared/protocol.md: documented the new message.

Client

  • Session::on_playlist_cleared sets state.playlist = None and the existing idle-screen path (crates/client/src/player.rs, already exercised by a freshly enrolled device) takes over. Cache and manifest are untouched on purpose — only the screen changes, so re-assigning the same playlist later needs no re-transfer.

The decision you asked me to make first: an unassigned device shows the existing idle/"no playlist" screen and keeps nothing of what it was showing — written up as plan/decisions/0014-unassigned-device-shows-idle.md (0013 was already taken twice in this file, by the way — looks like a numbering collision from two branches landing independently; not touching that here, flagging it in case nobody's seen it). Reviewed the options against building fallback content (#56) first; chose not to block this fix on that larger, unscoped feature.

Not done, and deliberately so: the issue mentions "writes the audit entry" and "same campus-scoping rules as assign." Campus scoping: done, mirrors assign_playlist exactly. Audit entry: there is no audit-log write path anywhere in the server yet for any playlist operation — assign_playlist itself writes none, only shared::audit::AuditCategory exists as a taxonomy (plan/server/audit-log.md is still Draft). I did not build an audit-log write path as part of this issue; that would be new infrastructure well beyond "unassign a device," and assign would need it first for the two operations to be consistent. Flagging for you to decide whether that's a separate issue.

Tests

  • crates/shared/src/protocol.rs: wire-format test for PlaylistCleared.
  • crates/client/src/session.rs: clearing drops the playlist, leaves the manifest/cache alone.
  • crates/server/tests/playlist_integration.rs: unknown device → 404; no assignment → idempotent 204; assign-then-unassign removes the row (verified by the formerly-blocked playlist delete now succeeding) and pushes PlaylistCleared; a retried unassign is idempotent.

Panel side (the checkbox, Save-time diffing, and the Devices-screen "none" option) is signage #210, per your comment on #209 — not touched here.

Local gates (--rust-only) running now in the working tree; will report the result and push once green.

Implemented the server side (and the protocol + client support needed for the push to actually clear the screen), on `feature/GRI-2073-unassign-device-playlist`. **Server** - `DELETE /api/v1/devices/{device_id}/playlist` (`crates/server/src/playlists/{mod,handlers,store}.rs`): same `ContentAssign` permission and campus-visibility check as `POST .../playlist`. An unknown or not-visible device is `404`. Otherwise idempotent: `204` whether or not the device had an assignment to remove. Pushes `PlaylistCleared` to the device's live connection if it has one (same `DeviceConnections::push`, `false` ignored, same reasoning as assign). - `plan/server/rest-api.md`: documented the new route. **Protocol** - New `ServerControl::PlaylistCleared` (`crates/shared/src/protocol.rs`), additive per the envelope's `#[serde(other)]` rule — an old client reads it as `Unknown` and ignores it rather than failing to parse. - `plan/shared/protocol.md`: documented the new message. **Client** - `Session::on_playlist_cleared` sets `state.playlist = None` and the existing idle-screen path (`crates/client/src/player.rs`, already exercised by a freshly enrolled device) takes over. Cache and manifest are untouched on purpose — only the screen changes, so re-assigning the same playlist later needs no re-transfer. **The decision you asked me to make first:** an unassigned device shows the existing idle/"no playlist" screen and keeps nothing of what it was showing — written up as `plan/decisions/0014-unassigned-device-shows-idle.md` (0013 was already taken twice in this file, by the way — looks like a numbering collision from two branches landing independently; not touching that here, flagging it in case nobody's seen it). Reviewed the options against building fallback content (#56) first; chose not to block this fix on that larger, unscoped feature. **Not done, and deliberately so:** the issue mentions "writes the audit entry" and "same campus-scoping rules as assign." Campus scoping: done, mirrors `assign_playlist` exactly. Audit entry: there is no audit-log write path anywhere in the server yet for *any* playlist operation — `assign_playlist` itself writes none, only `shared::audit::AuditCategory` exists as a taxonomy (`plan/server/audit-log.md` is still Draft). I did not build an audit-log write path as part of this issue; that would be new infrastructure well beyond "unassign a device," and `assign` would need it first for the two operations to be consistent. Flagging for you to decide whether that's a separate issue. **Tests** - `crates/shared/src/protocol.rs`: wire-format test for `PlaylistCleared`. - `crates/client/src/session.rs`: clearing drops the playlist, leaves the manifest/cache alone. - `crates/server/tests/playlist_integration.rs`: unknown device → 404; no assignment → idempotent 204; assign-then-unassign removes the row (verified by the formerly-blocked playlist delete now succeeding) and pushes `PlaylistCleared`; a retried unassign is idempotent. Panel side (the checkbox, Save-time diffing, and the Devices-screen "none" option) is signage #210, per your comment on #209 — not touched here. Local gates (`--rust-only`) running now in the working tree; will report the result and push once green.
Member

Server side (DELETE /api/v1/devices/{id}/playlist, reconnect-clear fix) is done, gates green, pushing to PR #214.

Flagging a scope gap found while merging #218 (left sub-menu/tabs refactor): the panel has no frontend path to unassign a device at all. PlaylistDevicesTab.tsx still renders an assigned device as disabled={alreadyAssigned} — checking my own earlier commit (5f3512e), I only ever touched crates/ (server+client), never frontend-web/. So this issue's panel acceptance criteria (uncheck+Save unassigns, Devices screen set-to-none) is unimplemented.

That's front-end engineer scope, not mine. Leaving this comment so whoever picks up the panel half has the pointer; not closing #209 until that lands.

Server side (DELETE /api/v1/devices/{id}/playlist, reconnect-clear fix) is done, gates green, pushing to PR #214. Flagging a scope gap found while merging #218 (left sub-menu/tabs refactor): the panel has no frontend path to unassign a device at all. `PlaylistDevicesTab.tsx` still renders an assigned device as `disabled={alreadyAssigned}` — checking my own earlier commit (5f3512e), I only ever touched `crates/` (server+client), never `frontend-web/`. So this issue's panel acceptance criteria (uncheck+Save unassigns, Devices screen set-to-none) is unimplemented. That's front-end engineer scope, not mine. Leaving this comment so whoever picks up the panel half has the pointer; not closing #209 until that lands.
Member

CI is green on PR #214 (commit cf5a74e9) after the offline-unassign fix and the dev merge: cargo test/clippy/fmt/deny/frontend-web/repo-boundary/pre-push-hook all pass. Server+client half of this issue (DELETE route, PlaylistCleared push, idle-screen fallback decision in plan/decisions/0014) is complete and ready to merge. Panel UI (checkbox unassign + Devices-screen 'none') is tracked separately as #210 and was never in scope for this PR.

CI is green on PR #214 (commit cf5a74e9) after the offline-unassign fix and the dev merge: cargo test/clippy/fmt/deny/frontend-web/repo-boundary/pre-push-hook all pass. Server+client half of this issue (DELETE route, PlaylistCleared push, idle-screen fallback decision in plan/decisions/0014) is complete and ready to merge. Panel UI (checkbox unassign + Devices-screen 'none') is tracked separately as #210 and was never in scope for this PR.
vivy closed this issue 2026-11-15 12:34:52 +00:00
Author
Owner

Merged in #214. One known limit, recorded for a follow-up: the 'pending clear' mark for a device that was offline at unassign time is kept in server memory only. A server restart before that device reconnects loses it, and the device then keeps its old playlist. Fix later by storing the mark in the database, or by letting the client report its playlist id in hello.

Merged in #214. One known limit, recorded for a follow-up: the 'pending clear' mark for a device that was offline at unassign time is kept in server memory only. A server restart before that device reconnects loses it, and the device then keeps its old playlist. Fix later by storing the mark in the database, or by letting the client report its playlist id in hello.
Sign in to join this conversation.
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage#209
No description provided.