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): append-only board history core + pure event diff

enesc99da1336079
diff --git a/src/core/board-log.test.ts b/src/core/board-log.test.ts
new file mode 100644
index 000000000..ba98d634d
--- /dev/null
+++ b/src/core/board-log.test.ts
@@ -0,0 +1,134 @@
+import { describe, expect, it, beforeEach, afterEach } from 'vitest'
+import fs from 'fs'
+import os from 'os'
+import path from 'path'
+import type { BoardLogEntry } from '@shared/types'
+import { buildLine, parseLines, validEntry, BoardLogStore, type RemoteLogExec } from './board-log'
+
+const entry = (over: Partial<BoardLogEntry> = {}): BoardLogEntry => ({
+ id: 'e1',
+ ts: 1000,
+ author: { name: 'enes', color: '#f00' },
+ kind: 'comment',
+ text: 'hello',
+ ...over
+})
+
+describe('buildLine / parseLines / validEntry', () => {
+ it('buildLine is single-line JSON + newline, round-trips through parseLines', () => {
+ const e = entry({ text: 'line one\nline two' }) // newline in text is JSON-escaped, stays one line
+ const line = buildLine(e)
+ expect(line.endsWith('\n')).toBe(true)
+ expect(line.slice(0, -1).includes('\n')).toBe(false)
+ expect(parseLines(line)).toEqual([e])
+ })
+
+ it('parseLines is tolerant: skips a garbage line, keeps the valid one', () => {
+ const good = buildLine(entry({ id: 'ok' }))
+ const raw = 'not json\n' + '{"missing":"fields"}\n' + good
+ expect(parseLines(raw)).toEqual([entry({ id: 'ok' })])
+ })
+
+ it('parseLines is newest-first and capped at 500 by default; all:true returns everything', () => {
+ const raw = Array.from({ length: 600 }, (_, i) => buildLine(entry({ id: `e${i}`, ts: i }))).join('')
+ const capped = parseLines(raw)
+ expect(capped).toHaveLength(500)
+ expect(capped[0].id).toBe('e599') // newest first
+ expect(capped[499].id).toBe('e100')
+ expect(parseLines(raw, { all: true })).toHaveLength(600)
+ expect(parseLines(raw, { cap: 3 }).map((e) => e.id)).toEqual(['e599', 'e598', 'e597'])
+ })
+
+ it('validEntry accepts a comment and an event entry, rejects malformed shapes', () => {
+ expect(validEntry(entry())).toBe(true)
+ expect(validEntry(entry({ kind: 'event', text: undefined, event: { type: 'card-moved', from: 'a', to: 'b' } }))).toBe(true)
+ expect(validEntry(null)).toBe(false)
+ expect(validEntry({ id: 1, ts: 0, author: { name: 'x', color: 'y' }, kind: 'comment' })).toBe(false)
+ expect(validEntry({ id: 'x', ts: 'no', author: { name: 'x', color: 'y' }, kind: 'comment' })).toBe(false)
+ expect(validEntry({ id: 'x', ts: 0, author: { name: 'x' }, kind: 'comment' })).toBe(false)
+ expect(validEntry({ id: 'x', ts: 0, author: { name: 'x', color: 'y' }, kind: 'nope' })).toBe(false)
+ })
+})
+
+describe('BoardLogStore (local fs)', () => {
+ let dir: string
+ beforeEach(() => {
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'board-log-'))
+ })
+ afterEach(() => {
+ fs.rmSync(dir, { recursive: true, force: true })
+ })
+
+ it('append writes to <cwd>/.nodeterm/board-log.jsonl and read returns newest-first', async () => {
+ const store = new BoardLogStore({})
+ expect(await store.append(dir, entry({ id: 'a', ts: 1 }))).toBe(true)
+ expect(await store.append(dir, entry({ id: 'b', ts: 2 }))).toBe(true)
+ expect(fs.existsSync(path.join(dir, '.nodeterm', 'board-log.jsonl'))).toBe(true)
+ const got = await store.read(dir)
+ expect(got.map((e) => e.id)).toEqual(['b', 'a'])
+ })
+
+ it('read returns [] when the log file does not exist', async () => {
+ expect(await new BoardLogStore({}).read(dir)).toEqual([])
+ })
+
+ it('append never throws and returns false when the path is unwritable', async () => {
+ // A regular file where the cwd should be → mkdir(<file>/.nodeterm) fails with ENOTDIR.
+ const file = path.join(dir, 'not-a-dir')
+ fs.writeFileSync(file, 'x')
+ await expect(new BoardLogStore({}).append(file, entry())).resolves.toBe(false)
+ })
+
+ it('watch fires (debounced) when the log changes, and the returned unsub stops it', async () => {
+ const store = new BoardLogStore({})
+ await store.append(dir, entry({ id: 'seed' }))
+ let hits = 0
+ const unsub = store.watch(dir, () => {
+ hits++
+ })
+ await store.append(dir, entry({ id: 'later' }))
+ await new Promise((r) => setTimeout(r, 500))
+ unsub()
+ expect(hits).toBeGreaterThanOrEqual(1)
+ const after = hits
+ await store.append(dir, entry({ id: 'after-unsub' }))
+ await new Promise((r) => setTimeout(r, 400))
+ expect(hits).toBe(after)
+ })
+})
+
+describe('BoardLogStore (remote exec injected)', () => {
+ it('append passes the newline-free JSON line to remote.append; read tails and parses', async () => {
+ const appended: Array<{ path: string; line: string }> = []
+ let tailReq: { path: string; lines: number } | undefined
+ const raw = buildLine(entry({ id: 'r1', ts: 1 })) + buildLine(entry({ id: 'r2', ts: 2 }))
+ const remote: RemoteLogExec = {
+ append: async (p, line) => {
+ appended.push({ path: p, line })
+ },
+ tail: async (p, lines) => {
+ tailReq = { path: p, lines }
+ return raw
+ }
+ }
+ const store = new BoardLogStore({ remote })
+ expect(await store.append('/srv/proj', entry({ id: 'r2', ts: 2 }))).toBe(true)
+ expect(appended[0].path).toBe('/srv/proj/.nodeterm/board-log.jsonl')
+ expect(appended[0].line.includes('\n')).toBe(false) // printf adds the newline remote-side
+ const got = await store.read('/srv/proj', { cap: 10 })
+ expect(tailReq).toEqual({ path: '/srv/proj/.nodeterm/board-log.jsonl', lines: 10 })
+ expect(got.map((e) => e.id)).toEqual(['r2', 'r1'])
+ })
+
+ it('remote append returns false when the exec rejects; watch is a no-op unsub', async () => {
+ const remote: RemoteLogExec = {
+ append: async () => {
+ throw new Error('ssh down')
+ },
+ tail: async () => ''
+ }
+ const store = new BoardLogStore({ remote })
+ expect(await store.append('/srv/proj', entry())).toBe(false)
+ expect(typeof store.watch('/srv/proj', () => {})).toBe('function')
+ })
+})
diff --git a/src/core/board-log.ts b/src/core/board-log.ts
new file mode 100644
index 000000000..cb6e13926
--- /dev/null
+++ b/src/core/board-log.ts
@@ -0,0 +1,149 @@
+import fs from 'fs'
+import path from 'path'
+import { watch, type FSWatcher } from 'fs'
+import type { BoardLogEntry } from '@shared/types'
+
+// Append-only board history. Each project's board log lives beside its nodes at
+// `<cwd>/.nodeterm/board-log.jsonl`, one JSON entry per line, oldest-first on disk. Local
+// projects use node:fs directly; SSH projects go through an injected RemoteLogExec (the seam
+// that keeps this file electron-free — the ssh command builders live in main/ssh-fs.ts). The
+// pure line build/parse helpers are exported so the diff/renderer can reason about entries.
+
+const LOG_DIR = '.nodeterm'
+const LOG_FILE = 'board-log.jsonl'
+const DEFAULT_CAP = 500
+// `all` still needs a finite tail count for the remote path; larger than any realistic log.
+const ALL_LINES = 1_000_000_000
+
+export interface ParseOpts {
+ cap?: number
+ all?: boolean
+}
+
+/** Remote (SSH) log I/O, injected so core stays electron-free. `line` has no trailing newline
+ * (the remote `printf '%s\n'` adds it); `tail` returns the last `lines` lines, oldest-first. */
+export interface RemoteLogExec {
+ append(path: string, line: string): Promise<void>
+ tail(path: string, lines: number): Promise<string>
+}
+
+/** True when `x` is a structurally-valid BoardLogEntry. Tolerant callers use it to skip
+ * corrupt/foreign lines rather than throwing the whole log away. */
+export function validEntry(x: unknown): x is BoardLogEntry {
+ if (!x || typeof x !== 'object') return false
+ const e = x as Record<string, unknown>
+ if (typeof e.id !== 'string' || typeof e.ts !== 'number') return false
+ const a = e.author as Record<string, unknown> | undefined
+ if (!a || typeof a !== 'object' || typeof a.name !== 'string' || typeof a.color !== 'string') return false
+ if (e.kind !== 'comment' && e.kind !== 'event') return false
+ if (e.nodeId !== undefined && typeof e.nodeId !== 'string') return false
+ if (e.text !== undefined && typeof e.text !== 'string') return false
+ if (e.event !== undefined && (typeof e.event !== 'object' || e.event === null)) return false
+ return true
+}
+
+/** One log line: single-line JSON + '\n'. Any newline in `text` is JSON-escaped, so the line
+ * never breaks the one-entry-per-line invariant. */
+export function buildLine(entry: BoardLogEntry): string {
+ return JSON.stringify(entry) + '\n'
+}
+
+/** Parse a raw log blob → entries, NEWEST-FIRST. Tolerant: lines that fail JSON.parse or the
+ * shape check are skipped. Capped at `cap` (default 500) unless `all` is set. */
+export function parseLines(raw: string, opts: ParseOpts = {}): BoardLogEntry[] {
+ const out: BoardLogEntry[] = []
+ for (const line of raw.split('\n')) {
+ const t = line.trim()
+ if (!t) continue
+ let obj: unknown
+ try {
+ obj = JSON.parse(t)
+ } catch {
+ continue
+ }
+ if (validEntry(obj)) out.push(obj)
+ }
+ out.reverse() // disk is oldest-first; callers want newest-first
+ if (opts.all) return out
+ return out.slice(0, opts.cap ?? DEFAULT_CAP)
+}
+
+function posixJoin(cwd: string, ...parts: string[]): string {
+ return [cwd.replace(/\/+$/, ''), ...parts].join('/')
+}
+
+export class BoardLogStore {
+ private remote?: RemoteLogExec
+ constructor(opts: { remote?: RemoteLogExec }) {
+ this.remote = opts.remote
+ }
+
+ private localPath(cwd: string): string {
+ return path.join(cwd, LOG_DIR, LOG_FILE)
+ }
+ private remotePath(cwd: string): string {
+ return posixJoin(cwd, LOG_DIR, LOG_FILE)
+ }
+
+ /** Append one entry. Fire-and-forget-safe: never throws — returns false on any fs/exec error. */
+ async append(cwd: string, entry: BoardLogEntry): Promise<boolean> {
+ const line = buildLine(entry)
+ if (this.remote) {
+ try {
+ await this.remote.append(this.remotePath(cwd), line.replace(/\n$/, ''))
+ return true
+ } catch {
+ return false
+ }
+ }
+ try {
+ fs.mkdirSync(path.join(cwd, LOG_DIR), { recursive: true })
+ fs.appendFileSync(this.localPath(cwd), line)
+ return true
+ } catch {
+ return false
+ }
+ }
+
+ /** Read the log, newest-first (see parseLines). Missing file / failed read → []. */
+ async read(cwd: string, opts: ParseOpts = {}): Promise<BoardLogEntry[]> {
+ if (this.remote) {
+ try {
+ const raw = await this.remote.tail(this.remotePath(cwd), opts.all ? ALL_LINES : opts.cap ?? DEFAULT_CAP)
+ return parseLines(raw, opts)
+ } catch {
+ return []
+ }
+ }
+ let raw: string
+ try {
+ raw = await fs.promises.readFile(this.localPath(cwd), 'utf-8')
+ } catch {
+ return []
+ }
+ return parseLines(raw, opts)
+ }
+
+ /** Watch the log for changes; `cb` fires (debounced 250ms) on each change. Returns an unsub.
+ * Watches the `.nodeterm` dir (tolerant of the log file not existing yet); remote → no-op. */
+ watch(cwd: string, cb: () => void): () => void {
+ if (this.remote) return () => {}
+ const dir = path.join(cwd, LOG_DIR)
+ let timer: ReturnType<typeof setTimeout> | undefined
+ let watcher: FSWatcher
+ try {
+ watcher = watch(dir, (_event, filename) => {
+ if (filename && filename !== LOG_FILE) return
+ clearTimeout(timer)
+ timer = setTimeout(cb, 250)
+ })
+ watcher.on('error', () => {})
+ } catch {
+ return () => {}
+ }
+ return () => {
+ clearTimeout(timer)
+ watcher.close()
+ }
+ }
+}
diff --git a/src/main/ssh-fs.test.ts b/src/main/ssh-fs.test.ts
index 956ebcb34..c68478035 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, parseLsEntries, SshFs } from './ssh-fs'
+import { sshListArgs, sshReadArgs, sshReadBinaryArgs, sshWriteArgs, sshMkdirArgs, sshExistsArgs, sshCheckIgnoreArgs, sshAppendArgs, sshTailArgs, parseLsEntries, SshFs } from './ssh-fs'
const conn = { host: 'h', user: 'u' }
const ref = { conn, controlPath: '/s.sock' }
@@ -40,6 +40,26 @@ describe('ssh-fs arg builders', () => {
it('mkdir leaves a leading ~/ unquoted so the remote shell tilde-expands the path', () => {
expect(sshMkdirArgs(conn, '/s', '~/projects/new').join(' ')).toContain(`mkdir -p ~/'projects/new'`)
})
+ it('append mkdir -p the dirname, printf %s\\n the single-quoted line, >> the quoted path', () => {
+ const j = sshAppendArgs(conn, '/s.sock', '/d/e/log.jsonl', '{"id":"a"}').join(' ')
+ expect(j).toContain(`mkdir -p '/d/e'`)
+ expect(j).toContain("printf '%s\\n' '{\"id\":\"a\"}'")
+ expect(j).toContain(`>> '/d/e/log.jsonl'`)
+ })
+ it('append single-quote-escapes a quote in the line content', () => {
+ expect(sshAppendArgs(conn, '/s', '/d/log', `{"t":"a'b"}`).join(' ')).toContain(`printf '%s\\n' '{"t":"a'\\''b"}'`)
+ })
+ it('append leaves a leading ~/ unquoted for the mkdir dirname and the >> target', () => {
+ const j = sshAppendArgs(conn, '/s', '~/p/log.jsonl', 'L').join(' ')
+ expect(j).toContain(`mkdir -p ~/'p'`)
+ expect(j).toContain(`>> ~/'p/log.jsonl'`)
+ })
+ it('tail runs tail -n <lines> on the quoted path', () => {
+ expect(sshTailArgs(conn, '/s.sock', '/a b/log', 500).join(' ')).toContain(`tail -n 500 '/a b/log'`)
+ })
+ 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('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 3a6535284..e6f4c1bd6 100644
--- a/src/main/ssh-fs.ts
+++ b/src/main/ssh-fs.ts
@@ -38,6 +38,19 @@ export function sshWriteArgs(conn: SshConnection, cp: string, path: string): str
export function sshMkdirArgs(conn: SshConnection, cp: string, path: string): string[] {
return childArgs(conn, cp, `mkdir -p ${quoteRemotePath(path)}`)
}
+export function sshAppendArgs(conn: SshConnection, cp: string, path: string, line: string): string[] {
+ // Append one board-log line. `printf '%s\n'` (never `echo`) supplies the trailing newline and
+ // treats the line literally — the JSON content is posixQuote'd, so a `%`/backslash/quote in it
+ // is inert. mkdir -p keeps the first append on a fresh clone from failing.
+ return childArgs(
+ conn,
+ cp,
+ `mkdir -p ${quoteRemotePath(dirname(path))} && printf '%s\\n' ${posixQuote(line)} >> ${quoteRemotePath(path)}`
+ )
+}
+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 sshExistsArgs(conn: SshConnection, cp: string, path: string): string[] {
return childArgs(conn, cp, `test -e ${quoteRemotePath(path)}`)
}
diff --git a/src/renderer/lib/boardLogDiff.test.ts b/src/renderer/lib/boardLogDiff.test.ts
new file mode 100644
index 000000000..0236fd167
--- /dev/null
+++ b/src/renderer/lib/boardLogDiff.test.ts
@@ -0,0 +1,105 @@
+import { describe, expect, it } from 'vitest'
+import type { ProjectKanban } from '@shared/types'
+import { boardLogEvents } from './boardLogDiff'
+
+const col = (id: string, title: string) => ({ id, title, color: '#111' })
+const board = (columns: ProjectKanban['columns'], assignments: ProjectKanban['assignments']): ProjectKanban => ({
+ columns,
+ assignments
+})
+// Every real node is relevant by default; a pruned node returns '' (see prune test).
+const title = (id: string) => `card-${id}`
+
+describe('boardLogEvents', () => {
+ it('assignment added → card-moved from Ungrouped to the new column', () => {
+ const cols = [col('c1', 'To Do')]
+ const prev = board(cols, [])
+ const next = board(cols, [{ nodeId: 'n1', columnId: 'c1' }])
+ expect(boardLogEvents(prev, next, title)).toEqual([
+ { nodeId: 'n1', event: { type: 'card-moved', from: 'Ungrouped', to: 'To Do' } }
+ ])
+ })
+
+ it('assignment columnId changed → card-moved from old to new column name', () => {
+ const cols = [col('c1', 'To Do'), col('c2', 'Done')]
+ const prev = board(cols, [{ nodeId: 'n1', columnId: 'c1' }])
+ const next = board(cols, [{ nodeId: 'n1', columnId: 'c2' }])
+ expect(boardLogEvents(prev, next, title)).toEqual([
+ { nodeId: 'n1', event: { type: 'card-moved', from: 'To Do', to: 'Done' } }
+ ])
+ })
+
+ it('assignment removed while node still relevant → card-moved to Ungrouped', () => {
+ const cols = [col('c1', 'To Do')]
+ const prev = board(cols, [{ nodeId: 'n1', columnId: 'c1' }])
+ const next = board(cols, [])
+ expect(boardLogEvents(prev, next, title)).toEqual([
+ { nodeId: 'n1', event: { type: 'card-moved', from: 'To Do', to: 'Ungrouped' } }
+ ])
+ })
+
+ it('assignment removed by prune (node gone) → no move', () => {
+ const cols = [col('c1', 'To Do')]
+ const prev = board(cols, [{ nodeId: 'gone', columnId: 'c1' }])
+ const next = board(cols, [])
+ // cardTitle('gone') === '' → the node no longer exists (pruneAssignments), so no move noise.
+ expect(boardLogEvents(prev, next, (id) => (id === 'gone' ? '' : `card-${id}`))).toEqual([])
+ })
+
+ it('column added → column-added {title}', () => {
+ const prev = board([col('c1', 'To Do')], [])
+ const next = board([col('c1', 'To Do'), col('c2', 'Done')], [])
+ expect(boardLogEvents(prev, next, title)).toEqual([{ event: { type: 'column-added', title: 'Done' } }])
+ })
+
+ it('column title changed → column-renamed {from,to}', () => {
+ const prev = board([col('c1', 'To Do')], [])
+ const next = board([col('c1', 'Doing')], [])
+ expect(boardLogEvents(prev, next, title)).toEqual([{ event: { type: 'column-renamed', from: 'To Do', to: 'Doing' } }])
+ })
+
+ it('column deleted → only column-deleted {title}; per-card moves to Ungrouped are suppressed', () => {
+ const prev = board([col('c1', 'To Do'), col('c2', 'Done')], [
+ { nodeId: 'n1', columnId: 'c2' },
+ { nodeId: 'n2', columnId: 'c2' }
+ ])
+ // deleteColumn('c2') removes the column AND both assignments.
+ const next = board([col('c1', 'To Do')], [])
+ expect(boardLogEvents(prev, next, title)).toEqual([{ event: { type: 'column-deleted', title: 'Done' } }])
+ })
+
+ it('pure column reorder → []', () => {
+ const prev = board([col('c1', 'To Do'), col('c2', 'Done')], [])
+ const next = board([col('c2', 'Done'), col('c1', 'To Do')], [])
+ expect(boardLogEvents(prev, next, title)).toEqual([])
+ })
+
+ it('intra-column card order change → []', () => {
+ const cols = [col('c1', 'To Do')]
+ const prev = board(cols, [
+ { nodeId: 'a', columnId: 'c1' },
+ { nodeId: 'b', columnId: 'c1' }
+ ])
+ const next = board(cols, [
+ { nodeId: 'b', columnId: 'c1' },
+ { nodeId: 'a', columnId: 'c1' }
+ ])
+ expect(boardLogEvents(prev, next, title)).toEqual([])
+ })
+
+ it('no change at all → []', () => {
+ const cols = [col('c1', 'To Do')]
+ const b = board(cols, [{ nodeId: 'a', columnId: 'c1' }])
+ expect(boardLogEvents(b, b, title)).toEqual([])
+ })
+
+ it('dangling prev assignment (column already missing) resolves from-name to Ungrouped', () => {
+ // Assignment points at a column that exists in neither board (a leftover from elsewhere);
+ // moving it into a real column reads as coming from Ungrouped.
+ const prev = board([col('c1', 'To Do')], [{ nodeId: 'n1', columnId: 'dead' }])
+ const next = board([col('c1', 'To Do')], [{ nodeId: 'n1', columnId: 'c1' }])
+ expect(boardLogEvents(prev, next, title)).toEqual([
+ { nodeId: 'n1', event: { type: 'card-moved', from: 'Ungrouped', to: 'To Do' } }
+ ])
+ })
+})
diff --git a/src/renderer/lib/boardLogDiff.ts b/src/renderer/lib/boardLogDiff.ts
new file mode 100644
index 000000000..f2b3bd5ab
--- /dev/null
+++ b/src/renderer/lib/boardLogDiff.ts
@@ -0,0 +1,60 @@
+import type { BoardLogEvent, ProjectKanban } from '@shared/types'
+
+// Pure prev→next board diff → the events worth recording in the board log. No fs, no IPC:
+// the caller computes the next board (renderer/lib/kanban.ts) and asks here what changed.
+// Column names are resolved at event time; the virtual (unassigned) column is 'Ungrouped'.
+
+const UNGROUPED = 'Ungrouped'
+
+/** Board events implied by a prev→next board change. Column names resolved at event time;
+ * the virtual column is named 'Ungrouped'. Pure; returns [] when nothing loggable changed. */
+export function boardLogEvents(
+ prev: ProjectKanban,
+ next: ProjectKanban,
+ cardTitle: (nodeId: string) => string
+): Array<{ nodeId?: string; event: BoardLogEvent }> {
+ const out: Array<{ nodeId?: string; event: BoardLogEvent }> = []
+ const prevCols = new Map(prev.columns.map((c) => [c.id, c.title]))
+ const nextCols = new Map(next.columns.map((c) => [c.id, c.title]))
+
+ // Column added / renamed, in next order.
+ for (const c of next.columns) {
+ const old = prevCols.get(c.id)
+ if (old === undefined) out.push({ event: { type: 'column-added', title: c.title } })
+ else if (old !== c.title) out.push({ event: { type: 'column-renamed', from: old, to: c.title } })
+ }
+ // Column deleted — records ONLY column-deleted; the per-card "moved to Ungrouped" noise that
+ // deleteColumn produces (it drops the column's assignments too) is suppressed below.
+ const deleted = new Set<string>()
+ for (const c of prev.columns) {
+ if (!nextCols.has(c.id)) {
+ deleted.add(c.id)
+ out.push({ event: { type: 'column-deleted', title: c.title } })
+ }
+ }
+
+ const prevA = new Map(prev.assignments.map((a) => [a.nodeId, a.columnId]))
+ const nextA = new Map(next.assignments.map((a) => [a.nodeId, a.columnId]))
+ const nodeIds: string[] = []
+ const seen = new Set<string>()
+ for (const a of [...prev.assignments, ...next.assignments]) {
+ if (!seen.has(a.nodeId)) {
+ seen.add(a.nodeId)
+ nodeIds.push(a.nodeId)
+ }
+ }
+
+ for (const nodeId of nodeIds) {
+ const pc = prevA.get(nodeId)
+ const nc = nextA.get(nodeId)
+ if (pc === nc) continue // unchanged, or same column with only an intra-column reorder
+ const fromName = pc === undefined ? UNGROUPED : prevCols.get(pc) ?? UNGROUPED
+ const toName = nc === undefined ? UNGROUPED : nextCols.get(nc) ?? UNGROUPED
+ if (nc === undefined) {
+ if (pc !== undefined && deleted.has(pc)) continue // column deleted → not a move
+ if (!cardTitle(nodeId)) continue // node no longer exists (pruneAssignments) → not a move
+ }
+ out.push({ nodeId, event: { type: 'card-moved', from: fromName, to: toName } })
+ }
+ return out
+}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index fc2bdcd78..7b1d05495 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -218,6 +218,34 @@ export interface ProjectKanban {
assignments: KanbanAssignment[]
}
+/** Who produced a board-log entry (a teammate on a shared board, or this user). */
+export interface BoardLogAuthor {
+ name: string
+ color: string
+}
+
+/** A structural board change worth recording. `type` is closed; the optional fields carry
+ * the human-readable names resolved at event time (the virtual column is named 'Ungrouped'). */
+export interface BoardLogEvent {
+ type: 'card-created' | 'card-moved' | 'column-added' | 'column-renamed' | 'column-deleted'
+ from?: string
+ to?: string
+ /** Column title for column-added/deleted; card title for card-created. */
+ title?: string
+}
+
+/** One line of the append-only board history (`.nodeterm/board-log.jsonl`). A `comment`
+ * carries `text`; an `event` carries `event`. Serialized one-per-line as JSON. */
+export interface BoardLogEntry {
+ id: string
+ ts: number
+ author: BoardLogAuthor
+ nodeId?: string
+ kind: 'comment' | 'event'
+ text?: string
+ event?: BoardLogEvent
+}
+
/** A project is one canvas/page: its own nodes, viewport, and default working dir. */
export interface Project {
id: string