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.

feat(board-log): project-routed append/read/changed across desktop, server and ssh

enes029f6ddd6ad6
diff --git a/src/core/board-log-handlers.test.ts b/src/core/board-log-handlers.test.ts
new file mode 100644
index 000000000..e8dd0c847
--- /dev/null
+++ b/src/core/board-log-handlers.test.ts
@@ -0,0 +1,157 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import fs from 'fs'
+import os from 'os'
+import path from 'path'
+import { fakePlatform, type FakePlatform } from './platform-fake'
+import { registerBoardLogHandlers, type BoardLogRoute, type BoardLogRouter } from './board-log-handlers'
+import { boardLogRemotePath, type RemoteLogExec } from './board-log'
+import { IPC } from '../shared/ipc'
+import type { BoardLogEntry, BoardLogReadResult } from '../shared/types'
+
+const entry = (over: Partial<BoardLogEntry> = {}): BoardLogEntry => ({
+ id: 'e1',
+ ts: 1000,
+ author: { name: 'enes', color: '#f00' },
+ kind: 'comment',
+ text: 'hello',
+ ...over
+})
+
+// A router that always returns a fixed route — most tests need only one project.
+const routerFor = (route: BoardLogRoute): BoardLogRouter => ({ route: () => route })
+
+const append = (f: FakePlatform, projectId: string, e: BoardLogEntry) =>
+ f.handlers[IPC.boardLogAppend](projectId, e) as Promise<boolean>
+const read = (f: FakePlatform, projectId: string, opts?: unknown) =>
+ f.handlers[IPC.boardLogRead](projectId, opts) as Promise<BoardLogReadResult>
+
+describe('registerBoardLogHandlers — routing', () => {
+ let dir: string
+ beforeEach(() => {
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-boardlog-h-'))
+ })
+ afterEach(() => {
+ fs.rmSync(dir, { recursive: true, force: true })
+ })
+
+ it('local: append writes and read returns the entry newest-first', async () => {
+ const f = fakePlatform()
+ registerBoardLogHandlers(f, routerFor({ kind: 'local', cwd: dir }))
+ expect(await append(f, 'p1', entry({ id: 'a' }))).toBe(true)
+ expect(await append(f, 'p1', entry({ id: 'b' }))).toBe(true)
+ const res = await read(f, 'p1')
+ expect(res.unsupported).toBeUndefined()
+ expect(res.entries.map((e) => e.id)).toEqual(['b', 'a'])
+ // file is on disk under .nodeterm
+ expect(fs.existsSync(path.join(dir, '.nodeterm', 'board-log.jsonl'))).toBe(true)
+ })
+
+ it('unsupported: append resolves false, read returns { entries: [], unsupported: true }', async () => {
+ const f = fakePlatform()
+ registerBoardLogHandlers(f, routerFor({ kind: 'unsupported' }))
+ expect(await append(f, 'p1', entry())).toBe(false)
+ expect(await read(f, 'p1')).toEqual({ entries: [], unsupported: true })
+ })
+
+ it('remote: routes through the injected exec (append + tail)', async () => {
+ const store: string[] = []
+ const exec: RemoteLogExec = {
+ append: async (_p, line) => void store.push(line),
+ tail: async () => store.join('\n')
+ }
+ const f = fakePlatform()
+ registerBoardLogHandlers(f, routerFor({ kind: 'remote', remoteCwd: '/remote/cwd', exec, fingerprint: async () => '0' }))
+ expect(await append(f, 'p1', entry({ id: 'x' }))).toBe(true)
+ const res = await read(f, 'p1')
+ expect(res.entries.map((e) => e.id)).toEqual(['x'])
+ })
+
+ it('append never throws when the remote exec rejects → resolves false', async () => {
+ const exec: RemoteLogExec = {
+ append: async () => {
+ throw new Error('ssh down')
+ },
+ tail: async () => ''
+ }
+ const f = fakePlatform()
+ registerBoardLogHandlers(f, routerFor({ kind: 'remote', remoteCwd: '/r', exec, fingerprint: async () => '0' }))
+ await expect(append(f, 'p1', entry())).resolves.toBe(false)
+ })
+})
+
+describe('registerBoardLogHandlers — change subscription', () => {
+ let dir: string
+ beforeEach(() => {
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-boardlog-h-'))
+ })
+ afterEach(() => {
+ fs.rmSync(dir, { recursive: true, force: true })
+ })
+
+ it('local watch: broadcasts boardLogChanged on the project channel after an append', async () => {
+ const f = fakePlatform()
+ registerBoardLogHandlers(f, routerFor({ kind: 'local', cwd: dir }))
+ // A real project's .nodeterm dir exists (project.json lives there); the store watches that dir,
+ // so create it before subscribing (an initial append does that).
+ await append(f, 'p1', entry({ id: 'a' }))
+ f.listeners[IPC.boardLogSubscribe]('p1')
+ await append(f, 'p1', entry({ id: 'b' }))
+ // fs.watch is debounced 250ms in the store; give it margin
+ await new Promise((r) => setTimeout(r, 500))
+ const pushed = f.sent.filter((s) => s.channel === IPC.boardLogChanged('p1'))
+ expect(pushed.length).toBeGreaterThanOrEqual(1)
+ f.listeners[IPC.boardLogUnsubscribe]('p1')
+ })
+
+ it('remote poll: broadcasts only when the fingerprint changes; stops on last unsubscribe', async () => {
+ vi.useFakeTimers()
+ try {
+ let fp = 'a'
+ const calls = { fingerprint: 0 }
+ const exec: RemoteLogExec = { append: async () => {}, tail: async () => '' }
+ const f = fakePlatform()
+ registerBoardLogHandlers(
+ f,
+ routerFor({
+ kind: 'remote',
+ remoteCwd: '/r',
+ exec,
+ fingerprint: async () => {
+ calls.fingerprint++
+ return fp
+ }
+ })
+ )
+ // two subscribers, ref-counted
+ f.listeners[IPC.boardLogSubscribe]('p1')
+ f.listeners[IPC.boardLogSubscribe]('p1')
+ await vi.advanceTimersByTimeAsync(0) // initial tick sets last = 'a' (no push)
+ expect(f.sent.filter((s) => s.channel === IPC.boardLogChanged('p1'))).toHaveLength(0)
+
+ fp = 'b'
+ await vi.advanceTimersByTimeAsync(5000)
+ expect(f.sent.filter((s) => s.channel === IPC.boardLogChanged('p1'))).toHaveLength(1)
+
+ // one unsubscribe keeps the poll alive (count still 1)
+ f.listeners[IPC.boardLogUnsubscribe]('p1')
+ const before = calls.fingerprint
+ await vi.advanceTimersByTimeAsync(5000)
+ expect(calls.fingerprint).toBeGreaterThan(before)
+
+ // last unsubscribe stops the poll: no further fingerprint calls
+ f.listeners[IPC.boardLogUnsubscribe]('p1')
+ const settled = calls.fingerprint
+ await vi.advanceTimersByTimeAsync(15000)
+ expect(calls.fingerprint).toBe(settled)
+ } finally {
+ vi.useRealTimers()
+ }
+ })
+})
+
+describe('boardLogRemotePath', () => {
+ it('joins cwd/.nodeterm/board-log.jsonl posix-style', () => {
+ expect(boardLogRemotePath('/home/u/proj')).toBe('/home/u/proj/.nodeterm/board-log.jsonl')
+ expect(boardLogRemotePath('~/proj/')).toBe('~/proj/.nodeterm/board-log.jsonl')
+ })
+})
diff --git a/src/core/board-log-handlers.ts b/src/core/board-log-handlers.ts
new file mode 100644
index 000000000..6f9eef722
--- /dev/null
+++ b/src/core/board-log-handlers.ts
@@ -0,0 +1,106 @@
+import type { CorePlatform } from './platform'
+import { BoardLogStore, type RemoteLogExec } from './board-log'
+import { IPC } from '../shared/ipc'
+import type { BoardLogEntry, BoardLogReadOpts, BoardLogReadResult } from '../shared/types'
+
+// Board-log RPC surface, registered ONCE for every shell (Electron main + Server Edition) through
+// CorePlatform — the same seam fs-handlers.ts uses, so the two can never drift. The pure log I/O is
+// already in core/board-log.ts; this only wires request/response + the per-project change push, and
+// delegates the "where does this project's log live?" question to an injected BoardLogRouter (the one
+// piece that differs per shell: desktop resolves SSH connections, the server never does).
+
+/** Where a project's board log lives, resolved per call by the shell.
+ * - `local` → node:fs under `cwd/.nodeterm/board-log.jsonl`.
+ * - `remote` → desktop SSH: `exec` does the append/tail over the ControlMaster; `fingerprint`
+ * returns a cheap size/hash (`wc -c`) the change-poll compares every 5s.
+ * - `unsupported` → inline/no-cwd canvas, a disconnected SSH project, or an SSH project on the
+ * Server Edition (v1). Reads answer `{ entries: [], unsupported: true }`; appends `false`. */
+export type BoardLogRoute =
+ | { kind: 'local'; cwd: string }
+ | { kind: 'remote'; remoteCwd: string; exec: RemoteLogExec; fingerprint: () => Promise<string> }
+ | { kind: 'unsupported' }
+
+export interface BoardLogRouter {
+ route(projectId: string): BoardLogRoute
+}
+
+const POLL_MS = 5000
+
+/** Registers boardLogAppend / boardLogRead / boardLogSubscribe / boardLogUnsubscribe and drives the
+ * per-project `boardLogChanged` push. Ref-counted per project: the first subscriber starts a watch
+ * (local fs.watch) or a poll (desktop SSH), the last one stops it. */
+export function registerBoardLogHandlers(platform: CorePlatform, router: BoardLogRouter): void {
+ const localStore = new BoardLogStore({})
+
+ platform.handle(IPC.boardLogAppend, async (projectId: string, entry: BoardLogEntry): Promise<boolean> => {
+ const r = router.route(projectId)
+ if (r.kind === 'local') return localStore.append(r.cwd, entry)
+ if (r.kind === 'remote') return new BoardLogStore({ remote: r.exec }).append(r.remoteCwd, entry)
+ return false
+ })
+
+ platform.handle(
+ IPC.boardLogRead,
+ async (projectId: string, opts?: BoardLogReadOpts): Promise<BoardLogReadResult> => {
+ const r = router.route(projectId)
+ if (r.kind === 'local') return { entries: await localStore.read(r.cwd, opts) }
+ if (r.kind === 'remote')
+ return { entries: await new BoardLogStore({ remote: r.exec }).read(r.remoteCwd, opts) }
+ return { entries: [], unsupported: true }
+ }
+ )
+
+ // Change subscription, ref-counted per project id (the renderer subscribes/unsubscribes as its
+ // board panel mounts/unmounts; a leaked subscription is at worst one idle fs.watch/poll).
+ interface Sub {
+ count: number
+ stop: () => void
+ }
+ const subs = new Map<string, Sub>()
+
+ const startWatch = (projectId: string): (() => void) => {
+ const emit = (): void => platform.broadcast(IPC.boardLogChanged(projectId), projectId)
+ const r = router.route(projectId)
+ if (r.kind === 'local') return localStore.watch(r.cwd, emit)
+ if (r.kind === 'remote') {
+ let last: string | undefined
+ let alive = true
+ const tick = async (): Promise<void> => {
+ if (!alive) return
+ try {
+ const fp = await r.fingerprint()
+ if (last !== undefined && fp !== last) emit()
+ last = fp
+ } catch {
+ /* transient ssh failure: keep the last fingerprint, retry next tick */
+ }
+ }
+ void tick()
+ const timer = setInterval(() => void tick(), POLL_MS)
+ return () => {
+ alive = false
+ clearInterval(timer)
+ }
+ }
+ return () => {}
+ }
+
+ platform.on(IPC.boardLogSubscribe, (projectId: string) => {
+ const existing = subs.get(projectId)
+ if (existing) {
+ existing.count++
+ return
+ }
+ subs.set(projectId, { count: 1, stop: startWatch(projectId) })
+ })
+
+ platform.on(IPC.boardLogUnsubscribe, (projectId: string) => {
+ const existing = subs.get(projectId)
+ if (!existing) return
+ existing.count--
+ if (existing.count <= 0) {
+ existing.stop()
+ subs.delete(projectId)
+ }
+ })
+}
diff --git a/src/core/board-log.ts b/src/core/board-log.ts
index cb6e13926..d9378fe32 100644
--- a/src/core/board-log.ts
+++ b/src/core/board-log.ts
@@ -72,6 +72,12 @@ function posixJoin(cwd: string, ...parts: string[]): string {
return [cwd.replace(/\/+$/, ''), ...parts].join('/')
}
+/** The remote (POSIX) path of a project's board log under `cwd`. Exported so the desktop SSH
+ * change-poll can fingerprint the same file the store's RemoteLogExec reads/writes. */
+export function boardLogRemotePath(cwd: string): string {
+ return posixJoin(cwd, LOG_DIR, LOG_FILE)
+}
+
export class BoardLogStore {
private remote?: RemoteLogExec
constructor(opts: { remote?: RemoteLogExec }) {
@@ -82,7 +88,7 @@ export class BoardLogStore {
return path.join(cwd, LOG_DIR, LOG_FILE)
}
private remotePath(cwd: string): string {
- return posixJoin(cwd, LOG_DIR, LOG_FILE)
+ return boardLogRemotePath(cwd)
}
/** Append one entry. Fire-and-forget-safe: never throws — returns false on any fs/exec error. */
diff --git a/src/core/workspace-store.ts b/src/core/workspace-store.ts
index 7b6a53116..7af79db19 100644
--- a/src/core/workspace-store.ts
+++ b/src/core/workspace-store.ts
@@ -363,6 +363,12 @@ export class WorkspaceStore {
return (this.index?.entries ?? []).filter((e) => e.ssh).map((e) => e.id)
}
+ /** The local folder cwd of a project by id (index lookup), or undefined for ssh/inline/unknown
+ * projects. Sync (reads the in-memory index): the board-log router's local-vs-unsupported call. */
+ localCwdForProject(projectId: string): string | undefined {
+ return this.index?.entries.find((e) => e.id === projectId && e.cwd)?.cwd
+ }
+
/** The local ref cwds of the current index — the workspace half of the phone bridge's fs/git
* jail. The phone browses EVERY project over `projects.list`, so jailing to only the active
* canvas's node cwds denied any project the desktop didn't happen to have focused. */
diff --git a/src/main/index.ts b/src/main/index.ts
index 2f2515e13..72f9fd9c5 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -5,6 +5,9 @@ import { randomUUID } from 'crypto'
import { app, BrowserWindow, dialog, ipcMain, Notification, powerMonitor, shell, systemPreferences } from 'electron'
import { IPC } from '../shared/ipc'
import { registerFsHandlers } from '../core/fs-handlers'
+import { registerBoardLogHandlers, type BoardLogRoute } from '../core/board-log-handlers'
+import type { RemoteLogExec } from '../core/board-log'
+import { boardLogRemotePath } from '../core/board-log'
import { PtyManager } from '../core/pty-manager'
import { WorkspaceStore } from '../core/workspace-store'
import { WorkspaceWatcher } from '../core/workspace-watcher'
@@ -92,7 +95,7 @@ import { decodeOffer } from './remote/pairing'
import { loadOrCreatePeerKeyPair } from './remote/peer-identity'
import { initSshProject } from './remote-ssh/ssh-project'
import { setGitRemoteResolver, type GitRemoteRef } from '../core/remote-ssh/remote-git'
-import { SshFs } from './ssh-fs'
+import { SshFs, sshAppendArgs, sshTailArgs, sshSizeArgs } from './ssh-fs'
import { makeRemoteWorkspaceIO } from './remote-workspace-io'
import {
registerMediaScheme,
@@ -647,6 +650,40 @@ app.whenReady().then(async () => {
return ref ? sshFs.exists(ref, p) : Promise.resolve(false)
})
+ // Board-log: same CorePlatform registrar as the Server Edition (core/board-log-handlers.ts), with
+ // a desktop router that adds SSH routing on top of the local-cwd/unsupported the server also does.
+ // A connected SSH project (refForProject → a ref with a remoteCwd) reads/writes/fingerprints over
+ // its ControlMaster; anything else falls to the local folder cwd, then unsupported.
+ registerBoardLogHandlers(corePlatform, {
+ route: (projectId: string): BoardLogRoute => {
+ const ref = sshProjectManager?.refForProject(projectId)
+ if (ref?.remoteCwd) {
+ const run = (args: string[], stdin?: string) =>
+ sshProjectManager!.sshRun(args, stdin)
+ const exec: RemoteLogExec = {
+ append: async (p, line) => {
+ const { code } = await run(sshAppendArgs(ref.conn, ref.controlPath, p, line))
+ if (code !== 0) throw new Error('board-log ssh append failed')
+ },
+ tail: async (p, lines) => {
+ const { code, stdout } = await run(sshTailArgs(ref.conn, ref.controlPath, p, lines))
+ return code === 0 ? stdout : ''
+ }
+ }
+ const remotePath = boardLogRemotePath(ref.remoteCwd)
+ const fingerprint = async (): Promise<string> => {
+ const { code, stdout } = await run(sshSizeArgs(ref.conn, ref.controlPath, remotePath))
+ if (code !== 0) throw new Error('board-log ssh fingerprint failed')
+ return stdout.trim()
+ }
+ return { kind: 'remote', remoteCwd: ref.remoteCwd, exec, fingerprint }
+ }
+ const cwd = workspaceStore.localCwdForProject(projectId)
+ if (cwd) return { kind: 'local', cwd }
+ return { kind: 'unsupported' }
+ }
+ })
+
ipcMain.handle(IPC.dialogSelectFolder, async () => {
const result = await dialog.showOpenDialog({ properties: ['openDirectory', 'createDirectory'] })
return result.canceled || result.filePaths.length === 0 ? null : result.filePaths[0]
diff --git a/src/main/ssh-fs.test.ts b/src/main/ssh-fs.test.ts
index c68478035..9b1d444a7 100644
--- a/src/main/ssh-fs.test.ts
+++ b/src/main/ssh-fs.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from 'vitest'
-import { sshListArgs, sshReadArgs, sshReadBinaryArgs, sshWriteArgs, sshMkdirArgs, sshExistsArgs, sshCheckIgnoreArgs, sshAppendArgs, sshTailArgs, parseLsEntries, SshFs } from './ssh-fs'
+import { sshListArgs, sshReadArgs, sshReadBinaryArgs, sshWriteArgs, sshMkdirArgs, sshExistsArgs, sshCheckIgnoreArgs, sshAppendArgs, sshTailArgs, sshSizeArgs, parseLsEntries, SshFs } from './ssh-fs'
const conn = { host: 'h', user: 'u' }
const ref = { conn, controlPath: '/s.sock' }
@@ -60,6 +60,13 @@ describe('ssh-fs arg builders', () => {
it('tail leaves a leading ~/ unquoted and coerces the line count to a safe integer', () => {
expect(sshTailArgs(conn, '/s', '~/p/log', 12.9).join(' ')).toContain(`tail -n 12 ~/'p/log'`)
})
+ it('size runs `cat | wc -c` on the quoted path (quiet + 0 on a missing file)', () => {
+ const j = sshSizeArgs(conn, '/s.sock', '/a b/log.jsonl').join(' ')
+ expect(j).toContain(`cat '/a b/log.jsonl' 2>/dev/null | wc -c`)
+ })
+ it('size leaves a leading ~/ unquoted so the remote shell tilde-expands the path', () => {
+ expect(sshSizeArgs(conn, '/s', '~/p/log.jsonl').join(' ')).toContain(`cat ~/'p/log.jsonl' 2>/dev/null | wc -c`)
+ })
it('exists runs test -e on the quoted path', () => {
expect(sshExistsArgs(conn, '/s.sock', '/a b/c').join(' ')).toContain(`test -e '/a b/c'`)
})
diff --git a/src/main/ssh-fs.ts b/src/main/ssh-fs.ts
index e6f4c1bd6..15aca647b 100644
--- a/src/main/ssh-fs.ts
+++ b/src/main/ssh-fs.ts
@@ -51,6 +51,12 @@ export function sshAppendArgs(conn: SshConnection, cp: string, path: string, lin
export function sshTailArgs(conn: SshConnection, cp: string, path: string, lines: number): string[] {
return childArgs(conn, cp, `tail -n ${Math.max(0, Math.trunc(lines))} ${quoteRemotePath(path)}`)
}
+export function sshSizeArgs(conn: SshConnection, cp: string, path: string): string[] {
+ // A cheap change fingerprint for the board-log poll: the byte size of the file, or `0` when it
+ // does not exist yet. `cat | wc -c` (not `wc -c < file`) stays quiet + prints 0 on a missing file
+ // instead of erroring, so the poll never mistakes "not there yet" for a failure.
+ return childArgs(conn, cp, `cat ${quoteRemotePath(path)} 2>/dev/null | wc -c`)
+}
export function sshExistsArgs(conn: SshConnection, cp: string, path: string): string[] {
return childArgs(conn, cp, `test -e ${quoteRemotePath(path)}`)
}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 2b79ec8dc..6c5a88ddc 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -480,6 +480,20 @@ const api: NodeTerminalApi = {
setLinks: (map) => ipcRenderer.invoke(IPC.contextLinkSetLinks, map),
info: () => ipcRenderer.invoke(IPC.contextLinkInfo)
},
+ boardLog: {
+ append: (projectId, entry) => ipcRenderer.invoke(IPC.boardLogAppend, projectId, entry),
+ read: (projectId, opts) => ipcRenderer.invoke(IPC.boardLogRead, projectId, opts),
+ onChanged: (projectId, cb) => {
+ const ch = IPC.boardLogChanged(projectId)
+ const handler = (): void => cb()
+ ipcRenderer.on(ch, handler)
+ ipcRenderer.send(IPC.boardLogSubscribe, projectId)
+ return () => {
+ ipcRenderer.removeListener(ch, handler)
+ ipcRenderer.send(IPC.boardLogUnsubscribe, projectId)
+ }
+ }
+ },
// Per-node subscriptions (each terminal/editor listens) — multiplexed so they don't pile up
// ipcRenderer listeners and trip the MaxListeners warning.
onMarkdownToggle: subscribe(IPC.appToggleMarkdown),
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index fccf0f468..78bac1326 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -11,7 +11,7 @@
// benign value, and everything else rejects with a coded error.
//
// The object is `satisfies Omit<NodeTerminalApi, 'pty' | 'workspace' | 'settings' | 'fs' | 'git'
-// | 'files' | 'context' | 'dialog'>`, so the TypeScript compiler is the completeness test: if
+// | 'files' | 'context' | 'boardLog' | 'dialog'>`, so the TypeScript compiler is the completeness test: if
// `NodeTerminalApi` gains a member, this file fails to typecheck until the stub is declared.
import {
@@ -110,6 +110,7 @@ export function buildStubApi(): Omit<
| 'git'
| 'files'
| 'context'
+ | 'boardLog'
| 'canvas'
| 'dialog'
| 'onAgentStatus'
@@ -329,6 +330,7 @@ export function buildStubApi(): Omit<
| 'git'
| 'files'
| 'context'
+ | 'boardLog'
| 'canvas'
| 'dialog'
| 'onAgentStatus'
diff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.ts
index 066d3c3ca..98888472d 100644
--- a/src/renderer/bridge/ws-bridge.ts
+++ b/src/renderer/bridge/ws-bridge.ts
@@ -16,6 +16,8 @@ import {
import { IPC } from '../../shared/ipc'
import {
UNKNOWN_CLAUDE_CLI_CAPS,
+ type BoardLogApi,
+ type BoardLogReadResult,
type ClaudeApi,
type ClaudeCliCaps,
type ContextApi,
@@ -279,7 +281,7 @@ export function buildRealApi(
*/
export function buildFilesApi(
client: RpcClient
-): Pick<NodeTerminalApi, 'fs' | 'git' | 'files' | 'context'> {
+): Pick<NodeTerminalApi, 'fs' | 'git' | 'files' | 'context' | 'boardLog'> {
const fs: FsApi = {
list: (dirPath) => client.request(IPC.fsList, dirPath) as ReturnType<FsApi['list']>,
read: (filePath) => client.request(IPC.fsRead, filePath) as Promise<string>,
@@ -384,7 +386,25 @@ export function buildFilesApi(
client.cast(IPC.contextEnsure, sessionId, cwd, accountId)
}
- return { fs, git, files, context }
+ // Board-log: REAL over the bridge for local projects (the server routes local; SSH projects on the
+ // server answer `unsupported`). `onChanged` is `.on` → subscribe, plus the ref-counted cast pair the
+ // preload sends so the server starts/stops watching this project's log.
+ const boardLog: BoardLogApi = {
+ append: (projectId, entry) =>
+ client.request(IPC.boardLogAppend, projectId, entry) as Promise<boolean>,
+ read: (projectId, opts) =>
+ client.request(IPC.boardLogRead, projectId, opts) as Promise<BoardLogReadResult>,
+ onChanged: (projectId, cb) => {
+ const unsub = client.subscribe(IPC.boardLogChanged(projectId), cb as Listener)
+ client.cast(IPC.boardLogSubscribe, projectId)
+ return () => {
+ unsub()
+ client.cast(IPC.boardLogUnsubscribe, projectId)
+ }
+ }
+ }
+
+ return { fs, git, files, context, boardLog }
}
/**
diff --git a/src/server/index.ts b/src/server/index.ts
index 7e2b7cb88..f84ddb729 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -13,6 +13,7 @@ import { SettingsStore } from '../core/settings-store'
import { WorkspaceStore } from '../core/workspace-store'
import { PtyManager } from '../core/pty-manager'
import { registerCoreHandlers } from './handlers'
+import { registerBoardLogHandlers, type BoardLogRoute } from '../core/board-log-handlers'
import { hookServer } from '../core/agents/hook-server'
import { installManagedAgentHooks } from '../core/agents/hooks'
import {
@@ -149,6 +150,16 @@ export async function startServer(
// fs + git + commit handlers (shared with desktop core services).
registerCoreHandlers(platform, { getSettings: () => settingsStore.get() })
+ // Board-log: same CorePlatform registrar as desktop, but the Server Edition has no SSH projects
+ // (terminals are local), so the router only ever resolves a local folder cwd or unsupported —
+ // an SSH-ref project answers `{ entries: [], unsupported: true }` (v1: no remote board log here).
+ registerBoardLogHandlers(platform, {
+ route: (projectId: string): BoardLogRoute => {
+ const cwd = workspaceStore.localCwdForProject(projectId)
+ return cwd ? { kind: 'local', cwd } : { kind: 'unsupported' }
+ }
+ })
+
// Agent status pipeline — mirrors the desktop boot order in src/main/index.ts:
// mirror-init → wire the hook-server listeners onto the platform → install the managed hook
// scripts → start the loopback hook server. The hook server binds its own port independent of
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index 6341d930c..0cb2ae8b2 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -52,6 +52,16 @@ export const IPC = {
canvasMut: 'canvas:mut',
contextLinkSetLinks: 'context-link:set-links',
contextLinkInfo: 'context-link:info',
+ /** Board-log (`.nodeterm/board-log.jsonl`): request/response append + read, routed per project
+ * (local cwd / desktop-ssh / unsupported) in core/board-log-handlers.ts. */
+ boardLogAppend: 'board-log:append',
+ boardLogRead: 'board-log:read',
+ /** Fire-and-forget ref-counted subscribe/unsubscribe: the first subscriber for a project starts
+ * the local fs.watch (or the desktop-ssh 5s poll); the last one stops it. */
+ boardLogSubscribe: 'board-log:subscribe',
+ boardLogUnsubscribe: 'board-log:unsubscribe',
+ /** Per-project push fired when a project's board log changes (mirrors ptyData/chatEvent naming). */
+ boardLogChanged: (projectId: string) => `board-log:changed:${projectId}`,
appUpdateAvailable: 'app:update-available',
appUpdateDownloaded: 'app:update-downloaded',
appUpdateProgress: 'app:update-progress',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 7b1d05495..76f961056 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -246,6 +246,32 @@ export interface BoardLogEntry {
event?: BoardLogEvent
}
+/** Read options for the board log: cap the newest N entries (default 500 in the store) or `all`. */
+export interface BoardLogReadOpts {
+ cap?: number
+ all?: boolean
+}
+
+/** Result of a board-log read. `unsupported` is set (with `entries: []`) when the project has no
+ * reachable log — an inline/no-cwd canvas, a disconnected SSH project, or an SSH project on the
+ * Server Edition (v1 has no remote board log there). */
+export interface BoardLogReadResult {
+ entries: BoardLogEntry[]
+ unsupported?: boolean
+}
+
+/** The board-log surface on `window.nodeTerminal`. Project-routed: the main/server side resolves
+ * the project to a local cwd, a desktop SSH connection, or unsupported. `append` is
+ * fire-and-forget-safe (resolves `false` on any failure, never throws). */
+export interface BoardLogApi {
+ /** Append one entry. Resolves `false` on any failure (unsupported project, fs/exec error). */
+ append(projectId: string, entry: BoardLogEntry): Promise<boolean>
+ /** Read the log newest-first (see BoardLogReadResult). */
+ read(projectId: string, opts?: BoardLogReadOpts): Promise<BoardLogReadResult>
+ /** Subscribe to change pushes for one project; returns an unsubscribe. */
+ onChanged(projectId: string, cb: () => void): () => void
+}
+
/** A project is one canvas/page: its own nodes, viewport, and default working dir. */
export interface Project {
id: string
@@ -1505,6 +1531,7 @@ export interface NodeTerminalApi {
license: LicenseApi
relayQuota: RelayQuotaApi
contextLink: ContextLinkApi
+ boardLog: BoardLogApi
usage: UsageApi
context: ContextApi
canvas: CanvasApi