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
fix(core): chat model/effort come from ONE record, never carried forward
review0dbbff2efbcb
diff --git a/src/core/transcript-ipc.test.ts b/src/core/transcript-ipc.test.tsindex b059f8d42..56ccf7535 100644--- a/src/core/transcript-ipc.test.ts+++ b/src/core/transcript-ipc.test.ts@@ -302,7 +302,7 @@ describe('registerTranscriptIpc — paged chat reads', () => {))registerTranscriptIpc()- const q = { sessionId: SID, cwd: CWD, accountId: undefined, nodeId: undefined, agentId: undefined }+ const q = { sessionId: SID, cwd: CWD }for (const page of [undefined, { maxBytes: 65536 }]) {const viaIpc = await paged(page)const direct = await readChatTranscript(q, page, {})diff --git a/src/core/transcript-reader.test.ts b/src/core/transcript-reader.test.tsindex 92c83f645..8ecaeb401 100644--- a/src/core/transcript-reader.test.ts+++ b/src/core/transcript-reader.test.ts@@ -156,20 +156,52 @@ describe('parseChatWindow — pure window parsing', () => {expect('effort' in r).toBe(false)})- it('model/effort: non-strings, over-long values and the <synthetic> error record are ignored', () => {- const rec = (o: object): string => JSON.stringify({ type: 'assistant', ...o }) + '\n'- const buf = Buffer.from(- rec({ effort: 'high', message: { model: 'claude-opus-5', content: [{ type: 'text', text: 'a' }] } }) +- rec({ effort: 'x'.repeat(101), message: { model: 'm'.repeat(101), content: [] } }) +- rec({ effort: 7, message: { model: 42, content: [] } }) +- // Claude writes an API-error line as model `<synthetic>` with no effort — not a model.- rec({ message: { model: '<synthetic>', content: [{ type: 'text', text: 'API Error' }] } })+ // ONE record answers both fields — the newest non-synthetic assistant record — never carried+ // forward from an older one (same rule as `parseLatestUsage` in context-tail.ts).+ const rec = (o: object): string => JSON.stringify({ type: 'assistant', ...o }) + '\n'++ it('model/effort: the newest record without an effort reports NO effort (never an older one)', () => {+ const r = parseChatWindow(+ Buffer.from(+ rec({ effort: 'high', message: { model: 'claude-opus-5', content: [{ type: 'text', text: 'a' }] } }) ++ rec({ message: { model: 'claude-fable-5', content: [{ type: 'text', text: 'b' }] } })+ ),+ 0+ )+ expect(r.model).toBe('claude-fable-5')+ expect('effort' in r).toBe(false)+ })++ it('model/effort: a <synthetic> record after a real one is skipped entirely', () => {+ const r = parseChatWindow(+ Buffer.from(+ rec({ effort: 'high', message: { model: 'claude-opus-5', content: [{ type: 'text', text: 'a' }] } }) ++ // Claude writes an API-error line as model `<synthetic>` with no effort — not a model.+ rec({ message: { model: '<synthetic>', content: [{ type: 'text', text: 'API Error' }] } })+ ),+ 0)- const r = parseChatWindow(buf, 0)expect(r.model).toBe('claude-opus-5')expect(r.effort).toBe('high')})+ it('model/effort: over-long or non-string values on the newest record are absent, not an older value', () => {+ for (const bad of [+ { effort: 'x'.repeat(101), message: { model: 'm'.repeat(101), content: [] } },+ { effort: 7, message: { model: 42, content: [] } }+ ]) {+ const r = parseChatWindow(+ Buffer.from(+ rec({ effort: 'high', message: { model: 'claude-opus-5', content: [{ type: 'text', text: 'a' }] } }) ++ rec(bad)+ ),+ 0+ )+ expect('model' in r).toBe(false)+ expect('effort' in r).toBe(false)+ }+ })+it('model/effort come only from records INSIDE the window (a partial first line is not read)', () => {const l1 = JSON.stringify({ type: 'assistant', effort: 'low', message: { model: 'old', content: [] } }) + '\n'const l2 = JSON.stringify({ type: 'user', message: { content: 'hi' } }) + '\n'diff --git a/src/core/transcript-reader.ts b/src/core/transcript-reader.tsindex 4fc0a3e9a..893a0e377 100644--- a/src/core/transcript-reader.ts+++ b/src/core/transcript-reader.ts@@ -141,12 +141,13 @@ export async function readTranscriptLines(filePath: string): Promise<TranscriptLinterface ChatRecordsOut {messages: ChatMessage[]unmatched: Map<string, string>- /** PAGED only: the newest assistant record's `message.model` / `effort` (see `assistantMeta`). */+ /** PAGED only: `message.model` / `effort` of the newest non-synthetic assistant record (one record). */model?: stringeffort?: string}-/** Longest `model` / `effort` value a paged read reports; anything longer is not a model name. */+/** Longest `model` / `effort` value a paged read reports, in UTF-16 code units (JS `.length`; Swift+ * `utf16.count`); anything longer is not a model name. */const CHAT_META_MAX_CHARS = 100/** The model claude stamps on a line it wrote itself (an API error, an interrupt) — not a model. */const SYNTHETIC_MODEL = '<synthetic>'@@ -170,10 +171,11 @@ function parseChatRecords(const unmatched = new Map<string, string>()const toolById = new Map<string, Extract<ChatPart, { kind: 'tool' }>>()let at: number | undefined- // Each updated independently from every assistant record (paged only), so the newest record that- // states one wins. Measured: claude's `<synthetic>` error lines carry no `effort` and a fake- // model, and older CLIs wrote no `effort` at all — neither may blank a value an earlier record in- // the same window stated.+ // A snapshot of ONE record (paged only): the newest non-synthetic assistant record answers BOTH+ // fields, and a field it does not state (or states invalidly) is absent — never carried forward+ // from an older record, which may describe a different model or CLI. Same rule as+ // `parseLatestUsage` (context-tail.ts). `<synthetic>` lines (API errors, interrupts — measured+ // with no `effort`) are claude's own, not a model turn, so they are skipped entirely.let model: string | undefinedlet effort: string | undefinedconst push = (m: ChatMessage, offset: number): void => {@@ -192,11 +194,9 @@ function parseChatRecords(}at = lineTime(o.timestamp)const content = o.message?.content- if (paged && o.type === 'assistant') {- const m = metaString(o.message?.model)- if (m && m !== SYNTHETIC_MODEL) model = m- const e = metaString(o.effort)- if (e) effort = e+ if (paged && o.type === 'assistant' && o.message?.model !== SYNTHETIC_MODEL) {+ model = metaString(o.message?.model)+ effort = metaString(o.effort)}if (o.type === 'assistant' && Array.isArray(content)) {const parts: ChatPart[] = []