Skip to content

Make background freezes and silent losses visible in room diagnostics#113

Merged
ankitsejwal merged 1 commit into
mainfrom
feat/room-diagnostics-freeze-visibility
Jul 9, 2026
Merged

Make background freezes and silent losses visible in room diagnostics#113
ankitsejwal merged 1 commit into
mainfrom
feat/room-diagnostics-freeze-visibility

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

Addresses #109. (Supersedes #112, which GitHub auto-closed when its base branch — the now-merged #111 — was deleted; rebased onto main and reopened here.)

Why

While debugging #107 (silent resume memory-wipe) and #108 (orphaned send after unlock, merged in #111), the room diagnostics dump was blind to exactly the events that mattered — we had to infer the iOS background freeze from a ~2-minute hole in the keepalive log. This makes those events explicit.

What's added

  • AppState transitionsbackground / foreground diag events, so a gap in the log reads as background … foreground instead of an unexplained hole (noteBackground() on the client; the hook's AppState listener now reports both edges).
  • Timer-suspension fingerprint — when a keepalive fires ≫ KEEPALIVE_MS after the previous one, emit suspend · resumed after Ns suspended. That's the smoking gun for a frozen event loop, turning a guess into a logged fact; it also catches timer throttling when AppState doesn't cleanly cycle.
  • Losable-send counter — a stale-send event when a send is routed to the outbox because the socket only looked open (the exact orphaned-send scenario from A message sent right after unlocking the phone can silently get no reply #108), so a would-be-lost message is visible instead of silent.
  • Longest inbound gap — a longestInboundGapMs snapshot field surfaced in the summary line (maxInboundGap=Ns) and as a panel row, flagging a past stall even after the socket recovered.
  • New diag kinds get panel colors (suspend amber, stale-send red, foreground green, background gray).

Deferred to a follow-up

The "flag an unexpected session swap" bullet — surfacing when the daemon silently fell back to a fresh, memoryless session (the direct #107 signal) — needs a daemon → phone wire flag. It's best landed on top of the #107 fix (#110); I'll open it as a follow-up.

Verification

tsc --noEmit clean. Additive / diagnostic-only — no change to connection behavior. (Mobile has no unit-test harness in this repo.)

The room diagnostics dump was blind to the events behind #107/#108 — an iOS
background freeze had to be inferred from a silent hole in the keepalive log.
Surface them explicitly: `background`/`foreground` AppState transitions, a
`suspend` event when a keepalive fires long-late (frozen timers), a `stale-send`
when a send is rerouted off a socket that only looked open, and a
`longestInboundGapMs` past-stall marker in the summary and panel.
@ankitsejwal ankitsejwal merged commit 85619ff into main Jul 9, 2026
@ankitsejwal ankitsejwal deleted the feat/room-diagnostics-freeze-visibility branch July 9, 2026 07:55
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