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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(ssh-project): Connect-over-SSH creation flow + remote dir browse + status
enes62a6b587e6c0
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex f9096edf1..035ba3acc 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -66,6 +66,7 @@ import type { SessionNodeInput } from '../lib/sessionList'import { UsageIndicator } from '../components/UsageIndicator'import { RemoteSessionView } from './RemoteSessionView'import { RemoteAccessDialog } from '../components/RemoteAccessDialog'+import { SshProjectDialog } from '../components/SshProjectDialog'import { transport } from '../terminal/local-transport'import { prepareQuickOpenFiles, type QuickOpenIndexedFile } from '../lib/quickOpenSearch'import { opensInEditor } from '../lib/openTarget'@@ -92,8 +93,10 @@ import { useSettings } from '../state/settings'import { useContextWindow } from '../state/contextWindow'import { useSessionNaming } from '../state/sessionNaming'import { useSshServers } from '../state/sshServers'+import { useSshConn } from '../state/sshConn'import { requireProOr } from '../state/upgradeGate'import type { SshServer } from '@shared/ssh'+import type { SshProjectStatus } from '@shared/types'import {applyCanvasMutation,claudeLaunchCommand,@@ -172,6 +175,10 @@ export function Canvas() {// When set, a full-surface remote mirror of a connected host is shown over the local canvas.const [remoteConnId, setRemoteConnId] = useState<string | null>(null)const [remoteDialogOpen, setRemoteDialogOpen] = useState(false)+ // "Connect over SSH…" project-creation dialog (from the Welcome screen).+ const [sshDialogOpen, setSshDialogOpen] = useState(false)+ // Live SSH ControlMaster status per project id (drives the thin connection banner).+ const [sshStatus, setSshStatus] = useState<Record<string, SshProjectStatus>>({})// A client has finished the handshake and is awaiting this host's approval (carries the SAS).const [pendingPeer, setPendingPeer] = useState<{ sas: string | null } | null>(null)const [confirm, setConfirm] = useState<{@@ -215,6 +222,10 @@ export function Canvas() {const activeProjectId = useProjects((s) => s.activeProjectId)const hasProjects = useProjects((s) => s.projects.length > 0)+ // The active project's SSH server (if it's an SSH project) — drives the connection banner.+ const activeSshServer = useProjects(+ (s) => s.projects.find((p) => p.id === s.activeProjectId)?.ssh?.server+ )nodesRef.current = nodesconst nodeTypes = useMemo(@@ -489,6 +500,17 @@ export function Canvas() {if (!activeProjectId) returnconst project = useProjects.getState().getProject(activeProjectId)if (!project) return+ // SSH project: (re)open its ControlMaster and record the controlPath so this project's+ // terminal nodes can run over it. Idempotent in main (a live master is reused), so a tab+ // switch back to a connected project is a no-op. Remote tmux is unaffected by the master.+ if (project.ssh) {+ window.nodeTerminal.sshProject+ .connect(project.id, project.ssh.server)+ .then(({ controlPath }) => useSshConn.getState().setControlPath(project.id, controlPath))+ .catch(() => {+ /* status surfaced via onStatus → the connection banner */+ })+ }loadingRef.current = trueconst flow = nodeStatesToFlow(project.nodes)setNodes(flow)@@ -854,9 +876,12 @@ export function Canvas() {const addTerminal = useCallback((center?: { x: number; y: number }, initialCommand?: string, groupId?: string) => {- const cwd = cwdForNewNodeIn(groupId) ?? useProjects.getState().getProject(activeProjectId)?.cwd+ const project = useProjects.getState().getProject(activeProjectId)+ const cwd = cwdForNewNodeIn(groupId) ?? project?.cwdsetNodes((ns) => {- const node = createTerminalNode(ns.length, cwd, center ?? viewCenter(), initialCommand)+ // In an SSH project the node is stamped remote (runs over the project's master); the+ // factory takes the project's ssh and roots the terminal at its remoteCwd.+ const node = createTerminalNode(ns.length, cwd, center ?? viewCenter(), initialCommand, project?.ssh)return [...ns, groupId ? parentInto(node, groupId) : node]})markDirty()@@ -1021,9 +1046,10 @@ export function Canvas() {const addAgentNode = useCallback((agentId: AgentId, center?: { x: number; y: number }, groupId?: string) => {- const cwd = cwdForNewNodeIn(groupId) ?? useProjects.getState().getProject(activeProjectId)?.cwd+ const project = useProjects.getState().getProject(activeProjectId)+ const cwd = cwdForNewNodeIn(groupId) ?? project?.cwdsetNodes((ns) => {- const node = createAgentNode(agentId, ns.length, cwd, center ?? viewCenter())+ const node = createAgentNode(agentId, ns.length, cwd, center ?? viewCenter(), undefined, project?.ssh)return [...ns, groupId ? parentInto(node, groupId) : node]})markDirty()@@ -2144,6 +2170,27 @@ export function Canvas() {void useSshServers.getState().hydrate()}, [])+ // Track SSH project connection status for the thin connection banner (keyed by project id).+ useEffect(() => {+ return window.nodeTerminal.sshProject.onStatus((e) =>+ setSshStatus((prev) => ({ ...prev, [e.projectId]: e.status }))+ )+ }, [])++ // Create an SSH project from the dialog: commit the current canvas, add + switch to the new+ // project (its master is opened by the active-project effect on switch), persist.+ const createSshProject = useCallback(+ (input: { server: SshServer; remoteCwd: string; label: string }) => {+ commitActiveToStore()+ const project = useProjects+ .getState()+ .addProject(input.label, undefined, { server: input.server, remoteCwd: input.remoteCwd })+ useProjects.getState().setActive(project.id)+ void writeDisk()+ },+ [commitActiveToStore, writeDisk]+ )+const addProject = useCallback(() => {commitActiveToStore()const project = useProjects.getState().addProject()@@ -2191,10 +2238,17 @@ export function Canvas() {if (id === store.activeProjectId) commitActiveToStore()// End the tmux sessions of every terminal in the deleted project, and drop their// persisted agent status (node unmount no longer removes it).- store.getProject(id)?.nodes.forEach((n) => {+ const project = store.getProject(id)+ project?.nodes.forEach((n) => {if ((n.kind ?? 'terminal') === 'terminal') transport.destroy(n.id)useAgentStatus.getState().remove(n.id)})+ // SSH project: tear down its ControlMaster (after the terminals' remote tmux sessions are+ // ended above) and drop the cached controlPath.+ if (project?.ssh) {+ void window.nodeTerminal.sshProject.disconnect(id)+ useSshConn.getState().clear(id)+ }store.deleteProject(id)void writeDisk()},@@ -2310,6 +2364,47 @@ export function Canvas() {<div className="top-banners"><AnnouncementBanner />+ {activeSshServer &&+ sshStatus[activeProjectId] &&+ sshStatus[activeProjectId] !== 'connected' &&+ (() => {+ const st = sshStatus[activeProjectId]+ const isError = st === 'error' || st === 'disconnected'+ const text =+ st === 'connecting'+ ? `Connecting to ${activeSshServer.label}…`+ : st === 'reconnecting'+ ? `Reconnecting to ${activeSshServer.label}…`+ : st === 'disconnected'+ ? `Disconnected from ${activeSshServer.label}`+ : `SSH connection error — ${activeSshServer.label}`+ return (+ <div+ title={`${activeSshServer.user}@${activeSshServer.host}`}+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: 8,+ padding: '6px 12px',+ fontSize: 12,+ color: 'var(--text)',+ background: isError ? 'rgba(120,40,40,0.92)' : 'rgba(90,72,30,0.92)',+ border: '1px solid var(--border)',+ borderRadius: 8+ }}+ >+ <span+ style={{+ width: 8,+ height: 8,+ borderRadius: '50%',+ background: isError ? '#ff6b6b' : '#e0b341'+ }}+ />+ {text}+ </div>+ )+ })()}</div><UpdateCard />@@ -2430,6 +2525,10 @@ export function Canvas() {setWelcomeOpen(false)void cloneRepo()}}+ onConnectSsh={() => {+ setWelcomeOpen(false)+ setSshDialogOpen(true)+ }}onClose={hasProjects ? () => setWelcomeOpen(false) : undefined}/>)}@@ -2443,6 +2542,17 @@ export function Canvas() {{remoteDialogOpen && <RemoteAccessDialog onClose={() => setRemoteDialogOpen(false)} />}+ {sshDialogOpen && (+ <SshProjectDialog+ onCreate={createSshProject}+ onManage={() => {+ setSettingsSection('ssh')+ setSettingsOpen(true)+ }}+ onClose={() => setSshDialogOpen(false)}+ />+ )}+{menu && (<ContextMenu x={menu.x} y={menu.y} items={menu.items} onClose={() => setMenu(null)} />)}diff --git a/src/renderer/components/SshProjectDialog.tsx b/src/renderer/components/SshProjectDialog.tsxnew file mode 100644index 000000000..0122ea563--- /dev/null+++ b/src/renderer/components/SshProjectDialog.tsx@@ -0,0 +1,285 @@+import { useCallback, useEffect, useRef, useState } from 'react'+import { createPortal } from 'react-dom'+import { useSshServers } from '../state/sshServers'+import type { SshServer } from '@shared/ssh'++interface SshProjectDialogProps {+ /** Create the SSH project (Canvas commits the active canvas, adds + switches to it). */+ onCreate: (input: { server: SshServer; remoteCwd: string; label: string }) => void+ /** Open Settings → SSH so the user can add/manage saved servers. */+ onManage: () => void+ onClose: () => void+}++type Step = 'pick' | 'connecting' | 'browse' | 'error'++/** Shared style for a clickable row (server / remote folder). Hover/focus left to defaults. */+const ROW_STYLE: React.CSSProperties = {+ display: 'flex',+ flexDirection: 'column',+ alignItems: 'flex-start',+ gap: 2,+ width: '100%',+ textAlign: 'left',+ padding: '8px 11px',+ background: 'var(--panel-header)',+ border: '1px solid var(--border)',+ borderRadius: 8,+ color: 'var(--text)',+ fontSize: 13,+ cursor: 'pointer'+}++/** Basename of an absolute remote path (for the project label). */+function baseName(p: string): string {+ const trimmed = p.replace(/\/+$/, '')+ const seg = trimmed.split('/').filter(Boolean).pop()+ return seg || trimmed || '~'+}++/** Parent directory of an absolute remote path; stops at '/'. */+function parentDir(p: string): string {+ const trimmed = p.replace(/\/+$/, '')+ const idx = trimmed.lastIndexOf('/')+ if (idx <= 0) return '/'+ return trimmed.slice(0, idx)+}++/**+ * "Connect over SSH…" project creation flow: pick a saved server, open its ControlMaster,+ * browse the remote filesystem, and create an SSH project rooted at the chosen folder.+ *+ * The browse uses a throwaway connection (a temporary project id) so the dialog never needs a+ * project id before one exists; Canvas establishes the project's real master on switch. The+ * temporary master is torn down on create/cancel.+ */+export function SshProjectDialog({ onCreate, onManage, onClose }: SshProjectDialogProps) {+ const servers = useSshServers((s) => s.servers)+ const [step, setStep] = useState<Step>('pick')+ const [server, setServer] = useState<SshServer | null>(null)+ const [path, setPath] = useState('~')+ const [dirs, setDirs] = useState<string[]>([])+ const [error, setError] = useState('')+ // Stable id for the temporary browse master, generated once.+ const browseIdRef = useRef(`ssh-browse-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`)+ const connectedRef = useRef(false)++ // Tear down the temporary browse master (best-effort) once it's no longer needed.+ const disconnectBrowse = useCallback(() => {+ if (connectedRef.current) {+ connectedRef.current = false+ void window.nodeTerminal.sshProject.disconnect(browseIdRef.current)+ }+ }, [])++ const close = useCallback(() => {+ disconnectBrowse()+ onClose()+ }, [disconnectBrowse, onClose])++ useEffect(() => {+ const onKey = (e: KeyboardEvent) => {+ if (e.key === 'Escape') close()+ }+ window.addEventListener('keydown', onKey)+ return () => window.removeEventListener('keydown', onKey)+ }, [close])++ // Disconnect the browse master if the dialog unmounts without an explicit close.+ useEffect(() => () => disconnectBrowse(), [disconnectBrowse])++ const list = useCallback(async (dir: string) => {+ const res = await window.nodeTerminal.sshProject.listDir(browseIdRef.current, dir)+ setPath(res.path)+ setDirs(res.dirs)+ }, [])++ const connect = useCallback(+ async (srv: SshServer) => {+ setServer(srv)+ setError('')+ setStep('connecting')+ try {+ await window.nodeTerminal.sshProject.connect(browseIdRef.current, srv)+ connectedRef.current = true+ await list('~')+ setStep('browse')+ } catch (err) {+ setError((err as Error)?.message || 'Could not connect to the server.')+ setStep('error')+ }+ },+ [list]+ )++ const useThisFolder = useCallback(() => {+ if (!server) return+ disconnectBrowse()+ onCreate({ server, remoteCwd: path, label: `${baseName(path)} · ${server.label}` })+ onClose()+ }, [server, path, disconnectBrowse, onCreate, onClose])++ const body = (() => {+ if (step === 'pick') {+ return (+ <>+ <p className="confirm__msg" style={{ fontWeight: 600 }}>+ Connect over SSH+ </p>+ <p className="confirm__msg">Pick a saved server to host this project's terminals.</p>+ <div style={{ display: 'flex', flexDirection: 'column', gap: 6, margin: '6px 0 14px' }}>+ {servers.length === 0 ? (+ <p className="confirm__msg" style={{ opacity: 0.7 }}>+ No saved servers yet.+ </p>+ ) : (+ servers.map((s) => (+ <button+ key={s.id}+ style={ROW_STYLE}+ title={`${s.user}@${s.host}`}+ onClick={() => void connect(s)}+ >+ <span style={{ fontWeight: 600 }}>{s.label}</span>+ <span style={{ opacity: 0.6, fontSize: 12 }}>+ {s.user}@{s.host}+ </span>+ </button>+ ))+ )}+ </div>+ <div className="confirm__actions">+ <button className="confirm__btn" onClick={close}>+ Cancel+ </button>+ <button+ className="confirm__btn primary"+ onClick={() => {+ onManage()+ close()+ }}+ >+ Add server…+ </button>+ </div>+ </>+ )+ }+ if (step === 'connecting') {+ return (+ <>+ <p className="confirm__msg" style={{ fontWeight: 600 }}>+ Connecting to {server?.label}…+ </p>+ <p className="confirm__msg" style={{ opacity: 0.7 }}>+ Establishing the SSH connection.+ </p>+ <div className="confirm__actions">+ <button className="confirm__btn" onClick={close}>+ Cancel+ </button>+ </div>+ </>+ )+ }+ if (step === 'error') {+ return (+ <>+ <p className="confirm__msg" style={{ fontWeight: 600 }}>+ Connection failed+ </p>+ <p className="confirm__msg" style={{ opacity: 0.8 }}>+ {error}+ </p>+ <div className="confirm__actions">+ <button className="confirm__btn" onClick={close}>+ Close+ </button>+ <button+ className="confirm__btn primary"+ onClick={() => server && void connect(server)}+ >+ Retry+ </button>+ </div>+ </>+ )+ }+ // browse+ const atRoot = path === '/'+ return (+ <>+ <p className="confirm__msg" style={{ fontWeight: 600 }}>+ Choose a folder on {server?.label}+ </p>+ <div+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: 8,+ margin: '4px 0 8px',+ fontSize: 12,+ color: 'var(--muted)'+ }}+ >+ <button+ className="confirm__btn"+ style={{ padding: '3px 9px' }}+ disabled={atRoot}+ onClick={() => void list(parentDir(path))}+ >+ ↑ Up+ </button>+ <span+ title={path}+ style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}+ >+ {path}+ </span>+ </div>+ <div+ style={{+ maxHeight: 240,+ overflowY: 'auto',+ border: '1px solid var(--border)',+ borderRadius: 8,+ margin: '0 0 14px'+ }}+ >+ {dirs.length === 0 ? (+ <p className="confirm__msg" style={{ opacity: 0.6, padding: '10px 12px' }}>+ No sub-folders here.+ </p>+ ) : (+ dirs.map((d) => (+ <button+ key={d}+ style={{ ...ROW_STYLE, border: 'none', borderRadius: 0, background: 'transparent' }}+ onClick={() => void list(`${path.replace(/\/+$/, '')}/${d}`)}+ >+ <span>📁 {d}</span>+ </button>+ ))+ )}+ </div>+ <div className="confirm__actions">+ <button className="confirm__btn" onClick={close}>+ Cancel+ </button>+ <button className="confirm__btn primary" onClick={useThisFolder}>+ Use this folder+ </button>+ </div>+ </>+ )+ })()++ return createPortal(+ <div className="confirm-overlay" onClick={close}>+ <div className="confirm" style={{ width: 440 }} onClick={(e) => e.stopPropagation()}>+ {body}+ </div>+ </div>,+ document.body+ )+}diff --git a/src/renderer/components/WelcomeScreen.tsx b/src/renderer/components/WelcomeScreen.tsxindex 842af5938..4d46eaf34 100644--- a/src/renderer/components/WelcomeScreen.tsx+++ b/src/renderer/components/WelcomeScreen.tsx@@ -4,6 +4,8 @@ interface WelcomeScreenProps {onNewProject: () => voidonOpenFolder: () => voidonCloneRepo: () => void+ /** Open the "Connect over SSH…" flow to create a project hosted on a remote server. */+ onConnectSsh: () => void/*** When provided, the screen is dismissable (opened on demand via "+", over existing projects)* — adds a close button, Escape, and click-outside. Omitted for the permanent no-projects screen.@@ -12,7 +14,13 @@ interface WelcomeScreenProps {}/** Start screen with quick actions — shown when there are no projects, or on demand via "+". */-export function WelcomeScreen({ onNewProject, onOpenFolder, onCloneRepo, onClose }: WelcomeScreenProps) {+export function WelcomeScreen({+ onNewProject,+ onOpenFolder,+ onCloneRepo,+ onConnectSsh,+ onClose+}: WelcomeScreenProps) {useEffect(() => {if (!onClose) returnconst onKey = (e: KeyboardEvent) => {@@ -95,6 +103,14 @@ export function WelcomeScreen({ onNewProject, onOpenFolder, onCloneRepo, onClose</svg><span>Clone repo…</span></button>++ <button className="welcome__card" onClick={onConnectSsh}>+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round">+ <rect x="3" y="5" width="18" height="14" rx="2" />+ <path d="M7 10l3 2-3 2M13 14h4" />+ </svg>+ <span>Connect over SSH…</span>+ </button></div></div>)diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex dc5efea7a..3477cf4ae 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -26,6 +26,8 @@ import { isZoomModifierHeld } from '../lib/zoomModifier'import { useSettings } from '../state/settings'import { useAgentStatus } from '../state/agentStatus'import { useAgentNodes } from '../state/agentNodes'+import { useProjects } from '../state/projects'+import { useSshConn } from '../state/sshConn'import { COLLAPSED_HEIGHT, NODE_COLORS, type CanvasNode } from '../state/workspace'import { hasHooks, canRecur, canContextLink, hasUsage, canChat, canResume, resumeCommand, agentConfig, type AgentId } from '@shared/agents/config'import { buildSshArgs, type SshConnection } from '@shared/ssh'@@ -35,6 +37,41 @@ function escapeDroppedPath(p: string): string {return p.replace(/([ \t"'`\\()&;|<>$!*?[\]{}#~])/g, '\\$1')}+/**+ * Resolve the `sshRemote` create option for an SSH-project terminal: the owning project's live+ * ControlMaster `controlPath` (set by Canvas's active-project effect on connect) plus the inline+ * connection and remote cwd. The controlPath may not be ready yet on a cold app load (child+ * effects run before the parent's connect resolves), so wait for it — briefly — before spawning.+ * Returns undefined if no master appears within the window (connection failed); the caller then+ * degrades gracefully instead of spawning a local tmux in a non-existent remote directory.+ */+async function resolveSshRemote(+ conn: SshConnection,+ cwd: string | undefined+): Promise<{ controlPath: string; conn: SshConnection; remoteCwd: string } | undefined> {+ const projectId = useProjects.getState().activeProjectId+ let controlPath = useSshConn.getState().getControlPath(projectId)+ if (!controlPath) {+ controlPath = await new Promise<string | undefined>((resolve) => {+ let settled = false+ const finish = (v?: string) => {+ if (settled) return+ settled = true+ clearTimeout(timer)+ unsub()+ resolve(v)+ }+ const unsub = useSshConn.subscribe((s) => {+ const v = s.byProject[projectId]+ if (v) finish(v)+ })+ const timer = setTimeout(() => finish(useSshConn.getState().getControlPath(projectId)), 20000)+ })+ }+ if (!controlPath) return undefined+ return { controlPath, conn, remoteCwd: cwd || '~' }+}+/*** Move-into-worktree handler bridge. Like GroupNode's worktree-action bridge: React Flow* instantiates custom nodes itself, so Canvas can't pass this callback through props. Canvas@@ -234,21 +271,38 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasN}const ssh = data.ssh as SshConnection | undefined+ // An SSH-project node (`sshRemoteTmux`) runs its tmux on the remote host over the project's+ // ControlMaster (`sshRemote`); a plain ssh-terminal node (createSshTerminalNode) instead runs+ // `ssh` as a LOCAL pty program. Only the latter sets shell:'ssh' + buildSshArgs.+ const sshRemoteTmux = !!data.sshRemoteTmux+ const localSsh = !!ssh && !sshRemoteTmux// Prefetch the persisted scrollback in parallel with the spawn so it's ready to replay the// instant the session resolves (a cold restart after a reboot recreates the tmux session// empty — see the `fresh` handling below). Cheap no-op ('') when there's no snapshot.const scrollbackPromise = window.nodeTerminal.pty.readScrollback(id).catch(() => '')- transport- .create({- cols: term.cols,- rows: term.rows,- shell: ssh ? 'ssh' : data.shell,- shellArgs: ssh ? buildSshArgs(ssh) : undefined,- cwd: data.cwd,- persistKey: id,- agentId: data.agentId- })- .then(async ({ sessionId: sid, fresh }) => {+ void (async () => {+ // SSH-project terminal: the project's live ControlMaster controlPath is established by+ // Canvas's active-project effect. On a cold app load child effects run before that parent+ // connect, so wait for it (briefly) before spawning. In Phase 1 a node only exists in the+ // active project's React Flow, so the active project is its owner.+ const sshRemote =+ sshRemoteTmux && ssh+ ? await resolveSshRemote(ssh, data.cwd as string | undefined)+ : undefined+ if (disposed) return+ transport+ .create({+ cols: term.cols,+ rows: term.rows,+ shell: localSsh ? 'ssh' : data.shell,+ shellArgs: localSsh ? buildSshArgs(ssh) : undefined,+ // Don't spawn a LOCAL tmux in a non-existent remote cwd if the master never came up.+ cwd: sshRemoteTmux && !sshRemote ? undefined : data.cwd,+ persistKey: id,+ agentId: data.agentId,+ sshRemote+ })+ .then(async ({ sessionId: sid, fresh }) => {if (disposed) {transport.kill(sid)return@@ -312,6 +366,7 @@ export function TerminalNode({ id, data, selected, parentId }: NodeProps<CanvasNif (cmd) transport.write(sid, `${cmd}\n`)}})+ })()const resize = () => {try {diff --git a/src/renderer/state/sshConn.ts b/src/renderer/state/sshConn.tsnew file mode 100644index 000000000..87d320dec--- /dev/null+++ b/src/renderer/state/sshConn.ts@@ -0,0 +1,31 @@+import { create } from 'zustand'++/**+ * Transient map of SSH project id → the live ControlMaster `controlPath` returned by+ * `sshProject.connect`. Not persisted: it's re-established on every launch by Canvas's+ * active-project effect. A remote terminal node reads its project's controlPath here to pass+ * `sshRemote` into `transport.create`, so the PTY runs over the project's master.+ */+interface SshConnState {+ byProject: Record<string, string>+ setControlPath(projectId: string, controlPath: string): void+ getControlPath(projectId: string): string | undefined+ clear(projectId: string): void+}++export const useSshConn = create<SshConnState>((set, get) => ({+ byProject: {},+ setControlPath(projectId, controlPath) {+ set((s) => ({ byProject: { ...s.byProject, [projectId]: controlPath } }))+ },+ getControlPath(projectId) {+ return get().byProject[projectId]+ },+ clear(projectId) {+ set((s) => {+ const next = { ...s.byProject }+ delete next[projectId]+ return { byProject: next }+ })+ }+}))