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
feat(realtime): improve web UI reactivity and admin visibility - #48
This branch started as a full audit of web UI reactivity: which websocket messages exist, which data can update from those messages, and where the UI still required manual refreshes. The resulting work tightens that path end-to-end: backend publishers now emit consistent catalog/user-state/job/session/task/scan events, and the React app has a single realtime provider that applies or invalidates the right data surfaces.
The diff is intentionally broad because the stale UI behavior was not isolated to one page. It affected library scans, metadata refreshes, dashboard counters, admin activity, scheduled tasks, library operation state, matcher backlog visibility, and device override management.
Reviewer Map
Realtime foundation
Added a global RealtimeEventsProvider mounted from web/src/App.tsx.
Centralized websocket handling for catalog, user-state, admin job, session, task, and scan channels.
Added usePageActivity so the frontend can distinguish focused, visible-but-unfocused, hidden, frozen, restored, and resumed states.
Canonicalized event names while preserving legacy catalog event compatibility:
catalog.library.changed
catalog.item.changed
user_state.changed
job.cancelled
Catalog publishers now dual-publish legacy names so older consumers do not silently stop receiving updates.
Hidden/frozen tabs pause updates and reconnect/refetch on resume; visible-but-unfocused tabs keep library/catalog updates live while dashboard snapshot polling is paused.
Catalog, scan, metadata, and user-state updates
Library scans and metadata enrichment now publish catalog item/library changes when new items, poster updates, and metadata refresh results arrive.
User-state mutations now publish scoped events for watched state, favorites, watchlist, progress, and home dismissals.
The web UI patches item detail user-state cache where possible and invalidates broader library/home/catalog surfaces when item or library changes arrive.
Active catalog surfaces refetch from realtime changes so newly scanned items and posters can appear without a page refresh.
Metadata refresh and library job events are surfaced consistently through admin job state instead of relying only on page-local polling.
Dashboard
Manual refresh now performs an explicit fresh snapshot instead of only invalidating cached data.
Refresh control has fixed sizing, disabled state while refreshing, and a minimum one-rotation spinner so fast refreshes do not flicker.
Last-updated text uses relative wording and sits next to the refresh action.
Auto-refresh runs every 60 seconds only while the dashboard is focused.
Websocket events mark dashboard data stale while visible-but-unfocused, then refocus triggers an immediate refresh with visible feedback.
Now Playing posters dim and show a paused indicator when the session is paused.
Profile chips were adjusted for contrast and to avoid layout issues.
Admin Activity and playback visibility
The stream connection label is now Realtime Updates.
Refresh and realtime status controls were tightened to avoid layout shifts.
The websocket disconnected indicator is steady rather than blinking.
IP addresses are clickable and populate/run the IP Lookup panel.
User identity and stream title/metadata link to the relevant admin user and library item pages.
Playback session payloads now include current position, paused state, profile information, and transcode hardware acceleration metadata.
Activity rows now show container, video, and audio decisions separately:
container: Direct / Remux / HLS
video/audio: Direct / Copy / Transcode
HW/SW transcode chips make the transcode mode explicit, with SW shown as higher-risk/red styling.
Playback details expand into a richer stream details area while keeping the compact row readable.
FFmpeg preview/log controls were reorganized; preview/details sections are only rendered when active.
Terminate and FFmpeg preview are front-and-center actions rather than buried in the overflow menu.
Admin jobs and cancellation
Added a running job cancel registry so cancellable admin jobs can be stopped through their active context.
Added cancelled as an admin job status and publish job.cancelled events for queued/running cancellations.
Library metadata refresh cancellation now works through the same admin job path and avoids writing cancellation state before the runner accepts cancellation.
awaitAdminJob handles cancelled cached jobs correctly.
Libraries page
Library action order is now Scan, Rescan Metadata, Verify Mounts, Edit, Delete.
Scan All uses the same icon/text treatment as Dashboard and the Catalog Maintenance color scheme.
Running scan or metadata refresh actions replace their action icon with a red stop control for that specific operation.
Per-task stop controls remain in the task details below the library.
Library task status stacks vertically when multiple operations are running or queued.
Scan status shows progress in the same style as Server Activity.
Check Mount feedback is single-line, timestamp-free, reserved-space, and fades after a short period.
Unmatched Items, Ambiguous Roots, and Stale External IDs are collapsible by default and show prominent counts while collapsed.
Matcher backlog / media matching visibility
Added match suppression state on media files so failed matches can be hidden from repeat processing without losing visibility.
Surfaced matcher backlog state so users can see the process that continues after scans finish.
Added retry/cancel/status behavior around matching work where it is actionable.
Removed failed-match alerts from Server Activity after deciding that backlog visibility belongs in the library/admin surfaces rather than the global activity stream.
Made the Match Media Files scheduled task always visible.
Scheduled Tasks
Running manual task actions now become a red Stop control rather than only saying Running.
The button has fixed width/minimum spinner behavior to avoid layout shift.
Task rows show progress where available.
Failed task chips expose the error in a tooltip.
Added last-run duration display where the backend has runtime data.
Renamed metadata queue fields to clearer labels:
Refresh Backlog
Due for Refresh
Processing
Waiting Since
Next Claim Timeout
Refresh Trending Discover now reports useful result details so a quick run does not look like a no-op.
Removed the unused Metadata section from Server Activity.
Devices
Added a user_devices registry so Admin Devices can list all known devices, including devices with no overrides yet.
Added a prominent All Devices / Devices with Overrides mode above the saved views/devices/settings columns.
Saved-view counts update based on the active top-level mode.
Per-device settings default to All Settings when viewing all devices and Overrides when viewing override-only devices.
Replaced the per-device All Settings / Overrides toggle with the same segmented-slider treatment used by the page-level mode.
Collections, playback history, and navigation
Collection defaults progress now renders below the Collections page header and before the collections list.
Playback History gained the same style of refresh control used on Dashboard and Activity.
Admin sidebar logo now links back to the app home.
Sidebar spacing below the logo was increased before Overview.
Backend Change Inventory
internal/notifications: canonical catalog/job event publishing plus compatibility behavior and tests.
internal/api/handlers: catalog/user-state event publication, admin job cancel endpoints, library matcher/backlog endpoints, playback session payload expansion, device registration/listing, and related tests.
internal/adminjob: cancel registry, cancellation-aware runner/repository behavior, and admin job model cleanup.
internal/libraryingest, internal/metadata, internal/scanner, internal/scanqueue, internal/worker: publish catalog changes and expose matcher state where relevant.
173_admin_job_cancelled_status permits the cancelled admin job status; down migration maps cancelled jobs to failed before restoring the previous constraint.
174_media_file_match_suppression adds media_files.match_suppressed_at plus a partial unmatched-ready index.
175_user_devices adds the device registry and backfills known devices from existing per-device settings.
001_schema.up.sql was updated so fresh installs include the new branch schema.
These migrations are additive for forward upgrades.
Validation
Passed:
git diff --check
go test ./...
cd web && ./node_modules/.bin/tsc -b --pretty false
cd web && ./node_modules/.bin/vitest run src/hooks/queries/homeDismissals.test.ts src/components/CollectionTemplateGallery/CollectionTemplateGallery.test.tsx src/pages/adminActivityPresentation.test.ts
Known baseline issue:
cd web && ./node_modules/.bin/vitest run still has 19 stale/unrelated harness failures outside this branch's changes. The remaining failures are around AdminSidebar expected text, EpisodeRow class expectations, ImpersonationBanner copy/layout expectations, SectionRow missing WatchPlaybackProvider, profile-management avatar defaults, ItemDetail QueryClient/router mocks, and ProfilesSettings missing useHouseholdSessions.
Risk / Review Focus
The biggest review area is websocket semantics. The implementation keeps legacy catalog event names alive while adding canonical names, but any admin-only websocket consumer should be aware of the new additive payload fields.
Device registry behavior should be checked against both existing devices with overrides and first-time devices without overrides.
Library cancellation should get reviewer attention around queued vs running metadata refresh jobs.
Scheduled task runtime visibility depends on whether the backend has duration data for the task; some tasks may still show no runtime until they produce measurable run metadata.
Android and Apple clients should not need immediate changes for normal user playback/catalog flows, but any client consuming admin websocket/session payloads should be aware of the additive fields.
Summary by CodeRabbit
New Features
Added Autoscan admin configuration with plugin-based polling, connection management, and path rewrite suggestions.
Implemented admin job cancellation with support for canceling queued and running jobs.
Added library metadata match queue management with retry and suppression controls.
Enabled device registration and tracking with override filtering for device settings.
Improvements
Enhanced playback session tracking to include hardware acceleration and position data.
Improved realtime event system with structured catalog and user state events.
Made match media task visible in task management dashboard.
Bug Fixes
Fixed audio decision logic for remux scenarios during transcode.
Context
This branch started as a full audit of web UI reactivity: which websocket messages exist, which data can update from those messages, and where the UI still required manual refreshes. The resulting work tightens that path end-to-end: backend publishers now emit consistent catalog/user-state/job/session/task/scan events, and the React app has a single realtime provider that applies or invalidates the right data surfaces.
The diff is intentionally broad because the stale UI behavior was not isolated to one page. It affected library scans, metadata refreshes, dashboard counters, admin activity, scheduled tasks, library operation state, matcher backlog visibility, and device override management.
Reviewer Map
Realtime foundation
RealtimeEventsProvidermounted fromweb/src/App.tsx.usePageActivityso the frontend can distinguish focused, visible-but-unfocused, hidden, frozen, restored, and resumed states.catalog.library.changedcatalog.item.changeduser_state.changedjob.cancelledCatalog, scan, metadata, and user-state updates
Dashboard
Admin Activity and playback visibility
Realtime Updates.Admin jobs and cancellation
cancelledas an admin job status and publishjob.cancelledevents for queued/running cancellations.awaitAdminJobhandles cancelled cached jobs correctly.Libraries page
Matcher backlog / media matching visibility
Scheduled Tasks
Devices
user_devicesregistry so Admin Devices can list all known devices, including devices with no overrides yet.Collections, playback history, and navigation
Backend Change Inventory
internal/notifications: canonical catalog/job event publishing plus compatibility behavior and tests.internal/api/handlers: catalog/user-state event publication, admin job cancel endpoints, library matcher/backlog endpoints, playback session payload expansion, device registration/listing, and related tests.internal/adminjob: cancel registry, cancellation-aware runner/repository behavior, and admin job model cleanup.internal/libraryingest,internal/metadata,internal/scanner,internal/scanqueue,internal/worker: publish catalog changes and expose matcher state where relevant.internal/playback,internal/transcodenode,cmd/silo/session_sync.go: position, paused state, profile, and HW acceleration metadata propagation.internal/taskmanager: task visibility/status/runtime/reporting improvements and tests.internal/userdb,internal/userstore: device registry storage and backfill support.Frontend Change Inventory
web/src/components/RealtimeEventsProvider.tsx: centralized websocket handling and React Query cache invalidation/patching.web/src/hooks/usePageActivity.ts: page lifecycle/focus/visibility/freeze tracking.web/src/pages/AdminDashboard.tsx: refresh lifecycle, foreground polling, last-updated text, now-playing pause overlay.web/src/pages/AdminActivity.tsxandadminActivityPresentation.ts: playback/session formatting, controls, links, details expansion, IP lookup behavior.web/src/pages/AdminLibraries.tsx: action row, task status, stop controls, matcher/library state, collapsible diagnostics.web/src/pages/AdminTasks.tsx: task run/stop treatment, runtime display, queue label cleanup, failed tooltip behavior.web/src/pages/AdminDevices.tsx: all-devices vs overrides mode, saved-view counts, per-device setting filter behavior.web/src/pages/AdminCollections.tsx: collection defaults progress placement.web/src/pages/AdminPlaybackHistory.tsx: refresh treatment.web/src/components/ServerActivity.tsx: realtime disconnected indicator and metadata section removal.web/src/components/AdminSidebar.tsx: logo home link and spacing.Schema / Migration Notes
171_playback_session_positionaddsplayback_sessions_sync.position_secondswith default0.172_playback_session_transcode_hw_acceladds nullable HW acceleration metadata to playback session sync rows.173_admin_job_cancelled_statuspermits thecancelledadmin job status; down migration maps cancelled jobs to failed before restoring the previous constraint.174_media_file_match_suppressionaddsmedia_files.match_suppressed_atplus a partial unmatched-ready index.175_user_devicesadds the device registry and backfills known devices from existing per-device settings.001_schema.up.sqlwas updated so fresh installs include the new branch schema.These migrations are additive for forward upgrades.
Validation
Passed:
git diff --checkgo test ./...cd web && ./node_modules/.bin/tsc -b --pretty falsecd web && ./node_modules/.bin/vitest run src/hooks/queries/homeDismissals.test.ts src/components/CollectionTemplateGallery/CollectionTemplateGallery.test.tsx src/pages/adminActivityPresentation.test.tsKnown baseline issue:
cd web && ./node_modules/.bin/vitest runstill has 19 stale/unrelated harness failures outside this branch's changes. The remaining failures are around AdminSidebar expected text, EpisodeRow class expectations, ImpersonationBanner copy/layout expectations, SectionRow missingWatchPlaybackProvider, profile-management avatar defaults, ItemDetail QueryClient/router mocks, and ProfilesSettings missinguseHouseholdSessions.Risk / Review Focus
Summary by CodeRabbit
New Features
Improvements
Bug Fixes