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.

Merge origin/feat/chat-view-copilot into feat/chat-view-agents

reviewb5eff4a2d47b
diff --cc CLAUDE.md
index 121d79b35,b5e982ceb..b2851ff0e
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@@ -1738,8 -1738,9 +1738,9 @@@ else, and its context links must keep c
`PERMISSION_MODE_CAPABLE`, `MODEL_SWITCH_CAPABLE`, with helpers (`hasHooks`,
`canBranch`, `canContextLink`, `canChat`, `canRename`, `canReadTitle`, `hasPermissionMode`, …).
Branch stays **Claude-only** purely by being in only `BRANCH_CAPABLE`. The ⌘M **ChatPanel**
- transcript view (`CHAT_CAPABLE` / `canChat`) is **claude + grok + gemini + codex** since 2026-09 (each with its own reader): grok's
- `chat_history.jsonl` gets its own reader, and `chat:read-transcript` routes by agent. That list had
- transcript view (`CHAT_CAPABLE` / `canChat`) is **claude + grok + copilot** since 2026-09: grok's
- `chat_history.jsonl` and copilot's `events.jsonl` each get their own reader, and
- `chat:read-transcript` routes by agent. That list had
++ transcript view (`CHAT_CAPABLE` / `canChat`) is **claude + grok + gemini + codex + copilot** since
++ 2026-09: grok's `chat_history.jsonl`, gemini's session file, codex's rollout and copilot's
++ `events.jsonl` each get their own reader, and `chat:read-transcript` routes by agent. That list had
to be SPLIT to do it — `CHAT_CAPABLE` carried two facts that coincided while claude was its only
member ("we can render this" and "claude's resolver can locate and parse this file"), and the
second now lives in `CLAUDE_TRANSCRIPT_READABLE` (claude only). Merging them back is a
@@@ -1815,24 -1816,21 +1816,39 @@@
harmful. The `auto` permission-mode **version gate is claude's alone** (it is fed by a `claude
--version` probe), and grok's mode flag must go **BEFORE** its `--` separator, which is
end-of-options. Full picture, dialect traps and the device checklist: **`docs/grok-agent.md`**.
+- **Grok chat view (⌘M + phone `chat.page`)** — `parseGrokChat` (`core/grok-chat.ts`) reads
+ `chat_history.jsonl` into claude's `ChatMessage`/`ChatPart` shapes (no new wire field): typed
+ prompts, assistant text, tool calls (`arg` = the salient argument — `command`, `target_file`, …, in
+ claude's `toolArg` order — else the raw JSON, 200 units) with results summarised like claude's,
+ `web_search` backend calls, harness-injected `synthetic_reason` lines as assistant-side `[reason]`
+ notes, and `model_id`/`reasoning_effort` of the NEWEST assistant record (never carried forward).
+ `reasoning` is hidden. It does NOT page: measured on 1.0.13, the file is rewritten via
+ `.sync.tmp` + rename and `/compact`/`/rewind`/history repair replace lines, so it is one capped
+ whole-file read with no keys and no `at`. Routing is by `capabilityAgentId`, so a custom agent built
+ on grok reaches grok's reader, never claude's cwd fallback. **A remote (SSH) grok node is read on its
+ host** (`core/remote-grok-chat.ts`, one `sh -c` round trip: `$GROK_HOME` if absolute else
+ `$HOME/.grok`, the session found by id across `sessions/*/<id>/`, two matches refused, the
+ paged-transcript window at 5 MiB) — its failures are terminal, never this machine's disk (the
+ hook-derived local map names a wrong-machine path for these nodes). The phone gets it for free:
+ `chat.page` reads through the same deps. Golden fixtures + exact rules for the Swift port:
+ `src/shared/chat-fixtures/grok/`. Not supported: the composer's model/effort labels (grok's `/model`
+ and `/effort` pickers are unmeasured — the TUI needed a login here), plan/question answer cards
+ (claude-only), pre-compaction history, and a local session whose map entry `SessionEnd` retired.
+ - **Copilot ⌘M chat view** (`core/copilot-chat.ts`, 2026-09; copilot 1.0.88 measured in BYOK mode
+ against a local fake model, plus the CLI's own `schemas/session-events.schema.json`). Reads
+ `<COPILOT_HOME>/session-state/<id>/events.jsonl` (then the snap package's
+ `~/snap/copilot-cli/common/.copilot`), located STRICTLY by the node's session id and routed by
+ `capabilityAgentId` before anything claude-shaped, so a missing journal is "not found", never
+ claude's cwd-newest or another session. The journal is append-only JSONL (compaction appends), so it
+ PAGES like claude's — `parseChatWindow`/`parseGrowingWindow` take copilot's record parser — and the
+ phone gets the same pages over the relay (`page()` gates only on `canChat`). Shown: typed prompts
+ (`content`, never `transformedContent`; the sources copilot's own timeline hides stay hidden),
+ assistant text, tool calls with results (`Error: …` on failure), a user's `!` shell command as the
+ `!` part, `Error:`/`Warning:`/`Info:` notices, and `model`. Never shown: the system prompt,
+ reasoning, sub-agent events (envelope `agentId` / `data.agentId` / `data.parentToolCallId`). Not
+ supported: remote (SSH) nodes (`unreadable`, "not supported yet" — never this machine's disk),
+ `effort` (not recorded), plan/question answer cards (claude-only), composer model labels (claude's
+ picker commands only). Golden fixtures: `src/shared/chat-fixtures/copilot/` (README "Copilot").
- **Antigravity** (`agy` 1.2.3 measured on Windows; the 1.2.12 Linux binary read; builtin since
2026-09 — Google's replacement for Gemini CLI on personal accounts) — in `AGENT_HOOK_TARGETS`
(badge, NEEDS YOU from `ask_question`, a closed set of one, `--after` and triggers) and
diff --cc src/core/transcript-ipc.ts
index 231bdef2d,d0fe6642e..75793226e
--- a/src/core/transcript-ipc.ts
+++ b/src/core/transcript-ipc.ts
@@@ -12,19 -12,12 +12,20 @@@
import fsp from 'node:fs/promises'
import { IPC } from '../shared/ipc'
import type { ChatTranscriptResult, TranscriptLine, TranscriptPresence } from '../shared/types'
-import { CHAT_PAGE_MAX_BYTES, normalizeChatPage, type ChatTranscriptPage } from '../shared/chat-page'
+import {
+ CHAT_PAGE_MAX_BYTES,
+ GROK_AMBIGUOUS_SESSION_MESSAGE,
+ normalizeChatPage,
+ type ChatTranscriptPage
+} from '../shared/chat-page'
import { platform } from './platform'
-import { chatMessagesFromGrok } from './grok-chat'
+import { parseGrokChat } from './grok-chat'
+import type { RemoteGrokChat } from './remote-grok-chat'
+import { readGeminiChatTranscript } from './gemini-chat'
+import { chatMessagesFromCodex, locateCodexRollout, parseCodexChatWindow } from './codex-chat'
+ import { chatMessagesFromCopilot, locateCopilotTranscript, parseCopilotChatWindow } from './copilot-chat'
-import { capabilityAgentId } from '../shared/agents/config'
import { locateGrok } from './handoff/locate'
+import { capabilityAgentId } from '../shared/agents/config'
import {
parseChatMessages,
parseChatWindow,
@@@ -141,7 -112,8 +142,8 @@@ async function parseGrowingWindow
page: ChatTranscriptPage,
first: { data: Buffer; start: number },
read: WindowRead,
- // The window parser: claude's, or another append-only JSONL reader's (copilot's).
- parseWindow: (buf: Buffer, bufStart: number) => ChatWindowParse = parseChatWindow
++ // The window parser: claude's, or another append-only JSONL reader's (codex's, copilot's).
+ parse: (buf: Buffer, bufStart: number) => ChatWindowParse = parseChatWindow
): Promise<ChatTranscriptResult> {
let w = first
let maxBytes = page.maxBytes
@@@ -207,42 -179,38 +209,74 @@@ async function readChatPage
return parseGrowingWindow(page, w, async (pg) => (await readChatWindow(p, pg)) ?? null)
}
+/**
+ * A paged read of a CODEX node's rollout — `readChatPage`'s shape with codex's own locator and parser
+ * (a rollout is append-only JSONL, so it pages by byte offset exactly like claude's transcript).
+ * Nothing claude-shaped runs: not `resolveTranscript` (its cwd fallback answers with the newest
+ * CLAUDE session in the directory), not claude's remote leg (it locates a claude file on the host).
+ * Remote first and terminal, as everywhere: a remote node is read on its host or not at all.
+ */
+async function readCodexChatPage(
+ q: TranscriptQuery,
+ page: ChatTranscriptPage,
+ deps: TranscriptIpcDeps
+): Promise<ChatTranscriptResult> {
+ const readRemote = deps.readRemoteCodexPage
+ if (readRemote) {
+ const remote = await readRemote(q, page)
+ if (remote !== null) {
+ if (!remote.ok) return remote.absent ? notFoundPage() : unreadablePage()
+ return parseGrowingWindow(
+ page,
+ remote,
+ async (p) => {
+ const r = await readRemote(q, p)
+ return r && r.ok ? r : null
+ },
+ parseCodexChatWindow
+ )
+ }
+ }
+ if (q.remoteOnly) return unreadablePage()
+ const p = await locateCodexRollout({ sessionId: q.sessionId, accountId: q.accountId }, deps.codexPathFor)
+ if (!p) return notFoundPage()
+ const w = await readChatWindow(p, page)
+ if (!w) return notFoundPage()
+ return parseGrowingWindow(page, w, async (pg) => (await readChatWindow(p, pg)) ?? null, parseCodexChatWindow)
+}
+
+ /**
+ * A copilot node's read. Its journal (`<COPILOT_HOME>/session-state/<id>/events.jsonl`) is
+ * append-only JSONL, so it pages exactly like claude's — same window, growth and cursor rules
+ * (`parseGrowingWindow`), copilot's record parser.
+ *
+ * Located STRICTLY by the node's session id: no cwd fallback, no claude resolver, no hook-fed claude
+ * path, no remote claude reader — each of those answers a copilot id with some other session. A
+ * remote (SSH) node's journal is on the host and no remote copilot reader exists yet, so it is
+ * `unreadable` (paged) / not found (legacy) BEFORE anything is read — never this machine's disk.
+ * A local read that fails is a plain not-found, like grok's, so `unreadable` on a copilot result
+ * can only mean "remote", which is what the panel says.
+ */
+ async function readCopilotChat(
+ sessionId: string | undefined,
+ remoteOnly: boolean | undefined,
+ page: ChatTranscriptPage | null
+ ): Promise<ChatTranscriptResult> {
+ if (remoteOnly) return page ? unreadablePage() : { messages: [], found: false }
+ const p = await locateCopilotTranscript(sessionId)
+ if (!page) {
+ const buf = p ? await readCappedTail(p) : undefined
+ return buf === undefined ? { messages: [], found: false } : { messages: chatMessagesFromCopilot(buf), found: true }
+ }
+ if (!p) return notFoundPage()
+ const w = await readChatWindow(p, page)
+ if (!w) return notFoundPage()
+ const out = await parseGrowingWindow(page, w, async (pg) => (await readChatWindow(p, pg)) ?? null, parseCopilotChatWindow)
+ // A LOCAL growth re-read that failed (the journal vanished mid-read) comes back `unreadable`, but
+ // on a copilot result the panel reads `unreadable` as "remote, unsupported" — keep that claim true.
+ return out.unreadable ? notFoundPage() : out
+ }
+
/**
* Resolve a session's transcript path: the exact session file when a (valid) sessionId is known,
* else the node's cwd — durable, and needing no live hook event. `accountId` scopes BOTH legs to
@@@ -344,27 -259,25 +378,30 @@@ export async function readChatTranscrip
// Routed by agent BEFORE anything claude-shaped runs. `resolveTranscript` below falls back to
// the newest claude transcript for the cwd when its sessionId leg misses, and a grok id always
// misses — so reaching that fallback with a grok node would answer with a stranger's
- // conversation. The remote leg is claude-only too (its reader tails claude's file), so a grok
- // node is served locally or not at all rather than being handed the wrong host's claude log.
+ // conversation. Resolved through the base harness, so a custom agent built on grok (which the
+ // panel and the phone admit via `canChat`) is routed here too instead of into that fallback.
+ if (agentId !== undefined && capabilityAgentId(agentId) === 'grok') {
+ return readGrokChat({ sessionId, cwd, accountId, nodeId, ...(remoteOnly ? { remoteOnly } : {}) }, page, deps)
+ }
+ // Gemini, routed through the base harness so a custom agent built on it (which the relay serves)
+ // reads gemini's file too. Its own locator, keyed strictly on the session id in the file header —
- // never claude's resolver, never a cwd — and local-only, like grok.
++ // never claude's resolver, never a cwd — and local-only (`CHAT_LOCAL_ONLY`).
+ if (agentId && capabilityAgentId(agentId) === 'gemini') return readGeminiChatTranscript({ sessionId, remoteOnly }, page)
+ // Codex — the builtin or a custom agent whose base harness it is — is routed BEFORE the claude
+ // path for the same reason as grok: a codex thread id never resolves under claude's tree, and the
+ // cwd fallback would then answer with somebody else's claude session.
+ if (agentId && capabilityAgentId(agentId) === 'codex') {
+ if (page) return readCodexChatPage({ sessionId, cwd, accountId, nodeId, ...(remoteOnly ? { remoteOnly } : {}) }, page, deps)
+ // The unpaged (legacy) read has no live caller — the ⌘M panel and the phone always page — so it
+ // is served locally or not at all, like grok's: a remote node's rollout is on its host.
+ if (remoteOnly) return { messages: [], found: false }
+ const cp = await locateCodexRollout({ sessionId, accountId }, deps.codexPathFor)
+ const text = cp ? await readCappedTail(cp) : undefined
+ return text === undefined ? { messages: [], found: false } : { messages: chatMessagesFromCodex(text), found: true }
+ }
+ // Copilot, by its base harness (a custom agent built on it reads the same journal). Before
- // anything claude-shaped, for the reason grok's branch below states.
++ // anything claude-shaped, for the same reason as grok and codex. Local-only (`CHAT_LOCAL_ONLY`).
+ if (agentId && capabilityAgentId(agentId) === 'copilot') return readCopilotChat(sessionId, remoteOnly, page)
- if (agentId === 'grok') {
- // Grok is read locally only — a remote grok node's history is on the host.
- if (remoteOnly) return page ? unreadablePage() : { messages: [], found: false }
- const gp = sessionId ? await locateGrok(sessionId) : undefined
- // Grok does NOT page: its history is small and its reader has no byte-offset keys, so a
- // paged request gets the whole (capped) read with `olderCursor: null` — "nothing older to
- // fetch" — and no carried results. Keys are absent; the panel falls back to its own.
- const paging = page ? { olderCursor: null, unmatchedResults: [] } : {}
- if (!gp) return { messages: [], found: false, ...paging }
- const buf = await readCappedTail(gp)
- return buf === undefined
- ? { messages: [], found: false, ...paging }
- : { messages: chatMessagesFromGrok(buf), found: true, ...paging }
- }
if (page) return readChatPage({ sessionId, cwd, accountId, nodeId, ...(remoteOnly ? { remoteOnly } : {}) }, page, deps)
const remote = deps.readRemote ? await deps.readRemote({ sessionId, cwd, accountId, nodeId }) : null
// A resolved-but-unreadable remote file is NOT "no conversation yet" — the read failed
diff --cc src/renderer/nodes/ChatPanel.ux.test.tsx
index a2103d74c,53037ad52..9669b06ca
--- a/src/renderer/nodes/ChatPanel.ux.test.tsx
+++ b/src/renderer/nodes/ChatPanel.ux.test.tsx
@@@ -249,32 -245,19 +249,44 @@@ describe('ChatPanel empty states', () =
await act(async () => {
pending[0].resolve({ messages: [], found: false, olderCursor: null, unmatchedResults: [], unreadable: true })
})
- expect(msgs().textContent).toContain("Reading a remote Grok session's transcript isn't supported yet.")
- expect(msgs().textContent).not.toContain("Couldn't read")
+ expect(msgs().textContent).toContain("Couldn't read the transcript.")
+ expect(msgs().textContent).not.toContain("isn't supported yet")
+ expect(host.querySelector('.term-chat__retry')).not.toBeNull()
+ })
+
+ it('a grok session id that matches two host sessions says so, with NO Retry (a retry cannot fix it)', async () => {
+ await render({ agentId: 'grok' })
+ // Over Electron IPC only the message survives a rejection (the `code` is dropped), wrapped in
+ // Electron's own prefix — the panel must recognise it from the message alone.
+ await act(async () => {
+ pending[0].reject(
+ new Error(`Error invoking remote method 'chat:read-transcript': Error: ${GROK_AMBIGUOUS_SESSION_MESSAGE}`)
+ )
+ })
+ expect(msgs().textContent).toContain(GROK_AMBIGUOUS_SESSION_MESSAGE)
+ expect(msgs().textContent).not.toContain('may not be reachable')
+ expect(msgs().textContent).not.toContain("can't be read on this surface")
+ expect(host.querySelector('.term-chat__retry')).toBeNull()
+ })
+
+ it('an unreadable REMOTE gemini read names Gemini, not Grok, and offers no Retry', async () => {
+ await render({ agentId: 'gemini' })
+ await act(async () => {
+ pending[0].resolve({ messages: [], found: false, olderCursor: null, unmatchedResults: [], unreadable: true })
+ })
+ expect(msgs().textContent).toContain("Reading a remote Gemini session's transcript isn't supported yet.")
++ expect(msgs().textContent).not.toContain('Grok')
+ expect(host.querySelector('.term-chat__retry')).toBeNull()
+ })
+
+ it('an unreadable REMOTE copilot read says so in copilot\'s own name, with no Retry', async () => {
+ // Core's copilot leg is local-only too (core/copilot-chat.ts): its `unreadable` can only be the
+ // remote refusal, which no retry heals.
+ await render({ agentId: 'copilot' })
+ await act(async () => {
+ pending[0].resolve({ messages: [], found: false, olderCursor: null, unmatchedResults: [], unreadable: true })
+ })
+ expect(msgs().textContent).toContain("Reading a remote GitHub Copilot session's transcript isn't supported yet.")
expect(msgs().textContent).not.toContain('Grok')
expect(host.querySelector('.term-chat__retry')).toBeNull()
})
diff --cc src/shared/agents/config.ts
index d0cb2dfcc,6d47c1d35..4082dd8a0
--- a/src/shared/agents/config.ts
+++ b/src/shared/agents/config.ts
@@@ -297,18 -294,10 +297,21 @@@ export const USAGE_CAPABLE = ['claude'
// conversation in its find bar and rehydrate its meter from it. That exact bug already happened once
// with codex and gemini; transcriptGates.ts documents it.
//
+// gemini joined in 2026-09 with its own reader (`core/gemini-chat.ts`): its session file is an upsert
+// log, not claude's shape, and it is located strictly by the session id in the file's header.
+// codex joined 2026-09-28 with its own reader (core/codex-chat.ts: the rollout's UI stream for what
+// the user typed, the model stream for answers and tools), local and over SSH.
- export const CHAT_CAPABLE = ['claude', 'grok', 'gemini', 'codex'] as const
+ // copilot joined 2026-09 with its own leaf, `core/copilot-chat.ts`: `<COPILOT_HOME>/session-state/
+ // <id>/events.jsonl`, located strictly by session id and routed there before anything claude-shaped
-// (`readChatTranscript`). Like grok it is CHAT_CAPABLE and NOT in the list below.
-export const CHAT_CAPABLE = ['claude', 'grok', 'copilot'] as const
++// (`readChatTranscript`). Like the others it is NOT in CLAUDE_TRANSCRIPT_READABLE below.
++export const CHAT_CAPABLE = ['claude', 'grok', 'gemini', 'codex', 'copilot'] as const
+// CHAT_CAPABLE agents whose reader has NO remote leg: a remote (SSH) node's session lives on its
+// host, so core answers `unreadable` before touching anything — and the local reader never sets that
- // flag. So an unreadable read of one of these can only mean "remote, unsupported", and the ⌘M panel
- // names it from the agent alone rather than offering a Retry that can never succeed. grok and codex
- // are NOT here: their remote nodes are read on the host (`core/remote-grok-chat.ts`,
- // `main/remote-codex-chat-page.ts`).
- export const CHAT_LOCAL_ONLY = ['gemini'] as const
++// flag (copilot maps a failed local read to not-found for exactly this reason). So an unreadable read
++// of one of these can only mean "remote, unsupported", and the ⌘M panel names it from the agent
++// alone rather than offering a Retry that can never succeed. grok and codex are NOT here: their
++// remote nodes are read on the host (`core/remote-grok-chat.ts`, `main/remote-codex-chat-page.ts`).
++export const CHAT_LOCAL_ONLY = ['gemini', 'copilot'] as const
// Agents whose transcript CLAUDE's own resolver can locate and parse — the gate for everything that
// goes through `resolveTranscript` (the find bar's index, the meter's mount-time rehydration).
//
diff --cc src/shared/chat-fixtures/README.md
index a254f3050,6bd16a86e..89caeb4d0
--- a/src/shared/chat-fixtures/README.md
+++ b/src/shared/chat-fixtures/README.md
@@@ -158,9 -158,102 +158,113 @@@ Most inputs are a few KB. Three inputs
construction) and `huge-last-line` (~1.1 MB). Their filler is deterministic lorem ipsum, and the
base64 image is generated by a seeded generator.
+## Other agents
+
+Each agent with its own reader keeps its fixtures in a subdirectory with its own README, generated
+by its own test; the pager and step format are the ones above.
+
+- `codex/` — codex rollouts (`src/core/codex-chat.ts`, `src/core/codex-chat-fixtures.test.ts`).
++- `gemini/` — gemini session files (`src/core/gemini-chat.ts`), one capped page; see its README.
++- `grok/` — grok `chat_history.jsonl` (`src/core/grok-chat.ts`), one capped page; see its README.
++- `copilot/` — copilot session journals (`src/core/copilot-chat.ts`); its rules are the "Copilot"
++ section below.
++
+ ## Copilot (`copilot/`)
+
+ The same contract for GitHub Copilot CLI's reader (`src/core/copilot-chat.ts`). Its session journal
+ is `<COPILOT_HOME>/session-state/<sessionId>/events.jsonl` (`COPILOT_HOME` defaults to
+ `~/.copilot`; the snap package writes under `~/snap/copilot-cli/common/.copilot`), one session
+ event per line in the envelope `{type, data, [agentId], id, timestamp, parentId}`. The record
+ shapes were **measured** on copilot 1.0.88 (a real CLI run in BYOK mode against a local fake model,
+ so every byte of content was synthetic) and cross-checked against the CLI's own
+ `schemas/session-events.schema.json`. The inputs here are synthetic too.
+
+ ```sh
+ UPDATE_CHAT_FIXTURES=1 npx vitest run src/core/copilot-chat-fixtures.test.ts
+ ```
+
+ | path | what it is |
+ |---|---|
+ | `copilot/inputs/<name>.jsonl` | A synthetic copilot session journal. |
+ | `copilot/expected/<name>.pages.json` | The page sequence, in exactly the format of the claude set above. |
+
+ **The pager and the window rules are the claude ones, byte for byte** (256 KiB tail, 512 KiB older
+ pages, ×4 growth to 5 MiB, one lookbehind byte, `olderCursor`, `noCompleteLine`): the journal is
+ append-only JSONL (compaction APPENDS `session.compaction_*` events; measured), so core reuses
+ `parseChatWindow` and `parseGrowingWindow` with copilot's record parser. `key` is the line's
+ absolute byte offset, a tool part's `id` is the call id, both only on a paged read.
+
+ ### Record rules (the Swift port must replicate this exactly)
+
+ `parseCopilotRecords`, applied to each complete line in order:
+
+ 1. A blank line is ignored. A line that is not JSON, not a JSON object, has no string `type` or no
+ object `data` is skipped (and counted in the reader's diagnostic `skipped`, which is never on the
+ wire).
+ 2. **Sub-agent events are dropped**, by the CLI's own test: a non-empty string `agentId` on the
+ envelope, OR a non-empty string `data.agentId`, OR a non-empty string `data.parentToolCallId`.
+ A sub-agent's turns belong to the `task` call whose result the main thread already shows.
+ 3. `at` = `Date.parse(timestamp)` in epoch ms when the envelope's `timestamp` is a parseable
+ non-empty string, else absent.
+ 4. `user.message`: `data.content` must be a string (else skipped). It becomes
+ `{role:"user", parts:[{kind:"text", text: content}]}` (verbatim, untrimmed) only when
+ `content.trim()` is non-empty AND the source is one copilot's own timeline shows: `data.source`
+ absent, `null`, `"user"`, or a string starting with `command-`, `schedule-` or `autopilot-`. Any
+ other source (`skill-*` injections, `agent-*` inter-agent prompts, a non-string) is hidden.
+ `transformedContent` (the model-facing text with injected datetime/instructions) and
+ `attachments` are never read.
+ 5. `assistant.message`: `data.content` (absent or `null` = `""`) must be a string and
+ `data.toolRequests` (absent or `null` = `[]`) an array, else the record is skipped. On a paged
+ read, `model` is set to `data.model` when it is a string of 1..100 UTF-16 units and CLEARED
+ otherwise, for every main-thread `assistant.message` (so the newest one decides, even one that
+ yields no parts; never carried forward). Parts, in order: a text part when `content.trim()` is
+ non-empty (text verbatim); then per request, which must be an object with non-empty string
+ `name` and `toolCallId` (else that one request is skipped): `{kind:"tool", name, arg}`, plus
+ `id: toolCallId` when paged. Pushed as an assistant message only when it has parts.
+ `reasoningText`, `reasoningOpaque`, `encryptedContent` and the `assistant.reasoning` event are
+ never read.
+ 6. **The `arg` rule:** `arguments` a string (a `custom` tool such as `apply_patch`) → its first 200
+ UTF-16 units. A plain object → the first of `command`, `path`, `file_path`, `pattern`, `url`,
+ `query`, `description`, `prompt`, `skill`, `question`, `intent` whose value is a NON-EMPTY
+ STRING (a non-string under an earlier key does not stop the search), first 200 units, untrimmed.
+ Anything else → `""`.
+ 7. `tool.user_requested` (a tool the USER ran, `!cmd` shell mode being a `bash` call): non-empty
+ string `toolName` and `toolCallId` required (else skipped). With `toolName === "bash"` and a
+ string `arguments.command`: `{kind:"tool", name:"!", arg: command.trim().slice(0, 200)}` — the
+ claude `!` line's shape. Otherwise `{kind:"tool", name: toolName, arg: <arg rule>}`. `id` when
+ paged. Pushed as its own assistant message. (Schema-derived: `-p` mode cannot produce it, so
+ this shape was not captured from a live run.)
+ 8. `tool.execution_complete`: non-empty string `toolCallId` required (else skipped). With
+ `error` = `data.error.message` if a string else `""`, and `content` = `data.result.content` if
+ a string else `""`: the text is `"Error: " + error` when `data.success !== true` and `error` is
+ non-empty, else `content`. `result` = that text split on `\n`, the first three lines joined by a
+ space, the first 500 UTF-16 units (claude's `summarizeResult`). An empty result sets nothing.
+ Otherwise it is set on the tool part registered under that call id (a later completion
+ overwrites; a later registration of the same id replaces the earlier part as the target); with
+ no such part, a paged read carries it in `unmatchedResults` (JS `Map` order: first insertion
+ wins the position, a later one the value).
+ 9. `session.error` / `session.warning` / `session.info`: `data.message` must be a string (else
+ skipped); pushed as an assistant text part `"Error: "` / `"Warning: "` / `"Info: "` + message —
+ the same three notices copilot's own chat adapter (ACP) emits.
+ 10. Every other type yields nothing and is not counted: `session.start`/`resume`/`shutdown`,
+ `system.message` (the ~44 KB system prompt), turn boundaries, permissions, hooks,
+ `abort`, compaction, model/mode/plan changes, `system.notification`, `skill.invoked`,
+ `subagent.*`, `session.binary_asset`, `tool.execution_start`, and any type a newer CLI adds.
+ 11. `effort` is never set: copilot records no per-response effort.
+
+ | fixture | pins |
+ |---|---|
+ | `plain-turns` | Prompts and markdown answers, non-ASCII, two assistant messages in one turn, a resume and a model change in between (the second model wins); the system prompt and all bookkeeping yield nothing. |
+ | `tools` | Nine tool calls: the arg rule per tool (`bash`→command, `view`/`create`/`edit`→path, `grep`→pattern, `sql`→query before description, `apply_patch`'s raw string, `read_bash`→`""`, a 200-unit cap), a denied call's `Error:` result, a >3-line result, a 500-unit cap, an empty result (no key), and a failure with no error message falling back to its content. |
+ | `tools-cross-page` | A call in the older page, its completion in the tail: the tail carries it in `unmatchedResults`, the older page has the tool part with its `id` and no `result`. |
+ | `subagent` | A `task` call with a sub-agent's full event run (envelope `agentId`, its own prompt, messages, tool calls and model): only the `task` part and its result reach the thread. |
+ | `notices` | `session.error` / `session.warning` / `session.info` rendered; `abort`, compaction, notifications, skill bodies, context/plan/mode changes, hooks, binary assets and an unknown type rendered as nothing. |
+ | `hidden-prompts` | Which `source` values show a prompt, and that blank prompts, the empty autopilot continuation and attachments add nothing. |
+ | `reasoning` | No reasoning, on the event or on a message; a reasoning-only message and a whitespace-only message yield nothing. |
+ | `model` | The newest main-thread message's model; a newer sub-agent message does not count. |
+ | `model-absent` | The newest main-thread message states no model: the key is absent (not carried forward). |
+ | `model-utf16` | 50 × U+1F9EA (exactly 100 UTF-16 units) is kept. |
+ | `model-over-cap` | 101 units: absent. |
+ | `user-requested` | A user `!` bash command (`name:"!"`, trimmed arg) and a user-requested `view`, each with its result. |
+ | `malformed` | Thirteen unreadable or ill-shaped lines, plus a good message holding two bad tool requests, between good ones: the good ones render, and a bad tool request costs only itself. |
+ | `huge-last-line` | A tool result carrying an image for the model (~300 KB) is the last line: the tail grows past 256 KiB and the result still attaches. |