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-project): projects store + factory remote stamping

enes88c88d74843f
diff --git a/src/renderer/state/projects.ts b/src/renderer/state/projects.ts
index c5a500c8f..6dab235b5 100644
--- a/src/renderer/state/projects.ts
+++ b/src/renderer/state/projects.ts
@@ -11,7 +11,7 @@ interface ProjectsState {
setActive(id: string): void
/** Adds a new project and returns it (caller commits the current canvas first). */
- addProject(name?: string, cwd?: string): Project
+ addProject(name?: string, cwd?: string, ssh?: Project['ssh']): Project
renameProject(id: string, name: string): void
setProjectCwd(id: string, cwd: string): void
/** Writes the serialized canvas (nodes + viewport + bridge links) back into a project. */
@@ -84,8 +84,8 @@ export const useProjects = create<ProjectsState>((set, get) => ({
set({ activeProjectId: id })
},
- addProject(name, cwd) {
- const project = createProject(get().projects.length, name, cwd)
+ addProject(name, cwd, ssh) {
+ const project = createProject(get().projects.length, name, cwd, ssh)
set((s) => ({ projects: [...s.projects, project] }))
return project
},
diff --git a/src/renderer/state/workspace.ts b/src/renderer/state/workspace.ts
index 5bf49e967..2a3062765 100644
--- a/src/renderer/state/workspace.ts
+++ b/src/renderer/state/workspace.ts
@@ -65,6 +65,11 @@ export interface NodeData {
* Unlike `remote` (relay), this IS persisted — the node auto-reconnects on relaunch.
*/
ssh?: import('@shared/ssh').SshConnection
+ /**
+ * When true (SSH-project terminals), this node runs in REMOTE tmux on the host in `ssh`
+ * (LocalTransport passes `sshRemote` to the PTY), rather than plain `ssh`-on-local-PTY. Persisted.
+ */
+ sshRemoteTmux?: boolean
[key: string]: unknown
}
@@ -91,12 +96,17 @@ function placeAt(center: { x: number; y: number } | undefined, index: number, w:
return center ? { x: center.x - w / 2, y: center.y - h / 2 } : staggeredPosition(index)
}
-/** Creates a new terminal node. `cwd` comes from the active project's default folder. */
+/**
+ * Creates a new terminal node. `cwd` comes from the active project's default folder. When `ssh`
+ * (the active SSH project's binding) is given, the node runs in REMOTE tmux on that host: its
+ * `data.ssh`/`data.sshRemoteTmux`/`data.cwd` are stamped from the binding instead of `cwd`.
+ */
export function createTerminalNode(
index: number,
cwd?: string,
center?: { x: number; y: number },
- initialCommand?: string
+ initialCommand?: string,
+ ssh?: Project['ssh']
): CanvasNode {
return {
id: nextId('term'),
@@ -110,8 +120,9 @@ export function createTerminalNode(
color: NODE_COLORS[index % NODE_COLORS.length],
group: null,
tags: [],
- cwd,
- initialCommand
+ cwd: ssh ? ssh.remoteCwd : cwd,
+ initialCommand,
+ ...(ssh ? { ssh: ssh.server, sshRemoteTmux: true } : {})
}
}
}
@@ -212,7 +223,8 @@ export function createAgentNode(
index: number,
cwd?: string,
center?: { x: number; y: number },
- initialPrompt?: string
+ initialPrompt?: string,
+ ssh?: Project['ssh']
): CanvasNode {
const { label, color, launchCmd } = resolveAgent(agentId)
const baseCmd = agentId === 'claude' ? claudeLaunchCommand() : launchCmd
@@ -232,8 +244,9 @@ export function createAgentNode(
group: null,
tags: [],
agentId,
- cwd,
- initialCommand
+ cwd: ssh ? ssh.remoteCwd : cwd,
+ initialCommand,
+ ...(ssh ? { ssh: ssh.server, sshRemoteTmux: true } : {})
}
}
}
@@ -354,13 +367,19 @@ export function createGroupNode(
}
}
-/** Creates a new project. */
-export function createProject(index: number, name?: string, cwd?: string): Project {
+/** Creates a new project. When `ssh` is set, this is an SSH project (its terminals run remote). */
+export function createProject(
+ index: number,
+ name?: string,
+ cwd?: string,
+ ssh?: Project['ssh']
+): Project {
return {
id: nextId('project'),
name: name ?? `Project ${index + 1}`,
color: NODE_COLORS[index % NODE_COLORS.length],
cwd,
+ ...(ssh ? { ssh } : {}),
viewport: { x: 0, y: 0, zoom: 1 },
nodes: []
}
@@ -585,6 +604,7 @@ export function nodeStatesToFlow(states: CanvasNodeState[]): CanvasNode[] {
highScore: n.highScore,
agentId,
ssh: n.ssh,
+ sshRemoteTmux: n.sshRemoteTmux,
worktree: n.worktree
}
}
@@ -638,6 +658,7 @@ export function flowToNodeStates(nodes: CanvasNode[]): CanvasNodeState[] {
highScore: n.data.highScore,
agentId: n.data.agentId,
ssh: n.data.ssh,
+ sshRemoteTmux: n.data.sshRemoteTmux,
worktree: n.data.worktree
}
})
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 1ed509136..eb081c976 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -62,6 +62,8 @@ export interface CanvasNodeState {
agentId?: AgentId
/** When set, the terminal runs `ssh` to this host on the local PTY; persisted (auto-reconnects). */
ssh?: import('./ssh').SshConnection
+ /** When true (SSH-project terminals), the node runs in REMOTE tmux on `ssh` rather than `ssh`-on-local-PTY. */
+ sshRemoteTmux?: boolean
// sticky-only
text?: string
// dino-only: best score reached in the T-Rex Runner game.