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(grok): read a linked grok node's transcript (context links)

Xavi Guardiaec3dcfb88250
diff --git a/docs/grok-agent.md b/docs/grok-agent.md
index c33f9ab12..997c402a8 100644
--- a/docs/grok-agent.md
+++ b/docs/grok-agent.md
@@ -41,11 +41,11 @@ is the cost of adding the next agent to the same list.
| `PERMISSION_MODE_CAPABLE` | **joined** | Grok shares claude's flag **spelling** and value vocabulary (`--permission-mode auto\|plan\|acceptEdits\|bypassPermissions`; our `manual` = no flag = grok's own `default`), which is why *its* membership needed no translation. Two things had to change around it: claude's `auto` **version gate** had to become agent-scoped (`activePermissionMode(agentId)`, `renderer/state/permissionMode.ts`), and the flag had to be emitted **before** grok's `--`. See §6. **Sharing the spelling is no longer what membership means:** the list is now `claude, grok, gemini, codex` (2026-08-09) and the last two spell it their own way (`--approval-mode`, `--ask-for-approval`), translated per agent in `src/shared/agents/approval-mode.ts` — which is also where `withPermissionMode` now lives, moved one layer up to break a `config ↔ approval-mode` cycle. |
| `CANVAS_CONTROL_CAPABLE` | **joined** | Nothing new to install: grok scans `~/.claude/skills` by default for Claude Code compatibility, which is exactly where `manage-nodeterm-canvas` is already written (locally, and on an SSH host by `RemoteHooks.installCanvasControl`). Membership is what sets `NODETERM_CANVAS_CONTROL=1` in the session env — `hook-server.buildPtyEnv` locally, `remoteHookEnvArgs` remotely, both through the single `canControlCanvas` predicate — i.e. what makes the sh+curl shim anything other than a no-op. **Unverified:** `grok inspect --json` was never run (§8). |
| `USAGE_CAPABLE` (the per-node context meter) | **not joined** | Needs a real `signals.json` yielding **both** a used-token count **and** the window total. A percentage against a guessed denominator is a wrong number presented as a fact, so no total ⇒ no meter. Task 5 of the plan stops at its capture step. (For reference, the list is now `claude, codex, gemini`; grok and **opencode** are the two builtins outside it. Codex states its own denominator in its rollout; gemini's comes from its model id through `geminiWindowFor`, mirroring the CLI's own `tokenLimit`. See `docs/gemini-agent.md` §4 — and note that **joining this list also switches on two features that read CLAUDE's transcript**, which is a trap grok will hit too: `docs/gemini-agent.md` §1.) Do not confuse this with grok *billing* usage — see the note below. |
-| `CONTEXT_LINK_CAPABLE` | **not joined** | Needs a parser for `updates.jsonl` pinned by a real fixture, plus a locator in `core/context-link.ts`. Task 10 stops at its capture step. (For reference, this list is `claude, codex, gemini, opencode` — grok is the only builtin outside it.) |
+| `CONTEXT_LINK_CAPABLE` | **joined** | Two pieces, both pinned by fixtures cut from real sessions rather than written from the docs: `linesFromGrok` (`core/context-link-render.ts`) renders grok's log, and `locateGrok` (`core/handoff/locate.ts`) finds it. The file is **`chat_history.jsonl`, not the `updates.jsonl`** this row used to name and grok's own hook payloads advertise — routing through the advertised path fails **silently**, handing the reader an empty transcript with nothing logged, which is why the locator pins it. The directory comes from the hook-fed `sessionId → dir` map, never from a scan. The path jail was widened to `$GROK_HOME/sessions` — that subdirectory, not `$GROK_HOME`, because `auth.json` lives in the same tree. Grok is no longer outside this list; the list is now `claude, codex, gemini, opencode, grok`, and the one builtin still outside it is **copilot**. |
| `SUBAGENT_CAPABLE` | **not joined** | Needs the `spawn_subagent` `PreToolUse`/`PostToolUse` payload fields, including whatever marks a **background** launch. Task 11 stops at its capture step. |
| `BRANCH_CAPABLE` | not joined | Branch sends claude's `/branch` and resumes by claude's session id; grok has no counterpart. |
-| `CHAT_CAPABLE` | not joined | The ⌘M `ChatPanel` renders claude's transcript `.jsonl`; grok's log is `updates.jsonl` and needs the same parser Task 10 is blocked on. |
-| `TRANSFER_SOURCE_CAPABLE` | not joined | Cross-agent transfer reads the source's native transcript — again the missing parser. Grok is a valid transfer **target** (it is an agent node like any other); it just cannot be the source. |
+| `CHAT_CAPABLE` | not joined | The ⌘M `ChatPanel` renders claude's transcript `.jsonl`. **The blocker named here is gone** — the parser exists (`linesFromGrok`, and the log is `chat_history.jsonl`, not `updates.jsonl`) — so what is left is a decision, not a missing piece: the panel has its own shape requirements beyond a list of lines, and nobody has measured them against grok's log. Do not read the omission as "impossible". |
+| `TRANSFER_SOURCE_CAPABLE` | not joined | Cross-agent transfer reads the source's native transcript. **Same correction as the row above:** the parser is no longer missing, so this is now an unmade decision rather than a blocked one. Grok is a valid transfer **target** (it is an agent node like any other); it just is not yet wired as the source. |
| `RECURRING_CAPABLE` | not joined | `/loop`, `/schedule`, `/cron` are detected from claude's `Skill` / `CronCreate` / `ScheduleWakeup` tool names; grok's tool vocabulary for these is unknown. |
**Grok billing usage ≠ the grok context meter.** These are two different features and the plan once
@@ -247,8 +247,10 @@ generated title (right name, just not overridable from grok's side) rather than
Confirming it is checklist item **14**.
**Not captured at all:** `signals.json` (blocks the context meter — the used-token key, the window
-total, and whether a total exists anywhere) and `updates.jsonl` (blocks context links, the ⌘M
-transcript view and transfer-as-source). Recipes for both, and for the `spawn_subagent` payload, are
+total, and whether a total exists anywhere). The transcript log is **no longer** in this list, and
+the entry that used to sit here was wrong twice over: it named `updates.jsonl`, when the readable
+conversation is its sibling `chat_history.jsonl`, and it said the gap blocked context links, which
+have since shipped off a fixture cut from a real session. Recipes for both, and for the `spawn_subagent` payload, are
Step 1 of Tasks 5, 10 and 11 in
`docs/superpowers/plans/2026-08-09-grok-agent-integration.md`. **Do not add a speculative key to any
parser**: the rule that made these tasks stop cleanly is that an unrecognized shape returns nothing,
@@ -325,8 +327,8 @@ ai-name / comments).
| Session name ⇄ node title | both legs | **write only.** `ws-bridge.readSessionName` returns `''` — a **pre-existing** gap, not a grok one: `IPC.ptyReadSessionName` has never been registered server-side, so claude's read leg is equally stubbed. The fix is to move the routing into core and register it from both shells, exactly as `core/transcript-ipc.ts` did for the ⌘M channels | the mirror's session-name sweep runs in both shells and routes per agent, so a grok name reaches the phone when it resolves at all |
| Permission mode | yes | yes (pure renderer + the mode flag) | **follow-up owed** — see §8 |
| In-place restart + cold-restore resume | yes | yes | N/A |
-| Canvas control | yes, via `~/.claude/skills` + the sh+curl shim (unverified) | **not wired at all** — `agent:control` has no server handler; pre-existing, unchanged by grok | N/A — no canvas |
-| Context links | **not implemented for grok** (§1) | not wired at all (`initContextLink` is never called from `src/server`) | N/A |
+| Canvas control | yes, via `~/.claude/skills` + the sh+curl shim. The discovery premise is no longer inferred: `grok inspect --json` on grok 1.0.13 lists `get-linked-context` with `vendor: claude` and `compatibilityStatus: enabled`, and `externalCompat.cells` reports `{surface: 'skills', enabled: true, source: 'default'}` — grok reads `~/.claude/skills` **by default**, without a config edit (§8.7) | **not wired at all** — `agent:control` has no server handler; pre-existing, unchanged by grok | N/A — no canvas |
+| Context links | **yes** — `locateGrok` resolves the linked node's `chat_history.jsonl` and `linesFromGrok` renders it. The whole leaf is in core (`core/handoff/locate.ts`, `core/context-link.ts`, `core/grok-session.ts`, `core/claude-accounts-core.ts`); the renderer only asks the pure `canContextLink`, so **no `window.nodeTerminal` member was added** and nothing new crosses the preload bridge | **yes, for free** — the row's old claim that `initContextLink` is never called from `src/server` is stale: `src/server/context-link.ts` calls it, driven off the persisted `bridges[]` instead of the renderer's live edges. Both shells feed the same `sessionId → dir` map from their raw hook listeners (`src/main/index.ts`, `src/server/agent-status.ts`) and both pass `grokHomeDir()` into the path jail — invariant 11 | **N/A** — linking is a canvas gesture and the phone has no canvas (`~/projects/nodeterm-ios`). The transcript it would read is the same file, so this is a surface gap, not a capability one |
| Context meter | **not implemented for grok** (§1) | the meter itself IS wired server-side (both shells create the per-agent tails — it is codex and gemini that use them, `docs/gemini-agent.md` §4); grok simply has no numbers to feed it on either surface | idem |
| Managed accounts | **deliberately N/A** — accounts are a claude config-dir mechanism. `createAgentNode` never stamps an `accountId` onto a non-claude node, and `CLAUDE_CONFIG_DIR` is irrelevant to `~/.grok/hooks`. A grok node in a managed-account project must still report status (checklist 7) | idem | idem |
| Brand logo | the **official** xAI mark, INLINED in `agentIcons.tsx` as `GrokMark` rather than shipped as an asset — it is a single monochrome path, so `fill="currentColor"` inherits the label colour and is correct in both themes. The other four marks are multi-colour and stay `<img src>` assets, where `currentColor` cannot inherit | same component, for free | the phone draws its own icons — **follow-up owed** |
@@ -370,9 +372,14 @@ ai-name / comments).
resolves immediately *because* it scans, which is the behaviour that made nodes adopt each other's
names); the checklist records how it feels.
6. **No live session-name poll in the browser** — see §7.
-7. **Canvas-control discovery is unverified.** `grok inspect --json` was never run, so the premise
- that grok lists our `~/.claude/skills` entries rests on its shipped docs
- (`~/.grok/docs/user-guide/08-skills.md`). Two residual per-user failure modes exist even if the
+7. ~~Canvas-control discovery is unverified.~~ **MEASURED, and the premise holds.** `grok inspect
+ --json` on grok 1.0.13 lists `get-linked-context` with `vendor: claude` and
+ `compatibilityStatus: enabled`, and `externalCompat.cells` reports
+ `{surface: 'skills', enabled: true, source: 'default'}` — `source: 'default'` is the part that
+ matters: grok reads `~/.claude/skills` with **no** config edit by the user. That closes checklist
+ **21** and, with it, the same unverified premise underneath `CANVAS_CONTROL_CAPABLE` and
+ `CONTEXT_LINK_CAPABLE`; the shipped docs (`~/.grok/docs/user-guide/08-skills.md`) turned out to be
+ right, but we no longer rest on them. Two residual per-user failure modes exist even if the
premise holds: `[compat.claude] skills = false` and `GROK_CLAUDE_SKILLS_ENABLED=false`, plus
grok's undisclosed vendor-default-skills filter. In each case `NODETERM_CANVAS_CONTROL=1` is set
while the skill is undiscoverable. **If grok does not list our skills, this changes shape** (a
@@ -505,14 +512,25 @@ Fixtures the unbuilt features need, modes, restart
resume the same session? Is it refused while the node is RUNNING?
Skills
-21. `grok inspect --json`: are `manage-nodeterm-canvas` and `get-linked-context` listed? If not,
- canvas control needs a different discovery path (§8.7) — re-plan, do not force it.
+21. ~~`grok inspect --json`: are `manage-nodeterm-canvas` and `get-linked-context` listed?~~
+ **ANSWERED on this machine, grok 1.0.13 (2026-09-02): yes.** `get-linked-context` comes back with
+ `vendor: claude` and `compatibilityStatus: enabled`, and `externalCompat.cells` reports
+ `{surface: 'skills', enabled: true, source: 'default'}`. Recorded in
+ `evidence/grok-skill-discovery.txt`. **What this item still asks of a NEW device** is the pair of
+ per-user failure modes, which a default-config machine cannot exercise: set
+ `[compat.claude] skills = false` in `~/.grok/config.toml`, and separately export
+ `GROK_CLAUDE_SKILLS_ENABLED=false`. In each case `NODETERM_CANVAS_CONTROL=1` is still set while
+ the skill is undiscoverable — i.e. the shim is armed and mute. Nobody has seen that state.
22. From a grok session, run the canvas shim: does a node appear on the canvas? The path differs
per surface — LOCAL sessions get `<userData>/canvas-control/nodeterm.sh` (the path written
into the skill's own SKILL.md), remote SSH sessions get `$HOME/.nodeterm/nodeterm.sh`.
-23. CAPTURE `updates.jsonl` (Task 10 Step 1) and the `spawn_subagent` PreToolUse/PostToolUse
- payloads (Task 11 Step 1). Grok is NOT in CONTEXT_LINK_CAPABLE, so `get-linked-context` from
- the grok side does nothing yet; a claude node linked to a grok node likewise reads nothing.
+23. CAPTURE the `spawn_subagent` PreToolUse/PostToolUse payloads (Task 11 Step 1). ~~And
+ `updates.jsonl` (Task 10 Step 1).~~ **That half is done, and the file was the wrong one:** the
+ readable conversation is `chat_history.jsonl`, its sibling; `updates.jsonl` is what the hook
+ payloads advertise, and following the advertisement fails silently. The fixture cut from a real
+ session lives at `src/core/__fixtures__/grok/chat_history.jsonl`. ~~Grok is NOT in
+ CONTEXT_LINK_CAPABLE~~ — it is now, so `get-linked-context` from the grok side and a claude node
+ linked to a grok node **should both read**. On a new device, check exactly that.
SSH
24. Connect an SSH project, then on the host: `cat $HOME/.grok/hooks/nodeterm-status.json`.
diff --git a/src/core/claude-accounts-core.ts b/src/core/claude-accounts-core.ts
index c9f3e3f0d..2a052b9ca 100644
--- a/src/core/claude-accounts-core.ts
+++ b/src/core/claude-accounts-core.ts
@@ -88,7 +88,8 @@ export function isSafeLocalTranscriptPath(
abs: string,
homeDir: string,
userDataPath: string,
- codexHomeDir?: string
+ codexHomeDir?: string,
+ grokHomeDir?: string
): boolean {
const legacyRoot = path.join(homeDir, '.claude', 'projects')
if (abs === legacyRoot || abs.startsWith(legacyRoot + path.sep)) return true
@@ -101,6 +102,14 @@ export function isSafeLocalTranscriptPath(
if (abs === geminiRoot || abs.startsWith(geminiRoot + path.sep)) return true
const codexRoot = path.join(codexHomeDir || path.join(homeDir, '.codex'), 'sessions')
if (abs === codexRoot || abs.startsWith(codexRoot + path.sep)) return true
+ // grok: `$GROK_HOME/sessions/<url-encoded cwd>/<sessionId>/`. `sessions` and not `$GROK_HOME`,
+ // because the same tree holds `auth.json` — a home-wide allowance would put the user's bearer
+ // token inside the jail this predicate exists to keep it out of. Same parameter discipline as
+ // codex: the shells own the env (`grokHomeDir()` in `agents/grok-paths.ts` resolves $GROK_HOME),
+ // this module stays pure path math, and getting it wrong fails CLOSED — a relocated grok home
+ // means the context link silently never resolves, never a widened read.
+ const grokRoot = path.join(grokHomeDir || path.join(homeDir, '.grok'), 'sessions')
+ if (abs === grokRoot || abs.startsWith(grokRoot + path.sep)) return true
const accountsRoot = path.join(userDataPath, 'claude-accounts')
if (abs !== accountsRoot && !abs.startsWith(accountsRoot + path.sep)) return false
// Relative to the accounts root: expect `<accountId>/projects[/…]`. Because `abs` is normalized
diff --git a/src/core/context-link.ts b/src/core/context-link.ts
index 1b51240c0..76cfe4a6b 100644
--- a/src/core/context-link.ts
+++ b/src/core/context-link.ts
@@ -38,7 +38,7 @@ import {
type ContextLinkVerb
} from './context-link-render'
import { hookServer } from './agents/hook-server'
-import { locateClaude, locateCodex, locateGemini } from './handoff/locate'
+import { locateClaude, locateCodex, locateGemini, locateGrok } from './handoff/locate'
import { opencodeConfigDir } from './agents/hooks/opencode'
export { setNodeTranscript } from './context-link-core'
@@ -130,7 +130,7 @@ export interface ContextLinkDeps {
// start mid-line, which only costs that one line (it fails to parse and is dropped).
const REMOTE_TRANSCRIPT_MAX_BYTES = 2 * 1024 * 1024
-const LINK_LOCATORS = { claude: locateClaude, codex: locateCodex, gemini: locateGemini }
+const LINK_LOCATORS = { claude: locateClaude, codex: locateCodex, gemini: locateGemini, grok: locateGrok }
// The link documents, by node id — the same objects written to disk, kept in memory because they
// are what authorizes a read (a node may only ever name a link inside ITS OWN document).
diff --git a/src/core/grok-context-link.test.ts b/src/core/grok-context-link.test.ts
new file mode 100644
index 000000000..ea48000db
--- /dev/null
+++ b/src/core/grok-context-link.test.ts
@@ -0,0 +1,79 @@
+// grok's leg of context-link: the locator, the path jail, and the capability membership.
+//
+// The trap this file exists to pin: grok's hook payloads DO carry a transcript path (measured on
+// 1.0.13, 2026-09-01 — the doc claimed otherwise for months), and it points at `updates.jsonl`.
+// The readable conversation is `chat_history.jsonl`, its SIBLING in the same session directory.
+// Routing this feature through the path the hooks advertise therefore fails SILENTLY: a real file
+// is read, `linesFromGrok` finds no line it recognises, and the linked agent is shown an empty
+// transcript with no error anywhere. A comment cannot go red, so this is a test.
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { mkdtempSync, writeFileSync, rmSync } from 'fs'
+import { tmpdir } from 'os'
+import path from 'path'
+import { canContextLink } from '../shared/agents/config'
+import { isSafeLocalTranscriptPath } from './claude-accounts-core'
+import { forgetGrokSession, rememberGrokSessionDir } from './grok-session'
+import { locateGrok } from './handoff/locate'
+import { GROK_CHAT_HISTORY_FILE, GROK_UPDATES_FILE } from './agents/grok-paths'
+
+const SESSION = '00000000-0000-4000-8000-000000000001'
+let dir = ''
+
+beforeEach(() => {
+ forgetGrokSession(SESSION)
+ dir = mkdtempSync(path.join(tmpdir(), 'grok-link-'))
+})
+
+describe('locateGrok', () => {
+ it('resolves the READABLE transcript, not the one the hooks advertise', async () => {
+ writeFileSync(path.join(dir, GROK_CHAT_HISTORY_FILE), '{"type":"user","content":"hi"}\n')
+ writeFileSync(path.join(dir, GROK_UPDATES_FILE), '{"anything":"the hook payload points here"}\n')
+ rememberGrokSessionDir(SESSION, dir)
+ const found = await locateGrok(SESSION)
+ expect(found).toBe(path.join(dir, GROK_CHAT_HISTORY_FILE))
+ expect(found).not.toContain(GROK_UPDATES_FILE)
+ })
+
+ it('learns nothing rather than guessing when no hook has reported the directory', async () => {
+ // Derived from what a hook told us, never searched: a scan of grok's sessions tree is how one
+ // node ends up reading another node's conversation.
+ expect(await locateGrok(SESSION)).toBeUndefined()
+ })
+
+ it('returns undefined when the session directory holds no chat history yet', async () => {
+ rememberGrokSessionDir(SESSION, dir)
+ expect(await locateGrok(SESSION)).toBeUndefined()
+ })
+})
+
+describe('the transcript path jail', () => {
+ const home = '/home/user'
+ const userData = '/data'
+ it('admits grok session files under its own root', () => {
+ const p = path.join(home, '.grok', 'sessions', 'enc', SESSION, GROK_CHAT_HISTORY_FILE)
+ expect(isSafeLocalTranscriptPath(p, home, userData, undefined, path.join(home, '.grok'))).toBe(true)
+ })
+ it('honours a relocated $GROK_HOME, and stops admitting the default one', () => {
+ const moved = '/elsewhere/grok'
+ const p = path.join(moved, 'sessions', 'enc', SESSION, GROK_CHAT_HISTORY_FILE)
+ expect(isSafeLocalTranscriptPath(p, home, userData, undefined, moved)).toBe(true)
+ expect(isSafeLocalTranscriptPath(path.join(home, '.grok', 'sessions', 'x'), home, userData, undefined, moved)).toBe(
+ false
+ )
+ })
+ it('is a per-ROOT widening, never $HOME', () => {
+ for (const bad of [path.join(home, '.ssh', 'id_rsa'), path.join(home, '.grok', 'auth.json'), home]) {
+ expect(isSafeLocalTranscriptPath(bad, home, userData, undefined, path.join(home, '.grok'))).toBe(false)
+ }
+ })
+})
+
+describe('capability membership', () => {
+ it('lets grok read a linked node', () => {
+ expect(canContextLink('grok')).toBe(true)
+ })
+})
+
+afterEach(() => {
+ if (dir) rmSync(dir, { recursive: true, force: true })
+})
diff --git a/src/core/handoff/locate.ts b/src/core/handoff/locate.ts
index e7faeab35..3d9134931 100644
--- a/src/core/handoff/locate.ts
+++ b/src/core/handoff/locate.ts
@@ -1,6 +1,8 @@
// Per-agent transcript file locators. Each resolves an on-disk transcript path from the
// sessionId captured via hooks. Filesystem + home-dir access only — lives in core so both
// the handoff feature (src/main) and context-link (src/core) can use it.
+import { grokSessionDirFor } from '../grok-session'
+import { GROK_CHAT_HISTORY_FILE } from '../agents/grok-paths'
import fs from 'fs'
import os from 'os'
import path from 'path'
@@ -38,6 +40,34 @@ export async function locateCodex(sessionId: string): Promise<string | undefined
// gemini: ~/.gemini/tmp/<proj>/chats/session-*.jsonl — find the file whose first-line
// header sessionId equals the requested sessionId.
+/**
+ * grok's transcript, from the session directory a hook told us about — DERIVED, never searched.
+ *
+ * Two things here are load-bearing and neither is obvious:
+ *
+ * 1. The file is `chat_history.jsonl`, NOT the `updates.jsonl` that grok's own hook payloads
+ * advertise as their transcript path. Both are siblings in the same session directory, and
+ * only the first holds the conversation `linesFromGrok` can read. Routing this through the
+ * advertised path fails SILENTLY — a real file is opened, no line parses, and the linked agent
+ * is handed an empty transcript with nothing logged. `grok-context-link.test.ts` pins it.
+ * 2. The directory comes from `grokSessionDirFor`, the hook-fed map, and there is deliberately no
+ * fallback that scans grok's sessions tree. A scan keyed on anything weaker than the session id
+ * is how one node ends up reading another node's conversation — the same trap claude's
+ * cwd-newest fallback set for codex. No hook yet ⇒ no transcript yet, which degrades to nothing
+ * rather than to somebody else's.
+ */
+export async function locateGrok(sessionId: string): Promise<string | undefined> {
+ const dir = grokSessionDirFor(sessionId)
+ if (!dir) return undefined
+ const p = path.join(dir, GROK_CHAT_HISTORY_FILE)
+ try {
+ await fs.promises.access(p, fs.constants.R_OK)
+ return p
+ } catch {
+ return undefined
+ }
+}
+
export async function locateGemini(sessionId: string): Promise<string | undefined> {
const tmp = path.join(os.homedir(), '.gemini', 'tmp')
let projects: string[]
diff --git a/src/main/index.ts b/src/main/index.ts
index 70f2b3b8a..dc45cebdb 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1,3 +1,4 @@
+import { grokHomeDir } from '../core/agents/grok-paths'
import { join, resolve, posix } from 'path'
import { startSessionNameSweep, displayNodeTitle } from '../core/session-name-sweep'
import { readAgentSessionName, type AgentSessionNameDeps } from '../core/agent-session-name'
@@ -2562,7 +2563,11 @@ app.whenReady().then(async () => {
const abs = resolve(tp)
// codexHome() honors $CODEX_HOME — a relocated codex (the snap-codex case this project has hit
// before) would otherwise fail the jail and its meter would silently never fill.
- return isSafeLocalTranscriptPath(abs, homedir(), app.getPath('userData'), codexHome())
+ // grokHomeDir() honors $GROK_HOME for the same reason and with the same failure shape: closed,
+ // so a relocated grok home would silently never resolve a context link. BOTH shells pass it
+ // (invariant 11) — a jail widened in one shell only is a feature the Server Edition lacks with
+ // nothing to say so.
+ return isSafeLocalTranscriptPath(abs, homedir(), app.getPath('userData'), codexHome(), grokHomeDir())
? abs
: undefined
}
diff --git a/src/renderer/lib/noteLink.ts b/src/renderer/lib/noteLink.ts
index 1cfaaec29..eaeb1e664 100644
--- a/src/renderer/lib/noteLink.ts
+++ b/src/renderer/lib/noteLink.ts
@@ -8,7 +8,11 @@ import { oneLine } from '@shared/one-line'
export interface LinkEndpoint {
/** React Flow node type: 'terminal' | 'sticky' | 'editor' | … */
kind: string
- /** Terminal node whose agent is CONTEXT_LINK_CAPABLE (claude/codex/gemini). */
+ /**
+ * Terminal node whose agent is `CONTEXT_LINK_CAPABLE`. Deliberately not spelled out here: the
+ * list has gained two members since this comment was written (opencode, then grok) and named
+ * them wrong in between. Ask `canContextLink`; the list lives in `shared/agents/config.ts`.
+ */
contextCapable: boolean
}
diff --git a/src/server/agent-status.ts b/src/server/agent-status.ts
index 16c66be94..ad6f1c3cd 100644
--- a/src/server/agent-status.ts
+++ b/src/server/agent-status.ts
@@ -7,6 +7,7 @@
// local logic.
//
// This module must import nothing from electron or `../main` (see no-electron.test.ts).
+import { grokHomeDir } from '../core/agents/grok-paths'
import { resolve } from 'path'
import { homedir } from 'os'
import { hookServer } from '../core/agents/hook-server'
@@ -162,7 +163,11 @@ export function wireAgentStatus(
const abs = resolve(tp)
// codexHome() honors $CODEX_HOME — a relocated codex (the snap-codex case this project has hit
// before) would otherwise fail the jail and its meter would silently never fill.
- return isSafeLocalTranscriptPath(abs, homedir(), platform.userDataDir, codexHome())
+ // grokHomeDir() honors $GROK_HOME for the same reason and with the same failure shape: closed,
+ // so a relocated grok home would silently never resolve a context link. BOTH shells pass it
+ // (invariant 11) — a jail widened in one shell only is a feature the Server Edition lacks with
+ // nothing to say so.
+ return isSafeLocalTranscriptPath(abs, homedir(), platform.userDataDir, codexHome(), grokHomeDir())
? abs
: undefined
}
diff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.ts
index 6ad042df9..8a1038d5f 100644
--- a/src/shared/agents/config.capabilities.test.ts
+++ b/src/shared/agents/config.capabilities.test.ts
@@ -176,8 +176,17 @@ describe('grok capabilities', () => {
expect(canControlCanvas('grok')).toBe(true)
})
+ it('reads a linked node, on the same already-installed skill the canvas verb uses', () => {
+ // The leaf that had to exist first: `locateGrok` (core/handoff/locate.ts), resolving the
+ // session directory a hook reported and returning `chat_history.jsonl` — NOT the
+ // `updates.jsonl` grok's payloads advertise, which parses to nothing and would show the
+ // linked agent an empty transcript with no error. Discovery needs no installer of its own,
+ // and that is now MEASURED rather than assumed: on 1.0.13, `grok inspect --json` lists
+ // `get-linked-context` as `vendor: 'claude', compatibilityStatus: 'enabled'`.
+ expect(canContextLink('grok')).toBe(true)
+ })
+
it('does not yet claim the capabilities whose per-agent leaf is unwritten', () => {
- expect(canContextLink('grok')).toBe(false)
expect(hasUsage('grok')).toBe(false)
expect(canBranch('grok')).toBe(false)
expect(canSubagent('grok')).toBe(false)
diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.ts
index 9fe7e5333..bffbf9574 100644
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@ -130,7 +130,17 @@ export const UNCONDITIONAL_SESSION_ID_CAPABLE = ['copilot'] as const
export const SUBAGENT_CAPABLE = ['claude', 'codex'] as const
export const RECURRING_CAPABLE = ['claude'] as const // /loop, /schedule, /cron
export const BRANCH_CAPABLE = ['claude'] as const
-export const CONTEXT_LINK_CAPABLE = ['claude', 'codex', 'gemini', 'opencode'] as const
+// grok joins with NO installer of its own: it scans `~/.claude/skills` for Claude Code
+// compatibility, which is exactly where `get-linked-context` is already written — the same
+// argument `CANVAS_CONTROL_CAPABLE` makes below. That premise used to be marked unverified;
+// MEASURED on 1.0.13 (2026-09-01): `grok inspect --json` lists the skill with
+// `vendor: 'claude', compatibilityStatus: 'enabled'`, and `externalCompat.cells` reports
+// `{surface:'skills', enabled:true, source:'default'}`.
+// Two user settings can switch that off — `[compat.claude] skills = false` in
+// `~/.grok/config.toml`, and `GROK_CLAUDE_SKILLS_ENABLED=false`. Then the skill is undiscoverable
+// however this list reads, and the same `inspect` cell is what says so (`enabled:false`, a
+// non-default `source`) rather than leaving support to guess.
+export const CONTEXT_LINK_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'grok'] as const
// Agents whose per-node context meter we can fill. Each needs BOTH numbers: a used count and a
// TRUSTWORTHY window.
// - claude: used from its transcript's assistant usage, window INFERRED from the model family