nextDisplaySyncStatus function

DisplayStatusEdge nextDisplaySyncStatus(
  1. SyncStatus shown,
  2. SyncStatus raw
)

The #399 posture-dwell truth table. shown is the currently displayed status, raw the new raw emission. Total over every pair; never throws.

Implementation

DisplayStatusEdge nextDisplaySyncStatus(SyncStatus shown, SyncStatus raw) {
  final shownStalled = shown is SyncStatus_Stalled;
  final rawStalled = raw is SyncStatus_Stalled;
  if (shownStalled == rawStalled) {
    // Same posture side — including Stalled→Stalled reason changes (new
    // information, not flicker) and every healthy↔healthy move.
    return DisplayStatusEdge.adopt;
  }
  if (rawStalled) {
    // Entering the alarm posture: must survive the dwell (transient-hiccup
    // grace — item 3's "dwell before promoting").
    return DisplayStatusEdge.dwell;
  }
  // Leaving the shown alarm posture: proof (a completed pass) and the calm
  // reserved-Offline sibling flip instantly; attempt CLAIMS (Scanning /
  // Connecting / Idle / Unknown) must survive the dwell — they are exactly
  // the sub-second retry blips the debounce exists to absorb.
  return raw is SyncStatus_UpToDate || raw is SyncStatus_Offline
      ? DisplayStatusEdge.adopt
      : DisplayStatusEdge.dwell;
}