Skip to content

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

Closed
ankitsejwal wants to merge 1 commit into
fix/room-stale-open-on-resumefrom
feat/room-diagnostics-freeze-visibility
Closed

Make background freezes and silent losses visible in room diagnostics#112
ankitsejwal wants to merge 1 commit into
fix/room-stale-open-on-resumefrom
feat/room-diagnostics-freeze-visibility

Conversation

@ankitsejwal

Copy link
Copy Markdown
Member

Addresses #109.

Why

While debugging #107 (silent resume memory-wipe) and #108 (orphaned send after unlock), 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 fell back to a fresh, memoryless session (the #107 signal) — needs a daemon → phone wire change to mark the fallback. That touches the same daemon files as the in-flight #107 fix (#110), so I left it out here to avoid conflicting with that PR; it's best landed on top of #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.)

Stacked on #108 (base branch fix/room-stale-open-on-resume, since both touch roomClient.ts + useLucidAsk.tsx) — merge after #108.

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.
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