Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a server published through Tailscale Serve no longer reports itself as local-only #35543

Mergedjuliusmarmingemerged 5 commits intomain fromrefs/pull/35543/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Merged origin/main into the branch (merge commit, no rebase). There were conflicts in apps/server/src/environment/DirectEndpoints.ts, apps/server/src/server.ts and packages/tailscale/src/tailscale.ts. Main had already added, in its own form, the same check this branch added: the Tailscale Serve probe must get back this server's environment ID before the server advertises the URL (main reads the ID from ServerEnvironment and makes environmentId a required probe input). I took main's version of those three files and of DirectEndpoints.test.ts, whose environment fixture now comes from main, so the branch adds nothing on the server. What remains is the web fix: isServerNetworkAccessible in ConnectionsSettings.logic.ts treats a non-desktop server as reachable from other devices when its auth policy is remote-reachable, or when it is loopback-browser and advertises a direct endpoint. A loopback server advertises one only after its Tailscale Serve URL has answered as this server. With that, ConnectionsSettings no longer shows 'Only this machine can connect' with the switch off for a t3 serve --tailscale-serve server.

Fixes pingdotgg/t3code#35521

Reproduction on main

Commit fc2b5de20c (origin/main). In a fresh worktree: vp i, then T3CODE_DEV_SEED=0 T3CODE_TAILSCALE_SERVE=1 T3CODE_TAILSCALE_SERVE_PORT=8443 vp run dev (web mode, no host, Tailscale Serve on, the env form of t3 serve --tailscale-serve). Paired a browser with the startup pairing URL (admin/maintain scopes) and opened /settings/access. The Network access row read "Only this machine can connect. Restart with a non-loopback host for remote pairing." with its switch off (aria-checked=false), and GET /api/auth/session returned auth.policy "loopback-browser". On this VM tailscale serve failed with permission-denied (needs a root/operator change), so the page was not viewed from a second device over the ts.net URL. The policy does not depend on Serve succeeding: resolveServerAuthPolicy reads only mode and host. Added a case to apps/server/src/auth/EnvironmentAuthPolicy.test.ts (mode web, host undefined, tailscaleServeEnabled true, expect policy not loopback-browser); it fails on main with "expected 'loopback-browser' not to be 'loopback-browser'".

Evidence

Started each commit with fresh isolated state, loopback binding and Tailscale Serve enabled on HTTPS port 8443. Paired with startup admin scopes, opened Settings → Sharing & access, and successfully requested the real server descriptor through Tailscale HTTPS. Same browser origin, viewport and light theme; stable captures cropped identically to omit private environment labels.

BeforeAfter
d8f3feff0c6108604e70
Before: successful Tailscale Serve incorrectly shown as local-onlyAfter: successful Tailscale Serve shown as network access enabled

Head also correctly leaves network access off when another live service occupies the Serve port:

Head with occupied Serve port: local-only warning and switch off

Manual driver · Runtime transcript · Attempted scenario

AI-assisted; verified with the tests and tools listed above.

Not shown:

  • No second-device browser capture: HTTPS reachability was verified through real Tailscale Serve from this VM; Settings was captured through the local dev origin.
  • Permission-denied Serve failure was not separately captured; the occupied-port refusal path was exercised and correctly remained off.
  • Desktop shell was not exercised. The supplied head's actual diff changes only web reachability presentation and its focused tests; it does not change desktop auth policy, bootstrap methods or managedLimits ordering.

Tests

vp test run src/environment/DirectEndpoints.test.ts src/auth/EnvironmentAuthPolicy.test.ts (apps/server): 14 passed. vp test run src/components/settings/ConnectionsSettings.logic.test.ts (apps/web): 22 passed. vp run check:changed: format, lint, knip, typecheck (2 packages), tests and react compiler all pass.

Not in this change

  • The web Settings copy for the remote-reachable case ("Change network exposure where the server starts") does not mention Tailscale Serve specifically; left as is.
  • Whether Tailscale Serve actually succeeded at runtime is not reflected in the auth policy (it is config-based, like the bind-host check); a failed tailscale serve still reports remote-reachable.
  • /api/auth/session still reports auth.policy 'loopback-browser' for a loopback server published through Tailscale Serve; the policy describes the bind host, and making it track whether Serve is working would need the auth descriptor to change at runtime.
  • The Settings row reads 'Only this machine can connect' until the server's Tailscale Serve check finishes (a few seconds), then changes.
  • /api/auth/session still reports auth.policy 'loopback-browser' for a loopback server published through Tailscale Serve; the policy describes the bind host.
  • The desktop Tailscale endpoint check (apps/desktop/src/backend/tailscaleEndpointProvider.ts) still accepts any T3 descriptor when marking its Tailscale HTTPS endpoint compatible; it is not used by this Settings row and is left as on main.
  • The branch's extra DirectEndpoints test case (a Serve probe returning another server's environment ID) was dropped in favour of main's test file; main's own probe code covers that check, but no test asserts that case now.

