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.

feat(ssh): renderer ssh-servers store, node factory, persistence

enes7d69fcefb15d
diff --git a/src/renderer/state/sshServers.ts b/src/renderer/state/sshServers.ts
new file mode 100644
index 000000000..ef4aa0bb2
--- /dev/null
+++ b/src/renderer/state/sshServers.ts
@@ -0,0 +1,22 @@
+import { create } from 'zustand'
+import type { SshServer } from '@shared/ssh'
+
+interface SshServersState {
+ servers: SshServer[]
+ hydrate(): Promise<void>
+ save(server: SshServer): Promise<void>
+ remove(id: string): Promise<void>
+}
+
+export const useSshServers = create<SshServersState>((set) => ({
+ servers: [],
+ async hydrate() {
+ set({ servers: await window.nodeTerminal.ssh.list() })
+ },
+ async save(server) {
+ set({ servers: await window.nodeTerminal.ssh.save(server) })
+ },
+ async remove(id) {
+ set({ servers: await window.nodeTerminal.ssh.remove(id) })
+ }
+}))
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 2d637d939..fa850cfe9 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -49,6 +49,11 @@ export interface NodeData {
* connection (see flowToNodeStates).
*/
remote?: { connectionId: string }
+ /**
+ * When set, this terminal runs `ssh` to a remote host on the LOCAL PTY (LocalTransport).
+ * Unlike `remote` (relay), this IS persisted — the node auto-reconnects on relaunch.
+ */
+ ssh?: import('@shared/ssh').SshConnection
[key: string]: unknown
}
@@ -127,6 +132,39 @@ export function createRemoteTerminalNode(
}
}
+/**
+ * Creates a terminal node that runs `ssh` to a saved server on the local PTY. The connection
+ * is snapshotted inline (`data.ssh`) so the node survives the server being edited/deleted.
+ */
+export function createSshTerminalNode(
+ server: import('@shared/ssh').SshServer,
+ index: number,
+ center?: { x: number; y: number }
+): CanvasNode {
+ return {
+ id: nextId('ssh'),
+ type: 'terminal',
+ position: placeAt(center, index, TERMINAL_SIZE.width, TERMINAL_SIZE.height),
+ width: TERMINAL_SIZE.width,
+ height: TERMINAL_SIZE.height,
+ style: { width: TERMINAL_SIZE.width, height: TERMINAL_SIZE.height },
+ data: {
+ title: server.label,
+ color: NODE_COLORS[index % NODE_COLORS.length],
+ group: null,
+ tags: [],
+ ssh: {
+ host: server.host,
+ user: server.user,
+ port: server.port,
+ identityFile: server.identityFile,
+ extraArgs: server.extraArgs,
+ label: server.label
+ }
+ }
+ }
+}
+
/**
* Command that launches Claude Code. Detection works via hooks installed globally in
* ~/.claude/settings.json (gated by NODETERM_* env that the PTY manager sets), so a plain
@@ -433,7 +471,8 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
filePath: n.filePath,
diffStaged: n.diffStaged,
commitOid: n.commitOid,
- agentId
+ agentId,
+ ssh: n.ssh
}
}
})
@@ -481,7 +520,8 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
filePath: n.data.filePath,
diffStaged: n.data.diffStaged,
commitOid: n.data.commitOid,
- agentId: n.data.agentId
+ agentId: n.data.agentId,
+ ssh: n.data.ssh
}
})
}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 531b769f8..e4d472835 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -46,6 +46,8 @@ export interface CanvasNodeState {
cwd?: string
/** Which agent runs in this terminal node (claude/codex/gemini/custom). */
agentId?: AgentId
+ /** When set, the terminal runs `ssh` to this host on the local PTY; persisted (auto-reconnects). */
+ ssh?: import('./ssh').SshConnection
// sticky-only
text?: string
// editor / diff