Skip to content

fix: trigger native captive portal popup for Starbucks and Komeda WiFi - #704

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/neverssl-captive-portal-popup
Jan 30, 2026
Merged

fix: trigger native captive portal popup for Starbucks and Komeda WiFi#704
shunkakinoki merged 1 commit into
mainfrom
fix/neverssl-captive-portal-popup

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Jan 30, 2026

Copy link
Copy Markdown
Owner

Changes Made

  • Restart WiFi interface when connectivity is lost on captive portals
  • Increases WiFi restart delay to 3 seconds for reliability
  • Supports both STARBUCKS and Komeda_Wi-Fi networks
  • No notifications - uses native macOS captive portal popup

Technical Details

  • Modified home-manager/services/neverssl-keepalive/keepalive.sh
  • When ping to 1.1.1.1 fails on Starbucks or Komeda_Wi-Fi:
    • Turns WiFi off with networksetup -setairportpower en0 off
    • Waits 3 seconds (increased from 1 second)
    • Turns WiFi back on with networksetup -setairportpower en0 on
  • macOS automatically shows native "Click to sign in to WiFi network" popup

Testing

  • WiFi restart logic triggers native macOS captive portal
  • 3 second delay ensures proper interface power cycle
  • No notification spam - relies on system popup

🤖 Generated with pi


Summary by cubic

Triggers the native macOS captive portal popup for Starbucks and Komeda_Wi‑Fi by restarting Wi‑Fi when connectivity fails. Improves reliability with a 3s delay and removes custom notifications.

  • Bug Fixes
    • On macOS, when on STARBUCKS or Komeda_Wi‑Fi and ping to 1.1.1.1 fails, power-cycles en0 to trigger the system captive portal.
    • Replaces opening captive.apple.com with a Wi‑Fi restart.
    • Implemented in home-manager/services/neverssl-keepalive/keepalive.sh.

Written for commit 4aa5de1. Summary will update on new commits.

Copilot AI review requested due to automatic review settings January 30, 2026 04:23
@mesa-dot-dev

mesa-dot-dev Bot commented Jan 30, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@shunkakinoki shunkakinoki added the automerge Label to trigger automatic merging when checks pass. label Jan 30, 2026
@shunkakinoki
shunkakinoki enabled auto-merge (squash) January 30, 2026 04:23
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the neverssl-keepalive script for macOS users by implementing a more robust mechanism for handling captive portals. Instead of attempting to open a specific URL, the script now intelligently restarts the WiFi interface when connectivity issues are detected on designated networks, thereby prompting the operating system's native captive portal sign-in experience. This change aims to provide a more seamless and reliable connection process in public WiFi environments.

Highlights

  • Enhanced Captive Portal Handling: The script now restarts the WiFi interface on macOS when connectivity is lost on specific captive portal networks (Starbucks, Komeda_Wi-Fi) to trigger the native macOS captive portal popup, replacing the previous method of opening a URL.
  • Increased WiFi Restart Delay: The delay for restarting the WiFi interface has been increased to 3 seconds, aiming for improved reliability in triggering the native captive portal.
  • Expanded Network Support: Support for 'Komeda_Wi-Fi' networks has been added, alongside the existing 'STARBUCKS' network detection.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • WiFi connectivity recovery improved: the system now automatically restarts your wireless connection when connectivity fails, enabling faster and more reliable recovery
  • New Features

    • Expanded WiFi network support to include additional networks in the automatic keepalive service

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Updated macOS keepalive script to detect additional SSID (Komeda_Wi-Fi) and, on failed connectivity to 1.1.1.1, restart the Wi‑Fi interface (toggle off, sleep, toggle on) instead of opening a captive portal URL.

Changes

Cohort / File(s) Summary
neverssl-keepalive script
home-manager/services/neverssl-keepalive/keepalive.sh
Expanded SSID matching to include Komeda_Wi-Fi; replaced open http://captive.apple.com behavior with a Wi‑Fi restart sequence using networksetup -setairportpower <device> off, sleep 3, then on.
tests
spec/keepalive_spec.sh
Updated test description and expectations to assert Wi‑Fi restart commands (networksetup -setairportpower) and sleep delay, replacing prior expectation of opening captive.apple.com.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

codex

Poem

