Skip to content

fix(mobile): delay the offline banner by 5s, hide it at once - #5139

Merged
iscekic merged 1 commit into
mainfrom
fix/offline-banner-show-delay
Aug 7, 2026
Merged

fix(mobile): delay the offline banner by 5s, hide it at once#5139
iscekic merged 1 commit into
mainfrom
fix/offline-banner-show-delay

Conversation

@iscekic

@iscekic iscekic commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

After a long background, the app foregrounds and the offline banner flashes for a moment before it goes away. NetInfo reports a false offline right after resume, and the banner's debounce was shorter than that window.

Change

src/lib/offline-banner-state.ts used one symmetric 1 s debounce for both directions. It now splits them:

  • Show: 5 s. The connection must stay down for 5 s before the banner appears. The false-offline window ends first, so nothing is drawn.
  • Hide: immediate. A banner that is up while the connection works is the worse error, and a symmetric delay would make the reported flash last longer.

No AppState listener. The bogus event lands after the app is already active, so a plain delay covers it.

Scope

query-client-lifecycle.tsx and user-web-connection-lifecycle.ts read the same NetInfo events and stay undebounced. React Query pausing for a second is invisible and correct.

Trade-off

A real disconnect is reported up to 5 s late. Failed requests still surface their own errors. A cold start while offline shows the banner 5 s in, not 1 s.

Checks

pnpm format && pnpm typecheck && pnpm lint && pnpm check:unused pass. pnpm test: 3906 tests pass. Unit tests only — the simulator cannot reproduce iOS suspension with stale NetInfo.

NetInfo reports a false offline for a moment after a long background.
The 1s symmetric debounce was shorter than that window, so the banner
flashed on every foreground.

Show waits 5s. Hide is immediate: a banner that is up while the
connection works is the worse error.
@iscekic iscekic self-assigned this Aug 7, 2026
@kilo-code-bot

kilo-code-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Reviewed the asymmetric offline-banner debounce (5s show delay, immediate hide) across the store, banner component, and both updated test suites; the state machine handles all transition paths correctly (pending-cancel on recovery, immediate online commit, destroy-time cancellation) with no timer, listener, or subscription leaks introduced.

Files Reviewed (4 files)
  • apps/mobile/src/lib/offline-banner-state.ts
  • apps/mobile/src/components/offline-banner.tsx
  • apps/mobile/src/lib/offline-banner-state.test.ts
  • apps/mobile/src/lib/hooks/use-offline-banner-state.mounted.test.tsx

Reviewed by kimi-k3 · Input: 4.3K · Output: 868 · Cached: 101K

Review guidance: REVIEW.md from base branch main

@iscekic
iscekic enabled auto-merge (squash) August 7, 2026 15:27
@iscekic iscekic added the human-ready The PR is ready for human review. label Aug 7, 2026
@iscekic
iscekic merged commit ec69ce9 into main Aug 7, 2026
17 of 19 checks passed
@iscekic
iscekic deleted the fix/offline-banner-show-delay branch August 7, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants