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(server): server e2e tests no longer install hooks into the real ~/.claude
enescd74c3030f89
diff --git a/src/server/config.ts b/src/server/config.tsindex 0e844703f..781c4e766 100644--- a/src/server/config.ts+++ b/src/server/config.ts@@ -12,6 +12,15 @@ export type ServerConfig = {rendererDir: stringinsecureHttp: booleanpasswordSeed?: string+ /**+ * Merge the managed agent hooks into the user's real agent config dirs (~/.claude,+ * ~/.codex, ~/.gemini) at boot. Defaults to true — the server needs them to receive+ * agent status. Tests MUST pass false: the installed hook points at+ * `<dataDir>/agent-hooks/<agent>.sh`, so a temp dataDir that gets removed after the run+ * would leave a dangling hook behind in the developer's real settings.json, breaking+ * every subsequent agent session on the machine.+ */+ installHooks?: boolean}/**diff --git a/src/server/index.ts b/src/server/index.tsindex 0ac3c3931..686f3531f 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -97,11 +97,15 @@ export async function startServer(// the main HTTP server below.initAgentStatusMirror()wireAgentStatus(platform)- try {- // Fail-open: installManagedAgentHooks is itself best-effort, but a throw must never block boot.- installManagedAgentHooks()- } catch (e) {- console.warn('[nodeterm-server] managed hook install failed', e)+ // `installHooks: false` (tests) skips the merge into the user's real ~/.claude et al —+ // the hook it would write points into `dataDir`, which a test then deletes.+ if (config.installHooks !== false) {+ try {+ // Fail-open: installManagedAgentHooks is itself best-effort, but a throw must never block boot.+ installManagedAgentHooks()+ } catch (e) {+ console.warn('[nodeterm-server] managed hook install failed', e)+ }}await hookServer.start()diff --git a/test/server/agent-status-e2e.test.ts b/test/server/agent-status-e2e.test.tsindex a89db06ea..9a21b6068 100644--- a/test/server/agent-status-e2e.test.ts+++ b/test/server/agent-status-e2e.test.ts@@ -35,7 +35,11 @@ describe('agent-status e2e: hook POST → agent:status over ws', () => {dataDir,rendererDir: path.join(dataDir, 'no-renderer'),insecureHttp: false,- passwordSeed: 'agst-e2e-pw'+ passwordSeed: 'agst-e2e-pw',+ // The loopback hook server still boots (that's what this test exercises); we only skip+ // merging the managed hook into the developer's real ~/.claude — it would point into+ // `dataDir`, which afterAll removes, leaving a dangling hook behind.+ installHooks: false})port = srv.portclose = srv.closediff --git a/test/server/files-scm-e2e.test.ts b/test/server/files-scm-e2e.test.tsindex dbb679080..af79ce079 100644--- a/test/server/files-scm-e2e.test.ts+++ b/test/server/files-scm-e2e.test.ts@@ -22,7 +22,10 @@ describe('files/scm e2e: fs.read + git over ws', () => {const srv = await startServer({port: 0, host: '127.0.0.1', dataDir,rendererDir: path.join(dataDir, 'no-renderer'), insecureHttp: false,- passwordSeed: 'scm-e2e-pw'+ passwordSeed: 'scm-e2e-pw',+ // Never touch the developer's real ~/.claude — the hook would point into `dataDir`,+ // which afterAll removes, leaving a dangling hook that breaks every agent session.+ installHooks: false})port = srv.port; close = srv.closeconst res = await fetch(`http://127.0.0.1:${port}/auth/login`, {diff --git a/test/server/hook-install-guard.test.ts b/test/server/hook-install-guard.test.tsnew file mode 100644index 000000000..d55547bec--- /dev/null+++ b/test/server/hook-install-guard.test.ts@@ -0,0 +1,55 @@+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'++// Guard for a bug that bit a developer for real: `startServer` merges the managed agent hooks+// into the user's REAL agent config dirs (~/.claude/settings.json et al), pointing them at+// `<dataDir>/agent-hooks/<agent>.sh`. A test booting the server with a temp `dataDir` and then+// removing it therefore left a DANGLING hook behind in the developer's own settings.json —+// which Claude Code runs on every tool call, so every later session on that machine died.+// `installHooks: false` is the opt-out; every server test must pass it. This test keeps the+// flag honest (and the default — a real deployment does need the hooks installed).+vi.mock('../../src/core/agents/hooks', () => ({ installManagedAgentHooks: vi.fn() }))++import { startServer } from '../../src/server/index'+import { installManagedAgentHooks } from '../../src/core/agents/hooks'++describe('startServer: managed hook install is opt-out-able', () => {+ let dataDir: string+ let close: (() => Promise<void>) | undefined++ beforeEach(() => {+ dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-e2e-hookguard-'))+ vi.mocked(installManagedAgentHooks).mockClear()+ })++ afterEach(async () => {+ await close?.()+ close = undefined+ fs.rmSync(dataDir, { recursive: true, force: true })+ })++ const boot = (installHooks?: boolean) =>+ startServer({+ port: 0,+ host: '127.0.0.1',+ dataDir,+ rendererDir: path.join(dataDir, 'no-renderer'),+ insecureHttp: false,+ passwordSeed: 'hookguard-pw',+ ...(installHooks === undefined ? {} : { installHooks })+ })++ it('does NOT touch the real agent config dirs when installHooks is false', async () => {+ const srv = await boot(false)+ close = srv.close+ expect(installManagedAgentHooks).not.toHaveBeenCalled()+ }, 30_000)++ it('installs the hooks by default (real deployments need them)', async () => {+ const srv = await boot(undefined)+ close = srv.close+ expect(installManagedAgentHooks).toHaveBeenCalledOnce()+ }, 30_000)+})diff --git a/test/server/server-e2e.test.ts b/test/server/server-e2e.test.tsindex 5aaaaaf32..e8b51a2f7 100644--- a/test/server/server-e2e.test.ts+++ b/test/server/server-e2e.test.ts@@ -25,7 +25,10 @@ describe.skipIf(!hasTmux)('server e2e: login → ws → pty echo round-trip', ()const srv = await startServer({port: 0, host: '127.0.0.1', dataDir,rendererDir: path.join(dataDir, 'no-renderer'), insecureHttp: false,- passwordSeed: 'e2e-password-123'+ passwordSeed: 'e2e-password-123',+ // Never touch the developer's real ~/.claude — the hook would point into `dataDir`,+ // which afterAll removes, leaving a dangling hook that breaks every agent session.+ installHooks: false})port = srv.portclose = srv.close