🐰 A hop, a sniff, the SSIDs grow—

Starbucks, Komeda in a row.
No URL chase, just power flip,
Wi‑Fi blinks on with a tiny skip.
Hooray, the portal wakes from its nap—🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing the captive portal popup trigger for Starbucks and Komeda WiFi networks by restarting the WiFi interface.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description clearly describes the changes made: restarting WiFi interfaces for Starbucks and Komeda networks, increasing delay to 3 seconds, and using native macOS popups instead of notifications.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/neverssl-captive-portal-popup

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.

@mesa-dot-dev

mesa-dot-dev Bot commented Jan 30, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Triggers the native macOS captive portal popup for Starbucks and Komeda_Wi-Fi by restarting the Wi-Fi interface when connectivity is lost. This change improves reliability with a 3-second delay and removes custom notifications in favor of the system popup.

What changed?

  • home-manager/services/neverssl-keepalive/keepalive.sh:
    • The script now restarts the Wi-Fi interface on macOS (networksetup -setairportpower en0 off followed by on) instead of attempting to open captive.apple.com to trigger the captive portal when connectivity is lost.
    • The detection of captive portal networks has been expanded to include "Komeda_Wi-Fi" in addition to "STARBUCKS".
    • The Wi-Fi restart delay has been increased to 3 seconds (from 1 second) for improved reliability.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the keepalive script to improve handling of captive portals on specific WiFi networks on macOS by restarting the WiFi interface, which is a clever way to trigger the native system popup. The change also extends support to Komeda WiFi networks.

My main feedback is regarding the use of the hardcoded network interface en0. This is not guaranteed to be the WiFi interface on all Mac hardware, which could make the script fail on some machines. I've added a specific comment with a suggestion to dynamically detect the WiFi interface to make the script more robust.

Additionally, it appears the tests in spec/keepalive_spec.sh have not been updated to reflect these changes. The existing tests check for the old behavior and will likely fail. Please remember to update the tests to cover the new WiFi restart logic.

With these adjustments, this will be a solid improvement.

Comment on lines +22 to +24
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Hardcoding the network interface as en0 is not reliable, as the WiFi interface can have a different name (e.g., en1) on different Mac models. This hardcoded value is used here and also on line 16 to get the SSID. It would be more robust to dynamically determine the WiFi interface name.

Since a code suggestion can only replace the selected lines, I'm providing an example in this comment body for you to apply across the entire darwin-specific block:

if [[ $OSTYPE == "darwin"* ]]; then
  WIFI_DEVICE=$(networksetup -listallhardwareports | awk '/Hardware Port: Wi-Fi/{getline; print $2}')
  if [[ -z "$WIFI_DEVICE" ]]; then exit 0; fi

  SSID=$(networksetup -getairportnetwork "$WIFI_DEVICE" 2>/dev/null | awk -F": " '{print $2}' || echo "")

  if [[ $SSID == *"STARBUCKS"* ]] || [[ $SSID == *"Komeda_Wi-Fi"* ]]; then
    if ! ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1; then
      networksetup -setairportpower "$WIFI_DEVICE" off
      sleep 3
      networksetup -setairportpower "$WIFI_DEVICE" on
    fi
  fi
fi

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modifies the captive portal handling for WiFi networks to trigger the native macOS captive portal popup instead of opening a URL. The approach now restarts the WiFi interface when connectivity is lost on specific networks (Starbucks and Komeda WiFi).

Changes:

  • Replaced URL-based captive portal trigger with WiFi interface restart (networksetup commands)
  • Added support for Komeda_Wi-Fi networks alongside existing Starbucks support
  • Introduced 3-second delay between WiFi power off and on

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 16 to +24
SSID=$(networksetup -getairportnetwork en0 2>/dev/null | awk -F": " '{print $2}' || echo "")

# Check for Starbucks networks (e.g., at_STARBUCKS_Wi2)
if [[ $SSID == *"STARBUCKS"* ]]; then
# Check for Starbucks or Komeda networks
if [[ $SSID == *"STARBUCKS"* ]] || [[ $SSID == *"Komeda_Wi-Fi"* ]]; then
if ! ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1; then
open "http://captive.apple.com" 2>/dev/null || true
# Restart WiFi to trigger macOS captive portal popup
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The script hardcodes the WiFi interface as 'en0', which may not be correct on all macOS systems. Different Mac models and configurations can have WiFi on different interfaces (e.g., en1, en2). Consider detecting the active WiFi interface dynamically, or make the interface name configurable. You could use 'networksetup -listallhardwareports' to find the WiFi interface programmatically.

