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/main into feat/chat-teammate-messages

review6b0d945f0fc3
diff --cc src/core/transcript-reader.ts
index 7f18f016b,8bb5a1cb5..1890f9c85
--- a/src/core/transcript-reader.ts
+++ b/src/core/transcript-reader.ts
@@@ -355,22 -350,17 +356,33 @@@ export function classifySystemRecord
return null
}
+/** A teammate record (core/chat-teammate.ts) as ONE `Agent message` part: `arg` names the sender(s),
+ * `result` holds each element as text. The rich read draws `teammate` parts instead. */
+function teammateRecord(team: TeammateElement[]): SystemRecord {
+ const senders = [...new Set(team.map((el) => (el.unverified ? `${el.from} (unverified)` : el.from)))]
+ return {
+ name: AGENT_MESSAGE_TOOL,
+ arg: capArg(senders.join(', ')),
+ result: capResult(team.map(teammateElementText).join('\n\n'))
+ }
+}
+
+/** A teammate element as the `teammate` part the rich read draws. */
+function teammatePart(el: TeammateElement): Extract<ChatPart, { kind: 'teammate' }> {
+ return { kind: 'teammate', ...el }
+}
+
+ /** What a tool call cancelled by an interrupt shows as its result (`ChatParseOptions.rich`). */
+ export const INTERRUPTED_TOOL_RESULT = 'Interrupted'
+
+ /** The result Claude Code writes for a tool call the user cancelled or refused. MEASURED on 2.1.285
+ * (`__fixtures__/claude/interrupt-capture.json`): an `is_error` tool_result starting with this. */
+ const TOOL_REJECTION_PREFIX = "The user doesn't want to proceed with this tool use."
+
+ function isToolRejection(c: { is_error?: unknown; content?: unknown }): boolean {
+ return c.is_error === true && summarizeResult(c.content).startsWith(TOOL_REJECTION_PREFIX)
+ }
+
/** A system record's tool part (`result` only when non-empty). */
function systemPart(r: SystemRecord): Extract<ChatPart, { kind: 'tool' }> {
const part: Extract<ChatPart, { kind: 'tool' }> = { kind: 'tool', name: r.name, arg: r.arg }
diff --cc src/renderer/lib/chatPaging.test.ts
index 89d77efd4,b238655dc..486f7bddd
--- a/src/renderer/lib/chatPaging.test.ts
+++ b/src/renderer/lib/chatPaging.test.ts
@@@ -26,7 -26,7 +26,7 @@@ const page =
const texts = (t: ChatThread): string[] =>
t.messages.map((m) => {
const p = m.parts[0]
- return p.kind === 'tool' ? `tool:${p.id}:${p.result ?? '-'}` : p.kind === 'image' ? 'image' : p.kind === 'teammate' ? 'teammate' : p.text
- return p.kind === 'tool' ? `tool:${p.id}:${p.result ?? '-'}` : p.kind === 'image' ? 'image' : p.kind === 'interrupt' ? 'interrupt' : p.text
++ return p.kind === 'tool' ? `tool:${p.id}:${p.result ?? '-'}` : p.kind === 'image' ? 'image' : p.kind === 'teammate' ? 'teammate' : p.kind === 'interrupt' ? 'interrupt' : p.text
})
describe('attachCarried', () => {
diff --cc src/renderer/nodes/ChatPanel.tsx
index a89a36e93,f10effab0..9c609316b
--- a/src/renderer/nodes/ChatPanel.tsx
+++ b/src/renderer/nodes/ChatPanel.tsx
@@@ -63,10 -63,9 +63,11 @@@ import { TODO_WRITE_TOOL, latestTodoInd
import { ChatToolGroup } from './ChatToolGroup'
import { ChatImage } from './ChatImage'
import { ChatToolDiff } from './ChatToolDiff'
+import { ChatTeammateMessage } from './ChatTeammate'
+import { isTeammateMessage } from '../lib/chatTeammate'
import { FALLBACK_SESSION_NOTE, transcriptReadCwd } from '../lib/transcriptSession'
import { chatPageDirection, pageChatThread } from '../lib/chatPageKeys'
+ import { CLAUDE_INTERRUPT_LINE, chatEscInterrupts, chatInterruptRefusalText } from '../lib/chatEscInterrupt'
// Memoized bubble: marked+DOMPurify re-ran for EVERY message on each ChatPanel render (each
// turn-finish reload, each keystroke re-render). Text is stable per message, so cache per text.
@@@ -1025,10 -1065,13 +1067,17 @@@ export function ChatPanel(
) : p.kind === 'image' ? (
// An image the user attached to the prompt (the opt-in `rich` read): a thumbnail, click to enlarge.
<ChatImage key={key} mediaType={p.mediaType} data={p.data} />
+ ) : p.kind === 'teammate' ? (
+ // A teammate's message (the opt-in `rich` read). A message of them is drawn whole below, so a
+ // run from one teammate folds into one row; this is the part on its own.
+ <ChatTeammateMessage key={key} parts={[p]} Markdown={MarkdownText} />
+ ) : p.kind === 'interrupt' ? (
+ // The user interrupted the turn (the opt-in `rich` read). Claude saves that as a user record,
+ // but the user did not type it: drawn as Claude's own TUI line, hanging off what came before.
+ <div key={key} className="term-chat__interrupt">
+ <span className="term-chat__interrupt-hook" aria-hidden="true">⎿</span>
+ {CLAUDE_INTERRUPT_LINE}
+ </div>
) : p.body && !staleTodo(p, i, latestTodo) ? (
// A plan / question / the latest todo list is the content itself, not plumbing: shown
// expanded, in full, flowing with the thread (no inner scroll box). The answer stays under it.
diff --cc src/shared/types.ts
index 2f733191e,b2ca9e1b0..607ffc55e
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@@ -3627,22 -3632,15 +3632,31 @@@ export type ChatPart
mediaType: string
data: string
}
+ | {
+ /**
+ * A message from an agent team's teammate (core/chat-teammate.ts): Claude Code records it in the
+ * lead's transcript as a user record, but nobody typed it. Present only on the opt-in `rich`
+ * read; without it the record is one `Agent message` tool part. `text` = a plain message's
+ * markdown body; `idle` = the teammate reporting that its turn ended (then `text` is absent).
+ * `color` is the teammate's TUI color name, as recorded (untrusted: map it, never use it as CSS).
+ */
+ kind: 'teammate'
+ from: string
+ color?: string
+ summary?: string
+ unverified?: boolean
+ text?: string
+ idle?: ChatTeammateIdle
+ }
+ | {
+ /**
+ * The user interrupted the turn here (Esc, or Ctrl+C once): one of Claude Code's fixed marker
+ * records (`CLAUDE_INTERRUPT_MARKERS`), which it saves as a USER record but which the user did
+ * not type. Present only on the opt-in `rich` read; without it the marker stays a user text
+ * part, as before. The renderer draws Claude's own TUI line for it.
+ */
+ kind: 'interrupt'
+ }
| {
kind: 'tool'
name: string