Skip to content

Fix tray Settings sync-status — false "not connected" while device is actively pushing #123

@ntatschner

Description

@ntatschner

Problem

The tray Settings → Sync indicator reports the device as disconnected / sync as not working, but the device is in fact paired and actively pushing events to the server. The component's state is derived from a stale or wrong signal — either polling a stale local config flag instead of the live /devices row, or the heartbeat-evaluation cadence is mis-keyed.

Approach

Fix the state derivation to use canonical server-side signals.

Repro:

  1. Pair a device, confirm events are landing server-side (check /v1/me/events or the audit log).
  2. Open Settings → Sync.
  3. Observe the indicator showing "not connected" / "sync off" / red status despite events flowing.

Fix should:

  • Compare against the canonical signal (server-side devices.last_seen_at recency + devices.sync_enabled), not a local cached flag.
  • Update on the same 10s tick the rest of the Status pane uses.
  • Add an integration test that pins the false-positive case (paired + recent heartbeat + cfg.sync_with_cloud=true → indicator should be green).

Acceptance criteria

  • Sync indicator derives state from devices.last_seen_at + devices.sync_enabled
  • Indicator refreshes on the same 10s tick as the rest of the Status pane
  • Integration test pins the previously-false-positive case (green when paired + heartbeat fresh + sync_with_cloud true)
  • Regression test for the opposite case (red when paired but heartbeat stale)
  • No regression to the legitimate disconnected case (red when device not paired or sync_with_cloud false)

Risks / Open questions

  • 10s tick may be too coarse for snappy feedback after a manual pair → would need lower tick + ratelimit
  • Timezone / clock-skew between tray and server when comparing last_seen_at recency
  • What threshold counts as "recent enough" for last_seen_at — needs a single project-wide constant, not a magic number per call site
Original draft notes

Bug. The Settings pane's sync-status indicator reports the device as disconnected / sync as not working, but the device is in fact paired and actively pushing events to the server. The component's state appears to be derived from a stale or wrong signal — either it's polling a stale local config flag rather than the live /devices row, or the heartbeat-evaluation cadence is mis-keyed.

Repro:

  1. Pair a device, confirm events are landing server-side (check /v1/me/events or the audit log).
  2. Open Settings → Sync.
  3. Observe the indicator showing "not connected" / "sync off" / red status despite events flowing.

Fix should:

  • Compare against the canonical signal (server-side devices.last_seen_at recency + devices.sync_enabled), not a local cached flag.
  • Update on the same 10s tick the rest of the Status pane uses.
  • Probably worth an integration test that pins the false-positive case (paired + recent heartbeat + cfg.sync_with_cloud=true → indicator should be green).

Tracking

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions