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
fix(ssh-hooks): per-project remote endpoint file so a folder-picker browse can't kill hook delivery
enes9b5fc62b3c76
diff --git a/src/main/remote-ssh/remote-hooks.test.ts b/src/main/remote-ssh/remote-hooks.test.tsindex a31e165a9..5aab30a6e 100644--- a/src/main/remote-ssh/remote-hooks.test.ts+++ b/src/main/remote-ssh/remote-hooks.test.ts@@ -20,12 +20,16 @@ describe('RemoteHooks.setup', () => {it('opens a reverse forward, writes the endpoint file, and installs the managed hook for claude', async () => {const { rh, calls } = mk()const res = await rh.setup('p1', conn, '/s.sock', { port: 51234, token: 'tok', version: '1' })- expect(res?.endpointPath).toBe('/home/u/.nodeterm/hook-endpoint.env')+ // Endpoint file is PER-PROJECT (was a single shared hook-endpoint.env): each connection —+ // real project OR a transient folder-picker browse — has its own reverse-tunnel socket, so a+ // shared file let the last writer (often a short-lived browse whose tunnel then died) point+ // every session at a dead socket, silently killing hook delivery for all real projects.+ expect(res?.endpointPath).toBe('/home/u/.nodeterm/hook-endpoint-p1.env')const joined = calls.map((c) => c.args.join(' '))// reverse forward binds the ABSOLUTE remote socket (no unexpanded ~).expect(joined.some((j) => j.includes('-O forward') && j.includes('/home/u/.nodeterm/hook-p1.sock:127.0.0.1:51234'))).toBe(true)- // endpoint file written to the absolute path, with the absolute sock + token.- expect(joined.some((j) => j.includes('cat > /home/u/.nodeterm/hook-endpoint.env'))).toBe(true)+ // endpoint file written to the absolute PER-PROJECT path, with the absolute sock + token.+ expect(joined.some((j) => j.includes('cat > /home/u/.nodeterm/hook-endpoint-p1.env'))).toBe(true)expect(calls.some((c) =>@@ -43,6 +47,18 @@ describe('RemoteHooks.setup', () => {// no unexpanded tilde survives in any remote path/command.expect(joined.some((j) => j.includes('~/'))).toBe(false)})++ it('gives two different projects (or a browse) distinct endpoint files — no shared clobber', async () => {+ const a = await mk().rh.setup('proj', conn, '/s', { port: 1, token: 't', version: '1' })+ const { rh, calls } = mk()+ const b = await rh.setup('ssh-browse-xyz', conn, '/s', { port: 2, token: 't', version: '1' })+ expect(a?.endpointPath).toBe('/home/u/.nodeterm/hook-endpoint-proj.env')+ expect(b?.endpointPath).toBe('/home/u/.nodeterm/hook-endpoint-ssh-browse-xyz.env')+ // the browse writes ITS OWN endpoint file, never the real project's.+ const joined = calls.map((c) => c.args.join(' '))+ expect(joined.some((j) => j.includes('cat > /home/u/.nodeterm/hook-endpoint-ssh-browse-xyz.env'))).toBe(true)+ expect(joined.some((j) => j.includes('hook-endpoint-proj.env'))).toBe(false)+ })})describe('RemoteHooks.ensureFullscreenTui', () => {diff --git a/src/main/remote-ssh/remote-hooks.ts b/src/main/remote-ssh/remote-hooks.tsindex 097513c3e..bea063c48 100644--- a/src/main/remote-ssh/remote-hooks.ts+++ b/src/main/remote-ssh/remote-hooks.ts@@ -53,7 +53,14 @@ export class RemoteHooks {if (code !== 0 || !home) return null // fail-open: nothing else would workconst remoteDir = `${home}/.nodeterm`const sock = `${remoteDir}/hook-${projectId}.sock`- const endpoint = `${remoteDir}/hook-endpoint.env`+ // PER-PROJECT endpoint file. The sock is already per-project, but the endpoint file used to+ // be a single shared `hook-endpoint.env`: every connect — a real project AND every transient+ // folder-picker browse (projectId `ssh-browse-*`, same connect() path) — overwrote it with+ // its own sock. A browse's tunnel dies when the picker closes, leaving the shared file+ // pointing at a dead socket, so every real project's hook POSTs (`curl --unix-socket`) failed+ // silently → no status badge / context meter / subagent cards / session-name sync on ANY SSH+ // node. A per-project file means each session sources ITS OWN project's live sock.+ const endpoint = `${remoteDir}/hook-endpoint-${projectId}.env`// 1. reverse unix-socket forward (stale socket → remove first so -R can bind).await this.r.run(childArgs(conn, controlPath, `mkdir -p ${remoteDir} && rm -f ${sock}`))await this.r.run(hookForwardArgs(conn, controlPath, sock, hook.port))