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(kanban): fold runs of like board-log events into one ×N row

review5fcc85a5b7b7
diff --git a/src/renderer/components/kanban/BoardLogFeed.test.tsx b/src/renderer/components/kanban/BoardLogFeed.test.tsx
new file mode 100644
index 000000000..535cc834c
--- /dev/null
+++ b/src/renderer/components/kanban/BoardLogFeed.test.tsx
@@ -0,0 +1,56 @@
+// @vitest-environment jsdom
+//
+// The card feed folds runs of like events into one "×N" row at RENDER time; expanding it shows
+// every row it holds. Comments and the two audit types always render one row per entry.
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import type { BoardLogEntry, BoardLogEvent } from '@shared/types'
+import { BoardLogFeed } from './BoardLogPanel'
+
+let root: Root
+let host: HTMLElement
+const A = { name: 'enes', color: '#0a84ff' }
+const ev = (id: string, ts: number, type: BoardLogEvent['type']): BoardLogEntry => ({
+ id, ts, author: A, nodeId: 'card', kind: 'event', event: { type, from: 'To Do', to: 'Done' }
+})
+
+beforeEach(() => {
+ vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+})
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+ vi.unstubAllGlobals()
+})
+
+const rows = (): number => host.querySelectorAll('.board-log__event, .board-log__comment').length
+
+describe('BoardLogFeed', () => {
+ it('shows a run of like events as one ×N row that expands to every entry', () => {
+ const feed = [ev('3', 3000, 'card-moved'), ev('2', 2000, 'card-moved'), ev('1', 1000, 'card-moved')]
+ act(() => root.render(<BoardLogFeed feed={feed} />))
+ expect(rows()).toBe(1)
+ const more = host.querySelector<HTMLButtonElement>('.board-log__fold')!
+ expect(more.textContent).toContain('×3')
+ act(() => {
+ more.dispatchEvent(new MouseEvent('click', { bubbles: true }))
+ })
+ expect(rows()).toBe(3)
+ expect(host.querySelector('.board-log__fold')?.getAttribute('aria-expanded')).toBe('true')
+ })
+
+ it('renders every audit row on its own', () => {
+ const feed = [
+ ev('3', 3000, 'agent-message'),
+ ev('2', 2000, 'agent-message'),
+ ev('1', 1000, 'agent-read-cookies')
+ ]
+ act(() => root.render(<BoardLogFeed feed={feed} />))
+ expect(rows()).toBe(3)
+ expect(host.querySelector('.board-log__fold')).toBeNull()
+ })
+})
diff --git a/src/renderer/components/kanban/BoardLogPanel.tsx b/src/renderer/components/kanban/BoardLogPanel.tsx
index c178bd890..7bc42f974 100644
--- a/src/renderer/components/kanban/BoardLogPanel.tsx
+++ b/src/renderer/components/kanban/BoardLogPanel.tsx
@@ -1,9 +1,10 @@
-import { useEffect, useState } from 'react'
+import { useEffect, useMemo, 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 { collapseFeed } from '../../lib/boardLogCollapse'
import type { KanbanSession } from './KanbanView'
interface BoardLogPanelProps {
@@ -118,16 +119,55 @@ export function BoardLogPanel({ card }: BoardLogPanelProps) {
{!unsupported && error && (
<div className="board-log__error">Some board history couldn’t be saved.</div>
)}
- <div className="board-log__feed">
- {feed.map((entry) => (
- <FeedRow key={entry.id} entry={entry} />
- ))}
- </div>
+ <BoardLogFeed feed={feed} />
+ </div>
+ )
+}
+
+/** The feed itself, newest first. Runs of like events render folded as one "×N" row that expands
+ * in place (lib/boardLogCollapse — a VIEW; the log is never rewritten). Comments and the audit
+ * types are always one row each. Which groups are open is component state keyed by the group's
+ * newest entry id, so a new entry landing on top does not collapse a row the user just opened. */
+export function BoardLogFeed({ feed }: { feed: readonly BoardLogEntry[] }) {
+ const [open, setOpen] = useState<ReadonlySet<string>>(() => new Set())
+ const items = useMemo(() => collapseFeed(feed), [feed])
+ const toggle = (key: string): void =>
+ setOpen((cur) => {
+ const next = new Set(cur)
+ if (next.has(key)) next.delete(key)
+ else next.add(key)
+ return next
+ })
+ return (
+ <div className="board-log__feed">
+ {items.map((item) => {
+ if (item.kind === 'single') return <FeedRow key={item.entry.id} entry={item.entry} />
+ const expanded = open.has(item.key)
+ const fold = (
+ <button
+ className="board-log__fold"
+ aria-expanded={expanded}
+ title={expanded ? 'Collapse' : `Show all ${item.entries.length}`}
+ onClick={() => toggle(item.key)}
+ >
+ ×{item.entries.length}
+ </button>
+ )
+ return expanded ? (
+ <div key={item.key} className="board-log__group board-log__group--open">
+ {item.entries.map((entry, i) => (
+ <FeedRow key={entry.id} entry={entry} fold={i === 0 ? fold : undefined} />
+ ))}
+ </div>
+ ) : (
+ <FeedRow key={item.key} entry={item.entries[0]} fold={fold} />
+ )
+ })}
</div>
)
}
-function FeedRow({ entry }: { entry: BoardLogEntry }) {
+function FeedRow({ entry, fold }: { entry: BoardLogEntry; fold?: React.ReactNode }) {
const when = formatStamp(entry.ts)
const whenAgo = formatTimeAgo(entry.ts)
if (entry.kind === 'event' && entry.event) {
@@ -138,6 +178,7 @@ function FeedRow({ entry }: { entry: BoardLogEntry }) {
{entry.author.name}
</span>{' '}
<span className="board-log__event-body">{eventBody(entry.event)}</span>
+ {fold}
<span className="board-log__time">{when}</span>
</div>
)
diff --git a/src/renderer/lib/boardLogCollapse.test.ts b/src/renderer/lib/boardLogCollapse.test.ts
new file mode 100644
index 000000000..6a0d9a9be
--- /dev/null
+++ b/src/renderer/lib/boardLogCollapse.test.ts
@@ -0,0 +1,88 @@
+import { describe, expect, it } from 'vitest'
+import type { BoardLogEntry, BoardLogEvent } from '@shared/types'
+import { BOARD_LOG_COLLAPSE_WINDOW_MS, NEVER_COLLAPSE, collapseFeed } from './boardLogCollapse'
+
+const ME = { name: 'enes', color: '#0a84ff' }
+const AGENT = { name: 'claude-1', color: '#d97757' }
+let n = 0
+const ev = (ts: number, type: BoardLogEvent['type'], author = ME, extra: Partial<BoardLogEvent> = {}): BoardLogEntry => ({
+ id: `e${n++}`,
+ ts,
+ author,
+ nodeId: 'card',
+ kind: 'event',
+ event: { type, ...extra }
+})
+const comment = (ts: number, author = ME): BoardLogEntry => ({
+ id: `c${n++}`,
+ ts,
+ author,
+ nodeId: 'card',
+ kind: 'comment',
+ text: 'hi'
+})
+const MIN = 60_000
+const shape = (items: ReturnType<typeof collapseFeed>): Array<number> =>
+ items.map((i) => (i.kind === 'group' ? i.entries.length : 1))
+
+describe('collapseFeed (render-time only — the log itself is never rewritten)', () => {
+ it('folds consecutive same-author same-type events within 2 minutes into one ×N row', () => {
+ // newest-first, like the feed
+ const feed = [ev(10 * MIN, 'card-moved'), ev(9.5 * MIN, 'card-moved'), ev(9 * MIN, 'card-moved')]
+ const out = collapseFeed(feed)
+ expect(shape(out)).toEqual([3])
+ expect(out[0].kind === 'group' && out[0].entries.map((e) => e.id)).toEqual(feed.map((e) => e.id))
+ })
+
+ it('keeps the entries it folds, newest first, so the row can expand', () => {
+ const feed = [ev(2 * MIN, 'due-set'), ev(1 * MIN, 'due-set')]
+ const out = collapseFeed(feed)
+ expect(out[0].kind).toBe('group')
+ })
+
+ it('the window is anchored at the group’s NEWEST row — a ×N never spans more than 2 minutes', () => {
+ // 90 s apart each: a chained window would fold all four; an anchored one cannot.
+ const feed = [ev(6 * MIN, 'card-moved'), ev(4.5 * MIN, 'card-moved'), ev(3 * MIN, 'card-moved'), ev(1.5 * MIN, 'card-moved')]
+ expect(shape(collapseFeed(feed))).toEqual([2, 2])
+ })
+
+ it('does not fold across a different author, a different type, or a comment between them', () => {
+ expect(shape(collapseFeed([ev(3, 'card-moved'), ev(2, 'card-moved', AGENT), ev(1, 'card-moved')]))).toEqual([1, 1, 1])
+ expect(shape(collapseFeed([ev(3, 'card-moved'), ev(2, 'due-set'), ev(1, 'card-moved')]))).toEqual([1, 1, 1])
+ expect(shape(collapseFeed([ev(3, 'card-moved'), comment(2), ev(1, 'card-moved')]))).toEqual([1, 1, 1])
+ })
+
+ it('never folds comments', () => {
+ expect(shape(collapseFeed([comment(3), comment(2), comment(1)]))).toEqual([1, 1, 1])
+ })
+
+ it('never folds the two AUDIT types, however alike the rows are', () => {
+ expect([...NEVER_COLLAPSE].sort()).toEqual(['agent-message', 'agent-read-cookies'])
+ for (const type of NEVER_COLLAPSE) {
+ const feed = [ev(3, type, AGENT), ev(2, type, AGENT), ev(1, type, AGENT)]
+ expect(shape(collapseFeed(feed))).toEqual([1, 1, 1])
+ }
+ })
+
+ it('an author with the same name but a different colour is someone else', () => {
+ const other = { name: 'enes', color: '#ff0000' }
+ expect(shape(collapseFeed([ev(2, 'card-moved'), ev(1, 'card-moved', other)]))).toEqual([1, 1])
+ })
+
+ it('exactly 2 minutes still folds; a millisecond more does not', () => {
+ expect(shape(collapseFeed([ev(BOARD_LOG_COLLAPSE_WINDOW_MS, 'card-moved'), ev(0, 'card-moved')]))).toEqual([2])
+ expect(shape(collapseFeed([ev(BOARD_LOG_COLLAPSE_WINDOW_MS + 1, 'card-moved'), ev(0, 'card-moved')]))).toEqual([1, 1])
+ })
+
+ it('tolerates an event entry with no event payload (renders it alone)', () => {
+ const broken = { ...ev(2, 'card-moved'), event: undefined }
+ expect(shape(collapseFeed([broken, broken]))).toEqual([1, 1])
+ })
+
+ it('does not mutate its input', () => {
+ const feed = [ev(2, 'card-moved'), ev(1, 'card-moved')]
+ const copy = JSON.parse(JSON.stringify(feed))
+ collapseFeed(feed)
+ expect(feed).toEqual(copy)
+ })
+})
diff --git a/src/renderer/lib/boardLogCollapse.ts b/src/renderer/lib/boardLogCollapse.ts
new file mode 100644
index 000000000..d7125f9d0
--- /dev/null
+++ b/src/renderer/lib/boardLogCollapse.ts
@@ -0,0 +1,59 @@
+/**
+ * Render-time folding of the card activity feed: consecutive rows by the same author, of the same
+ * event type, within two minutes, show as ONE "×N" row that expands to the rows it holds.
+ *
+ * The log itself (`.nodeterm/board-log.jsonl`, append-only and git-shared) is NEVER rewritten —
+ * this is a view over it, so a teammate on an older build, and this user expanding the row, still
+ * see every entry exactly as it was written.
+ *
+ * Rules:
+ * - comments never fold (each one is something a person wrote);
+ * - `NEVER_COLLAPSE` types never fold — `agent-message` and `agent-read-cookies` are AUDIT rows:
+ * a trace whose rows can be folded away is a trace a reader can miss one row of;
+ * - the window is anchored at the group's NEWEST row, so a "×N" never spans more than two
+ * minutes. A chained window (each row within 2 min of the previous one) would let a card dragged
+ * back and forth every 90 seconds for an hour collapse into a single row claiming one moment;
+ * - "same author" is name AND colour: that pair is the presence identity the feed attributes by.
+ */
+import type { BoardLogEntry, BoardLogEvent } from '@shared/types'
+
+export const BOARD_LOG_COLLAPSE_WINDOW_MS = 2 * 60_000
+
+/** Audit event types: always one row each. */
+export const NEVER_COLLAPSE: ReadonlySet<BoardLogEvent['type']> = new Set<BoardLogEvent['type']>([
+ 'agent-message',
+ 'agent-read-cookies'
+])
+
+export type FeedItem =
+ | { kind: 'single'; entry: BoardLogEntry }
+ /** Two or more foldable rows, newest first. `key` is the newest row's id. */
+ | { kind: 'group'; key: string; entries: BoardLogEntry[] }
+
+const foldable = (e: BoardLogEntry): boolean =>
+ e.kind === 'event' && !!e.event && !NEVER_COLLAPSE.has(e.event.type)
+
+const sameRun = (head: BoardLogEntry, e: BoardLogEntry): boolean =>
+ foldable(e) &&
+ e.author?.name === head.author?.name &&
+ e.author?.color === head.author?.color &&
+ e.event?.type === head.event?.type &&
+ Math.abs(head.ts - e.ts) <= BOARD_LOG_COLLAPSE_WINDOW_MS
+
+/** Folds a newest-first, card-scoped feed. Pure; never mutates its input. */
+export function collapseFeed(feed: readonly BoardLogEntry[]): FeedItem[] {
+ const out: FeedItem[] = []
+ let i = 0
+ while (i < feed.length) {
+ const head = feed[i]
+ let j = i + 1
+ if (foldable(head)) while (j < feed.length && sameRun(head, feed[j])) j++
+ out.push(
+ j - i > 1
+ ? { kind: 'group', key: head.id, entries: feed.slice(i, j) }
+ : { kind: 'single', entry: head }
+ )
+ i = j
+ }
+ return out
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 47def20ed..be21bf22e 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -11527,6 +11527,29 @@ button.group-node__setup:disabled {
font-size: 10px;
color: rgba(var(--tint-rgb), 0.35);
}
+/* A run of like events folded at render time (lib/boardLogCollapse) — the ×N toggle. */
+.board-log__fold {
+ background: rgba(var(--tint-rgb), 0.07);
+ border: 1px solid rgba(var(--tint-rgb), 0.12);
+ border-radius: 999px;
+ color: rgba(var(--tint-rgb), 0.65);
+ font-size: 10px;
+ font-variant-numeric: tabular-nums;
+ padding: 0 6px;
+ cursor: pointer;
+}
+.board-log__fold:hover,
+.board-log__fold[aria-expanded='true'] {
+ color: var(--text-strong);
+ border-color: rgba(var(--tint-rgb), 0.25);
+}
+.board-log__group--open {
+ display: flex;
+ flex-direction: column;
+ gap: inherit;
+ border-left: 2px solid rgba(var(--tint-rgb), 0.1);
+ padding-left: 6px;
+}
.board-log__text {
font-size: 12px;
line-height: 1.45;