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(context-link): CLI parses codex rollout + gemini chat transcripts

enes55c7d921def7
diff --git a/src/main/context-link-core.ts b/src/main/context-link-core.ts
index f1be0a506..e130331cb 100644
--- a/src/main/context-link-core.ts
+++ b/src/main/context-link-core.ts
@@ -138,6 +138,7 @@ function transcriptForCwd(cwd) {
function resolveTranscript(node) {
if (node.transcriptPath && fs.existsSync(node.transcriptPath)) return node.transcriptPath
+ if (node.agent && node.agent !== 'claude') return ''
return transcriptForCwd(node.cwd)
}
@@ -147,6 +148,60 @@ function textOf(content) {
return ''
}
+// Flatten codex/gemini content: string, or array of parts carrying a .text field.
+function flatText(c) {
+ if (typeof c === 'string') return c
+ if (Array.isArray(c)) return c.map(function (x) { return x && typeof x.text === 'string' ? x.text : '' }).filter(Boolean).join('\\n')
+ return ''
+}
+
+// codex rollout line ({type:'response_item', payload}) -> 0..n display strings.
+function linesFromCodex(raw) {
+ var o
+ try { o = JSON.parse(raw) } catch (e) { return [] }
+ if (o.type !== 'response_item' || !o.payload) return []
+ var p = o.payload
+ var res = []
+ if (p.type === 'message') {
+ var role = p.role === 'user' ? 'user' : 'assistant'
+ var t = flatText(p.content)
+ if (t) res.push(role + ': ' + t)
+ } else if (p.type === 'function_call') {
+ var a = typeof p.arguments === 'string' ? p.arguments : JSON.stringify(p.arguments || '')
+ res.push(' $ ' + (p.name || 'tool') + ' ' + String(a).slice(0, 200))
+ } else if (p.type === 'function_call_output') {
+ var s = flatText(p.output).split('\\n').slice(0, 3).join(' ').slice(0, 500)
+ if (s) res.push(' = ' + s)
+ }
+ return res
+}
+
+// gemini chat file is event-sourced: replay $set/$push/bare-message lines, then flatten.
+function linesFromGeminiFile(buf) {
+ var messages = []
+ buf.split('\\n').forEach(function (raw) {
+ var t = raw.trim()
+ if (!t) return
+ var o
+ try { o = JSON.parse(t) } catch (e) { return }
+ if (o.$set && typeof o.$set === 'object' && Array.isArray(o.$set.messages)) { messages = o.$set.messages; return }
+ if (o.$push && typeof o.$push === 'object') {
+ var m = o.$push.messages
+ if (Array.isArray(m)) messages = messages.concat(m)
+ else if (m && typeof m === 'object') messages.push(m)
+ return
+ }
+ if (o.content !== undefined && o.sessionId === undefined) messages.push(o)
+ })
+ var res = []
+ messages.forEach(function (m) {
+ var role = m.type === 'user' ? 'user' : (m.type === 'gemini' || m.type === 'model') ? 'assistant' : String(m.type || 'message')
+ var t = flatText(m.content)
+ if (t) res.push(role + ': ' + t)
+ })
+ return res
+}
+
// Parse one transcript JSONL line into 0..n display strings.
function linesFrom(raw) {
var o
@@ -177,8 +232,10 @@ function readTranscript(node) {
if (!p) { out('"' + node.title + '" has no conversation transcript yet.'); return [] }
var buf
try { buf = fs.readFileSync(p, 'utf-8') } catch (e) { out('Could not read "' + node.title + '" transcript.'); return [] }
+ if (node.agent === 'gemini') return linesFromGeminiFile(buf)
+ var parse = node.agent === 'codex' ? linesFromCodex : linesFrom
var lines = []
- buf.split('\\n').forEach(function (raw) { if (raw.trim()) lines.push.apply(lines, linesFrom(raw)) })
+ buf.split('\\n').forEach(function (raw) { if (raw.trim()) lines.push.apply(lines, parse(raw)) })
return lines
}
diff --git a/src/main/context-link.cli.test.ts b/src/main/context-link.cli.test.ts
index 4a6ba5681..5195e5a33 100644
--- a/src/main/context-link.cli.test.ts
+++ b/src/main/context-link.cli.test.ts
@@ -23,12 +23,38 @@ beforeAll(() => {
})
].join('\n')
writeFileSync(join(dir, 'b.jsonl'), transcript)
+ const codexTranscript = [
+ JSON.stringify({ type: 'session_meta', payload: { id: 'sess-x' } }),
+ JSON.stringify({
+ type: 'response_item',
+ payload: { type: 'message', role: 'user', content: [{ type: 'input_text', text: 'fix the tests' }] }
+ }),
+ JSON.stringify({
+ type: 'response_item',
+ payload: { type: 'message', role: 'assistant', content: [{ type: 'output_text', text: 'Sure, running them.' }] }
+ }),
+ JSON.stringify({
+ type: 'response_item',
+ payload: { type: 'function_call', name: 'shell', arguments: '{"command":["npm","test"]}' }
+ }),
+ JSON.stringify({ type: 'response_item', payload: { type: 'function_call_output', output: '2 passed' } })
+ ].join('\n')
+ writeFileSync(join(dir, 'codex.jsonl'), codexTranscript)
+ const geminiTranscript = [
+ JSON.stringify({ sessionId: 'g-sess', projectHash: 'abc' }),
+ JSON.stringify({ $set: { messages: [{ type: 'user', content: 'hello gemini' }] } }),
+ JSON.stringify({ $push: { messages: { type: 'gemini', content: 'hello back' } } })
+ ].join('\n')
+ writeFileSync(join(dir, 'gemini.jsonl'), geminiTranscript)
writeFileSync(
join(dir, 'node-A.json'),
JSON.stringify({
self: { id: 'node-A' },
links: [
{ id: 'node-B', title: 'Builder', cwd: '', transcriptPath: join(dir, 'b.jsonl'), tmux: 'nt-node-B' },
+ { id: 'node-X', title: 'Coder', cwd: '', transcriptPath: join(dir, 'codex.jsonl'), tmux: 'nt-node-X', agent: 'codex' },
+ { id: 'node-G', title: 'Gem', cwd: '', transcriptPath: join(dir, 'gemini.jsonl'), tmux: 'nt-node-G', agent: 'gemini' },
+ { id: 'node-Y', title: 'ColdCoder', cwd: '/nowhere', transcriptPath: '', tmux: 'nt-node-Y', agent: 'codex' },
{ id: 'note-1', title: 'Deploy notes', cwd: '', transcriptPath: '', tmux: '', note: 'use the staging key' }
],
tmuxBin: null,
@@ -89,4 +115,20 @@ describe('context-cli', () => {
expect(out).toContain('sticky note')
expect(out).toContain('no terminal')
})
+ it('renders a codex rollout transcript', () => {
+ const out = run('node-A', ['summary', '-n', '20', '--node', 'node-X'])
+ expect(out).toContain('user: fix the tests')
+ expect(out).toContain('assistant: Sure, running them.')
+ expect(out).toContain('$ shell')
+ expect(out).toContain('= 2 passed')
+ })
+ it('renders a gemini chat transcript (event-sourced replay)', () => {
+ const out = run('node-A', ['transcript', '--node', 'node-G'])
+ expect(out).toContain('user: hello gemini')
+ expect(out).toContain('assistant: hello back')
+ })
+ it('non-claude agent without a resolved path gets no cwd fallback', () => {
+ const out = run('node-A', ['summary', '--node', 'node-Y'])
+ expect(out).toContain('no conversation transcript yet')
+ })
})