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>
This commit is contained in:
Brad Baker
2026-07-23 18:40:02 -05:00
committed by GitHub
co-authored by Copilot Autofix powered by AI copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
parent 096db5c636
commit db0dea08cf
+31 -7
View File
@@ -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 (
<>
<div className="flex items-center gap-3 border-b border-border px-3 py-1.5 text-xs text-muted-foreground">
@@ -147,13 +177,7 @@ export function PanePreview({
<CommandHistoryProvider key={attachNonce}>
<Terminal
ref={terminalRef}
hostConfig={
{
...host,
sshPort: host.port,
instanceId: instanceIdRef.current,
} as TerminalHostConfig
}
hostConfig={terminalHostConfig}
isVisible={true}
title={pane.sessionName}
showTitle={false}