Repository navigation
fix(connect): tailscale-state pre-check on fresh-pair + gist-discovery paths (closes #78) - #84
Merged
Merged
Conversation
…y paths (#78) The resume path already calls advise_tailscale_if_down (bash) / Advise-TailscaleIfDown (ps1) before SSH-pair, but that gate doesn't cover the cold-start `airc join <invite>` from a fresh scope OR the gist-discovery resolution that lands at the same SSH-pair point with a tailnet host_target. Without this guard, a logged-out Tailscale produced a silent unreachable-host + self-heal cascade — Memento's case 2026-04-25, surfaced as airc issue #78. Symmetric one-line addition to the universal-pair-attempt point in both bash (cmd_connect, just before "Connecting to") and PowerShell (cmd_connect, same spot). Reuses the existing advise_tailscale_if_down / Advise-TailscaleIfDown helpers — no new detection logic, just extends the call site to the path that bypassed it. Both languages stay in lockstep per pure-shell-cross-platform discipline; bash and ps1 ship together. 133/133 integration tests pass (no regression on existing pair flows; test for the down-state itself filed as a follow-up since it requires mocking tailscale-status output cleanly). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a Tailscale “down/logged-out” pre-flight check to the fresh-pair and gist-discovery join paths so users get actionable guidance before hitting unreachable-host/self-heal behavior (issue #78).
Changes:
- Add
advise_tailscale_if_downgate just before the TCP pair handshake inairc(bash). - Add
Advise-TailscaleIfDowngate at the equivalent point inairc.ps1(PowerShell).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
airc |
Adds Tailscale-down pre-check before attempting the join/pair handshake. |
airc.ps1 |
Mirrors the same Tailscale-down pre-check in the PowerShell connect flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1652
to
+1662
| # Tailscale-down pre-flight on fresh-pair / gist-discovery paths. | ||
| # Resume path (line ~1241) already calls advise_tailscale_if_down, but | ||
| # that gate doesn't cover (a) cold-start `airc join <invite>` from a | ||
| # fresh scope or (b) the gist-discovery resolution that lands here | ||
| # with a tailnet host_target. Without this check, a logged-out | ||
| # Tailscale produced a silent unreachable-host + self-heal cascade | ||
| # (issue #78, Memento's case 2026-04-25). Same call site shape as the | ||
| # resume path: detect-and-instruct, do not auto-tailscale-up. | ||
| if ! advise_tailscale_if_down "$peer_host_only"; then | ||
| die "Re-run airc join after starting Tailscale." | ||
| fi |
Comment on lines
+2027
to
+2037
| # Tailscale-down pre-flight on fresh-pair / gist-discovery paths. | ||
| # Resume path (line ~1877) already calls Advise-TailscaleIfDown, but | ||
| # that gate doesn't cover (a) cold-start `airc join <invite>` from a | ||
| # fresh scope or (b) the gist-discovery resolution that lands here | ||
| # with a tailnet host_target. Without this check, a logged-out | ||
| # Tailscale produces a silent unreachable-host + self-heal cascade | ||
| # (issue #78, Memento's case 2026-04-25). Same call shape as resume | ||
| # path: detect-and-instruct, do not auto-tailscale-up. | ||
| if (Advise-TailscaleIfDown -TargetHost $peerHostOnly) { | ||
| Die 'Re-run airc join after starting Tailscale.' | ||
| } |
…84) Copilot caught the bigger bug under #78: advise_tailscale_if_down / Advise-TailscaleIfDown only matched CGNAT against strings starting with `100.`, but `host_target` is stored in config.json as `user@host` (e.g. `[email protected]`). The resume path was passing the full `user@host` form directly into the helper, the case match never hit, the function returned 0 (proceed), and the silent-tailscale-down bug fired anyway. The check existed but was structurally broken for its exact use case. Fix the helper itself rather than every call site: strip `${var##*@}` (bash) / `($var -split '@')[-1]` (PowerShell) at function entry, before the CGNAT pattern match. All call sites become safe — resume path included. Same fix applied to is_peer_offline_in_tailnet / Test-PeerOfflineInTailnet since they share the identical pattern (called via host_target from cmd_send's send-fast-path). 133/133 tests pass on this branch with both fixes. Credit: copilot-pull-request-reviewer caught the user@ prefix issue on PR #84 review — important catch, the headline bug was a symptom of this deeper structural issue. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
3 of 4 tasks
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #78. The resume path already gates on
advise_tailscale_if_down(bash) /Advise-TailscaleIfDown(ps1) before SSH-pair, but the cold-startairc join <invite>and gist-discovery paths land at the same SSH-pair point WITHOUT the gate. A logged-out Tailscale on those paths produces silent unreachable-host + self-heal cascade — Memento's case from 2026-04-25.Symmetric one-block addition in both bash (
airc) and PowerShell (airc.ps1) at the universal pair-attempt point, just before the "Connecting to" line. Reuses existing helpers — no new detection logic.Why both languages
Per pure-shell-cross-platform discipline + Joel: don't neglect Windows. Bash and ps1 ship in lockstep on this PR. green @green-022a — please validate on your native PS port.
Test plan
test/integration.sh— 133/133 pass on canary HEAD with this changetailscale logout,airc join <CGNAT-host invite>, expect loud message)Out of scope (filed as follow-ups)
airc doctor --connect), feat: bootstrap-airc onboarding scripts (one-command setup for first-time users) #81 (bootstrap-airc scripts), feat: airc list shows last-activity + marks stale/empty rooms #82 (list-activity), bug: stale pairing not detected after host gist gets deleted/replaced #83 (stale-pairing detect)🤖 Generated with Claude Code