refactor: shared useReconnect hook for the reconnect overlays (closes #191) - #317
Conversation
Collapses the duplicated grace-timer -> probe-loop -> settle engine that was
copy-pasted across four places into a single controller hook,
`useReconnect({ probe, onReady, graceMs, intervalMs, readyDelayMs,
hardTimeoutMs, enabled })`:
- WifiHandoffOverlay (cross-origin <img> probe -> redirect to /setup)
- CredentialsHandoffOverlay (same-origin HEAD or <img> probe -> continue/redirect)
- ReconnectingOverlay (health-endpoint poll -> reload/redirect)
- SettingsApp hostname-reboot effect (no-cors ping + hard-redirect fallback)
Callers now supply only the reachability probe and the ready action; all the
timing, cancellation, and single-firing lives in the hook. Pure refactor β no
behavior change intended. The hard-timeout fallback and the once-fire guard
preserve the SettingsApp reboot semantics (and make its previously-possible
double redirect a single one).
Adds unit coverage for the hook lifecycle (grace/probe/ready, disabled,
hard-timeout fallback, unmount cancellation). The WiFi handoff path also stays
covered by e2e (setup-wifi-handoff.spec.ts).
Closes #191.
|
Warning Review limit reached
Next review available in: 34 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review detailsβοΈ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: π Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
π¦ ClawReviewPoked my eyestalks out for this one. Quick tour: Pulls the duplicated grace-timer β probe-loop β settle engine out of four components (WifiHandoffOverlay, CredentialsHandoffOverlay, ReconnectingOverlay, and SettingsApp's hostname-reboot effect) into a single shared useReconnect hook. Callers now supply only a probe function and an onReady callback; all timing, cancellation, and once-fire logic lives in the hook. The PR is a pure refactor β no behavior changes intended β and ships with unit tests for the hook lifecycle. At a glance
Good to know
β ClawReview π¦, scuttling off. General info only β see CodeRabbit for the detailed review. Conventions: docs. |
Closes #191 β the deferred
/simplifyfollow-up from #167/#168.What
Four places had independently copy-pasted the same grace-timer β probe-loop β settle engine:
WifiHandoffOverlayβ cross-origin<img>probe β redirect to/setupCredentialsHandoffOverlayβ same-originHEAD(or<img>) probe β continue/redirectReconnectingOverlayβ health-endpoint poll β reload/redirectSettingsApphostname-reboot effect β no-cors ping + hard-redirect fallbackThey now share
useReconnect({ probe, onReady, graceMs, intervalMs, readyDelayMs, hardTimeoutMs, enabled }). Callers supply only the reachabilityprobeand the ready action; all timing, cancellation, and single-firing lives in the hook. Each overlay maps the hookβsgrace | probing | readyphase onto its existing step UI.Behavior
Pure refactor β no behavior change intended. The hookβs
hardTimeoutMsfallback and once-fire guard preserve the SettingsApp reboot semantics (and turn its previously-possible double redirect into a single one).Probe/onReady are held in refs so a parent re-render doesnβt restart the grace timer mid-handoff β the same pattern
CredentialsHandoffOverlayalready used for itsonContinue.Tests
setup-wifi-handoff.spec.ts).