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(transcript-index): incremental refresh planner
enes64c8eea923ba
diff --git a/src/main/transcript-index-core.test.ts b/src/main/transcript-index-core.test.tsindex aefa6a331..f6e11d6d5 100644--- a/src/main/transcript-index-core.test.ts+++ b/src/main/transcript-index-core.test.ts@@ -3,7 +3,9 @@ import {extractEntryFields,makeSnippet,searchEntries,+ planRefresh,INDEX_TEXT_CAP_BYTES,+ type ScanFile,type TranscriptIndexEntry} from './transcript-index-core'@@ -65,3 +67,27 @@ describe('searchEntries', () => {expect(searchEntries(entries, 'tmux', 1)).toHaveLength(1)})})++describe('planRefresh', () => {+ const prior: TranscriptIndexEntry[] = [+ { sessionId: 'a', transcriptPath: '/p/a.jsonl', cwd: '/c', mtime: 100, title: 't', text: 'x' },+ { sessionId: 'b', transcriptPath: '/p/b.jsonl', cwd: '/c', mtime: 100, title: 't', text: 'x' }+ ]++ it('re-reads new and changed files, keeps unchanged, drops vanished', () => {+ const scan: ScanFile[] = [+ { sessionId: 'a', transcriptPath: '/p/a.jsonl', mtime: 100 }, // unchanged -> keep+ { sessionId: 'b', transcriptPath: '/p/b.jsonl', mtime: 200 }, // changed -> read+ { sessionId: 'c', transcriptPath: '/p/c.jsonl', mtime: 50 } // new -> read+ ]+ const plan = planRefresh(prior, scan)+ expect(plan.keep.map((e) => e.sessionId)).toEqual(['a'])+ expect(plan.toRead.map((f) => f.sessionId).sort()).toEqual(['b', 'c'])+ })++ it('drops entries whose file is gone (not in scan)', () => {+ const plan = planRefresh(prior, [{ sessionId: 'a', transcriptPath: '/p/a.jsonl', mtime: 100 }])+ expect(plan.keep.map((e) => e.sessionId)).toEqual(['a'])+ expect(plan.toRead).toEqual([])+ })+})diff --git a/src/main/transcript-index-core.ts b/src/main/transcript-index-core.tsindex 329096721..2b1cd5a90 100644--- a/src/main/transcript-index-core.ts+++ b/src/main/transcript-index-core.ts@@ -78,3 +78,31 @@ export function searchEntries(mtime: e.mtime}))}++// A directory listing of one transcript file (path + mtime), without its parsed contents.+export interface ScanFile {+ sessionId: string+ transcriptPath: string+ mtime: number+}++// The outcome of diffing a fresh scan against the prior index: which files to (re-)read and+// which prior entries to keep as-is. Entries absent from the scan are dropped (not returned).+export interface RefreshPlan {+ toRead: ScanFile[]+ keep: TranscriptIndexEntry[]+}++// Decide what an incremental refresh must do: re-read scan files that are new or whose mtime+// increased, keep prior entries whose file is unchanged and still present, drop the rest.+export function planRefresh(prior: TranscriptIndexEntry[], scan: ScanFile[]): RefreshPlan {+ const priorById = new Map(prior.map((e) => [e.sessionId, e]))+ const toRead: ScanFile[] = []+ const keep: TranscriptIndexEntry[] = []+ for (const f of scan) {+ const p = priorById.get(f.sessionId)+ if (p && p.mtime === f.mtime) keep.push(p)+ else toRead.push(f)+ }+ return { toRead, keep }+}