Skip to content

feat: opt-in auto-connect on start preference#78

Merged
dantraynor merged 3 commits into
mainfrom
issue-73
May 21, 2026
Merged

feat: opt-in auto-connect on start preference#78
dantraynor merged 3 commits into
mainfrom
issue-73

Conversation

@dantraynor

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in Auto-connect on start toggle to the connected view's quick settings (off by default). When enabled, the extension sends up once per browser session if the first status after init reports Stopped or NoState. NeedsLogin / NeedsMachineAuth / Starting / Running / InUseOtherUser are skipped.

An explicit manual disconnect within the same browser session is respected: chrome.storage.session tracks an "already handled" flag that survives MV3 service-worker restarts but clears on browser restart, so cycling the SW after a manual down won't re-up the node. There's a defensive fallback if storage.session is unavailable — the feature still works, just without the explicit-disconnect guarantee.

Design choices (from the issue's open questions):

  • Global — single autoConnectOnStart boolean in chrome.storage.local, matches the existing lastExitNodeID pattern.
  • Quick settings — toggle lives next to Shields Up / MagicDNS in the connected view.
  • Respect explicit disconnect within a session — see above.

docs/FEATURE_PARITY.md line 35 flipped to Yes with a note describing the new behavior.

Closes #73

Test plan

  • pnpm typecheck — clean across both packages
  • pnpm test — 296/296 pass (27 new tests; covers the auto-up matrix, session-flag interaction, manual-disconnect path, and the missing-API fallback)
  • pnpm build — Chrome + Firefox MV3 bundles build cleanly
  • Manual: enable toggle while connected, restart browser, confirm Tailscale comes up automatically
  • Manual: with toggle on, click disconnect, close popup, wait for SW to idle (>30s), reopen popup — should remain disconnected
  • Manual: with toggle on, full browser restart after manual disconnect — should auto-connect again
  • Manual: with toggle off, restart browser — no auto-connect

Adds an "Auto-connect on start" toggle (off by default) to the
connected view's quick settings. When enabled, the extension sends
`up` once per browser session if the first status after `init`
reports `Stopped` or `NoState`. NeedsLogin / NeedsMachineAuth /
Starting / Running / InUseOtherUser are skipped.

An explicit manual disconnect within the session is respected:
chrome.storage.session tracks an "already handled" flag that
survives service-worker restarts but clears on browser restart,
so cycling the MV3 SW after a manual `down` won't re-up the node.

Closes #73
# Conflicts:
#	packages/shared/src/background/background.ts
@dantraynor dantraynor merged commit 3213992 into main May 21, 2026
5 checks passed
@dantraynor dantraynor deleted the issue-73 branch May 21, 2026 02:50
@dantraynor dantraynor added the enhancement New feature or request label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "Auto-connect on start" preference

1 participant