From 79bbd80ba64386d9de7cb99fb73bc2f6189b3bf4 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 25 Nov 2026 15:02:32 +0100 Subject: [PATCH] fix(devices): say why Tailscale stays off on a socket-only host A host whose main address is a Unix socket or named pipe reports lockedBy "main" for older clients, so Devices showed "Always on, because this host already accepts Tailscale connections" next to a switch that was off. The row now reads the status's mainIsSocket and says "Off, because this host listens on a local socket". The socket hint wins over the launch-command hint: when PASEO_LISTEN sets a socket, the socket is why Tailscale cannot be on. "Tailscale is not running on this host" still wins over both. The hint rule moves out of the row component so it can be tested with the host's own status shapes. A browser cannot reach a socket-only host directly, so the server's listener tests cover the status side. --- .../app/src/devices/tailscale-hint.test.ts | 36 +++++++++++++++++++ packages/app/src/devices/tailscale-hint.ts | 13 +++++++ packages/app/src/devices/tailscale-row.tsx | 14 ++------ packages/app/src/i18n/resources/ar.ts | 1 + packages/app/src/i18n/resources/en.ts | 1 + packages/app/src/i18n/resources/es.ts | 1 + packages/app/src/i18n/resources/fr.ts | 1 + packages/app/src/i18n/resources/ja.ts | 1 + packages/app/src/i18n/resources/ko.ts | 1 + packages/app/src/i18n/resources/pt-BR.ts | 1 + packages/app/src/i18n/resources/ru.ts | 1 + packages/app/src/i18n/resources/zh-CN.ts | 1 + 12 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 packages/app/src/devices/tailscale-hint.test.ts create mode 100644 packages/app/src/devices/tailscale-hint.ts diff --git a/packages/app/src/devices/tailscale-hint.test.ts b/packages/app/src/devices/tailscale-hint.test.ts new file mode 100644 index 0000000000..46ecf8c2b0 --- /dev/null +++ b/packages/app/src/devices/tailscale-hint.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, it } from "vitest"; +import type { TailscaleStatus } from "@getpaseo/protocol/messages"; +import { i18n } from "@/i18n/i18next"; +import { describeTailscale } from "./tailscale-hint"; + +// Statuses as the host reports them; see `createDaemonListeners` in the server's listeners.ts. +const off: TailscaleStatus = { ip: "100.101.102.103", address: null, state: "off" }; + +describe("the Tailscale row's hint", () => { + it("says why Tailscale stays off when the host listens on a socket", () => { + const socketHint = "Off, because this host listens on a local socket"; + expect(describeTailscale({ ...off, lockedBy: "main", mainIsSocket: true }, i18n.t)).toBe( + socketHint, + ); + expect(describeTailscale({ ...off, lockedBy: "launch", mainIsSocket: true }, i18n.t)).toBe( + socketHint, + ); + }); + + it("keeps the hint of every other state", () => { + const hint = (status: TailscaleStatus) => describeTailscale(status, i18n.t); + expect(hint(off)).toBe("Direct over your tailnet, enter an address"); + expect(hint({ ip: null, address: null, state: "unavailable", lockedBy: "launch" })).toBe( + "Tailscale is not running on this host", + ); + expect(hint({ ...off, state: "waiting", address: "100.101.102.103:6767" })).toBe( + "Waiting for Tailscale to start on this host", + ); + expect(hint({ ...off, state: "on", address: "100.101.102.103:6767", lockedBy: "main" })).toBe( + "Always on, because this host already accepts Tailscale connections", + ); + expect(hint({ ...off, lockedBy: "launch" })).toBe( + "Controlled by the command that starts this host", + ); + }); +}); diff --git a/packages/app/src/devices/tailscale-hint.ts b/packages/app/src/devices/tailscale-hint.ts new file mode 100644 index 0000000000..519befdc96 --- /dev/null +++ b/packages/app/src/devices/tailscale-hint.ts @@ -0,0 +1,13 @@ +import type { TailscaleStatus } from "@getpaseo/protocol/messages"; +import type { TFunction } from "i18next"; + +/** The line under the Tailscale label for each state the host reports, most specific first. */ +export function describeTailscale(status: TailscaleStatus, t: TFunction): string { + if (status.state === "unavailable") return t("devices.tailscale.unavailable"); + if (status.state === "waiting") return t("devices.tailscale.waiting"); + // A socket is why Tailscale cannot be on, even when the launch command also fixes the address. + if (status.mainIsSocket) return t("devices.tailscale.socket"); + if (status.lockedBy === "launch") return t("devices.tailscale.launch"); + if (status.lockedBy === "main") return t("devices.tailscale.alwaysOn"); + return t("devices.tailscale.hint"); +} diff --git a/packages/app/src/devices/tailscale-row.tsx b/packages/app/src/devices/tailscale-row.tsx index 9f86505bfe..a60dfca109 100644 --- a/packages/app/src/devices/tailscale-row.tsx +++ b/packages/app/src/devices/tailscale-row.tsx @@ -1,7 +1,5 @@ import { useCallback, useMemo } from "react"; import { useMutation, useQueryClient } from "@tanstack/react-query"; -import type { TailscaleStatus } from "@getpaseo/protocol/messages"; -import type { TFunction } from "i18next"; import { useTranslation } from "react-i18next"; import { SettingsAction, SettingsRowChildren, SettingsSwitch } from "@/components/settings"; import { useToast } from "@/contexts/toast-context"; @@ -10,6 +8,7 @@ import { useHostRuntimeClient, useHostRuntimeSnapshot } from "@/runtime/host-run import { useSessionStore } from "@/stores/session-store"; import { confirmDialog } from "@/utils/confirm-dialog"; import { copyToClipboard } from "@/utils/copy-to-clipboard"; +import { describeTailscale } from "./tailscale-hint"; const UPDATES_DOCS_URL = "https://paseo.sh/docs/updates"; const TAILSCALE_DOWNLOAD_URL = "https://tailscale.com/download"; @@ -71,7 +70,7 @@ function TailscaleControl({ serverId, client }: { serverId: string; client: Host <>