Skip to content

fix(tailscale): detect + trigger login when installed but logged out - #105

Merged
joelteply merged 1 commit into
canaryfrom
fix/tailscale-logged-out-detection
Apr 25, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/tailscale-logged-out-detection

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Tailscale-installed-but-logged-out is the most common 'tailscale down' case (post-reboot, fresh install, expired auth) and was being misdiagnosed as 'daemon down'. Detect the logged-out state distinctly and auto-foreground the Tailscale.app sign-in dialog on macOS, or print 'tailscale up' on Linux/Windows. install.sh post-flight does the same proactively.

advise_tailscale_if_down treated three different states identically
(not installed / daemon down / logged out) and printed the same wrong
"start the daemon" message for the third — which is the most common
state in practice (post-reboot, fresh install, expired auth).

Now distinguished:
- Status output contains "Logged out" / "NeedsLogin": daemon is up but
  user isn't signed in.
  - macOS with Tailscale.app: 'open -a Tailscale' to foreground the
    sign-in dialog automatically.
  - Linux/Windows: print 'tailscale up' (CLI prompts a sign-in URL).
- Status command rc=0 but no logged-out marker: connected, fall through.
- Status command fails: daemon down (existing path).
- CLI not present: not installed (existing path).

install.sh post-flight does the same check + auto-foreground so users
don't even hit the airc-join confusion if they ran the curl on a
machine where the GUI was just installed but never signed in.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings April 25, 2026 21:02
@joelteply
joelteply merged commit 7e02703 into canary Apr 25, 2026
1 check passed
@joelteply
joelteply deleted the fix/tailscale-logged-out-detection branch April 25, 2026 21:02

Copilot AI 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.

Pull request overview

Improves Tailscale “down” diagnostics by distinguishing the common “installed but logged out” state from “daemon down”, and proactively surfacing login steps (including foregrounding the macOS GUI sign-in).

Changes:

  • Add an install-time post-flight check that detects logged-out Tailscale and prompts/opens sign-in guidance.
  • Update airc runtime diagnostics to treat “logged out / needs login” distinctly from “daemon not running”, and adjust messaging accordingly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
install.sh Adds a post-install Tailscale status check to detect logged-out state and prompt the user to sign in.
airc Enhances advise_tailscale_if_down to detect logged-out state and provide platform-specific recovery instructions.

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

Comment thread airc
# probe still fails it's a peer-offline problem, not a tailnet
# problem. resolve_tailscale_bin() handles Windows tailscale.exe +
# the macOS .app bundle path that PATH lookups miss.
local ts_bin; ts_bin=$(resolve_tailscale_bin)

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

Because airc runs with set -e, ts_bin=$(resolve_tailscale_bin) will cause the script to exit when Tailscale isn't installed (resolve_tailscale_bin returns non-zero). That prevents the later if [ -z "$ts_bin" ] branch from printing the helpful install instructions. Consider making this assignment non-fatal (e.g., append || true or capture the result in a conditional) so the function can continue and emit the intended guidance.

Suggested change
local ts_bin; ts_bin=$(resolve_tailscale_bin)
local ts_bin=""
if ts_bin=$(resolve_tailscale_bin); then
:
else
ts_bin=""
fi

Copilot uses AI. Check for mistakes.
Comment thread airc
Comment on lines +417 to +418
ts_status_out=$("$ts_bin" status 2>&1)
ts_status_rc=$?

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

ts_status_out=$("$ts_bin" status 2>&1) will terminate the entire script when tailscale status returns non-zero (e.g., daemon down), due to set -e. As a result, none of the following diagnostic logic will run in the very cases it’s meant to handle. Capture the output/rc in a way that suppresses -e for this command (e.g., use an if ts_status_out=...; then ...; else ...; fi pattern, or temporarily set +e around the call).

Suggested change
ts_status_out=$("$ts_bin" status 2>&1)
ts_status_rc=$?
if ts_status_out=$("$ts_bin" status 2>&1); then
ts_status_rc=0
else
ts_status_rc=$?
fi

Copilot uses AI. Check for mistakes.
Comment thread install.sh
Comment on lines +367 to +369
ts_bin="tailscale"
elif [ -x /Applications/Tailscale.app/Contents/MacOS/Tailscale ]; then
ts_bin="/Applications/Tailscale.app/Contents/MacOS/Tailscale"

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

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

