Skip to content

DeviceManager: order-based discovery (extracted from #865) - #872

Draft
Christian-Holbrook wants to merge 1 commit into
masterfrom
device-manager-orders
Draft

DeviceManager: order-based discovery (extracted from #865)#872
Christian-Holbrook wants to merge 1 commit into
masterfrom
device-manager-orders

Conversation

@Christian-Holbrook

Copy link
Copy Markdown
Collaborator

What

Extracts just the orders system from #865, re-grafted onto current master (which has since gained Roku Cloud Emulator support — the source of #865's conflicts).

Triggers no longer scan/health-check directly. Instead they submit orders into per-type pending sets, and visible views fulfill them:

  • Order types: broadcast (SSDP scan) and reconcile (health-check all), each with a reason (startup, network, sleep, refresh-clicked, config-changed, unhealthy-device, stale).
  • Reasons accumulate and dedupe; one fulfillment satisfies every queued reason; take is atomic per type.
  • Nothing hits the network while no view is visible — orders queue until the Devices panel or device picker opens (or is already open).
  • Live orders are fulfilled immediately by visible views via the new order-submitted event (replacing scanNeeded-changed); timer-driven stale orders are excluded from live fulfillment and are staleness-gated inside broadcast().
  • The unhealthy-device rescan is now a rate-limited order (1/min), terminating the old scan → fail → scan feedback loop.
  • Removed: scanNeeded flag, setScanNeeded, refresh(), scan(), discoverAll().

What this deliberately does NOT include from #865

The freshness rewrite (ensureDeviceFresh, peekDevice, lastCheckedByIp trust windows, getDeviceInfo consolidation, hidden-view lazy reads). reconcile() drives the existing healthCheckAllDevices(force) machinery unchanged; healthCheckDevice keeps its current signature.

Testing

  • Ported the orders test suites from DeviceManager rewrite: order-based discovery #865 (Orders unit tests, submit/fulfill/stale-timer/broadcast/reconcile, picker order flow, view-provider fulfillment) and adapted them to master's API.
  • Full suite: 1308 passing / 1 failing — the failing BaseWebviewViewProvider timeout also fails on clean master (pre-existing, unrelated).

🤖 Generated with Claude Code

Extracted from #865, rebased onto master's RCE-aware DeviceManager.

Triggers (startup, sleep, network change, config change, refresh click,
unhealthy device, staleness timers) now submit orders instead of scanning
directly. Orders queue in per-type pending sets (broadcast/reconcile) and
are fulfilled only by visible views, so nothing hits the network while no
one is looking. Reasons accumulate and dedupe; one fulfillment satisfies
all queued reasons; stale orders are staleness-gated and skipped by live
fulfillment.

The freshness rewrite from #865 (ensureDeviceFresh, peekDevice, cache
trust windows, getDeviceInfo consolidation) is intentionally NOT included;
reconcile() drives the existing healthCheckAllDevices(force) machinery.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant