diff --git a/src/App.tsx b/src/App.tsx index 4f6374d..276bd4b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1265,14 +1265,18 @@ export default function App() { case "spawn_pane": { const a = args as { spec?: SpawnSpec }; const summary = a.spec ? `Spawn ${describeSpec(a.spec)} pane` : "Spawn pane"; - const ssh = - a.spec && a.spec.kind === "ssh" - ? { - hostLabel: a.spec.hostId - ? hosts.find((h) => h.id === a.spec!.hostId)?.label ?? a.spec.host - : a.spec.host, - } - : undefined; + // Bind the narrowed SSH variant to a local so the closure inside + // hosts.find() doesn't lose the discriminant. Using a.spec! here + // would compile under tsc --noEmit but fail under tsc -b. + let ssh: { hostLabel: string } | undefined; + if (a.spec && a.spec.kind === "ssh") { + const sshSpec = a.spec; + ssh = { + hostLabel: sshSpec.hostId + ? hosts.find((h) => h.id === sshSpec.hostId)?.label ?? sshSpec.host + : sshSpec.host, + }; + } return { summary, ssh }; } case "connect_host": {