Open
Conversation
Replace the custom useInitialLoadState hook and Result-type ceremony with a simpler approach: 1. Add connectionEpoch to API.tsx - increments on successful reconnect 2. Contexts re-run initial load when epoch changes (automatic recovery) 3. Inline timeouts using Promise.race (3 lines vs separate utility) 4. Keep simple loading/loadError state (no new abstractions) Deleted: - src/browser/hooks/useInitialLoadState.ts (72 LoC) - src/browser/hooks/useInitialLoadState.test.ts (61 LoC) - src/common/utils/withTimeout.ts (21 LoC) - src/constants/initialLoad.ts (1 LoC) Net: -218 LoC while maintaining all functionality: - Timeouts on initial load (15s) - Error display + retry button in AppLoader - Automatic retry on reconnect (new behavior via epoch) The key insight: API provider already detects disconnects and reconnects. Contexts just needed to re-run their load when the connection comes back.
1. Instant first reconnect attempt (0ms delay), then exponential backoff - First retry: instant - Subsequent: 100ms, 200ms, 400ms... up to 10s 2. ConnectionStatusBanner shows reconnection/degraded status - Appears at top of app when connection is unstable - Shows attempt count during reconnection - Warns about degraded connections (pings failing) 3. AppLoader re-syncs stores on connectionEpoch change - Ensures stores get fresh client on reconnect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Background
Implementation
useInitialLoadStatewith attempt guards, timeout support, and retry helpersValidation
Risks
Generated with
mux• Model:openai:gpt-5.2-codex• Thinking:high• Cost:$9.61