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.

test(server): files/scm e2e over ws; docs(server): Phase 3a scope

enes7fdda7232acc
diff --git a/docs/SERVER.md b/docs/SERVER.md
index 3e6bd0cac..caf4f7945 100644
--- a/docs/SERVER.md
+++ b/docs/SERVER.md
@@ -140,6 +140,40 @@ Two intentional departures from `docs/superpowers/specs/2026-07-10-server-editio
`bufferedAmount` yet. Deferred to Phase 3.
- **Single user.** One password, no accounts/roles.
+## Phase 3a: files, editor, diff & source control
+
+Phase 3a widens the browser surface from terminals-only to the file-and-git
+workflow. The server now registers the core **fs**, **git**, and **commit-message**
+handlers and the browser bridge exposes real `fs` / `git` / `files` / `context`
+APIs, so several node kinds and panels that were stubbed in Phase 2 now work in the
+browser:
+
+- **Editor & diff nodes** — Monaco editor nodes read/write files over `fs:read` /
+ `fs:write` (⌘S saves), and diff nodes render `git:show-file` + `fs:read` — both
+ now function unchanged in the browser.
+- **Source Control panel** — stage / unstage / discard, diff, branch switch/create,
+ commit + push, and the ✦ AI commit message (BYO local agent CLI on the staged
+ diff) all run against the server's `git` service.
+- **Explorer** — the file tree lists the project `cwd` via `fs:list`.
+
+The following affordances change shape in the browser (no native OS is reachable):
+
+- **Folder / file picker** — there is **no native dialog**. "Open folder…" and file
+ pickers use an **in-app server-directory browser** (built on `fs:list`) that lets
+ you navigate and pick a path on the server's filesystem.
+- **`shell.openExternal`** — opens the URL in a **new browser tab** rather than a
+ desktop-side default browser.
+- **"Reveal in Finder" / "open with default app"** — **inert** in the browser
+ (there is no desktop file manager to reveal into); these actions are hidden or
+ no-op rather than erroring.
+
+The **backpressure / flow-control** gap noted in the Phase 2 limitations is now
+closed: a flooding PTY is automatically paused based on the WebSocket
+`bufferedAmount` and resumed when it drains, so the WS is protected.
+
+**Still deferred to Phase 3b:** the SDK **chat node** and the **agent-status
+badges/hooks** are not yet wired into the server bridge.
+
## Manual browser smoke checklist
Run against a real browser (this is the human-verified path; the automated harness
@@ -159,3 +193,11 @@ only exercises the HTTP/auth surface). With `npm run server:dev` running:
page. Same warm-reattach: the tmux server outlived the app, so state is intact.
7. **Lockout** — sign out (or open a fresh session), enter the wrong password 5 times;
the 6th attempt should be rejected with a "too many attempts" lockout for ~60s.
+8. **Open a folder (Phase 3a)** — use "Open folder…"; the **in-app server-directory
+ picker** appears (no native dialog). Navigate to a git repo on the server and pick
+ it; a project opens on its `cwd`.
+9. **Edit & save a file (Phase 3a)** — open a file (Explorer or picker) into an editor
+ node, make an edit, press ⌘S; the dirty dot clears and the change lands on disk.
+10. **Source Control (Phase 3a)** — open the Source Control panel; your edit shows as a
+ change. Click it to see the **diff**, **stage** it (+), type a message, and
+ **commit**; the file leaves the change list and the commit appears in recent commits.
diff --git a/test/server/files-scm-e2e.test.ts b/test/server/files-scm-e2e.test.ts
new file mode 100644
index 000000000..dbb679080
--- /dev/null
+++ b/test/server/files-scm-e2e.test.ts
@@ -0,0 +1,64 @@
+import { describe, it, expect, beforeAll, afterAll } from 'vitest'
+import fs from 'fs'
+import os from 'os'
+import path from 'path'
+import { execFileSync } from 'child_process'
+import WebSocket from 'ws'
+import { startServer } from '../../src/server/index'
+import { SESSION_COOKIE } from '../../src/server/http'
+import { IPC } from '../../src/shared/ipc'
+
+describe('files/scm e2e: fs.read + git over ws', () => {
+ let dataDir: string, repo: string, close: () => Promise<void>, port: number, cookie: string
+
+ beforeAll(async () => {
+ dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-e2e-scm-'))
+ repo = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-e2e-repo-'))
+ 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, 'r.txt'), 'hello\n')
+ git('add', '.'); git('commit', '-qm', 'init')
+
+ const srv = await startServer({
+ port: 0, host: '127.0.0.1', dataDir,
+ rendererDir: path.join(dataDir, 'no-renderer'), insecureHttp: false,
+ passwordSeed: 'scm-e2e-pw'
+ })
+ port = srv.port; close = srv.close
+ const res = await fetch(`http://127.0.0.1:${port}/auth/login`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
+ body: 'password=scm-e2e-pw',
+ redirect: 'manual'
+ })
+ cookie = res.headers.get('set-cookie')!.split(';')[0]
+ }, 30_000)
+
+ afterAll(async () => {
+ await close?.()
+ fs.rmSync(dataDir, { recursive: true, force: true })
+ fs.rmSync(repo, { recursive: true, force: true })
+ })
+
+ it('reads a file and gets git status over ws', async () => {
+ const ws = new WebSocket(`ws://127.0.0.1:${port}/ws`, { headers: { cookie } })
+ await new Promise<void>((res, rej) => { ws.on('open', () => res()); ws.on('error', rej) })
+ function rpc(id: number, method: string, args: unknown[]): Promise<unknown> {
+ return new Promise((resolve) => {
+ const onMsg = (d: WebSocket.RawData, isBinary: boolean) => {
+ if (isBinary) return
+ const m = JSON.parse(d.toString())
+ if (m.t === 'res' && m.id === id) { ws.off('message', onMsg); resolve(m) }
+ }
+ ws.on('message', onMsg)
+ ws.send(JSON.stringify({ t: 'req', id, method, args }))
+ })
+ }
+ const read = (await rpc(1, IPC.fsRead, [path.join(repo, 'r.txt')])) as { ok: boolean; result: string }
+ expect(read.ok).toBe(true)
+ expect(read.result).toBe('hello\n')
+ const status = (await rpc(2, IPC.gitStatus, [repo])) as { ok: boolean }
+ expect(status.ok).toBe(true)
+ ws.close()
+ }, 30_000)
+})