screentinker/frontend/js/views
ScreenTinker f5ca26ae2d fix(socket): offline debounce + truthful single-device command feedback
Two dashboard-accuracy improvements for issue #3.

Disconnect debounce (5s):
- Brief transient flaps (Engine.IO ping miss, eviction-then-reconnect,
  Wi-Fi blip) no longer immediately flip the device to offline in the
  dashboard. Disconnect handler now defers the offline transition;
  register handlers cancel the pending timer if reconnect lands in
  window.
- Existing stale-disconnect guard kept as fast-path for the eviction
  case (no timer scheduled at all when the active heartbeat conn is
  already a different socket).
- Re-check at timer fire compares socketIds: aborts only if a
  GENUINELY DIFFERENT socket reclaimed the device. Just the closing
  socket's own (not-yet-cleaned-up) entry is treated as stale and
  proceeds with offline transition.
- Server-restart mid-grace is handled by the heartbeat checker safety
  net (existing component): any 'online' row with last_heartbeat
  older than heartbeatTimeout gets marked offline on next sweep.

Truthful single-device command feedback:
- dashboard:device-command handler now checks deviceNs.adapter.rooms
  for an active socket before emitting (matches the group-command
  route's pattern).
- If room is empty, falls through to commandQueue.queueCommand (lazy
  require - if commit C is reverted, MODULE_NOT_FOUND is cached and
  every subsequent call gets consistent queued=false behavior).
- Returns three-state ack to caller: { delivered, queued, reason }.
- Server log line was misleading - now logs 'Command delivered to
  device X' vs 'Command for offline device X (queued=true/false)'.

Frontend:
- sendCommand() takes optional callback. Without one, fires-and-forgets
  (no behavior change for non-wired callers). With one, uses Socket.IO
  .timeout(5000).emit so the callback always fires (ack or no_ack).
- Six device-detail command buttons wired to three-state toasts:
  reboot, shutdown, screen_off, screen_on, launch, update.
  - delivered: green/success toast (existing localized message)
  - queued: amber/warning toast (new generic message)
  - no_ack: red/error toast
  - fallback: red/error toast
- Two callers intentionally left fire-and-forget:
  - window._sendCmd (generic remote-overlay keypress/touch helper)
  - enable_system_capture (has its own visual state machine; out of
    scope for this commit)

Three new i18n keys (en.js only; other locales follow later):
- device.toast.command_queued
- device.toast.command_undeliverable
- device.toast.command_no_ack

Refs #3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 13:11:40 -05:00
..
activity.js i18n batch 6: wire teams + activity + help (~62 keys) 2026-04-29 20:16:21 -05:00
admin.js Phase 2.1: tenancy middleware, permission helpers, JWT workspace context, frontend + backend role-rename compat 2026-05-11 20:02:00 -05:00
billing.js i18n batch 5: wire layout-editor + video-wall + billing (~85 keys) 2026-04-29 20:13:38 -05:00
content-library.js i18n: extract all strings, add 6 language translations, restructure i18n module 2026-04-29 19:25:22 -05:00
dashboard.js fix(dashboard): selection bar surfaces 'pick 1 more' hint when 1 display selected so the disabled Create Video Wall button isn't silently unresponsive 2026-05-11 22:56:15 -05:00
designer.js i18n batch 2b: wire designer.js (~80 keys) 2026-04-29 19:57:12 -05:00
device-detail.js fix(socket): offline debounce + truthful single-device command feedback 2026-05-14 13:11:40 -05:00
help.js i18n batch 6: wire teams + activity + help (~62 keys) 2026-04-29 20:16:21 -05:00
kiosk.js i18n batch 4: wire schedule + reports + kiosk (~95 keys) 2026-04-29 20:09:32 -05:00
layout-editor.js i18n batch 5: wire layout-editor + video-wall + billing (~85 keys) 2026-04-29 20:13:38 -05:00
login.js i18n: extract all strings, add 6 language translations, restructure i18n module 2026-04-29 19:25:22 -05:00
onboarding.js i18n batch 3b: wire onboarding.js + admin.js (~84 keys) 2026-04-29 20:04:23 -05:00
playlists.js fix(frontend): playlists.js thumbnail path uses API endpoint instead of legacy direct path 2026-05-12 11:44:30 -05:00
reports.js i18n batch 4: wire schedule + reports + kiosk (~95 keys) 2026-04-29 20:09:32 -05:00
schedule.js fix(schedule): add delete button to schedule edit modal so schedules can be removed from the UI (DELETE /api/schedules/:id already existed) 2026-05-11 23:05:03 -05:00
settings.js feat(email): Microsoft Graph send + alert spam protection + preferences UI 2026-05-12 18:16:40 -05:00
teams.js i18n batch 6: wire teams + activity + help (~62 keys) 2026-04-29 20:16:21 -05:00
video-wall.js Video walls: free-form canvas editor, leader-driven sync, group dissolve, progress bars 2026-04-29 23:11:16 -05:00
widgets.js i18n batch 2a: wire widgets.js (~107 keys) 2026-04-29 19:52:31 -05:00