Copilot uses AI. Check for mistakes.
open "http://captive.apple.com" 2>/dev/null || true
# Restart WiFi to trigger macOS captive portal popup
networksetup -setairportpower en0 off
sleep 3

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The PR description states "Increases WiFi restart delay to 3 seconds for reliability" and "increased from 1 second", but the previous code opened captive.apple.com directly without any delay. There was no previous 1-second delay to increase from. This discrepancy in the PR description is misleading.

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +24
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The networksetup commands may fail due to insufficient permissions or if the WiFi interface is busy. Consider adding error handling to prevent the script from failing due to 'set -euo pipefail'. For example, you could append '|| true' to these commands or temporarily disable error handling for this block to ensure the script continues to run even if the WiFi restart fails.

Suggested change
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on
networksetup -setairportpower en0 off || true
sleep 3
networksetup -setairportpower en0 on || true

Copilot uses AI. Check for mistakes.
# macOS-specific: Open captive portal for Starbucks WiFi if connectivity is lost
# macOS-specific: Restart WiFi to trigger captive portal popup when connectivity is lost
if [[ $OSTYPE == "darwin"* ]]; then
SSID=$(networksetup -getairportnetwork en0 2>/dev/null | awk -F": " '{print $2}' || echo "")

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The script uses system utilities (networksetup, ping, and awk) that may not be in the PATH configured in default.nix. The launchd configuration at line 15 of default.nix only includes curl in the PATH. On macOS, networksetup is in /usr/sbin/, ping is in /sbin/, and awk is in /usr/bin/. Consider updating the PATH in default.nix to include these system directories, following the pattern used in home-manager/services/docker-postgres/default.nix line 14, which sets PATH to include /usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin. You should add /usr/sbin and /sbin to ensure these commands are available.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +24
# Restart WiFi to trigger macOS captive portal popup
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The test at line 107 in spec/keepalive_spec.sh expects the script to include 'captive.apple.com', but this has been removed in favor of the WiFi restart approach. The test needs to be updated to check for the new behavior (networksetup commands and sleep 3) instead.

Copilot uses AI. Check for mistakes.
# Check for Starbucks networks (e.g., at_STARBUCKS_Wi2)
if [[ $SSID == *"STARBUCKS"* ]]; then
# Check for Starbucks or Komeda networks
if [[ $SSID == *"STARBUCKS"* ]] || [[ $SSID == *"Komeda_Wi-Fi"* ]]; then

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The test description at line 88 in spec/keepalive_spec.sh is titled 'Starbucks WiFi detection (macOS)' but the code now supports both Starbucks and Komeda networks. The test suite should be updated to reflect this broader scope and include test cases for Komeda_Wi-Fi pattern matching.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to +24
if ! ping -c 1 -W 2 1.1.1.1 >/dev/null 2>&1; then
open "http://captive.apple.com" 2>/dev/null || true
# Restart WiFi to trigger macOS captive portal popup
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

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

The script will restart WiFi every 3 seconds (the StartInterval in default.nix) when connected to Starbucks or Komeda networks without internet connectivity. This could be disruptive to the user if the captive portal is never completed or if connectivity is unavailable. Consider adding a mechanism to track the last restart time and only restart WiFi if a certain cooldown period has elapsed (e.g., 30-60 seconds), or add a file-based flag to indicate a restart was attempted recently.

