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(server): git + commit handlers, wired into boot (registerCoreHandlers)
enes12cd520e9e0b
diff --git a/src/server/handlers/index.test.ts b/src/server/handlers/index.test.tsnew file mode 100644index 000000000..2ecb6748d--- /dev/null+++ b/src/server/handlers/index.test.ts@@ -0,0 +1,59 @@+import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'+import { execFileSync } from 'child_process'+import { ServerPlatform } from '../platform-server'+import { registerCoreHandlers } from './index'+import { IPC } from '../../shared/ipc'+import { DEFAULT_SETTINGS, type GitStatus } from '../../shared/types'+import { initPlatform, resetPlatformForTests } from '../../core/platform'++let repo: string, platform: ServerPlatform, ui: number+beforeEach(() => {+ repo = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-git-'))+ const git = (...a: string[]) => execFileSync('git', a, { cwd: repo })+ git('init', '-q')+ git('config', 'user.email', 't@t')+ git('config', 'user.name', 't')+ fs.writeFileSync(path.join(repo, 'a.txt'), 'one\n')+ git('add', '.')+ git('commit', '-qm', 'init')+ fs.writeFileSync(path.join(repo, 'a.txt'), 'two\n')+ platform = new ServerPlatform({ userDataDir: repo, appVersion: '0' })+ // GitService.registerIpc() registers via the global core platform(), so wire it here+ // (boot does this via initPlatform() before registerCoreHandlers — mirror that order).+ initPlatform(platform)+ registerCoreHandlers(platform, { getSettings: () => DEFAULT_SETTINGS })+ ui = platform.attach({ sendText: () => {}, sendBinary: () => {} })+})+afterEach(() => {+ resetPlatformForTests()+ fs.rmSync(repo, { recursive: true, force: true })+})++async function call(method: string, ...args: unknown[]) {+ const res = await platform.dispatch(ui, { t: 'req', id: 1, method, args })+ if (!res.ok) throw new Error(res.error.code)+ return res.result+}++describe('registerCoreHandlers (git)', () => {+ it('git.status reports the modified file', async () => {+ const status = (await call(IPC.gitStatus, repo)) as GitStatus+ // a.txt is modified in the working tree (unstaged) → `changes`.+ expect([...status.staged, ...status.changes].some((f) => f.path === 'a.txt')).toBe(true)+ })+ it('git.showFile returns HEAD content', async () => {+ // git-service's runner trims trailing whitespace from git output.+ expect(await call(IPC.gitShowFile, repo, 'HEAD', 'a.txt')).toBe('one')+ })+ it('git.diff returns a unified diff of the working change', async () => {+ const diff = (await call(IPC.gitDiff, repo, 'a.txt', false, false)) as string+ expect(diff).toContain('-one')+ expect(diff).toContain('+two')+ })+ it('fs handlers are registered too (delegated)', async () => {+ expect(await call(IPC.fsRead, path.join(repo, 'a.txt'))).toBe('two\n')+ })+})diff --git a/src/server/handlers/index.ts b/src/server/handlers/index.tsnew file mode 100644index 000000000..1af6cba50--- /dev/null+++ b/src/server/handlers/index.ts@@ -0,0 +1,29 @@+import type { Settings } from '../../shared/types'+import type { ServerPlatform } from '../platform-server'+import { GitService } from '../../core/git-service'+import { generateCommitMessage } from '../../core/commit-message'+import { registerFsHandlers } from './fs'+import { IPC } from '../../shared/ipc'++/** Register the Phase-3a handler surface (fs + git + commit) on the server platform.+ * git.setActiveRemote is a local-only no-op here: it exists to arm SSH-project remote+ * routing on desktop, which the server edition does not have (terminals are local). */+export function registerCoreHandlers(+ platform: ServerPlatform,+ deps: { getSettings: () => Settings }+): { gitService: GitService } {+ registerFsHandlers(platform)++ const gitService = new GitService()+ // registers all git:* channels via the global core platform().handle+ gitService.registerIpc()++ // Desktop: ipcMain.handle(IPC.commitGenerate, (_e, cwd) => generateCommitMessage(cwd, settingsStore.get()))+ platform.handle(IPC.commitGenerate, (cwd: string) =>+ generateCommitMessage(cwd, deps.getSettings())+ )+ // Local server has no SSH projects; keep git running against the local remote.+ platform.handle(IPC.gitSetActiveRemote, () => null)++ return { gitService }+}diff --git a/src/server/index.ts b/src/server/index.tsindex e12c3320c..c163b376f 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -12,6 +12,7 @@ import { initPlatform } from '../core/platform'import { SettingsStore } from '../core/settings-store'import { WorkspaceStore } from '../core/workspace-store'import { PtyManager } from '../core/pty-manager'+import { registerCoreHandlers } from './handlers'import { IPC } from '@shared/ipc'/**@@ -78,6 +79,9 @@ export async function startServer(ptyManager.captureSession(persistKey, full))+ // fs + git + commit handlers (shared with desktop core services).+ registerCoreHandlers(platform, { getSettings: () => settingsStore.get() })+const server = http.createServer(createHttpHandler({ auth, rendererDir: config.rendererDir }))attachWsServer(server, { platform, auth })