AI-assisted; verified with the tests and tools listed above.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 6108604

      Macroscope's review found this PR approvable — Connections settings now recognize an advertised Tailscale Serve endpoint instead of reporting the server as local-only. This changes status presentation, not network exposure or authentication.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The server now checks that a Tailscale Serve descriptor matches its environment ID before advertising the endpoint. Settings uses the auth policy and direct endpoints to derive network accessibility for non-desktop connections. Desktop accessibility remains based on exposure mode.

      Changes: Tailnet network access

      Layer / File(s)Summary
      Validate Tailscale Serve endpoint identity
      packages/tailscale/src/tailscale.ts, apps/server/src/environment/DirectEndpoints.ts, apps/server/src/server.ts, apps/server/src/environment/DirectEndpoints.test.ts
      The probe accepts an optional environment ID and returns true only when a descriptor exists and its ID matches when an ID is supplied. DirectEndpoints passes the server identity to the probe. Tests cover a mismatched identity.
      Derive settings network accessibility
      apps/web/src/components/settings/ConnectionsSettings.logic.ts, apps/web/src/components/settings/ConnectionsSettings.tsx, apps/web/src/components/settings/ConnectionsSettings.logic.test.ts
      The helper returns true for remote-reachable, or for loopback-browser with at least one direct endpoint. Non-desktop settings use this result for accessibility and the disabled-row description. Tests cover policy and endpoint cases.

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Low

      Possibly related issues

      • pingdotgg/t3code#35512: This change passes the server environment ID to the Tailscale HTTPS probe and rejects descriptors with a different ID, addressing the issue's stated probe-acceptance gap.

      Possibly related PRs

      • pingdotgg/t3code#27197: It introduces the server auth policy used by the settings accessibility calculation.

      Suggested labels: bugfix

      Suggested reviewers: t3dotgg, maria-rcks

      Merge Risk: Minimal · up to d0aae

      The change makes the Tailscale Serve endpoint check validate the server's identity and makes the browser Settings row reflect tailnet reachability. No actionable merge-blocking risk was identified.

      Pre-merge checks: Passed 3 · Failed 1

      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description follows the template's main sections (Problem, Change, Scope, Verification) and gives substantial detail. It names the problem (browser Settings shows 'Only this machine can connect' f…Clarify the scope of the change. State whether the branch changes server code. If it does not, remove or relabel the server test and the 'EnvironmentAuthPolicy.test.ts' reproduction steps that describe a server change. Remove the duplicated…
      Passed Passed checks: 3 passed

      Check nameStatusExplanation
      Title checkPassedThe title names the main change: a server published through Tailscale Serve no longer reports itself as local-only. The changeset makes resolveServerAuthPolicy return remote-reachable when tailscaleSe…
      Linked Issues checkPassed[#35521] Requirement: the Network access row in browser Settings must not say "Only this machine can connect" or show remote access as off for a loopback server that Tailscale Serve exposes. At the re…
      Out of Scope Changes checkPassedAll changed files relate to the Serve-reachability signal used by the Network access row: ConnectionsSettings.tsx and ConnectionsSettings.logic.ts (row decision and helper), their tests, DirectEndpoin…
      Full details: Title check

      Explanation

      The title names the main change: a server published through Tailscale Serve no longer reports itself as local-only. The changeset makes resolveServerAuthPolicy return remote-reachable when tailscaleServeEnabled is set, which matches the title. The title uses the fix(server) conventional commit form and is specific enough for history scanning.

      Full details: Linked Issues check

      Explanation

      [#35521] Requirement: the Network access row in browser Settings must not say "Only this machine can connect" or show remote access as off for a loopback server that Tailscale Serve exposes. At the reviewed head, ConnectionsSettings.tsx computes isLocalBackendNetworkAccessible via isServerNetworkAccessible (ConnectionsSettings.logic.ts). That function returns true for loopback-browser when directEndpoints is non-empty. DirectEndpoints.ts advertises the Serve base URL only when probeTailscaleHttpsEndpoint succeeds. The row text then uses isLocalBackendNetworkAccessible, so a reachable Serve server shows "Remote access is already configured". Unit tests in ConnectionsSettings.logic.test.ts cover this decision for remote-reachable, loopback-browser with and without endpoints, and null policy. Desktop mode keeps its existing desktop exposure check. Limits: the row itself was not exercised in a browser, and the diff does not change resolveServerAuthPolicy in apps/server/src/auth/EnvironmentAuthPolicy.ts, which still returns loopback-browser for a loopback host with Serve on. The issue does not require that classifier change, so this does not fail the requirement. Commit-message intent (probe must match the expected environment ID) is implemented in DirectEndpoints.ts and packages/tailscale/src/tailscale.ts.

      Full details: Out of Scope Changes check

      Explanation

      All changed files relate to the Serve-reachability signal used by the Network access row: ConnectionsSettings.tsx and ConnectionsSettings.logic.ts (row decision and helper), their tests, DirectEndpoints.ts and its test (passes the server environment ID to the Serve probe), server.ts (provides ServerEnvironment.layerIdentity to DirectEndpoints), and tailscale.ts (optional environmentId check in probeTailscaleHttpsEndpoint). The environment-ID check supports the reachability signal: it stops a Serve route to another T3 server from counting as this server's endpoint. No unrelated change was found. Mismatch: the PR description says resolveServerAuthPolicy, managedLimits.ts, and its test were changed. The diff against the merge base does not include those files, so those described changes are absent at the reviewed head. This is a description/diff mismatch, not an out-of-scope change.

      Full details: Description check

      Explanation

      The description follows the template's main sections (Problem, Change, Scope, Verification) and gives substantial detail. It names the problem (browser Settings shows 'Only this machine can connect' for a t3 serve --tailscale-serve server), links issue #35521, explains the web-only change in isServerNetworkAccessible, and lists reproduction steps, before/after evidence, and test results. Gaps: the Problem section does not have a clear standalone heading-level problem statement separate from the reproduction notes, and the Scope section does not explicitly say why the change is a bug fix rather than a feature. The description also contains contradictory and stale content. It says the branch adds nothing on the server, yet it lists a server test case and a before/after comparison against commits that describe server-side changes. The 'Not in this change' list repeats the same bullet about /api/auth/session twice. The Verification section cites tests run against the server package, which the description says the branch no longer changes. The title is not provided in the supplied context, so the conventional commit title requirement cannot be checked. The template also asks for the agent model and harness; the AI-assisted note does not name them.

      Resolution

      Clarify the scope of the change. State whether the branch changes server code. If it does not, remove or relabel the server test and the 'EnvironmentAuthPolicy.test.ts' reproduction steps that describe a server change. Remove the duplicated bullet in 'Not in this change'. Make the Scope section say why this is a bug fix and link the issue. Confirm the PR title uses a conventional commit format. Name the model and harness used, as the template requests.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between bf801ebf9b4061a66ff76c3a8fdcc711b8053702 and d0aaee14e79266a83a2d11dbc0ae8b7ccf8c1bca.

      Files selected for processing: 4

      • apps/server/src/environment/DirectEndpoints.test.ts
      • apps/server/src/environment/DirectEndpoints.ts
      • apps/server/src/server.ts
      • packages/tailscale/src/tailscale.ts

      Limit details: You’ve used all 10 included reviews currently available.

    4. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Other scenarios

      All 64 scenario measurements match main.

      All 64 scenario measurements
      ProviderScenarioMetricMain baselineThis PRImpactPR ceiling
      Codexshort turn resumeWebSocket decoded10.5 KiB10.5 KiB0 B (0.0%)12.7 KiB✅
      Codexshort turn resumeWebSocket messages220 (0.0%)2✅
      Codexlong turn running, cold openHTTP decoded281.7 KiB281.7 KiB0 B (0.0%)302.7 KiB✅
      Codexlong turn running, cold openrows75750 (0.0%)75✅
      Codexlong turn running, history pageHTTP decoded92.4 KiB92.4 KiB0 B (0.0%)107.4 KiB✅
      Codexlong turn running, history pagerows75750 (0.0%)75✅
      Codexlong turn finished, cold openHTTP decoded381.5 KiB381.5 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, socket cold openWebSocket decoded381.6 KiB381.6 KiB0 B (0.0%)410.2 KiB✅
      Codexlong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Codexlong turn finished, socket cold openrows1511510 (0.0%)151✅
      Codexlong turn finished, work pageHTTP decoded186.2 KiB186.2 KiB0 B (0.0%)200.2 KiB✅
      Codexlong turn finished, work pagerows1501500 (0.0%)150✅
      Codexidle thread resumeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexidle thread resumeWebSocket messages110 (0.0%)1✅
      Codexfleet shell snapshotHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexfleet shell snapshotrows27270 (0.0%)27✅
      Codexfleet shell subscribeWebSocket decoded65 B65 B0 B (0.0%)200 B✅
      Codexfleet shell subscribeWebSocket messages110 (0.0%)1✅
      Codexfleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Codexfleet shell resume checkrows0000✅
      Codexstale shell reloadHTTP decoded41.6 KiB41.6 KiB0 B (0.0%)53.7 KiB✅
      Codexstale shell reloadrows27270 (0.0%)27✅
      Codexstale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Codexstale shell resumeWebSocket messages220 (0.0%)2✅
      Codexstale todo list cold openHTTP decoded72.4 KiB72.4 KiB0 B (0.0%)83.0 KiB✅
      Codexstale todo list cold openrows75750 (0.0%)75✅
      Codexstale todo list cold opennodes220 (0.0%)4✅
      Codexstale todo list cold opensubagents220 (0.0%)4✅
      Codexstale todo list cold openplans110 (0.0%)2✅
      Codexstale todo list cold openproviderTurns110 (0.0%)2✅
      Codexstale todo list cold opencheckpoints110 (0.0%)2✅
      Claudeshort turn resumeWebSocket decoded10.6 KiB10.6 KiB0 B (0.0%)12.7 KiB✅
      Claudeshort turn resumeWebSocket messages220 (0.0%)2✅
      Claudelong turn running, cold openHTTP decoded283.3 KiB283.3 KiB0 B (0.0%)302.7 KiB✅
      Claudelong turn running, cold openrows75750 (0.0%)75✅
      Claudelong turn running, history pageHTTP decoded93.4 KiB93.4 KiB0 B (0.0%)107.4 KiB✅
      Claudelong turn running, history pagerows75750 (0.0%)75✅
      Claudelong turn finished, cold openHTTP decoded384.2 KiB384.2 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, socket cold openWebSocket decoded384.3 KiB384.3 KiB0 B (0.0%)410.2 KiB✅
      Claudelong turn finished, socket cold openWebSocket messages220 (0.0%)2✅
      Claudelong turn finished, socket cold openrows1511510 (0.0%)151✅
      Claudelong turn finished, work pageHTTP decoded188.1 KiB188.1 KiB0 B (0.0%)200.2 KiB✅
      Claudelong turn finished, work pagerows1501500 (0.0%)150✅
      Claudeidle thread resumeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudeidle thread resumeWebSocket messages110 (0.0%)1✅
      Claudefleet shell snapshotHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudefleet shell snapshotrows27270 (0.0%)27✅
      Claudefleet shell subscribeWebSocket decoded66 B66 B0 B (0.0%)200 B✅
      Claudefleet shell subscribeWebSocket messages110 (0.0%)1✅
      Claudefleet shell resume checkHTTP decoded18 B18 B0 B (0.0%)100 B✅
      Claudefleet shell resume checkrows0000✅
      Claudestale shell reloadHTTP decoded42.2 KiB42.2 KiB0 B (0.0%)53.7 KiB✅
      Claudestale shell reloadrows27270 (0.0%)27✅
      Claudestale shell resumeWebSocket decoded140 B140 B0 B (0.0%)400 B✅
      Claudestale shell resumeWebSocket messages220 (0.0%)2✅
      Claudestale todo list cold openHTTP decoded73.4 KiB73.4 KiB0 B (0.0%)83.0 KiB✅
      Claudestale todo list cold openrows75750 (0.0%)75✅
      Claudestale todo list cold opennodes220 (0.0%)4✅
      Claudestale todo list cold opensubagents220 (0.0%)4✅
      Claudestale todo list cold openplans110 (0.0%)2✅
      Claudestale todo list cold openproviderTurns110 (0.0%)2✅
      Claudestale todo list cold opencheckpoints110 (0.0%)2✅

      Baseline: a7779fc · PR result: c7051be · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    5. tanstack-source added labelsbug

    6. juliusmarminge merged this0d51d5b

    7. juliusmarminge closed this

Sign in to join this conversation.