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(board-log): comments & activity panel in the card modal, event emission from the board funnels
enese1ccf71c08dc
diff --git a/src/renderer/bridge/relay-api.ts b/src/renderer/bridge/relay-api.tsindex 6ea9d3831..e97e2cbf0 100644--- a/src/renderer/bridge/relay-api.ts+++ b/src/renderer/bridge/relay-api.ts@@ -124,8 +124,8 @@ export function buildRelayApi(connectionId: string, transport?: FrameTransport):// silent no-op): ──// The SDK chat node has no relay chat builder yet (the Server Edition defers it too). Routing to// the local chat driver would run it on the WRONG machine (a host cwd that does not exist- // locally), so refuse with E_UNSUPPORTED instead. contextLink / transcripts / handoff stay LOCAL- // by way of `...local` (a v1 degrade: they read/write on this machine, not the host).+ // locally), so refuse with E_UNSUPPORTED instead. contextLink / transcripts / handoff / boardLog+ // stay LOCAL by way of `...local` (a v1 degrade: they read/write on this machine, not the host).chat: stub.chat,// Agent canvas-control (`agent:control`) is not wired over the relay (matches the Server// Edition); inert no-ops rather than a local subscription that never carries the host's events.diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex c8dc3891d..29f76c2a4 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -181,8 +181,10 @@ import { useEntitlement } from '../state/entitlement'import type { SshServer, SshConnection } from '@shared/ssh'import { sshHostKey } from '@shared/ssh'import type { CanvasNodeState, Project, ProjectKanban, SshProjectStatus, TranscriptHit } from '@shared/types'-import { KanbanView, type KanbanCreateChoice } from '../components/kanban/KanbanView'+import { KanbanView, type KanbanCreateChoice, type KanbanSession } from '../components/kanban/KanbanView'import { assignNode, defaultKanban } from '../lib/kanban'+import { boardLogEvents } from '../lib/boardLogDiff'+import { useBoardLog } from '../state/boardLog'import { isKanbanOpen, useViewMode } from '../state/viewMode'import {createCanvasPublisher,@@ -648,6 +650,10 @@ export function Canvas() {const settings = useSettings((s) => s.settings)const viewportRef = useRef<Viewport>({ x: 0, y: 0, zoom: 1 })const nodesRef = useRef<CanvasNode[]>(nodes)+ // Live mirror of the derived board cards (defined far below), so the board-log emission funnel+ // in onKanbanChange — declared above kanbanSessions — can resolve a node's card title without a+ // dep cycle. Assigned right after that useMemo, same render-mirror idiom as nodesRef.+ const kanbanSessionsRef = useRef<KanbanSession[]>([])// focusNodeById, for callbacks declared ABOVE its definition (openFile's dedupe focuses the// already-open node). Assigned right after the definition, same render-mirror idiom as nodesRef.const focusNodeRef = useRef<(nodeId: string) => void>(() => {})@@ -1237,10 +1243,24 @@ export function Canvas() {(next: ProjectKanban) => {const id = useProjects.getState().activeProjectIdif (!id) return+ // The board BEFORE this change — read fresh at callback entry (a stale closed-over value+ // would misattribute the diff). Same lazy-default as the KanbanView render.+ const prev = useProjects.getState().getProject(id)?.kanban ?? seedBoarduseProjects.getState().setProjectKanban(id, next)markDirty() // rides the existing debounced persist (commitActiveToStore + workspace.save)+ // cardTitle must return '' for — and ONLY for — nodes that no longer exist (the diff reads+ // '' as "pruned removal, not a move"). A LIVE node with an empty title maps to 'Untitled',+ // never '' (see boardLogEvents' JSDoc).+ const sessions = kanbanSessionsRef.current+ const cardTitle = (nodeId: string): string => {+ const s = sessions.find((x) => x.id === nodeId)+ return s ? s.title || 'Untitled' : ''+ }+ for (const { nodeId, event } of boardLogEvents(prev, next, cardTitle)) {+ useBoardLog.getState().append(api, id, { kind: 'event', nodeId, event })+ }},- [markDirty]+ [markDirty, api, seedBoard])// The node states that go on the wire: React Flow's managed nodes minus the ephemeral cards@@ -4086,6 +4106,7 @@ export function Canvas() {}),[nodes])+ kanbanSessionsRef.current = kanbanSessions// Create a node from the board's per-column "+ New" menu: it lands on the canvas (view// center) and, for a real column, is assigned there. The assignment is written directly —@@ -4116,13 +4137,33 @@ export function Canvas() {activePermissionMode())setNodes((ns) => [...ns, node])+ const board = project?.kanban ?? seedBoardif (columnId) {- const board = project?.kanban ?? seedBoarduseProjects.getState().setProjectKanban(activeProjectId, assignNode(board, node.id, columnId, null))}markDirty()+ // Log card-created directly here — the assignment above is written straight to the store+ // (not via onKanbanChange), so its diff never runs and never double-logs a card-moved.+ const toName = columnId+ ? board.columns.find((c) => c.id === columnId)?.title ?? 'Ungrouped'+ : 'Ungrouped'+ const kindLabel =+ choice.kind === 'terminal'+ ? 'Terminal'+ : choice.kind === 'sticky'+ ? 'Sticky note'+ : agentConfig(choice.agentId)?.label ??+ useSettings.getState().settings.customAgents.find((a) => a.id === choice.agentId)+ ?.label ??+ choice.agentId+ const title = (node.data.title as string) || kindLabel+ useBoardLog.getState().append(api, activeProjectId, {+ kind: 'event',+ nodeId: node.id,+ event: { type: 'card-created', to: toName, title }+ })},- [activeProjectId, viewCenter, setNodes, markDirty, seedBoard]+ [activeProjectId, viewCenter, setNodes, markDirty, seedBoard, api])const openNodeFromKanban = useCallback(diff --git a/src/renderer/components/kanban/BoardLogPanel.tsx b/src/renderer/components/kanban/BoardLogPanel.tsxnew file mode 100644index 000000000..302d13695--- /dev/null+++ b/src/renderer/components/kanban/BoardLogPanel.tsx@@ -0,0 +1,105 @@+import { useEffect, useState } from 'react'+import type { BoardLogEntry, BoardLogEvent } from '@shared/types'+import { formatTimeAgo } from '../../lib/usageFormat'+import { useSession } from '../../session/session'+import { useProjects } from '../../state/projects'+import { useBoardLog } from '../../state/boardLog'+import type { KanbanSession } from './KanbanView'++interface BoardLogPanelProps {+ /** The card whose activity this panel shows — feed + composer are scoped to `card.id`. */+ card: KanbanSession+}++/** Human one-liner for an activity event. column-* events carry no nodeId and so never reach a+ * card-scoped feed; they are handled defensively for completeness. */+function eventLine(name: string, e: BoardLogEvent): string {+ switch (e.type) {+ case 'card-created':+ return `${name} created this card in ${e.to ?? 'Ungrouped'}`+ case 'card-moved':+ return `${name} moved this card ${e.from ?? 'Ungrouped'} → ${e.to ?? 'Ungrouped'}`+ case 'column-added':+ return `${name} added column ${e.title ?? ''}`.trimEnd()+ case 'column-renamed':+ return `${name} renamed column ${e.from ?? ''} → ${e.to ?? ''}`+ case 'column-deleted':+ return `${name} deleted column ${e.title ?? ''}`.trimEnd()+ }+}++/** Right panel of the card modal (all card kinds): a composer on top and the card's own+ * comments + activity feed newest-first. Reads/writes the board log for the ACTIVE project via+ * its session api — resolved here (not threaded from Canvas). Subscribes on mount, so a teammate's+ * comment or a board change lands live; unsubscribes on unmount / card swap. */+export function BoardLogPanel({ card }: BoardLogPanelProps) {+ const { api } = useSession()+ const projectId = useProjects((s) => s.activeProjectId)+ const entries = useBoardLog((s) => s.entriesByProject[projectId])+ const unsupported = useBoardLog((s) => !!s.unsupportedByProject[projectId])+ const error = useBoardLog((s) => !!s.errorByProject[projectId])+ const [draft, setDraft] = useState('')++ useEffect(() => {+ if (!projectId) return+ void useBoardLog.getState().load(api, projectId)+ const unsub = useBoardLog.getState().subscribeChanged(api, projectId)+ return unsub+ }, [api, projectId])++ const send = () => {+ const text = draft.trim()+ if (!text) return+ useBoardLog.getState().append(api, projectId, { kind: 'comment', nodeId: card.id, text })+ setDraft('')+ }++ // Card-scoped: this card's comments + its own events. Column events (no nodeId) never match.+ const feed = (entries ?? []).filter((e) => e.nodeId === card.id)++ return (+ <div className="board-log">+ <div className="board-log__title">Comments & activity</div>+ {unsupported ? (+ <div className="board-log__hint">Board history needs a project folder</div>+ ) : (+ <textarea+ className="board-log__composer"+ value={draft}+ placeholder="Write a comment…"+ onChange={(e) => setDraft(e.target.value)}+ onKeyDown={(e) => {+ // Enter sends; Shift+Enter inserts a newline (default textarea behavior).+ if (e.key === 'Enter' && !e.shiftKey) {+ e.preventDefault()+ send()+ }+ }}+ />+ )}+ {error && <div className="board-log__error">Couldn’t save your last comment.</div>}+ <div className="board-log__feed">+ {feed.map((entry) => (+ <FeedRow key={entry.id} entry={entry} />+ ))}+ </div>+ </div>+ )+}++function FeedRow({ entry }: { entry: BoardLogEntry }) {+ const when = formatTimeAgo(entry.ts)+ if (entry.kind === 'event' && entry.event) {+ return <div className="board-log__event">{eventLine(entry.author.name, entry.event)}</div>+ }+ return (+ <div className="board-log__comment">+ <div className="board-log__meta">+ <span className="board-log__dot" style={{ background: entry.author.color }} />+ <span className="board-log__author">{entry.author.name}</span>+ <span className="board-log__time">{when}</span>+ </div>+ <div className="board-log__text">{entry.text}</div>+ </div>+ )+}diff --git a/src/renderer/components/kanban/CardModal.tsx b/src/renderer/components/kanban/CardModal.tsxindex d1ea0470b..be2b404d9 100644--- a/src/renderer/components/kanban/CardModal.tsx+++ b/src/renderer/components/kanban/CardModal.tsx@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'import { createPortal } from 'react-dom'import { isTopDialog, nextDialogId, popDialog, pushDialog } from '../dialog-stack'import type { KanbanSession } from './KanbanView'+import { BoardLogPanel } from './BoardLogPanel'import { ModalTerminal } from './ModalTerminal'interface CardModalProps {@@ -99,24 +100,28 @@ export function CardModal({ session, columnTitle, onClose, onOpenCanvas, onRenam</button></div><div className="kanban-modal__body">- {session.kind === 'sticky' ? (- <textarea- className="kanban-modal__sticky"- value={session.text ?? ''}- placeholder="Write a note…"- onChange={(e) => onEditSticky(e.target.value)}- />- ) : (- <div className="kanban-modal__pane" data-kind={session.kind}>- {session.kind === 'terminal' ? (- // A live SECOND client on the node's session — keyed by node id so switching cards- // remounts a fresh viewer. Chat has no PTY; it opens on the canvas.- <ModalTerminal key={session.id} nodeId={session.id} spawn={session.spawn} />- ) : (- <div className="kanban-modal__placeholder">Chat sessions open on the canvas.</div>- )}- </div>- )}+ {/* Body is a flex row: the card's own pane (2/3) + the board-log panel (1/3, all kinds). */}+ <div className="kanban-modal__main">+ {session.kind === 'sticky' ? (+ <textarea+ className="kanban-modal__sticky"+ value={session.text ?? ''}+ placeholder="Write a note…"+ onChange={(e) => onEditSticky(e.target.value)}+ />+ ) : (+ <div className="kanban-modal__pane" data-kind={session.kind}>+ {session.kind === 'terminal' ? (+ // A live SECOND client on the node's session — keyed by node id so switching cards+ // remounts a fresh viewer. Chat has no PTY; it opens on the canvas.+ <ModalTerminal key={session.id} nodeId={session.id} spawn={session.spawn} />+ ) : (+ <div className="kanban-modal__placeholder">Chat sessions open on the canvas.</div>+ )}+ </div>+ )}+ </div>+ <BoardLogPanel card={session} /></div></div></div>,diff --git a/src/renderer/lib/boardLogDiff.ts b/src/renderer/lib/boardLogDiff.tsindex f2b3bd5ab..b20f75e18 100644--- a/src/renderer/lib/boardLogDiff.ts+++ b/src/renderer/lib/boardLogDiff.ts@@ -7,7 +7,12 @@ import type { BoardLogEvent, ProjectKanban } from '@shared/types'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. */+ * the virtual column is named 'Ungrouped'. Pure; returns [] when nothing loggable changed.+ *+ * BINDING INVARIANT — `cardTitle` MUST return '' for, and ONLY for, a nodeId whose node no+ * longer exists: a removed assignment with an empty title is read as a prune (not a move) and+ * suppressed. A LIVE node with an empty title must map to a non-empty placeholder ('Untitled'),+ * never '' — otherwise moving/removing an untitled card would be silently dropped. */export function boardLogEvents(prev: ProjectKanban,next: ProjectKanban,diff --git a/src/renderer/state/boardLog.ts b/src/renderer/state/boardLog.tsnew file mode 100644index 000000000..2a44a0bf3--- /dev/null+++ b/src/renderer/state/boardLog.ts@@ -0,0 +1,102 @@+import { create } from 'zustand'+import type { BoardLogEntry, NodeTerminalApi } from '@shared/types'+import { loadIdentity } from './presence'++/**+ * Board-log store — the renderer view of a project's append-only board history+ * (`.nodeterm/board-log.jsonl`, project-routed by the `boardLog` api). One entry list per+ * project id; the modal's "Comments & activity" panel reads it and appends to it.+ *+ * The api is passed IN (never captured off `window.nodeTerminal`): a remote project's board log+ * lives on its host and is reached through that session's api, so every call takes the api the+ * caller resolved for the project (Canvas uses its session api; the panel uses `useSession()`).+ *+ * `append` is OPTIMISTIC + fire-and-forget: it stamps the entry, prepends it locally (the log is+ * newest-first, matching `read`), and calls `api.boardLog.append` without awaiting — on a `false`+ * result or a rejection it raises a quiet per-project `error` flag (the local entry stays; the+ * next change-push reload reconciles). `read` is authoritative: it REPLACES the list, so our own+ * appended entry (same client-generated id, persisted verbatim) never duplicates on reload.+ */++/** The default author when the user has never picked a presence identity. */+const ANON_AUTHOR = { name: 'you', color: '#8e8e93' }++/** Shared stable empty list — a project with no loaded entries returns this exact array, so a+ * reactive selector does not see a fresh `[]` (and re-render) on every unrelated store write. */+const EMPTY: BoardLogEntry[] = []++/** The caller-supplied part of an entry; the store stamps `id`/`ts`/`author`. */+export type BoardLogAppendInput = Pick<BoardLogEntry, 'kind' | 'nodeId' | 'text' | 'event'>++interface BoardLogState {+ /** Loaded entries per project id, NEWEST-FIRST. */+ entriesByProject: Record<string, BoardLogEntry[]>+ /** Projects whose log is unreachable (inline/no-cwd, disconnected SSH, server-side SSH). */+ unsupportedByProject: Record<string, boolean>+ /** Quiet flag: an append failed for this project (the local entry is still shown). */+ errorByProject: Record<string, boolean>+ /** The entries for a project (stable empty array when none are loaded). */+ entriesFor(projectId: string): BoardLogEntry[]+ /** Read the log for a project and replace its list; records the unsupported/clears error flags. */+ load(api: NodeTerminalApi, projectId: string): Promise<void>+ /** Stamp + optimistically prepend an entry, then fire-and-forget the api append. */+ append(api: NodeTerminalApi, projectId: string, input: BoardLogAppendInput): void+ /** Wire `onChanged` → reload for a project; returns the unsubscribe. */+ subscribeChanged(api: NodeTerminalApi, projectId: string): () => void+}++export const useBoardLog = create<BoardLogState>((set, get) => ({+ entriesByProject: {},+ unsupportedByProject: {},+ errorByProject: {},++ entriesFor: (projectId) => get().entriesByProject[projectId] ?? EMPTY,++ load: async (api, projectId) => {+ try {+ const res = await api.boardLog.read(projectId)+ set((s) => ({+ entriesByProject: { ...s.entriesByProject, [projectId]: res.entries },+ unsupportedByProject: { ...s.unsupportedByProject, [projectId]: !!res.unsupported },+ // A successful read supersedes any stale append error for this project.+ errorByProject: { ...s.errorByProject, [projectId]: false }+ }))+ } catch {+ // A failed read leaves the last-known list untouched — never blank the panel on a hiccup.+ }+ },++ append: (api, projectId, input) => {+ const id = loadIdentity()+ const author = id ? { name: id.name, color: id.color } : ANON_AUTHOR+ const entry: BoardLogEntry = {+ id: crypto.randomUUID(),+ ts: Date.now(),+ author,+ kind: input.kind,+ ...(input.nodeId !== undefined ? { nodeId: input.nodeId } : {}),+ ...(input.text !== undefined ? { text: input.text } : {}),+ ...(input.event !== undefined ? { event: input.event } : {})+ }+ // Optimistic newest-first insert.+ set((s) => ({+ entriesByProject: {+ ...s.entriesByProject,+ [projectId]: [entry, ...(s.entriesByProject[projectId] ?? EMPTY)]+ }+ }))+ const flagError = () =>+ set((s) => ({ errorByProject: { ...s.errorByProject, [projectId]: true } }))+ api.boardLog+ .append(projectId, entry)+ .then((ok) => {+ if (!ok) flagError()+ })+ .catch(flagError)+ },++ subscribeChanged: (api, projectId) =>+ api.boardLog.onChanged(projectId, () => {+ void get().load(api, projectId)+ })+}))diff --git a/src/renderer/styles.css b/src/renderer/styles.cssindex 24e42d1a1..bfa4a034e 100644--- a/src/renderer/styles.css+++ b/src/renderer/styles.css@@ -6710,6 +6710,12 @@ body,min-height: 0;display: flex;}+/* The card's own pane (terminal / sticky / chat) takes 2/3; the board-log panel takes 1/3. */+.kanban-modal__main {+ flex: 2;+ min-width: 0;+ display: flex;+}.kanban-modal__sticky {flex: 1;background: none;@@ -6738,3 +6744,100 @@ body,min-width: 0;padding: 8px;}++/* ── Board log: the modal's "Comments & activity" panel (right 1/3) ── */+.board-log {+ flex: 1;+ min-width: 0;+ display: flex;+ flex-direction: column;+ border-left: 1px solid rgba(255, 255, 255, 0.08);+ background: rgba(255, 255, 255, 0.015);+}+.board-log__title {+ flex: 0 0 auto;+ font-size: 10px;+ text-transform: uppercase;+ letter-spacing: 0.05em;+ color: rgba(255, 255, 255, 0.4);+ padding: 12px 14px 8px;+}+.board-log__composer {+ flex: 0 0 auto;+ margin: 0 12px 10px;+ min-height: 52px;+ max-height: 140px;+ resize: none;+ background: rgba(255, 255, 255, 0.05);+ border: 1px solid rgba(255, 255, 255, 0.1);+ border-radius: 7px;+ color: rgba(255, 255, 255, 0.9);+ font-family: inherit;+ font-size: 12px;+ line-height: 1.45;+ padding: 8px 10px;+ outline: none;+}+.board-log__composer:focus {+ border-color: var(--accent);+}+.board-log__hint {+ flex: 0 0 auto;+ margin: 0 14px 10px;+ font-size: 11px;+ color: rgba(255, 255, 255, 0.35);+}+.board-log__error {+ flex: 0 0 auto;+ margin: 0 14px 8px;+ font-size: 10px;+ color: rgba(255, 120, 120, 0.75);+}+.board-log__feed {+ flex: 1;+ min-height: 0;+ overflow-y: auto;+ padding: 4px 14px 14px;+ display: flex;+ flex-direction: column;+ gap: 12px;+}+.board-log__comment {+ display: flex;+ flex-direction: column;+ gap: 3px;+}+.board-log__meta {+ display: flex;+ align-items: center;+ gap: 6px;+}+.board-log__dot {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ flex: 0 0 auto;+}+.board-log__author {+ font-size: 12px;+ font-weight: 600;+ color: rgba(255, 255, 255, 0.85);+}+.board-log__time {+ font-size: 10px;+ color: rgba(255, 255, 255, 0.35);+}+.board-log__text {+ font-size: 12px;+ line-height: 1.45;+ color: rgba(255, 255, 255, 0.82);+ white-space: pre-wrap;+ word-break: break-word;+ padding-left: 14px;+}+.board-log__event {+ font-size: 11px;+ line-height: 1.4;+ color: rgba(255, 255, 255, 0.42);+ padding-left: 14px;+}