Skip to content

feat: auto-unblock internet during update check#308

Merged
ng merged 2 commits intodevfrom
feat/306-auto-unblock-updates
Apr 2, 2026
Merged

feat: auto-unblock internet during update check#308
ng merged 2 commits intodevfrom
feat/306-auto-unblock-updates

Conversation

@ng
Copy link
Copy Markdown
Contributor

@ng ng commented Apr 1, 2026

Summary

  • When user initiates update check with internet blocked, shows prompt to temporarily allow internet
  • On allow: unblocks internet, proceeds with update, re-blocks automatically after completion/failure
  • Uses system.internetStatus and system.setInternetAccess APIs
  • Internet re-blocked in both success and failure paths via ref tracking

Closes #306

Test plan

  • With internet blocked: press update → verify prompt appears
  • Press "Allow & Update" → verify internet unblocks, update proceeds, internet re-blocks
  • Press Cancel → verify no changes
  • With internet already allowed: press update → verify normal flow (no prompt)

Summary by CodeRabbit

New Features

  • Update process now detects when internet access is blocked before proceeding
  • Displays a prompt asking users to allow internet access when needed
  • Added "Allow & Update" button for users to grant temporary internet access
  • Automatically re-restricts internet access after the update completes

When the user initiates an update while internet is blocked, the UpdateCard
now prompts to temporarily allow internet access. On confirmation it
unblocks WAN via system.setInternetAccess, proceeds with the update, and
automatically re-blocks internet after the service reconnects (or on
failure). If internet is already allowed, the flow is unchanged.

Closes #306
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

UpdateCard now checks internet connectivity before initiating updates. If WAN is blocked, users receive a prompt to temporarily allow internet access. Upon user consent, internet is unblocked, the update proceeds, and internet is re-blocked automatically afterward, with unmount cleanup handling early navigation.

Changes

Cohort / File(s) Summary
Internet Status Detection & Gating
src/components/status/UpdateCard.tsx
Added TRPC queries/mutations (system.internetStatus, system.setInternetAccess) to check if internet is blocked before updating. Introduced new state machine states (internet-prompt, unblocking) and control flow: if internet is blocked during confirming, transitions to internet-prompt instead of updating. Added didUnblockRef to track temporary unblock, reblockIfNeeded() to restore blocking post-update, and handleAllowInternet() to unblock on user consent. Updated polling logic to re-block on completion, added unmount cleanup for early navigation, and adjusted UI rendering/actions for new states.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant UI as UpdateCard UI
    participant Server as TRPC Server
    participant System as System

    User->>UI: Click "Check for Updates"
    UI->>Server: system.internetStatus (query)
    Server->>System: Check iptables/inet status
    System-->>Server: { blocked: true }
    Server-->>UI: Internet is blocked

    UI->>UI: Transition to internet-prompt state
    UI->>User: Show "Allow Internet?" prompt

    User->>UI: Click "Allow & Update"
    UI->>UI: Transition to unblocking state
    UI->>Server: system.setInternetAccess({ blocked: false })
    Server->>System: Unblock internet
    System-->>Server: Unblock complete
    Server-->>UI: Success
    
    UI->>UI: Set didUnblockRef = true
    UI->>UI: Trigger update check (normal flow)
    
    rect rgba(100, 150, 200, 0.5)
    UI->>Server: Check for updates (internet now available)
    Server->>System: Download/check via internet
    System-->>Server: Update available/complete
    Server-->>UI: Response
    end
    
    UI->>Server: system.setInternetAccess({ blocked: true })
    Server->>System: Re-block internet
    System-->>Server: Re-block complete
    Server-->>UI: Success
    
    UI->>UI: Transition to idle/success state
    UI->>User: Show result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A curious update came to play,
But internet was locked away.
"Let me through!" the bunny cries,
Unblock, update, then re-disguise. 🔒
Safe and sound, the pod's at peace.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding functionality to auto-unblock internet during update checks, which is the primary focus of the changeset.
Linked Issues check ✅ Passed The pull request implements all coding requirements from #306: internet status detection, prompt UI, temporary unblock via setInternetAccess, update execution, and re-block with reference tracking.
Out of Scope Changes check ✅ Passed All changes in UpdateCard.tsx are directly aligned with #306 requirements: adding internet status checks, prompt states, unblock/re-block logic, and corresponding UI updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/306-auto-unblock-updates

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 and usage tips.

Copy link
Copy Markdown
Contributor Author

@ng ng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial Code Review — Standard Depth

Fixed (1)

  • Unmount during polling leaves WAN open — Added reblockIfNeeded to useEffect cleanup. If user navigates away after "Allow & Update", internet is now re-blocked on unmount.

Rejected (3 — false positives)

  • Cancel leak — Cancel button is removed from DOM before unblock resolves; path unreachable
  • startUpdate throws past catch — startUpdate never propagates; its own catch always fires
  • Stale cache (10s) — staleTime defaults to 0 in this project; fresh fetch always issued

Noted (3 — architectural, not this PR)

  • blockWan() in system.ts omits mDNS rules vs install script (pre-existing Major)
  • sp-update double iptables management — design choice, UI manages WAN lifecycle
  • Silent re-block failure — best-effort is acceptable for this flow

Recommendation: Approve

@ng ng merged commit fee226b into dev Apr 2, 2026
5 of 6 checks passed
@ng ng deleted the feat/306-auto-unblock-updates branch April 2, 2026 03:07
@ng ng mentioned this pull request Apr 13, 2026
4 tasks
ng added a commit that referenced this pull request Apr 13, 2026
## Summary

Promotes everything on \`dev\` since the last main release (82 commits,
143 files, +9239/-2699).

### Headlining features
- **Schedule redesign (#303)** — read-only schedule view with explicit
curve management, full-screen \`CurveEditor\` (day picker + bedtime/wake
+ temp range + presets), \`Left | Right | Both\` side selector,
active-curve highlight, atomic \`batchUpdate\` writes, day-conflict
resolution, sparkline cards.
- **Mini feature flag (#420)** — \`ENABLE_MINI\` env var; PubNub moved
to \`optionalDependencies\`; conditional Mini router import.
- **Auto-off on no presence (#301)** — schedule respects bed presence.
- **Auto-unblock internet during update check (#308)**.
- **Schedule batchUpdate cap raised to 1000 (#424)** — fixes AI-curve
apply-to-all-days rejection.

### Operational fixes
- Pod 3 install path (#383, #384, #386, #392)
- Yocto image Python venv (#336)
- DAC socket / Avahi on device startup (#331)
- Free-sleep/sleepypod switch persistence (#337)
- Cross-machine standalone deploys (#308)
- Temperature unit conversion (#333)

### Dependency updates
~20 renovate PRs across React 19.2.5, Next 16.2.3, vitest 4.1.4,
tanstack/react-query 5.97.0, tRPC 11.16, lucide-react 1.x, etc.

### Misc
- ADR 0017 (uv) compiled into deployment wiki
- Snoo pentest methodology + recon plan
- Git hooks + ESLint cleanup (#313)
- CI hardening (#388)

## Test plan
- [x] All unit tests pass on dev (606+ tests)
- [x] Typecheck clean
- [x] Build succeeds (standalone output)
- [x] Deployed to Pod 4 at \`192.168.1.88\` and smoke-tested:
  - schedule on/off
  - create curve from preset
  - edit curve, change days, save
  - day-conflict reassign dialog
  - delete curve
  - side selector left/right/both
  - active-curve highlighting + next set point
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: auto-unblock internet during update check

1 participant