Copilot uses AI. Check for mistakes.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@home-manager/services/neverssl-keepalive/keepalive.sh`:
- Around line 21-24: The network setup toggles (networksetup -setairportpower
en0 off/on) are unguarded and will cause the script to exit under set -e if they
fail; update keepalive.sh to run each networksetup call with a guard (e.g.,
if/|| check) that captures non-zero exit status and logs a warning using the
same logging mechanism used earlier in the script (the existing networksetup
error handling at line 16) instead of letting the script abort, so failures due
to permissions, wrong interface, or missing device are reported but do not
terminate execution.
🧹 Nitpick comments (1)
home-manager/services/neverssl-keepalive/keepalive.sh (1)

16-24: Avoid hardcoding en0; detect the Wi‑Fi interface once.

On some Macs the Wi‑Fi device is en1, so the SSID read/toggle won’t work. A small pre‑step to detect the Wi‑Fi device makes this portable.

♻️ Recommended refactor
-  SSID=$(networksetup -getairportnetwork en0 2>/dev/null | awk -F": " '{print $2}' || echo "")
+  WIFI_IFACE=$(networksetup -listallhardwareports \
+    | awk '/Wi-Fi|AirPort/{getline; print $2; exit}')
+  if [[ -z $WIFI_IFACE ]]; then
+    echo "$(date): WARN: Wi‑Fi interface not found" >&2
+    exit 0
+  fi
+  SSID=$(networksetup -getairportnetwork "$WIFI_IFACE" 2>/dev/null | awk -F": " '{print $2}' || echo "")
...
-      networksetup -setairportpower en0 off
+      networksetup -setairportpower "$WIFI_IFACE" off
       sleep 3
-      networksetup -setairportpower en0 on
+      networksetup -setairportpower "$WIFI_IFACE" on

Comment on lines +21 to +24
# Restart WiFi to trigger macOS captive portal popup
networksetup -setairportpower en0 off
sleep 3
networksetup -setairportpower en0 on

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat -n home-manager/services/neverssl-keepalive/keepalive.sh

Repository: shunkakinoki/dotfiles

Length of output: 1141


Guard networksetup commands against failures under set -e.

Lines 22–24 call networksetup without error handling. If either command fails—due to missing admin privileges, wrong interface, or unavailable device—set -e will terminate the script before the WiFi toggle completes. This is inconsistent with line 16, which already handles networksetup errors. Add guards and log warnings on failure:

🛠️ Suggested hardening
      # Restart WiFi to trigger macOS captive portal popup
-     networksetup -setairportpower en0 off
-     sleep 3
-     networksetup -setairportpower en0 on
+     if ! networksetup -setairportpower en0 off; then
+       echo "$(date): WARN: failed to power off Wi‑Fi (needs admin?)" >&2
+     else
+       sleep 3
+       if ! networksetup -setairportpower en0 on; then
+         echo "$(date): WARN: failed to power on Wi‑Fi (needs admin?)" >&2
+       fi
+     fi
🤖 Prompt for AI Agents
In `@home-manager/services/neverssl-keepalive/keepalive.sh` around lines 21 - 24,
The network setup toggles (networksetup -setairportpower en0 off/on) are
unguarded and will cause the script to exit under set -e if they fail; update
keepalive.sh to run each networksetup call with a guard (e.g., if/|| check) that
captures non-zero exit status and logs a warning using the same logging
mechanism used earlier in the script (the existing networksetup error handling
at line 16) instead of letting the script abort, so failures due to permissions,
wrong interface, or missing device are reported but do not terminate execution.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="home-manager/services/neverssl-keepalive/keepalive.sh">

<violation number="1" location="home-manager/services/neverssl-keepalive/keepalive.sh:22">
P2: Unprotected `networksetup -setairportpower` calls can fail under the user LaunchAgent, and with `set -euo pipefail` will abort the script, breaking keepalive behavior.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread home-manager/services/neverssl-keepalive/keepalive.sh
- Restart WiFi interface when connectivity is lost on captive portals
- Increases WiFi restart delay to 3 seconds for reliability
- Supports both STARBUCKS and Komeda_Wi-Fi networks
- No notifications - uses native macOS captive portal popup
- Update shell tests to reflect new WiFi restart behavior
@shunkakinoki
shunkakinoki force-pushed the fix/neverssl-captive-portal-popup branch from 8d7345c to 4aa5de1 Compare January 30, 2026 05:37
@shunkakinoki
shunkakinoki disabled auto-merge January 30, 2026 05:38
@shunkakinoki
shunkakinoki merged commit 0125a15 into main Jan 30, 2026
23 of 24 checks passed
@shunkakinoki
shunkakinoki deleted the fix/neverssl-captive-portal-popup branch January 30, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Label to trigger automatic merging when checks pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants