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(grok): two-way session-name sync via grok's own session metadata
enes936d29754c20
diff --git a/src/core/__fixtures__/grok/summary.json b/src/core/__fixtures__/grok/summary.jsonnew file mode 100644index 000000000..7ff135ab7--- /dev/null+++ b/src/core/__fixtures__/grok/summary.json@@ -0,0 +1,12 @@+{+ "info": {},+ "session_summary": "Wired grok's status hooks into nodeterm and checked the badge on the canvas.",+ "generated_title": "Add grok status hooks to nodeterm",+ "created_at": "2026-08-09T09:14:02.481Z",+ "updated_at": "2026-08-09T09:41:37.902Z",+ "num_messages": 12,+ "num_chat_messages": 8,+ "current_model_id": "grok-4",+ "parent_session_id": null,+ "agent_name": "grok"+}diff --git a/src/core/grok-session.test.ts b/src/core/grok-session.test.tsnew file mode 100644index 000000000..3a3459760--- /dev/null+++ b/src/core/grok-session.test.ts@@ -0,0 +1,145 @@+// FIXTURE PROVENANCE — read this before trusting `__fixtures__/grok/summary.json`.+//+// It was NOT captured from a real grok session: there is no grok binary and no grok account on the+// machine this task was implemented on. It is CONSTRUCTED from the field list grok's shipped 1.0.0+// documentation gives for `summary.json` (`info`, `session_summary`, `generated_title`,+// `created_at`, `updated_at`, `num_messages`, `num_chat_messages`, `current_model_id`,+// `parent_session_id`, `agent_name`). The field NAMES come from that list; every VALUE is a+// plausible placeholder, the timestamp format is a guess, and nested shapes are left empty rather+// than invented (`info: {}`) — so only the two keys the assertions below pin (`generated_title`,+// `current_model_id`) may be relied upon.+//+// UNVERIFIED, and the reason the first TITLE_KEYS entry exists: the key grok's `/rename` (alias+// `/title`) writes a MANUAL title to is unknown. `'title'` is a first guess, placed first so a real+// manual title wins the moment someone confirms it. Until then the read leg adopts the documented+// `generated_title`, which is grok's own auto-name — correct, just not overridable from grok's side.+// Replacing this fixture with a real capture (and correcting TITLE_KEYS if the key differs) is the+// checklist item this task leaves open.+import { afterAll, describe, expect, it } from 'vitest'+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs'+import { tmpdir } from 'os'+import path from 'path'+import {+ forgetGrokSession,+ grokSessionDirFor,+ pickGrokSessionMeta,+ readGrokSessionMeta,+ readGrokSessionName,+ rememberGrokSessionDir+} from './grok-session'++const fixture = readFileSync(path.join(__dirname, '__fixtures__/grok/summary.json'), 'utf8')++describe('pickGrokSessionMeta', () => {+ it('reads the title and model out of a summary.json', () => {+ const meta = pickGrokSessionMeta(fixture)+ // Both assertions read from the fixture — do not relax them to `expect.any(String)`: the point+ // of the fixture is that the keys are pinned.+ expect(meta?.title).toBe('Add grok status hooks to nodeterm')+ expect(meta?.model).toBe('grok-4')+ })++ it('prefers a manually set title over the model-generated one', () => {+ const meta = pickGrokSessionMeta(JSON.stringify({ title: 'mine', generated_title: 'auto' }))+ expect(meta?.title).toBe('mine')+ })++ it('falls back to the generated title', () => {+ expect(pickGrokSessionMeta(JSON.stringify({ generated_title: 'auto' }))?.title).toBe('auto')+ })++ it('returns a null TITLE (not a null meta) when the session has no name yet', () => {+ // A session with a model but no title is normal early in its life — the node keeps its own+ // title and the poll simply finds nothing to adopt.+ expect(pickGrokSessionMeta(JSON.stringify({ current_model_id: 'grok-x' }))).toEqual({+ title: null,+ model: 'grok-x'+ })+ })++ it('returns null for anything that is not a summary object', () => {+ for (const bad of ['', 'not json', '[]', 'null', '"x"']) {+ expect(pickGrokSessionMeta(bad), bad).toBeNull()+ }+ })++ it('ignores non-string titles from a hand-edited file', () => {+ expect(pickGrokSessionMeta(JSON.stringify({ generated_title: 42 }))?.title).toBeNull()+ })+})++const root = mkdtempSync(path.join(tmpdir(), 'grok-session-'))+afterAll(() => rmSync(root, { recursive: true, force: true }))++/** A session directory holding `body` as its summary.json. */+const sessionDir = (name: string, body: string): string => {+ const dir = path.join(root, name)+ mkdirSync(dir, { recursive: true })+ writeFileSync(path.join(dir, 'summary.json'), body)+ return dir+}++describe('readGrokSessionMeta', () => {+ it('reads the directory summary.json', async () => {+ const dir = sessionDir(+ 'read-ok',+ JSON.stringify({ generated_title: 'from disk', current_model_id: 'grok-4' })+ )+ expect(await readGrokSessionMeta(dir)).toEqual({ title: 'from disk', model: 'grok-4' })+ })++ it('is null — never a throw — for a missing directory or an unparseable file', async () => {+ expect(await readGrokSessionMeta(path.join(root, 'nope'))).toBeNull()+ expect(await readGrokSessionMeta(sessionDir('garbage', 'not json'))).toBeNull()+ })+})++describe('the hook-fed sessionId → directory association', () => {+ it('remembers, forgets, and answers undefined for a session no hook mentioned', () => {+ rememberGrokSessionDir('s1', '/sessions/enc/s1')+ expect(grokSessionDirFor('s1')).toBe('/sessions/enc/s1')+ expect(grokSessionDirFor('never-seen')).toBeUndefined()+ expect(grokSessionDirFor(undefined)).toBeUndefined()+ forgetGrokSession('s1')+ expect(grokSessionDirFor('s1')).toBeUndefined()+ })++ it('ignores a half-known association', () => {+ // `grokSessionDir` returns null for a cwd grok stores under its slug+hash scheme; a caller that+ // passed that through must not register an empty path we would later open.+ rememberGrokSessionDir('', '/sessions/enc/x')+ rememberGrokSessionDir('s-empty-dir', '')+ expect(grokSessionDirFor('')).toBeUndefined()+ expect(grokSessionDirFor('s-empty-dir')).toBeUndefined()+ })++ it('is bounded, dropping the session heard from longest ago', () => {+ // 512 entries + 1: the oldest goes, and re-seeing a session makes it young again. Without the+ // bound a long-lived app grows this map for every session it ever observes.+ for (let i = 0; i < 512; i++) rememberGrokSessionDir(`b${i}`, `/d/${i}`)+ rememberGrokSessionDir('b0', '/d/0-again') // b0 is now the most recently seen+ rememberGrokSessionDir('overflow', '/d/overflow')+ expect(grokSessionDirFor('b0')).toBe('/d/0-again')+ expect(grokSessionDirFor('b1')).toBeUndefined() // evicted in b0's place+ expect(grokSessionDirFor('overflow')).toBe('/d/overflow')+ for (let i = 0; i < 512; i++) forgetGrokSession(`b${i}`)+ forgetGrokSession('overflow')+ })+})++describe('readGrokSessionName', () => {+ it('reads the name of a session a hook told us about', async () => {+ rememberGrokSessionDir(+ 'named',+ sessionDir('named', JSON.stringify({ generated_title: 'Ship it' }))+ )+ expect(await readGrokSessionName('named')).toBe('Ship it')+ forgetGrokSession('named')+ })++ it('is null for a session we have no directory for — it never searches for one', async () => {+ // The whole point of the association: with no hook-fed directory there is nothing to open, and+ // scanning grok's sessions tree would be how one node adopts another's name.+ expect(await readGrokSessionName('unknown-session')).toBeNull()+ })+})diff --git a/src/core/grok-session.ts b/src/core/grok-session.tsnew file mode 100644index 000000000..215b30976--- /dev/null+++ b/src/core/grok-session.ts@@ -0,0 +1,109 @@+// Reads what nodeterm needs from a grok session DIRECTORY. Grok's hook envelope carries no+// transcript path (claude's does), but every event carries `cwd` and `sessionId` — and grok stores+// a session at `$GROK_HOME/sessions/<url-encoded cwd>/<id>/`. So the directory is DERIVED, never+// searched, and this module only ever reads inside a directory a hook told us about.+//+// Documented contents (shipped 1.0.0): summary.json (`generated_title`, `session_summary`,+// `current_model_id`, `info`, timestamps, counts), signals.json (token usage, tool/turn counters),+// updates.jsonl (authoritative conversation log), chat_history.jsonl (raw model messages).+//+// This is grok's reader, and `transcript-reader.ts` stays claude's: a "shared" reader that knows two+// storage layouts is two readers in a trench coat, and the one thing neither must ever do is search+// the other's tree. The choice is made once, at the IPC handler.+import fs from 'fs'+import path from 'path'+import { GROK_SUMMARY_FILE } from './agents/grok-paths'++/** Read at most this much of summary.json — it is small, and a capped read bounds a corrupt file. */+const SUMMARY_MAX_BYTES = 256 * 1024++export interface GrokSessionMeta {+ /** The session's own name — what `/resume` shows and what the node title adopts. */+ title: string | null+ /** grok's model id, for anything that needs the model (e.g. the context window). */+ model: string | null+}++/**+ * Title keys in PREFERENCE order: a manually set title wins over the model-generated one, exactly+ * as claude's `custom-title` wins over its `ai-title`.+ *+ * `generated_title` is DOCUMENTED (grok 1.0.0). `'title'` is UNVERIFIED — it is a first guess at the+ * key grok's `/rename` (alias `/title`) writes a manual title to, which could not be captured+ * because no grok binary or account was available (see the provenance note atop grok-session.test.ts+ * and the fixture it describes). It is listed FIRST so a real manual title wins the moment the key is+ * confirmed; an unknown key is simply absent from the file, so a wrong guess degrades to the+ * generated title rather than to a wrong name.+ */+const TITLE_KEYS = ['title', 'generated_title'] as const++/** Pure: the meta from a summary.json body. null when this is not a summary object at all. */+export function pickGrokSessionMeta(summaryJson: string): GrokSessionMeta | null {+ let o: unknown+ try {+ o = JSON.parse(summaryJson)+ } catch {+ return null+ }+ if (!o || typeof o !== 'object' || Array.isArray(o)) return null+ const rec = o as Record<string, unknown>+ let title: string | null = null+ for (const k of TITLE_KEYS) {+ const v = rec[k]+ if (typeof v === 'string' && v.trim()) {+ title = v.trim()+ break+ }+ }+ const model = typeof rec.current_model_id === 'string' ? rec.current_model_id : null+ return { title, model }+}++/** Read a session directory's summary.json. null when it is absent or unreadable. */+export async function readGrokSessionMeta(sessionDir: string): Promise<GrokSessionMeta | null> {+ try {+ const fd = await fs.promises.open(path.join(sessionDir, GROK_SUMMARY_FILE), 'r')+ try {+ const buf = Buffer.alloc(SUMMARY_MAX_BYTES)+ const { bytesRead } = await fd.read(buf, 0, SUMMARY_MAX_BYTES, 0)+ return pickGrokSessionMeta(buf.subarray(0, bytesRead).toString('utf-8'))+ } finally {+ await fd.close()+ }+ } catch {+ return null+ }+}++// The hook-fed association: sessionId → its resolved session directory. Populated by the shells'+// raw listeners (which see cwd + sessionId together) so every later read is a direct open. Bounded+// because a long-lived app can see many sessions; the oldest entry is dropped first.+const MAX_TRACKED_SESSIONS = 512+const sessionDirs = new Map<string, string>()++export function rememberGrokSessionDir(sessionId: string, dir: string): void {+ if (!sessionId || !dir) return+ // Re-insert so the map's iteration order is least-recently-SEEN first: that is what makes the+ // eviction below drop the session nobody has heard from, not whichever one happened to be first.+ if (sessionDirs.has(sessionId)) sessionDirs.delete(sessionId)+ sessionDirs.set(sessionId, dir)+ if (sessionDirs.size > MAX_TRACKED_SESSIONS) {+ const oldest = sessionDirs.keys().next().value+ if (oldest !== undefined) sessionDirs.delete(oldest)+ }+}++export function grokSessionDirFor(sessionId: string | undefined): string | undefined {+ return sessionId ? sessionDirs.get(sessionId) : undefined+}++export function forgetGrokSession(sessionId: string | undefined): void {+ if (sessionId) sessionDirs.delete(sessionId)+}++/** The session NAME for a sessionId we have seen a hook for. null when unknown or unnamed. */+export async function readGrokSessionName(sessionId: string): Promise<string | null> {+ const dir = grokSessionDirFor(sessionId)+ if (!dir) return null+ return (await readGrokSessionMeta(dir))?.title ?? null+}diff --git a/src/main/index.ts b/src/main/index.tsindex 0d999f987..69a7c53f3 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -73,6 +73,12 @@ import { installManagedAgentHooks } from '../core/agents/hooks'import { createSubagentTail } from '../core/subagent-tail'import { createContextTail, type TaskNotification } from '../core/context-tail'import { grokRawFields, isAsyncSubagentLaunch, type NormalizedAgentEvent } from '../shared/agents/normalize'+import { grokSessionDir, grokSessionsDir } from '../core/agents/grok-paths'+import {+ forgetGrokSession,+ readGrokSessionName,+ rememberGrokSessionDir+} from '../core/grok-session'import {readSessionName,setRemoteTranscriptReader,@@ -546,8 +552,16 @@ app.whenReady().then(async () => {ptyManager.captureSession(persistKey, full))- corePlatform.handle(IPC.ptyReadSessionName, (sessionId: string, accountId?: string) =>- readSessionName(sessionId ?? '', accountId)+ // The reader is selected by the NODE's agent, so neither reader ever searches the other's tree:+ // grok keeps its session name in its own metadata (summary.json, in a directory derived from the+ // hook's cwd + sessionId), claude keeps it in a transcript .jsonl. `agentId` is a TRAILING+ // optional argument, so every pre-grok caller resolves through the claude reader unchanged.+ corePlatform.handle(+ IPC.ptyReadSessionName,+ (sessionId: string, accountId?: string, agentId?: string) =>+ agentId === 'grok'+ ? readGrokSessionName(sessionId ?? '')+ : readSessionName(sessionId ?? '', accountId))ipcMain.on(IPC.appCloseWindow, () => BrowserWindow.getFocusedWindow()?.close())@@ -1445,16 +1459,30 @@ app.whenReady().then(async () => {const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])hookServer.setRawListener((agentId, nodeId, payload) => {if (agentId === 'grok') {- // All this branch does is record the node↔session association, and it is deliberately the- // only thing: nothing reads the map for a grok node YET (the badge, the session chip and ⌘K- // all take their id from the NORMALIZED listener, and the phone's context ring only fires for- // a sessionId a context tail emits for). It is written now so the map is already populated- // when Tasks 4/5/10 add the readers — everything else the claude path does below hangs off- // `transcript_path`, and grok's envelope has none: its transcript is DERIVED from (cwd,- // sessionId). Read through `grokRawFields` so grok's two field dialects (camelCase and the- // SDK's snake_case) are decoded in exactly one place.+ // This branch records two associations, neither of which grok's envelope states outright.+ // Everything the claude path does below hangs off `transcript_path`, and grok has none.+ // Read through `grokRawFields` so grok's two field dialects (camelCase and the SDK's+ // snake_case) are decoded in exactly one place.const g = grokRawFields(payload)+ // 1. node → session: read by the phone's context ring and the ⌘K session lookup.if (nodeId && g.sessionId) nodeContextSession.set(nodeId, g.sessionId)+ // 2. session → its session DIRECTORY, derived from (cwd, sessionId) — the two fields every+ // grok hook does carry — and remembered here, the one place they arrive together. That is+ // what lets the session-name read (core/grok-session.ts) be a direct open rather than a scan+ // of grok's sessions tree, which is how one node would end up adopting another's name.+ // `grokSessionDir` returns null for a cwd grok stored under its slug+hash scheme instead, in+ // which case we learn nothing about this session rather than build half a path.+ if (g.sessionId && g.cwd) {+ const dir = grokSessionDir({+ sessionsDir: grokSessionsDir(),+ cwd: g.cwd,+ sessionId: g.sessionId+ })+ if (dir) rememberGrokSessionDir(g.sessionId, dir)+ }+ // The session is over: its directory can only go stale from here (grok never reuses an id),+ // and the map is bounded — so drop it instead of waiting for eviction.+ if (g.event === 'sessionend') forgetGrokSession(g.sessionId)return}if (agentId !== 'claude') returndiff --git a/src/preload/index.ts b/src/preload/index.tsindex f647496d8..cbc7d5d54 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -71,8 +71,8 @@ const api: NodeTerminalApi = {ipcRenderer.invoke(IPC.ptySendText, persistKey, text, opts?.enter),tmuxStatus: () => ipcRenderer.invoke(IPC.ptyTmuxStatus),paneCommand: (persistKey) => ipcRenderer.invoke(IPC.ptyPaneCommand, persistKey),- readSessionName: (sessionId, accountId) =>- ipcRenderer.invoke(IPC.ptyReadSessionName, sessionId, accountId),+ readSessionName: (sessionId, accountId, agentId) =>+ ipcRenderer.invoke(IPC.ptyReadSessionName, sessionId, accountId, agentId),onData: (sessionId, listener) => {const channel = IPC.ptyData(sessionId)const handler = (_e: unknown, data: string) => listener(data)diff --git a/src/renderer/bridge/ws-bridge.ts b/src/renderer/bridge/ws-bridge.tsindex f31c98230..7f93dde28 100644--- a/src/renderer/bridge/ws-bridge.ts+++ b/src/renderer/bridge/ws-bridge.ts@@ -228,7 +228,11 @@ export function buildRealApi(// shell yet" and gives up on its own deadline.paneCommand: (persistKey) =>client.request(IPC.ptyPaneCommand, persistKey).catch(() => null) as Promise<string | null>,- // No server handler — the session-name poll degrades to no adopted name.+ // No server handler — the session-name poll degrades to no adopted name. A PRE-EXISTING gap,+ // not a grok one: `IPC.ptyReadSessionName` has never been registered server-side, so claude's+ // read leg is equally stubbed here (the write leg works on both surfaces — it goes through+ // pty.sendText). Fixing it means moving the routing into core and registering it from both+ // shells, exactly as `core/transcript-ipc.ts` did for the ⌘M transcript channels.readSessionName: () => Promise.resolve(''),onData: (sessionId, listener) =>client.subscribe(IPC.ptyData(sessionId), listener as Listener),diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 82eae9971..84f955497 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -2834,12 +2834,14 @@ export function TerminalNode({}, [selected, id])// Keep the node title in sync with the agent session's display name — the name shown in- // `/resume`, read from the transcript (`/rename` name, else auto name). This is the authoritative- // source: `/rename` doesn't update the OSC terminal title, so reading the transcript is the only- // way the name shows up after a resume. Resolved strictly by THIS node's sessionId — we do NOT- // sync until it's known, otherwise same-folder nodes would adopt whichever session wrote last.- // Polls only while the title still auto-tracks the session (titleAuto) and stops once the user- // renames by hand. Claude-only via canRenameNode.+ // `/resume` (`/rename` name, else auto name). This is the authoritative source: `/rename` doesn't+ // update the OSC terminal title, so reading the agent's own session store is the only way the name+ // shows up after a resume. Resolved strictly by THIS node's sessionId — we do NOT sync until it's+ // known, otherwise same-folder nodes would adopt whichever session wrote last. Polls only while+ // the title still auto-tracks the session (titleAuto) and stops once the user renames by hand.+ // Gated on canRenameNode (RENAME_CAPABLE). `agentId` rides along so main picks the right reader:+ // claude's transcript .jsonl vs grok's summary.json. It is resolved at node creation and immutable+ // thereafter — same as `data.accountId` beside it — so neither belongs in the dep array.useEffect(() => {if (!canRenameNode || data.titleAuto === false) returnconst sid = status?.sessionId ?? ''@@ -2852,7 +2854,7 @@ export function TerminalNode({let timer: ReturnType<typeof setTimeout> | undefinedconst sync = async () => {if (!titleAutoRef.current || editingTitleRef.current) return- const name = await api.pty.readSessionName(sid, data.accountId)+ const name = await api.pty.readSessionName(sid, data.accountId, agentId)if (cancelled) returnif (name) delayMs = 15000if (diff --git a/src/server/agent-status.ts b/src/server/agent-status.tsindex 48dc47cd5..51d457da3 100644--- a/src/server/agent-status.ts+++ b/src/server/agent-status.ts@@ -18,6 +18,8 @@ import { createContextTail, type ContextTail, type TaskNotification } from '../cimport { setNodeTranscript } from '../core/context-link'import { isSafeLocalTranscriptPath } from '../core/claude-accounts-core'import { grokRawFields, isAsyncSubagentLaunch, type NormalizedAgentEvent } from '../shared/agents/normalize'+import { grokSessionDir, grokSessionsDir } from '../core/agents/grok-paths'+import { forgetGrokSession, rememberGrokSessionDir } from '../core/grok-session'import { IPC } from '../shared/ipc'import type { ServerPlatform } from './platform-server'@@ -142,16 +144,33 @@ export function wireAgentStatus(const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])hooks.setRawListener((agentId, nodeId, payload) => {if (agentId === 'grok') {- // All this branch does is record the node↔session association, and it is deliberately the- // only thing: nothing reads the map for a grok node YET (the badge, the session chip and ⌘K- // all take their id from the NORMALIZED listener, and the phone's context ring only fires for- // a sessionId a context tail emits for). It is written now so the map is already populated- // when Tasks 4/5/10 add the readers — everything else the claude path does below hangs off- // `transcript_path`, and grok's envelope has none: its transcript is DERIVED from (cwd,- // sessionId). Read through `grokRawFields` so grok's two field dialects (camelCase and the- // SDK's snake_case) are decoded in exactly one place.+ // This branch records two associations, neither of which grok's envelope states outright.+ // Everything the claude path does below hangs off `transcript_path`, and grok has none.+ // Read through `grokRawFields` so grok's two field dialects (camelCase and the SDK's+ // snake_case) are decoded in exactly one place.const g = grokRawFields(payload)+ // 1. node → session: read by the phone's context ring and the ⌘K session lookup.if (nodeId && g.sessionId) nodeContextSession.set(nodeId, g.sessionId)+ // 2. session → its session DIRECTORY, derived from (cwd, sessionId) — the two fields every+ // grok hook does carry — and remembered here, the one place they arrive together. That is+ // what lets the session-name read (core/grok-session.ts) be a direct open rather than a scan+ // of grok's sessions tree, which is how one node would end up adopting another's name.+ // `grokSessionDir` returns null for a cwd grok stored under its slug+hash scheme instead, in+ // which case we learn nothing about this session rather than build half a path.+ //+ // The Server Edition populates it exactly as the desktop does; what it does not yet serve is+ // the READ (IPC.ptyReadSessionName has no server handler — see the ws-bridge stub).+ if (g.sessionId && g.cwd) {+ const dir = grokSessionDir({+ sessionsDir: grokSessionsDir(),+ cwd: g.cwd,+ sessionId: g.sessionId+ })+ if (dir) rememberGrokSessionDir(g.sessionId, dir)+ }+ // The session is over: its directory can only go stale from here (grok never reuses an id),+ // and the map is bounded — so drop it instead of waiting for eviction.+ if (g.event === 'sessionend') forgetGrokSession(g.sessionId)return}if (agentId !== 'claude') returndiff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.tsindex c97f43697..c28fe7af2 100644--- a/src/shared/agents/config.capabilities.test.ts+++ b/src/shared/agents/config.capabilities.test.ts@@ -109,6 +109,12 @@ describe('grok capabilities', () => {expect(canResume('grok')).toBe(true)})+ it('syncs its session name in both directions', () => {+ // Write leg: grok's own `/rename <title>` (alias `/title`), the same one-way push into the+ // pane claude uses — so sessionRename.ts needs no change. Read leg: summary.json.+ expect(canRename('grok')).toBe(true)+ })+it('does not yet claim the capabilities whose per-agent leaf is unwritten', () => {expect(canContextLink('grok')).toBe(false)expect(canControlCanvas('grok')).toBe(false)diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.tsindex 2be45b3a5..d5ddf5872 100644--- a/src/shared/agents/config.ts+++ b/src/shared/agents/config.ts@@ -99,8 +99,11 @@ export const CHAT_CAPABLE = ['claude'] as const// Agents whose native transcript we can read + render for cross-agent transfer.export const TRANSFER_SOURCE_CAPABLE = ['claude', 'codex', 'gemini'] as const// Agents that support naming the session in two directions: they emit a session title we adopt-// into the node title, and accept `/rename <name>` to push a renamed node title back. Claude-only.-export const RENAME_CAPABLE = ['claude'] as const+// into the node title, and accept `/rename <name>` to push a renamed node title back. Read legs are+// per-agent (claude: the transcript .jsonl; grok: its session summary.json — see+// core/grok-session.ts, routed at the readSessionName IPC handler); the write leg is the same+// literal `/rename <name>` for both, which grok also accepts as `/title`.+export const RENAME_CAPABLE = ['claude', 'grok'] as const// Agents allowed to drive the canvas via the `nodeterm` CLI (open/show/write/close).// Discovery differs per agent: claude gets the manage-nodeterm-canvas skill; codex/gemini/// opencode a marker block in ~/.codex/AGENTS.md / ~/.gemini/GEMINI.md /diff --git a/src/shared/types.ts b/src/shared/types.tsindex 68cd836d2..bf0b8e789 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -554,11 +554,13 @@ export interface PtyApi {* node persistKey. null when it is unknown — no session, no tmux, or the query failed — which* callers must read as "not observed", never as evidence of a particular command. */paneCommand(persistKey: string): Promise<string | null>- /** The agent session's display name (`/rename` name, else auto name) read from its transcript,- * resolved strictly by sessionId; null if unknown. Keeps a node title in sync with the- * `/resume` name (e.g. after resume) without cross-contaminating same-folder sessions.- * `accountId` scopes the lookup to a managed Claude account's transcript root (default `~/.claude`). */- readSessionName(sessionId: string, accountId?: string): Promise<string | null>+ /** The agent session's display name (`/rename` name, else auto name) read from the agent's own+ * session store, resolved strictly by sessionId; null if unknown. Keeps a node title in sync with+ * the `/resume` name (e.g. after resume) without cross-contaminating same-folder sessions.+ * `accountId` scopes the lookup to a managed Claude account's transcript root (default `~/.claude`).+ * `agentId` picks the reader — grok's name lives in its session metadata, not a claude transcript;+ * omitted (every pre-grok caller) means the claude transcript reader. */+ readSessionName(sessionId: string, accountId?: string, agentId?: string): Promise<string | null>/** Listens for PTY output. Returns an unsubscribe function. */onData(sessionId: string, listener: (data: string) => void): () => void/** Fires when the PTY process exits. Returns an unsubscribe function. */