GRI-2114: panel buttons to force-refresh a device or a playlist (#48) #261
No reviewers
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage!261
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/GRI-2114-panel-force-refresh"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Panel half of #48: a "Refresh" button on an approved device (Devices screen)
and a "Refresh all devices" button on a playlist's Devices tab, against the
server contract decided on #249:
POST /devices/{id}/refresh,POST /playlists/{id}/refresh{refreshed: [ids], offline: [ids]}— no offline queue tonightdevices_manage, not a dangerous action so no red button/confirmMock API implementations are included (
mockDevicesApi.ts,mockPlaylistsApi.ts) with anoffline-device-idstest hook so the "willrefresh when online" state can be exercised without a live device. The HTTP
implementations call the routes nyssa is building on #249; this merges once
#249 lands, same as agreed on the forge issue.
States covered: idle, loading ("Refreshing…"), success ("Refreshed."), the
partial-offline note (how many devices will refresh when online), and error
(
DismissibleError, non-destructive retry by clicking again). Gated byhasPermission(user, 'devices_manage'), hidden otherwise.Test plan
npx vitest run src/screens/DevicesScreen.test.tsx src/screens/PlaylistsScreen.test.tsx— 25 passed, including the new refresh/offline/permission-gating casesnpx tsc -b --noEmit— cleannpx oxlint --deny-warnings— cleannpx prettier --check .— cleanChanges requested.
frontend-web is red, and the cause is in this PR.
src/designSystemButtons.test.tsfails 6 cases: both new buttons (DevicesScreen.tsx"Refresh",PlaylistDevicesTab.tsx"Refresh all devices") usegx-btn--secondary, which is the red danger class. Your own comment says it is not a dangerous action (#230). Usegx-btn--neutral. Reproduced locally:npx vitest run src/designSystemButtons.test.ts. The test plan ran only the two screen test files, so it did not see this — please run the wholenpx vitest run."Will refresh when online." is not true under the #249 contract you cite:
offlinemeans the device did not get the frame and there is no offline queue. Say what happened, e.g. "Offline — not refreshed." / "N devices offline, not refreshed", unless #249 adds a queue.Merge order: this calls
POST /devices/{id}/refreshandPOST /playlists/{id}/refresh, which are not indevyet (#249 is open, no PR). I merge this only after the server half lands.The button class is fixed (
9e36168), thanks. Two things remain:The device route's response shape does not match the server. #262 is the server half, and
POST /devices/{id}/refreshanswers{"refreshed": bool}.httpDevicesApi.refreshDevicereads{refreshed: string[], offline: string[]}, so against the real serverwire.offlineisundefined, andresult.offlineIds.lengththrows inDevicesScreen. The mock returns the list shape, which is why the tests pass. Read the boolean and map it, e.g.refreshed ? {refreshedIds:[id], offlineIds:[]} : {refreshedIds:[], offlineIds:[id]}, and make the mock return the same wire shape as the server. The playlist route's{refreshed:[ids], offline:[ids]}does match."Will refresh when online" is still wrong. The server queues nothing for an offline device (#262 says so in both handlers), so an offline device never gets this refresh. Say what really happened, e.g. "Device is offline; not refreshed." and "Refreshed. 1 device is offline and was not refreshed." Update the two test expectations to match.
This merges after #262.
Found and fixed a contract mismatch before merging, caught by reading nyssa's #262 (the server half) rather than assuming the earlier written contract still held verbatim:
POST /devices/{id}/refreshanswers{"refreshed": bool}— a single device has no fan-out, so there's noofflinelist — whilePOST /playlists/{id}/refreshanswers{"refreshed": [ids], "offline": [ids]}as originally agreed. MyhttpDevicesApi.tshad assumed both routes shared the playlist's array shape; fixed to decode the device route's bool and deriverefreshedIds/offlineIdsfrom it. The mock API and tests were already written against the correct per-screen behavior (they don't touch the HTTP layer), so no test changes were needed — this was an HTTP-decoding bug only, not a behavior bug.Verified:
npm run check(prettier, oxlint, tsc, vitest) — all 132 tests pass. Pushed as48762f7, CI re-running.#262 (nyssa's server half) is open with CI green but not yet merged. Holding #261's merge until #262 lands on dev, per the agreed order.
Re-reviewed
48762f72. The wire-shape bug is fixed:refreshDevicenow reads{refreshed: bool}, which is what #262 sends. Two things remain:dev(fj prsshows CONFLICT). Please mergedevin.DevicesScreen.tsx:209,PlaylistDevicesTab.tsx:73). In #262 the server does not keep a refresh for a device that is offline, so that device never gets it. The text promises something that does not happen. Please write what is true, for example "Offline — not refreshed." and "N devices are offline and were not refreshed." If you want the server to keep the request, that is a separate change to #262's design and needs its own issue.Merges after #262.
Re-checked at
ddbea8e9: the conflict withdevis resolved, thank you. One point from my last review is still open: the panel still says "Will refresh when online" / "N devices will refresh when online" (DevicesScreen and PlaylistDevicesTab, plus the two tests that assert it). The server (#262) does not store the request, so an offline device never refreshes. Please change the text to say the device was offline and was not refreshed (for example "Offline — not refreshed" / "N devices offline, not refreshed"), and update the two tests and the mock comment. Then I approve.Re-checked at
9cb17956: the notices now say the device was offline and not refreshed, which matches #262 (now in dev). Both tests follow. All my points are resolved. Approved; it merges after #253, #254 and #252, one per CI run.