Skip to content

fix(desktop): surface Tailscale Serve setup failures with admin link - #4552

Closed
GenKerensky wants to merge 4 commits into
pingdotgg:mainfrom
GenKerensky:fix/tailscale-serve-enable-error-toast
Closed

fix(desktop): surface Tailscale Serve setup failures with admin link#4552
GenKerensky wants to merge 4 commits into
pingdotgg:mainfrom
GenKerensky:fix/tailscale-serve-enable-error-toast

Conversation

@GenKerensky

@GenKerensky GenKerensky commented Jul 26, 2026

Copy link
Copy Markdown

Summary

  • Preflight tailscale serve when enabling Tailscale HTTPS in the desktop app, so setup failures fail the Enable action instead of silently restarting with an unchecked toggle.
  • Extract safe CLI diagnostics (including the login.tailscale.com/f/serve configure URL) without leaking raw stderr secrets.
  • Show an error toast with the CLI-style message and an Open setup action that opens the admin URL.

Problem

Enable persisted tailscaleServeEnabled: true and relaunched the app, but the child server swallowed tailscale serve failures as warnings. The UI toggle is driven by HTTPS probe success, so it stayed off with no user-visible error. Locally this was:

Serve is not enabled on your tailnet.
To enable, visit:
  https://login.tailscale.com/f/serve?node=...

Test plan

  • vp run --filter @t3tools/tailscale test
  • DesktopServerExposure unit tests (including Serve-not-enabled preflight failure)
  • typecheck for tailscale, desktop, server, web
  • Manual: with Serve disabled on the tailnet, open Settings → Connections → Tailscale HTTPS → Enable → confirm toast shows the error text and Open setup opens the Tailscale admin URL
  • Manual: after enabling Serve in the admin console, Enable succeeds, app relaunches, toggle becomes checked when HTTPS is reachable

Note

Surface Tailscale Serve setup failures with admin link and structured errors

  • When setTailscaleServeEnabled fails, a new DesktopTailscaleServeConfigureError is thrown with a user-readable reason and optional configureUrl extracted from sanitized CLI output (never raw stderr).
  • The failure toast in ConnectionsSettings.tsx now includes an action button to open the Tailscale Admin Serve URL in the browser when one is present in the error.
  • New utilities in tailscale.ts (extractTailscaleServeDiagnostics, formatTailscaleServeUserMessage, extractTailscaleServeConfigureUrl) parse and sanitize CLI errors into structured diagnostics and human-readable messages.
  • Behavioral Change: setTailscaleServeEnabled now performs a preflight ensureTailscaleServe check before persisting settings, and always returns requiresRelaunch=true on successful enable even when settings are unchanged.
📊 Macroscope summarized 4a0919b. 4 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1a257345-0db8-431f-be14-35b9b825b7d1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 26, 2026
Comment thread apps/desktop/src/backend/DesktopServerExposure.ts
Preflight `tailscale serve` when enabling HTTPS from the desktop app so
failures (e.g. Serve disabled on the tailnet) show an error toast with the
same configure URL the CLI prints, instead of silently restarting with an
unchecked toggle.
@GenKerensky
GenKerensky force-pushed the fix/tailscale-serve-enable-error-toast branch from b892ae3 to e470b80 Compare July 26, 2026 04:00

@macroscopeapp macroscopeapp 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.

The Effect Service Conventions check found one issue in the new DesktopTailscaleServeConfigureError. Details inline.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/backend/DesktopServerExposure.ts

@macroscopeapp macroscopeapp 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.

The Effect Service Conventions check found one issue in the new DesktopTailscaleServeConfigureError. Details inline.

Posted via Macroscope — Effect Service Conventions

Comment thread apps/desktop/src/backend/DesktopServerExposure.ts
After a successful Serve preflight, disable Serve when writing desktop
settings fails so HTTPS exposure is not left active while UI/settings
still report disabled.
Align DesktopTailscaleServeConfigureError with Effect service conventions:
preserve the underlying TailscaleCommandError as optional cause, store only
safe structural detail/configureUrl fields, and derive message from those
attributes instead of a free-form reason string.
preflightedServePort = servePort;
}

const result = yield* desktopSettings

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 backend/DesktopServerExposure.ts:594

When enabling Tailscale Serve, the rollback uses Effect.tapError, which only fires on typed errors. If desktopSettings.setTailscaleServe is interrupted or throws a defect after ensureTailscaleServe has already opened the HTTPS mapping, the rollback to disableTailscaleServe never runs — leaving Serve active while the UI and settings still show it as disabled. Consider using Effect.ensuring or an acquire-release pattern so the cleanup executes on all non-success exits, not just typed persistence errors.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/desktop/src/backend/DesktopServerExposure.ts around line 594:

When enabling Tailscale Serve, the rollback uses `Effect.tapError`, which only fires on typed errors. If `desktopSettings.setTailscaleServe` is interrupted or throws a defect after `ensureTailscaleServe` has already opened the HTTPS mapping, the rollback to `disableTailscaleServe` never runs — leaving Serve active while the UI and settings still show it as disabled. Consider using `Effect.ensuring` or an acquire-release pattern so the cleanup executes on all non-success exits, not just typed persistence errors.

Electron's process.execPath inside an AppImage points at the temporary
mount, which is unmounted on exit. Use the APPIMAGE env path so restart
actually brings the app back up.
if (appImagePath) {
return {
execPath: appImagePath,
args: [],

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.

🟡 Medium app/resolveDesktopRelaunchOptions.ts:23

The AppImage branch returns args: [], dropping all command-line arguments. When the app is launched with a meaningful argument (e.g. a file path or runtime switch) and then relaunches, the relaunched instance starts with no arguments and skips the requested startup behavior. The fix is to preserve argv.slice(1) in both branches, since switching execPath to $APPIMAGE doesn't require discarding args.

🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/desktop/src/app/resolveDesktopRelaunchOptions.ts around line 23:

The AppImage branch returns `args: []`, dropping all command-line arguments. When the app is launched with a meaningful argument (e.g. a file path or runtime switch) and then relaunches, the relaunched instance starts with no arguments and skips the requested startup behavior. The fix is to preserve `argv.slice(1)` in both branches, since switching `execPath` to `$APPIMAGE` doesn't require discarding args.

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

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant