From db0dea08cf892cec8a756c70971148e9173c7831 Mon Sep 17 00:00:00 2001 From: Brad Baker Date: Fri, 24 Jul 2026 09:40:02 +1000 Subject: [PATCH] fix tmux-monitor tailscale issue (#1076) * Initial plan * fix(tmux-monitor): explicitly handle tailscale auth in PanePreview hostConfig For Tailscale-auth hosts the pane-preview attach path was building the Terminal hostConfig with only the generic spread of host fields. This could omit or mismap auth-critical details and trigger a plain TCP/SSH reachability path that doesn't work with Tailscale-only SSH endpoints. The fix branches on `host.authType === "tailscale"` and: - Carries `authType: "tailscale"` explicitly so the backend always selects the Tailscale-aware PTY path regardless of how the host object evolves. - Derives `port` from `host.sshPort ?? host.port` so Tailscale SSH endpoints on a non-default SSH port are reached correctly. - Leaves all non-tailscale auth types on the unchanged code path. Reattach (bumping instanceId + attachNonce) continues to work because terminalHostConfig is recomputed on every render with the latest instanceIdRef.current value. * refactor(tmux-monitor): simplify tailscale port logic with extracted variable Address code review feedback: extract resolvedPort into a local variable to avoid the duplicated `host.sshPort ?? host.port` expression that was assigned to both `port` and `sshPort`. Restructure as an if/else block instead of an IIFE for readability. * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/ui/features/tmux-monitor/PanePreview.tsx | 38 ++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/ui/features/tmux-monitor/PanePreview.tsx b/src/ui/features/tmux-monitor/PanePreview.tsx index 87b1ed58..d9581948 100644 --- a/src/ui/features/tmux-monitor/PanePreview.tsx +++ b/src/ui/features/tmux-monitor/PanePreview.tsx @@ -70,6 +70,36 @@ export function PanePreview({ setAttachNonce((n) => n + 1); } + // For Tailscale-auth hosts the generic pane-preview attach path can fail + // host-reachability checks because the connection is initiated as a plain + // TCP/SSH dial rather than through the Tailscale transport that was used for + // the interactive terminal. Building the hostConfig with an explicit + // authType and a defensively derived SSH port ensures the backend selects + // the correct Tailscale-aware PTY path for both initial attach and reattach. + let terminalHostConfig: TerminalHostConfig; + if (host.authType === "tailscale") { + // Prefer host.sshPort when set (Tailscale SSH can be on a non-standard + // port); fall back to the general host.port. + const resolvedPort = host.sshPort ?? host.port; + terminalHostConfig = { + ...host, + port: resolvedPort, + sshPort: resolvedPort, + // Carry authType explicitly to guard against accidental omission + // in the spread (e.g. if host object shape changes upstream). + authType: "tailscale", + instanceId: instanceIdRef.current, + } as TerminalHostConfig; + } else { + const resolvedPort = host.sshPort ?? host.port; + terminalHostConfig = { + ...host, + port: resolvedPort, + sshPort: resolvedPort, + instanceId: instanceIdRef.current, + } as TerminalHostConfig; + } + return ( <>
@@ -147,13 +177,7 @@ export function PanePreview({