On Windows/Git Bash, Tailscale is typically tailscale.exe and command -v tailscale may fail (PATHEXT isn’t reliably honored — the airc script already has special handling for this). In ts_post_check, only checking tailscale (and the macOS .app path) means the “installed but logged out” state likely won’t be detected on Windows, which undermines the PR’s stated goal. Consider also checking tailscale.exe and/or the common install paths, similar to resolve_tailscale_bin in airc.

Suggested change
ts_bin="tailscale"
elif [ -x /Applications/Tailscale.app/Contents/MacOS/Tailscale ]; then
ts_bin="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
ts_bin="tailscale"
elif command -v tailscale.exe >/dev/null 2>&1; then
ts_bin="tailscale.exe"
elif [ -x /Applications/Tailscale.app/Contents/MacOS/Tailscale ]; then
ts_bin="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
elif [ -x "/c/Program Files/Tailscale/tailscale.exe" ]; then
ts_bin="/c/Program Files/Tailscale/tailscale.exe"
elif [ -x "/c/Program Files (x86)/Tailscale/tailscale.exe" ]; then
ts_bin="/c/Program Files (x86)/Tailscale/tailscale.exe"

Copilot uses AI. Check for mistakes.
joelteply added a commit that referenced this pull request Apr 25, 2026
PR #105 added logged-out detection to airc (bash) + install.sh but
left airc.ps1 and install.ps1 with the original "daemon down" fallback
that misdiagnoses signed-out users. Mirror the bash logic:

- Advise-TailscaleIfDown: distinguish logged-out (status output contains
  'Logged out' / 'NeedsLogin') from daemon-down. Tell the user to click
  the tray icon to sign in or run 'tailscale up'.
- install.ps1: post-flight check tests for the logged-out marker and
  surfaces a warning + actionable instruction before user runs 'airc
  join' for the first time.

Same exit-code semantics as bash; same env-var override (AIRC_NO_TAILSCALE).
Windows users now get the same correct diagnosis macOS/Linux do.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply added a commit that referenced this pull request Apr 25, 2026
* fix(tailscale): PS parity for logged-out detection

PR #105 added logged-out detection to airc (bash) + install.sh but
left airc.ps1 and install.ps1 with the original "daemon down" fallback
that misdiagnoses signed-out users. Mirror the bash logic:

- Advise-TailscaleIfDown: distinguish logged-out (status output contains
  'Logged out' / 'NeedsLogin') from daemon-down. Tell the user to click
  the tray icon to sign in or run 'tailscale up'.
- install.ps1: post-flight check tests for the logged-out marker and
  surfaces a warning + actionable instruction before user runs 'airc
  join' for the first time.

Same exit-code semantics as bash; same env-var override (AIRC_NO_TAILSCALE).
Windows users now get the same correct diagnosis macOS/Linux do.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix: race-loser detection in self-heal takeover paths

Two tabs that hit the same dead-host gist simultaneously both used to
delete + publish, ending up with split-brain (two competing #room
gists, peers split between them). Caught by running two real airc
join tabs against a stale gist — not by the integration scenario,
which only spawns one joiner.

Both takeover paths (heartbeat-stale fast-path, SSH-failure self-heal)
now:
  1. Jitter sleep 100-1500ms before delete to de-synchronize racers.
  2. Attempt the delete (rc tells us nothing definitive about the race
     — gh API may report success on either side under contention).
  3. Re-scan gh for OTHER gists with this room name (excluding our
     stale ID).
  4. If found: race-loser branch — re-exec with the winner's gist ID
     as JOINER, not as host. Avoids publishing a duplicate.
  5. If not found: race-winner branch — re-exec as host
     (existing AIRC_NO_DISCOVERY=1 path).

Doesn't fix every theoretical race window — perfectly-aligned timing
+ gh API caching could still produce a duplicate publish — but covers
the reproducible split-brain that real two-tab usage was creating.

Caught by Joel's "i imagine you are fucking over windows users" /
"this has to do with not testing ever" feedback. Memory rule added:
test_real_user_surface (run the actual user command, two-tab
scenarios cannot be validated from one tab).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants