Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(terminal): hide the SSH chip when it only repeats the project's host

review28316198988a
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 767d85323..06638515b 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -250,7 +250,13 @@ import { assembleResumeCommand } from '@shared/agents/launch'
import { agentEnvSnapshot } from '@renderer/lib/agentEnv'
import { normalizedAgentModel } from '@shared/agents/model-gateway'
import { ensureActivePermissionMode } from '../state/permissionMode'
-import { buildSshArgs, sshConnectionIdForProject, sshHostKey, type SshConnection } from '@shared/ssh'
+import {
+ buildSshArgs,
+ sshChipRepeatsProject,
+ sshConnectionIdForProject,
+ sshHostKey,
+ type SshConnection
+} from '@shared/ssh'
import {
chipFor,
commandTooltip,
@@ -1706,6 +1712,17 @@ export function TerminalNode({
// node (`isRemoteSessionNode` — an SSH-project terminal carries `data.ssh`/`data.sshRemoteTmux`).
// The affordance is absent, not merely refused on click.
const sshProject = useProjects((s) => !!s.projects.find((p) => p.id === s.activeProjectId)?.ssh)
+ // The project's SSH endpoint, as two primitives: the project object is rebuilt on every node
+ // serialization, so selecting `ssh.server` itself would re-render this node on each canvas edit.
+ const projectSshHost = useProjects((s) => s.getProject(s.activeProjectId)?.ssh?.server.host)
+ const projectSshUser = useProjects((s) => s.getProject(s.activeProjectId)?.ssh?.server.user)
+ const showSshChip =
+ !!data.ssh &&
+ !sshChipRepeatsProject(
+ data.ssh as SshConnection,
+ !!data.sshRemoteTmux,
+ projectSshHost !== undefined ? { host: projectSshHost, user: projectSshUser ?? '' } : undefined
+ )
const remoteSession = sshProject || isRemoteSessionNode(data)
// "Does this node's session live on another machine?" for the offscreen-dispose gate — asked in
// TWO halves, because the two ways of being remote are independent facts:
@@ -5628,7 +5645,8 @@ export function TerminalNode({
}
warning={accountFallback}
/>
- {data.ssh ? (
+ {/* Only where it says something the project tab does not — see `sshChipRepeatsProject`. */}
+ {showSshChip ? (
<span
className="term-ssh-chip"
title={`ssh ${(data.ssh as SshConnection).user}@${(data.ssh as SshConnection).host}`}
diff --git a/src/shared/ssh.test.ts b/src/shared/ssh.test.ts
index 6c0486cf4..811255851 100644
--- a/src/shared/ssh.test.ts
+++ b/src/shared/ssh.test.ts
@@ -10,6 +10,7 @@ import {
remoteTmuxConf,
parseLsDirs,
sshAttachmentId,
+ sshChipRepeatsProject,
sshConnectionIdForProject,
sshHostKey
} from './ssh'
@@ -111,6 +112,45 @@ describe('sshConnectionIdForProject', () => {
})
})
+describe('sshChipRepeatsProject', () => {
+ const project = { host: '95.217.38.239', user: 'root' }
+
+ it('hides the chip on an SSH-project terminal of that same host', () => {
+ expect(sshChipRepeatsProject(project, true, project)).toBe(true)
+ })
+
+ it('hides it for a remote-tmux node saved under another user: it runs as the project user', () => {
+ // `sshConnectionIdForProject` serves it from the project's master, so a chip naming the
+ // creator's user would not just repeat the project — it would be wrong.
+ expect(sshChipRepeatsProject({ host: '95.217.38.239', user: 'alice' }, true, project)).toBe(true)
+ })
+
+ it('keeps it for a plain `ssh` node as a DIFFERENT user on the same host', () => {
+ // That node runs its own local `ssh alice@host`, so the user is real information.
+ expect(sshChipRepeatsProject({ host: '95.217.38.239', user: 'alice' }, false, project)).toBe(
+ false
+ )
+ expect(sshChipRepeatsProject(project, false, project)).toBe(true)
+ })
+
+ it('keeps it for a node on another host (a host attachment)', () => {
+ expect(sshChipRepeatsProject({ host: 'devbox', user: 'root' }, true, project)).toBe(false)
+ })
+
+ it('keeps it in a LOCAL project, where nothing else says the node is remote', () => {
+ expect(sshChipRepeatsProject(project, false, undefined)).toBe(false)
+ expect(sshChipRepeatsProject(project, true, undefined)).toBe(false)
+ })
+
+ it('a hostless node never matches (undefined === undefined is not a match)', () => {
+ const hostless = { host: undefined, user: 'root' } as unknown as typeof project
+ expect(sshChipRepeatsProject(hostless, true, undefined)).toBe(false)
+ expect(sshChipRepeatsProject({ host: '', user: 'root' }, true, { host: '', user: 'root' })).toBe(
+ false
+ )
+ })
+})
+
describe('parseSshConfig', () => {
it('parses a named host with HostName/User/Port/IdentityFile', () => {
const cfg = `Host prod
diff --git a/src/shared/ssh.ts b/src/shared/ssh.ts
index a3f710f02..5f461eeaa 100644
--- a/src/shared/ssh.ts
+++ b/src/shared/ssh.ts
@@ -190,6 +190,28 @@ export function sshConnectionIdForProject(
: sshAttachmentId(projectId, conn)
}
+/**
+ * Whether a terminal node's `SSH user@host` header chip would only repeat its project: inside an
+ * SSH project every terminal on that host carries one, so the chip said the same thing on every
+ * node and told the user nothing the tab did not. It stays wherever it is information — a node on
+ * a different host (a host attachment), any SSH node in a LOCAL project, and a plain `ssh` node
+ * dialing another user on the project's host.
+ *
+ * The host test is `sshConnectionIdForProject`'s, so the chip disappears exactly for the nodes the
+ * project's own master serves. A remote-tmux node naming another user is one of them: it runs as
+ * the PROJECT's user, so its chip was not just redundant but wrong. A plain `ssh` node
+ * (`sshRemoteTmux` false) runs its own `ssh user@host` and does log in as its own user — for it
+ * the user must match too.
+ */
+export function sshChipRepeatsProject(
+ conn: Pick<SshConnection, 'host' | 'user'>,
+ sshRemoteTmux: boolean,
+ projectServer?: Pick<SshConnection, 'host' | 'user'>
+): boolean {
+ if (!conn.host || projectServer?.host !== conn.host) return false
+ return sshRemoteTmux || conn.user === projectServer.user
+}
+
/**
* Split a raw extra-args string into argv tokens, honoring single and double quotes.
* Unquoted whitespace separates tokens; quotes group; quote chars are stripped.