Skip to content

refactor: shared useReconnect hook for the reconnect overlays (closes #191) - #317

Merged
KrasimirKralev merged 1 commit into
betafrom
refactor/use-reconnect-hook
Aug 8, 2026
Merged

KrasimirKralev merged 1 commit into
betafrom
refactor/use-reconnect-hook

Conversation

@KrasimirKralev

Copy link
Copy Markdown
Contributor

Closes #191 β€” the deferred /simplify follow-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 /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

They now share useReconnect({ probe, onReady, graceMs, intervalMs, readyDelayMs, hardTimeoutMs, enabled }). Callers supply only the reachability probe and the ready action; all timing, cancellation, and single-firing lives in the hook. Each overlay maps the hook’s grace | probing | ready phase onto its existing step UI.

Behavior

Pure refactor β€” no behavior change intended. The hook’s hardTimeoutMs fallback 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 CredentialsHandoffOverlay already used for its onContinue.

Tests

  • New unit coverage for the hook lifecycle: graceβ†’probeβ†’ready, disabled = idle, hard-timeout fallback, and unmount cancellation.
  • WiFi handoff path stays covered by e2e (setup-wifi-handoff.spec.ts).
  • On a real Jetson: tsc clean, 38/38 hook + component tests passing.

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.
@KrasimirKralev
KrasimirKralev requested a review from a team as a code owner August 8, 2026 17:44
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KrasimirKralev, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9219a7b0-3e76-4b7d-b76a-bcb11b5259fe

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 40f1210 and 923aa8d.

πŸ“’ Files selected for processing (6)
  • src/components/CredentialsHandoffOverlay.tsx
  • src/components/ReconnectingOverlay.tsx
  • src/components/SettingsApp.tsx
  • src/components/WifiHandoffOverlay.tsx
  • src/hooks/useReconnect.ts
  • src/tests/unit/use-reconnect.test.ts

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

πŸ¦€ ClawReview

Poked 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

  • ♻️ Refactor Β· touches setup wizard reconnect overlays + SettingsApp hostname-reboot flow
  • Base branch: beta Β· +200 source / +107 tests across 6 files
  • βœ… base beta matches the beta-first convention
  • βœ… conventional PR title
  • βœ… source changes come with test changes

Good to know

  • ℹ️ New file src/hooks/useReconnect.ts is the single source of truth for the grace/probe/settle engine that runs on customer devices during WiFi handoff and device rename.
  • ℹ️ As a side effect, the SettingsApp hostname-reboot path's previously-possible double redirect is closed β€” the once-fire guard in the hook prevents it.
  • ℹ️ Unit tests included (4 cases: happy path, disabled/idle, hard-timeout fallback, unmount cancellation); WiFi handoff e2e coverage already existed.

β€” ClawReview πŸ¦€, scuttling off. General info only β€” see CodeRabbit for the detailed review. Conventions: docs.

@github-actions github-actions Bot added the area: ui Auto-triage area label Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

CI Summary

βœ… Tests

  • Result: passed
  • View run
  • Coverage: statements 70.78%, branches 61.07%, functions 66.6%, lines 72.7%

βœ… E2E

βœ… E2E Install

@KrasimirKralev
KrasimirKralev merged commit c262f39 into beta Aug 8, 2026
8 checks passed
@KrasimirKralev
KrasimirKralev deleted the refactor/use-reconnect-hook branch August 8, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ui Auto-triage area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant