The Open Framework for Building Agents
feat(eve): clarify live task rendering in the TUI (#4058)
OwenKepharta79fca4fdadc
diff --git a/.changeset/quiet-live-task-panel.md b/.changeset/quiet-live-task-panel.mdnew file mode 100644index 000000000..4ec912afd--- /dev/null+++ b/.changeset/quiet-live-task-panel.md@@ -0,0 +1,5 @@+---+"eve": patch+---++Task starts in the terminal UI now use ordinary tool-call styling. A bounded activity drawer above the prompt shows readable subagent labels, nested work, and the parent's current state and elapsed time. Activity remains visible above questions and approvals when screen space permits.diff --git a/docs/guides/dev-tui.md b/docs/guides/dev-tui.mdindex b145c06d3..0196be27b 100644--- a/docs/guides/dev-tui.md+++ b/docs/guides/dev-tui.md@@ -96,9 +96,9 @@ Required authorization or deployment setup still runs for the selected item. PreType a message and press `Enter` to send it. When the agent asks a question or requests tool approval, respond in the prompt shown by the UI. Each answer is sent as soon as you give it. When several requests are open, the prompt shows its place among them, such as `2 of 5`, and names the task that asked as its transcript lines do. Connection authorization can open a browser; keep local `eve dev` running until the browser returns to it.-The activity line shows **Thinking** while the model reasons or waits to respond, **Generating** while it writes a response or tool input, **Running** while tools execute, and **Waiting for** followed by task names while the turn waits on [tasks](../tools/tasks). A blinking dot and elapsed time indicate progress, with token counts shown when available. The activity line disappears when the turn finishes or needs your input.+The activity line shows **Thinking** while the model reasons or waits to respond, **Generating** while it writes a response or tool input, and **Running** while tools execute. A blinking dot and elapsed time indicate progress, with token counts shown when available. While [tasks](../tools/tasks) work, the drawer header replaces this line: it shows the parent's current activity, task count, and turn elapsed time without token counts. **Waiting** means the parent is waiting on work; **Working** appears without a turn timer when tasks remain active between turns.-A task, such as a call to a subagent, writes one line to the transcript when it starts and one when it finishes, fails, or is stopped. The finished line names how long the task took and, for a subagent, what it did, such as `Read 3 files, Ran 2 commands`. While tasks work, a panel above the prompt shows each task's current activity and elapsed time. The UI does not show the model's own `task_wait` and `task_cancel` calls; their effect appears as the waiting activity line and a stopped task's line.+A task, such as a call to a subagent, writes one line to the transcript when it starts and one when it finishes, fails, or is stopped. The finished line names how long the task took and, for a subagent, what it did, such as `Read 3 files, Ran 2 commands`. Task starts use the same tool-call styling as synchronous calls. While tasks work, an activity drawer above the prompt shows each task's name, current activity, and elapsed time without repeating its launch prompt. Subagents use labels such as `subagent(self-modification)`, with elapsed time beside the name and the latest observed tool grouped beneath an elbow. The tool remains visible between calls rather than switching to a starting placeholder. During questions and approvals, activity stays visible above the request with a shared divider when screen space permits; the request takes priority on small terminals. Background work started by a followed subagent appears beneath that subagent; deeper work uses an ownership path instead of further indentation. The panel caps its height and prioritizes tasks needing approval when work overflows. The UI does not show the model's own `task_wait` and `task_cancel` calls; their effect appears as the **Waiting** header and a stopped task's line.The prompt stays open while the agent works, including turns started elsewhere, such as a scheduled run. While a turn is running, `Enter` sends your message immediately as steering. Before assistant output begins, the runtime interrupts pending model generation and continues the same turn with your correction. Executing tools finish safely. After output begins, steering applies at the next workflow boundary and preserves streamed text.diff --git a/e2e/fixtures/agent-session-limits/evals/limits/session-token-limit-approve.eval.ts b/e2e/fixtures/agent-session-limits/evals/limits/session-token-limit-approve.eval.tsdeleted file mode 100644index 7ea914006..000000000--- a/e2e/fixtures/agent-session-limits/evals/limits/session-token-limit-approve.eval.ts+++ /dev/null@@ -1,108 +0,0 @@-import { defineEval } from "eve/evals";-import { equals, satisfies } from "eve/evals/expect";--/**- * Approving a session token-limit continuation over HTTP while messages queue- * behind an active model turn.- */-export default defineEval({- tags: ["real-model"],- description:- "Messages queued during an active turn preserve one limit prompt, and approve resets the budget.",- timeoutMs: 90_000,- async test(t) {- const conversation = await t.session();- const active = await conversation.start(- 'Call the `hold-open` tool exactly once with marker "limit-race". When the tool returns, reply with exactly "approved".',- );- await active.waitForEvent("actions.requested");-- const deliverWhileActive = async (message: string): Promise<void> => {- const response = await t.target.fetch(- `/eve/v1/session/${encodeURIComponent(active.sessionId)}`,- {- body: JSON.stringify({ message, turnPolicy: "queue" }),- headers: { "content-type": "application/json" },- method: "POST",- },- );- if (!response.ok) {- throw new Error(`Concurrent delivery failed (${String(response.status)}).`);- }- };-- await deliverWhileActive('Queued message A: preserve the original reply "approved".');- await deliverWhileActive('Queued message B: preserve the original reply "approved".');-- const prompted = await active.result();- prompted.event("input.requested", { count: 1 });- const request = conversation.requireInputRequest({- display: "confirmation",- optionIds: ["continue", "stop"],- toolName: "session_limit_continuation",- });-- const activeState = conversation.state;- if (activeState === undefined) {- throw new Error("The active eval session did not expose client state.");- }- // These requests have the same local-dev auth, so they can batch while- // the session-limit prompt remains pending.- const queuedSession = t.target.watchTurn(active.sessionId, {- startIndex: activeState.streamIndex,- });- const queued = await queuedSession.result();- queued.event("message.received", { count: 1 });- queued.notEvent("input.requested");- queued.eventsSatisfy(- "coalesces messages A and B in order while preserving the pending prompt",- (events) => {- const received = events.find((event) => event.type === "message.received");- if (received === undefined) return false;- const messageAIndex = received.data.message.indexOf("Queued message A");- const messageBIndex = received.data.message.indexOf("Queued message B");- return messageAIndex !== -1 && messageBIndex > messageAIndex;- },- );- t.check(- [...prompted.events, ...queued.events].filter((event) => event.type === "input.requested")- .length,- equals(1),- );-- const resumed = await queuedSession.session.respond([- {- optionId: "continue",- requestId: request.requestId,- },- ]);- resumed.expectOk();- resumed.event("step.started");- resumed.notEvent("input.requested");- resumed.messageIncludes("approved");- t.check(resumed.sessionId, equals(active.sessionId));- t.check(queuedSession.session.sessionId, equals(active.sessionId));-- const nextPrompt = await queuedSession.session.send(- 'Post-approval probe: reply with exactly "same session".',- );- nextPrompt.event("input.requested", { count: 1 });- nextPrompt.notEvent("message.completed");- t.check(nextPrompt.sessionId, equals(active.sessionId));- t.check(nextPrompt.status, equals("waiting"));- t.check(queuedSession.session.sessionId, equals(active.sessionId));-- const nextRequest = queuedSession.session.requireInputRequest({- display: "confirmation",- optionIds: ["continue", "stop"],- toolName: "session_limit_continuation",- });- t.check(- nextRequest.requestId,- satisfies(- (requestId: string) => requestId !== request.requestId,- "the next token window creates a distinct continuation request",- ),- );- },-});diff --git a/packages/eve/src/cli/dev/tui/blocks.test.ts b/packages/eve/src/cli/dev/tui/blocks.test.tsindex 3cc06d791..5df9397ee 100644--- a/packages/eve/src/cli/dev/tui/blocks.test.ts+++ b/packages/eve/src/cli/dev/tui/blocks.test.ts@@ -265,7 +265,7 @@ describe("renderBlockLines", () => {it("writes a task's start and end as single lines", () => {const agent = { kind: "task", taskKind: "agent", title: "researcher", live: false } as const;expect(render({ ...agent, subtitle: "Find the Q3 revenue numbers" })).toEqual([- " ※ researcher Find the Q3 revenue numbers",+ " ▪ researcher Find the Q3 revenue numbers",]);expect(render({ ...agent, status: "done", body: "finished in 1min 12s · Read 3 files" }),diff --git a/packages/eve/src/cli/dev/tui/blocks.ts b/packages/eve/src/cli/dev/tui/blocks.tsindex 73339fccd..71523b6c9 100644--- a/packages/eve/src/cli/dev/tui/blocks.ts+++ b/packages/eve/src/cli/dev/tui/blocks.ts@@ -16,7 +16,7 @@ import type { TaskKind } from "./task-activity.js";import type { Theme } from "./theme.js";import type { ToolGroupPresentation } from "./tool-presentation.js";import { isPromptControlCommand } from "./prompt-commands.js";-import { renderTool } from "./tool-rows.js";+import { renderTool, renderToolHeader } from "./tool-rows.js";import { truncate } from "./tool-format.js";import { elisionText, TOOL_COLUMN_LEAD } from "./rail.js";import {@@ -549,7 +549,12 @@ function renderTurnStats(block: Block, width: number, theme: Theme): string[] {* as it ends. Each is written once; what the task does in between lives in* the task panel above the prompt.*/-function renderTask(block: Block, width: number, theme: Theme): string[] {+function renderTask(block: DisplayBlock, width: number, theme: Theme): string[] {+ if (block.status === undefined) {+ return [+ ` ${renderToolHeader(block.title ?? "task", block.subtitle ?? "", theme.colors.gray(theme.glyph.square), width - 1, theme)}`,+ ];+ }const c = theme.colors;const { mark, detail, color } = taskLineStyle(block, theme);const head = `${TOOL_COLUMN_LEAD}${mark} ${c.bold(truncate(block.title ?? "task", width - 4))}`;diff --git a/packages/eve/src/cli/dev/tui/flow-drawer.ts b/packages/eve/src/cli/dev/tui/flow-drawer.tsindex d5907b5cd..3edf11b36 100644--- a/packages/eve/src/cli/dev/tui/flow-drawer.ts+++ b/packages/eve/src/cli/dev/tui/flow-drawer.ts@@ -28,9 +28,11 @@ export function renderTransientDrawer(theme: Theme,width: number,corner?: string,+ compact = false,+ labelSide: "left" | "right" = "right",): FlowDrawer {return {- rows: frameDrawer(body, theme, width, corner),+ rows: frameDrawer(body, theme, width, corner, compact, labelSide),controls: controls.map((control) => ` ${theme.colors.dim(control)}`),};}@@ -40,19 +42,21 @@ function frameDrawer(theme: Theme,width: number,corner?: string,+ compact = false,+ labelSide: "left" | "right" = "right",): string[] {const divider = theme.colors.dim(theme.glyph.dash.repeat(Math.max(1, width)));return [- corner === undefined ? divider : labeledRule(corner, theme, width),- "",+ corner === undefined ? divider : labeledRule(corner, theme, width, labelSide),+ ...(compact ? [] : [""]),...body,- "",+ ...(compact ? [] : [""]),divider,];}/** Ends the label two cells from the edge, mirroring the body's two-space indent. */-function labeledRule(label: string, theme: Theme, width: number): string {+function labeledRule(label: string, theme: Theme, width: number, side: "left" | "right"): string {const dash = theme.glyph.dash;// Two dashes lead, two trail, and a space pads each side of the label.const room = width - 6;@@ -62,5 +66,9 @@ function labeledRule(label: string, theme: Theme, width: number): string {? label: `${sliceVisible(label, room - visibleLength(theme.glyph.ellipsis))}${theme.glyph.ellipsis}`;const lead = width - visibleLength(text) - 4;- return theme.colors.dim(`${dash.repeat(lead)} ${text} ${dash.repeat(2)}`);+ return theme.colors.dim(+ side === "left"+ ? `${dash.repeat(2)} ${text} ${dash.repeat(lead)}`+ : `${dash.repeat(lead)} ${text} ${dash.repeat(2)}`,+ );}diff --git a/packages/eve/src/cli/dev/tui/task-activity.test.ts b/packages/eve/src/cli/dev/tui/task-activity.test.tsnew file mode 100644index 000000000..11c809e71--- /dev/null+++ b/packages/eve/src/cli/dev/tui/task-activity.test.ts@@ -0,0 +1,127 @@+import { describe, expect, it } from "vitest";+import { stripAnsi, visibleLength } from "#cli/ui/terminal-text.js";+import { renderTaskPanelRows, type TaskEntry } from "./task-activity.js";+import { createTheme } from "./theme.js";++const theme = createTheme({ color: false, unicode: true });+const task = (name: string, children: readonly TaskEntry[] = []): TaskEntry => ({+ callId: name,+ kind: "agent",+ name,+ toolName: name,+ input: {},+ label: undefined,+ purpose: "Find Alice's notes",+ startedAtMs: 0,+ childTools: new Map(),+ children,+});+const render = (entries: readonly TaskEntry[], width = 80, maxRows = 11) =>+ renderTaskPanelRows(entries, { width, maxRows, theme, nowMs: 12_000 }).map(stripAnsi);++describe("live task panel", () => {+ it("labels subagents, groups their activity, and flattens deeper ownership paths", () => {+ const rows = render([task("researcher", [task("analyst", [task("download")])])]);+ expect(rows[0]).toMatch(/^── Working · 3 tasks ─+$/);+ expect(visibleLength(rows[0]!)).toBe(80);+ expect(rows.slice(2, -2)).toEqual([+ " subagent(researcher) 12s",+ " └ subagent(analyst) 12s",+ " └ subagent(analyst) → subagent(download) 12s",+ ]);+ expect(rows.at(-1)).toBe("─".repeat(80));+ expect(rows.join("\n")).not.toContain("Find Alice's notes");+ });++ it("bounds fan-out and keeps nested approvals visible ahead of ordinary work", () => {+ const approval = task("reviewer");+ approval.childTools.set("approve", {+ kind: "tool",+ title: "run command",+ status: "approval",+ live: false,+ });+ const rows = render(+ [+ task("researcher", [task("download"), task("index")]),+ task("writer"),+ task("supervisor", [approval]),+ ],+ 80,+ 7,+ );+ expect(rows).toHaveLength(7);+ expect(rows.join("\n")).toContain("Needs your approval: run command");+ expect(rows.at(-2)).toBe("");+ expect(rows.at(-3)).toContain("5 more working");+ expect(rows.join("\n")).not.toContain("download ·");+ });++ it("keeps ownership when a hidden parent shares a name with an unrelated visible task", () => {+ const child = task("child");+ child.childTools.set("approval", {+ kind: "tool",+ title: "read",+ status: "approval",+ live: false,+ });+ const unrelated = { ...task("same"), callId: "unrelated" };+ const parent = { ...task("same", [child]), callId: "owner" };+ const rows = render([unrelated, parent], 100, 9).join("\n");+ expect(rows).toContain("└ subagent(same) → subagent(child)");+ });++ it("reports truncated work and attention instead of silently counting only projected entries", () => {+ const entry = { ...task("researcher"), omittedTasks: 32, omittedAttention: true };+ const rows = render([entry], 100, 7).join("\n");+ expect(rows).toContain("33+ tasks");+ expect(rows).toContain("at least 32 more working · Approval needed");+ });++ it("puts parent state and turn time in the header with breathing room around tasks", () => {+ const rows = renderTaskPanelRows([task("self-modification__agent")], {+ width: 80,+ maxRows: 6,+ theme,+ nowMs: 12_000,+ activity: "Waiting",+ turnElapsedMs: 16_000,+ }).map(stripAnsi);+ expect(rows).toHaveLength(5);+ expect(rows[0]).toMatch(/^── Waiting · 1 task · 16s ─+$/);+ expect(rows[1]).toBe("");+ expect(rows[2]).toBe(" agent editor 12s");+ expect(rows.slice(-2)).toEqual(["", "─".repeat(80)]);+ expect(rows.join("\n")).not.toContain("Waiting for");+ });++ it("retains the last command between calls instead of flashing Starting over it", () => {+ const entry = task("researcher");+ entry.childTools.set("read", {+ kind: "tool",+ title: "Read notes.md",+ status: "running",+ live: false,+ });+ expect(render([entry]).join("\n")).toContain("⎿ Read notes.md");+ entry.childTools.set("read", {+ kind: "tool",+ title: "Read notes.md",+ status: "done",+ live: false,+ });+ const settled = render([entry]).join("\n");+ expect(settled).toContain("subagent(researcher) 12s");+ expect(settled).toContain("⎿ Read notes.md");+ expect(settled).not.toContain("Starting");+ });++ it("fits narrow terminals and small row budgets without retaining an empty panel", () => {+ expect(render([])).toEqual([]);+ for (const width of [1, 12, 28]) {+ const rows = render([task("a-long-task-name", [task("nested")])], width, 2);+ expect(rows.length).toBeLessThanOrEqual(2);+ expect(rows.every((row) => visibleLength(row) <= width)).toBe(true);+ }+ });+});diff --git a/packages/eve/src/cli/dev/tui/task-activity.ts b/packages/eve/src/cli/dev/tui/task-activity.tsindex 9dde0ac24..1b5c85b36 100644--- a/packages/eve/src/cli/dev/tui/task-activity.ts+++ b/packages/eve/src/cli/dev/tui/task-activity.ts@@ -2,14 +2,15 @@* The tasks a turn has working: agents and tools that keep running while the* turn goes on. The transcript only ever grows at its end, so a task writes* one line when it starts and one when it ends; what it is doing in between- * lives here and renders in the fixed task panel above the prompt, the one- * region that redraws in place.+ * lives here in the activity drawer above the prompt, keeping live updates+ * out of immutable terminal scrollback.*/import type { Block } from "./blocks.js";+import { agentTaskLabel } from "./tool-presentation.js";import type { Theme } from "./theme.js";import { formatTurnDuration } from "./stream-format.js";-import { TOOL_COLUMN_LEAD } from "./rail.js";+import { renderTransientDrawer } from "./flow-drawer.js";import { truncate } from "./tool-format.js";import { isSelfModificationAgent } from "./tool-presentation.js";import { clipVisible, visibleLength } from "#cli/ui/terminal-text.js";@@ -25,6 +26,10 @@ export interface TaskEntry {readonly input: unknown;readonly label: string | undefined;readonly startedAtMs: number;+ readonly purpose?: string;+ readonly children?: readonly TaskEntry[];+ readonly omittedTasks?: number;+ readonly omittedAttention?: boolean;/** An agent's latest words or thinking, one line. */step?: string;/** Settled, waiting only for the agent's own last events. */@@ -33,8 +38,8 @@ export interface TaskEntry {readonly childTools: Map<string, Block>;}-/** The panel shows this many tasks; the rest collapse into one counted row. */-const maxPanelRows = 4;+/** Includes the heading and overflow summary, regardless of nesting. */+const maxPanelRows = 15;export class TaskActivity {readonly #entries = new Map<string, TaskEntry>();@@ -81,12 +86,12 @@ export class TaskActivity {this.#entries.clear();}- /** Parallel calls to one agent read `researcher`, `researcher #2`, …; a name is never renamed. */+ /** Parallel calls to one agent read `researcher`, `researcher:2`, …; a name is never renamed. */#uniqueName(baseName: string): string {const taken = new Set([...this.#entries.values()].map((entry) => entry.name));if (!taken.has(baseName)) return baseName;for (let ordinal = 2; ; ordinal += 1) {- const candidate = `${baseName} #${String(ordinal)}`;+ const candidate = `${baseName}:${String(ordinal)}`;if (!taken.has(candidate)) return candidate;}}@@ -97,7 +102,7 @@ export function waitingLabel(entries: readonly TaskEntry[]): string {if (entries.length === 1 && isSelfModificationAgent(entries[0]!.toolName)) {return "Modifying your agent";}- const names = entries.map((entry) => entry.name);+ const names = entries.map(taskLabel);if (names.length === 1) return `Waiting for ${names[0]!}`;if (names.length === 2) return `Waiting for ${names[0]!} and ${names[1]!}`;return `Waiting for ${String(names.length)} tasks`;@@ -121,51 +126,93 @@ function currentActivity(entry: TaskEntry): { text: string; attention: boolean }}const running = tools.findLast((tool) => tool.status === "running");if (running !== undefined) return { text: running.title ?? "Working", attention: false };+ const latest = tools.at(-1);+ if (latest?.title !== undefined) return { text: latest.title, attention: false };if (entry.step !== undefined) return { text: entry.step, attention: false };- return { text: entry.kind === "agent" ? "Starting" : "Working", attention: false };+ return { text: "", attention: false };+}++/** Stable ownership order, with only one visible level of indentation. */+function taskLabel(entry: TaskEntry): string {+ if (entry.kind !== "agent") return entry.name;+ return agentTaskLabel(entry.name);+}++function panelEntries(+ entries: readonly TaskEntry[],+): Array<{ entry: TaskEntry; path: TaskEntry[] }> {+ const rows: Array<{ entry: TaskEntry; path: TaskEntry[] }> = [];+ const visit = (tasks: readonly TaskEntry[], path: TaskEntry[]): void => {+ for (const entry of tasks) {+ rows.push({ entry, path });+ visit(entry.children ?? [], [...path, entry]);+ }+ };+ visit(entries, []);+ return rows;}-/**- * One row per working task — mark, name, current activity, elapsed time —- * capped so a wide fan-out cannot push the prompt off screen.- */export function renderTaskPanelRows(entries: readonly TaskEntry[],options: {readonly width: number;readonly theme: Theme;readonly nowMs: number;- readonly pulse: string;+ readonly activity?: string;+ readonly turnElapsedMs?: number;+ readonly maxRows?: number;},): string[] {+ if (entries.length === 0) return [];const { width, theme, nowMs } = options;const c = theme.colors;- const shown = entries.length > maxPanelRows ? entries.slice(0, maxPanelRows - 1) : entries;- const nameWidth = Math.min(24, Math.max(...shown.map((entry) => visibleLength(entry.name)), 0));- const rows = shown.map((entry) => {- const mark =- options.pulse.trim().length > 0- ? c.orange(theme.glyph.subagent)- : c.dim(theme.glyph.subagent);- const name = truncate(entry.name, nameWidth);- const padded = name + " ".repeat(Math.max(0, nameWidth - visibleLength(name)));+ const tasks = panelEntries(entries);+ const omitted = tasks.reduce((count, { entry }) => count + (entry.omittedTasks ?? 0), 0);+ const omittedAttention = tasks.some(({ entry }) => entry.omittedAttention);+ const total = tasks.length + omitted;+ const budget = Math.max(2, Math.min(maxPanelRows, options.maxRows ?? maxPanelRows));+ const padded = budget >= 5;+ const contentBudget = Math.max(0, budget - (padded ? 4 : 2));+ const overflow = omitted > 0 || tasks.length * 2 > contentBudget;+ const capacity = Math.max(0, Math.floor((contentBudget - (overflow ? 1 : 0)) / 2));+ // Approval requests must not disappear behind a busy branch's overflow summary.+ const attention = tasks.filter(({ entry }) => currentActivity(entry).attention);+ const selected = new Set(+ [...attention, ...tasks.filter((task) => !attention.includes(task))].slice(0, capacity),+ );+ const shown = tasks.filter((task) => selected.has(task));+ const rows: string[] = [];+ for (const { entry, path } of shown) {+ const nested = path.length > 0;+ const lead = ` ${nested ? `${theme.glyph.corner} ` : ""}`;+ const parentShown = shown.some((task) => task.entry === path.at(-1));+ const owners = parentShown ? path.slice(1) : path;+ const ownership =+ owners.length > 0+ ? `${owners.map(taskLabel).join(` ${theme.glyph.arrow} `)} ${theme.glyph.arrow} `+ : "";const elapsed = formatTurnDuration(nowMs - entry.startedAtMs);- const lead = `${TOOL_COLUMN_LEAD}${mark} ${padded} `;- const budget = width - visibleLength(lead) - elapsed.length - 2;- const activity = currentActivity(entry);- const text = budget >= 4 ? truncate(activity.text, budget) : "";- const color = activity.attention ? c.yellow : c.dim;- const gap = Math.max(1, width - visibleLength(lead) - visibleLength(text) - elapsed.length);- return clipVisible(`${lead}${color(text)}${" ".repeat(gap)}${c.dim(elapsed)}`, width);- });- const hidden = entries.length - shown.length;- if (hidden > 0) {rows.push(- clipVisible(- `${TOOL_COLUMN_LEAD}${c.dim(`${theme.glyph.ellipsis} ${String(hidden)} more working`)}`,- width,- ),+ clipVisible(`${lead}${c.bold(`${ownership}${taskLabel(entry)}`)} ${c.dim(elapsed)}`, width),);+ const activity = currentActivity(entry);+ const detailLead = ` ${nested ? " " : ""}${theme.glyph.elbow} `;+ const text = truncate(activity.text, Math.max(0, width - visibleLength(detailLead)));+ const color = activity.attention ? c.yellow : c.dim;+ if (text.length > 0) rows.push(clipVisible(`${detailLead}${color(text)}`, width));}- return rows;+ const hidden = total - shown.length;+ if (hidden > 0 && rows.length < contentBudget) {+ const summary = `${theme.glyph.ellipsis} ${omitted > 0 ? "at least " : ""}${hidden} more working${omittedAttention ? " · Approval needed" : ""}`;+ rows.push(clipVisible(` ${omittedAttention ? c.yellow(summary) : c.dim(summary)}`, width));+ }+ return renderTransientDrawer(+ rows,+ [],+ theme,+ width,+ `${options.activity ?? "Working"} ${theme.glyph.dot} ${total}${omitted > 0 ? "+" : ""} ${total === 1 ? "task" : "tasks"}${options.turnElapsedMs === undefined ? "" : ` ${theme.glyph.dot} ${formatTurnDuration(options.turnElapsedMs)}`}`,+ !padded,+ "left",+ ).rows;}diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.test.tsindex 90fd4333b..4d43f1040 100644--- a/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.test.ts@@ -1844,8 +1844,8 @@ describe("TerminalRenderer (inline scrollback)", () => {});const snapshot = screen.snapshot();- expect(snapshot).toContain("\n\n─");- expect(snapshot).toContain("Approve random_color?");+ expect(snapshot).toMatch(/^─+\n\n Approve random_color\?/);+ expect(snapshot).toMatch(/No\n\n─+\n y yes/);const yes = snapshot.split("\n").find((row) => row.includes("Yes"));expect(yes).toBe(" Yes");expect(snapshot).toContain("No");@@ -1876,7 +1876,7 @@ describe("TerminalRenderer (inline scrollback)", () => {});expect(screen.snapshot()).toMatch(- /─ subagent\(number_picker:13\) · 2 of 10 ──\n\n\s+Approve random_number\?/,+ /^── subagent\(number_picker:13\) · 2 of 10 ─+\n\n\s+Approve random_number\?/,);input.enter();await expect(approval).resolves.toEqual({ approved: true });@@ -3800,9 +3800,12 @@ describe("TerminalRenderer conversation", () => {let sequence = 0;const stamped = (event: UnstampedMessageStreamEvent) => stampTestEvent(event, ++sequence);- it("writes a task's start and end lines and shows it in the panel while it works", async () => {- const { screen, renderer } = makeRenderer(100, 30);- const prompt = readPrompt(renderer);+ it("keeps live tasks above approval with a shared divider and state in the header", async () => {+ const { screen, input, renderer } = makeRenderer(100, 30);+ const initialPrompt = readPrompt(renderer);+ input.type("Pick a number for Alice.");+ input.enter();+ await initialPrompt;const call = {callId: "pick_1",kind: "agent" as const,@@ -3842,11 +3845,34 @@ describe("TerminalRenderer conversation", () => {];renderer.renderConversation(conversationOf(working, { working: true }));const during = screen.snapshot();- expect(during).toContain("※ number_picker Pick a number for Alice.");- expect(during).toMatch(/※ number_picker +Starting/);- expect(during).toContain("Waiting for number_picker");+ expect(during).toContain("▪ Delegate subagent(number_picker) Pick a number for Alice.");+ expect(during).toMatch(/── Waiting · 1 task · \S+ ─+\n\n subagent\(number_picker\) \S+/);+ expect(during).toMatch(/subagent\(number_picker\) \S+\n\n─+\n❯/);+ expect(during).not.toContain("Starting");+ expect(countOccurrences(during, "Pick a number for Alice.")).toBe(1);+ expect(during).not.toContain("Waiting for");+ expect(during).not.toContain("↑");+ expect(during).not.toContain("↓");expect(during).not.toContain("task_wait");+ const approval = renderer.readToolApproval({+ approvalId: "approval_1",+ toolCallId: "child_tool",+ toolName: "wait_random_number",+ input: {},+ });+ expect(screen.snapshot()).toContain("Approve wait_random_number?");+ expect(screen.snapshot()).toMatch(/── Waiting · 1 task/);+ expect(screen.snapshot()).toMatch(+ /subagent\(number_picker\) \S+\n\n─+\n\n Approve wait_random_number\?/,+ );+ expect(countOccurrences(screen.snapshot(), " subagent(number_picker)")).toBe(1);+ input.enter();+ await expect(approval).resolves.toEqual({ approved: true });+ expect(screen.snapshot()).toContain("Waiting · 1 task");+ const prompt = readPrompt(renderer);+ expect(screen.snapshot()).toMatch(/subagent\(number_picker\) \S+\n\n─+\n❯/);+renderer.renderConversation(conversationOf([@@ -3857,8 +3883,8 @@ describe("TerminalRenderer conversation", () => {),);const after = screen.snapshot();- expect(after).toMatch(/✓ number_picker +finished in/);- expect(after).not.toMatch(/※ number_picker +Starting/);+ expect(after).toMatch(/✓ subagent\(number_picker\) +finished in/);+ expect(after).not.toContain("Waiting · 1 task");renderer.requestInterrupt();await prompt.catch(() => {});});diff --git a/packages/eve/src/cli/dev/tui/terminal-renderer.ts b/packages/eve/src/cli/dev/tui/terminal-renderer.tsindex e56e46b1b..8dd53aceb 100644--- a/packages/eve/src/cli/dev/tui/terminal-renderer.ts+++ b/packages/eve/src/cli/dev/tui/terminal-renderer.ts@@ -1127,6 +1127,8 @@ export class TerminalRenderer implements AgentTUIRenderer {this.#theme,width,this.#inputContextLabel(request.context),+ false,+ "left",);this.#paint();@@ -1233,6 +1235,8 @@ export class TerminalRenderer implements AgentTUIRenderer {this.#theme,width,this.#inputContextLabel(question.context),+ false,+ "left",);const textPanel = (width: number) => {@@ -1256,6 +1260,8 @@ export class TerminalRenderer implements AgentTUIRenderer {this.#theme,width,this.#inputContextLabel(question.context),+ false,+ "left",);};@@ -3145,17 +3151,20 @@ export class TerminalRenderer implements AgentTUIRenderer {this.#taskEndGraceTimer = undefined;}- #taskPanelRows(width: number): string[] {- const working = this.#transcript.tasks;- if (working.length === 0) return [];- return renderTaskPanelRows(working, {+ #taskPanelRows(width: number, maxRows = Math.max(8, Math.floor(this.#height() / 2))): string[] {+ const tasks = this.#transcript.tasks;+ if (tasks.length === 0) return [];+ const working = this.#view?.working === true && this.#flowlessStatus === undefined;+ const now = Date.now();+ const activity =+ working && this.#view !== undefined ? turnActivity(this.#view, tasks) : "Working";+ return renderTaskPanelRows(tasks, {width,theme: this.#theme,- nowMs: Date.now(),- pulse: this.#progressPulseGlyph(- this.#activityPulseStartedAtMs,- this.#theme.unicode ? PROGRESS_PULSE_GLYPH : PROGRESS_PULSE_ASCII_GLYPH,- ),+ nowMs: now,+ maxRows,+ activity: activity.startsWith("Waiting for ") ? "Waiting" : activity,+ turnElapsedMs: working ? Math.max(0, now - (this.#turnClock.startedAtMs ?? now)) : undefined,});}@@ -3539,11 +3548,12 @@ export class TerminalRenderer implements AgentTUIRenderer {return [...drawer.rows, ...drawer.controls];}- // The HITL drawer opens one row below the transcript, then owns the- // footer down to its controls with no status line beneath it.+ // The request keeps priority; activity uses the remaining height and shares its top rule.if (this.#hitlDrawer !== undefined) {const drawer = this.#hitlDrawer(width);- return [...rows, ...drawer.rows, ...drawer.controls];+ const available = this.#height() - drawer.rows.length - drawer.controls.length - 1;+ const activity = available >= 4 ? this.#taskPanelRows(width, available + 1) : [];+ return [...activity.slice(0, -1), ...drawer.rows, ...drawer.controls];}const flow = this.#setupFlow;@@ -3628,10 +3638,10 @@ export class TerminalRenderer implements AgentTUIRenderer {// The task panel is the one region that redraws in place while tasks// work, so it sits in the footer rather than the transcript.+ const working = this.#view?.working === true && this.#flowlessStatus === undefined;const taskRows = this.#taskPanelRows(width);if (taskRows.length > 0) {rows.push(...taskRows);- if (this.#inputActive) rows.push("");}// Messages typed while the agent starts wait in a panel directly above@@ -3645,9 +3655,8 @@ export class TerminalRenderer implements AgentTUIRenderer {// While work runs, the one live turn bar rides above the composer. The// `Done in … (↑ … ↓ …)` coda is this bar's settled form.- const working = this.#view?.working === true && this.#flowlessStatus === undefined;if (working) {- rows.push(this.#streamingTurnBar(width));+ if (taskRows.length === 0) rows.push(this.#streamingTurnBar(width));if (this.#cancelRequested) {rows.push(clip(@@ -3656,7 +3665,7 @@ export class TerminalRenderer implements AgentTUIRenderer {),);}- rows.push("");+ if (taskRows.length === 0 || this.#cancelRequested) rows.push("");}if (this.#inputActive) {@@ -3720,7 +3729,7 @@ export class TerminalRenderer implements AgentTUIRenderer {// The composer is closed while a command or other surface runs. A kept// draft stays visible so keys typed in this gap have somewhere to land.if (working || this.#draft.text.length > 0) {- this.#pushDraftPrompt(rows, width, { inert: working });+ this.#pushDraftPrompt(rows, width, { inert: working, adjacent: taskRows.length > 0 });this.#pushStatusLine(rows, width);return rows;}@@ -3767,8 +3776,12 @@ export class TerminalRenderer implements AgentTUIRenderer {}/** The kept draft as a prompt row, inert while work runs without the composer. */- #pushDraftPrompt(rows: string[], width: number, options: { inert: boolean }): void {- if (rows.at(-1) !== "") rows.push("");+ #pushDraftPrompt(+ rows: string[],+ width: number,+ options: { inert: boolean; adjacent?: boolean },+ ): void {+ if (!options.adjacent && rows.at(-1) !== "") rows.push("");const prompt: Parameters<typeof promptInputRows>[0] = {text: this.#draft.text,cursor: this.#draft.cursor,diff --git a/packages/eve/src/cli/dev/tui/tool-presentation.test.ts b/packages/eve/src/cli/dev/tui/tool-presentation.test.tsindex f15d52738..23b8c5672 100644--- a/packages/eve/src/cli/dev/tui/tool-presentation.test.ts+++ b/packages/eve/src/cli/dev/tui/tool-presentation.test.ts@@ -210,14 +210,21 @@ describe("presentTool", () => {{ message: "Look up GOOG.\nDetails…" },{ isSubagent: true },);- expect(parsed.title).toBe("Delegate stock-price");- expect(parsed.doneTitle).toBe("Delegated stock-price");+ expect(parsed.title).toBe("Delegate subagent(stock-price)");+ expect(parsed.doneTitle).toBe("Delegated subagent(stock-price)");expect(parsed.subtitle).toBe("Look up GOOG.");// The tool's name carries the target, so it shows before args parse.expect(presentPreparingTool("stock-price", { isSubagent: true }).title).toBe(- "Delegate stock-price …",+ "Delegate subagent(stock-price) …",);+ const selfModification = presentTool(+ "self-modification__agent",+ { message: "Edit Alice's agent" },+ { isSubagent: true },+ );+ expect(selfModification.title).toBe("Delegate agent editor");+ expect(selfModification.doneTitle).toBe("Delegated agent editor");// Without roster knowledge the generic formatter keeps its shape.expect(presentTool("stock-price", { message: "x" }).title).toBe("stock-price");});diff --git a/packages/eve/src/cli/dev/tui/tool-presentation.ts b/packages/eve/src/cli/dev/tui/tool-presentation.tsindex fd38677d5..be3cb9e13 100644--- a/packages/eve/src/cli/dev/tui/tool-presentation.ts+++ b/packages/eve/src/cli/dev/tui/tool-presentation.ts@@ -234,7 +234,9 @@ export function presentTool(// Named subagent dispatch: the tool name is the delegation target; the// message rides as the quiet subtitle. The row is transient — the// task's start line replaces it once the call becomes a task.- const name = agentDisplayName(toolName);+ const name = isSelfModificationAgent(toolName)+ ? agentDisplayName(toolName)+ : agentTaskLabel(agentDisplayName(toolName));return {title: `${DELEGATE_VERB} ${name}`,doneTitle: `Delegated ${name}`,@@ -311,6 +313,14 @@ export function isSelfModificationAgent(toolName: string): boolean {}/** The name an agent task goes by in the delegate row, task line, and task panel. */+export function agentTaskLabel(name: string): string {+ const readable = name+ .replace(/^self-modification__agent(?=:\d+$|$)/u, "agent editor")+ .replace(/__agent(?=:\d+$|$)/u, "");+ return readable === "subagent" || readable.startsWith("agent editor")+ ? readable+ : `subagent(${readable})`;+}export function agentDisplayName(toolName: string): string {const baseName = toolBaseName(toolName);return AGENT_DISPLAY_NAMES.get(baseName) ?? baseName;@@ -334,7 +344,7 @@ export function presentPreparingTool(// A named subagent's tool carries the delegation target in its name —// showable before the message finishes streaming.return {- title: `${DELEGATE_VERB} ${agentDisplayName(toolName)} …`,+ title: `${DELEGATE_VERB} ${agentTaskLabel(agentDisplayName(toolName))} …`,subtitle: "",summarizeResult: () => undefined,};diff --git a/packages/eve/src/cli/dev/tui/tool-rows.ts b/packages/eve/src/cli/dev/tui/tool-rows.tsindex 2c43d87d1..e8b97c282 100644--- a/packages/eve/src/cli/dev/tui/tool-rows.ts+++ b/packages/eve/src/cli/dev/tui/tool-rows.ts@@ -41,18 +41,7 @@ function renderToolRows(block.status === "done" && block.doneTitle !== undefined? block.doneTitle: (block.title ?? "tool");- // The header is indented one cell so its glyph shares a column with the- // `│`/`└` rail beneath it.- const headerWidth = width - 3;- const namePlain = clipVisible(name, headerWidth);- let header = ` ${icon} ${boldLeadingWord(namePlain, theme)}`;- const argsBudget = headerWidth - namePlain.length - 2;- const args = block.subtitle ?? "";- if (args.length > 0 && argsBudget >= 6) {- header += ` ${theme.colors.gray(truncate(args, argsBudget))}`;- }-- const rows = [header];+ const rows = [renderToolHeader(name, block.subtitle ?? "", icon, width, theme)];// Detail region: `│`-railed rows closed by a `└` corner. Group items and// write bodies share the rail so every accumulating tool reads the same.@@ -81,6 +70,23 @@ function renderToolRows(return rows;}+export function renderToolHeader(+ name: string,+ args: string,+ icon: string,+ width: number,+ theme: Theme,+): string {+ const headerWidth = Math.max(0, width - 3);+ const namePlain = clipVisible(name, headerWidth);+ let header = ` ${icon} ${boldLeadingWord(namePlain, theme)}`;+ const argsBudget = headerWidth - visibleLength(namePlain) - 2;+ if (args.length > 0 && argsBudget >= 6) {+ header += ` ${theme.colors.gray(truncate(args, argsBudget))}`;+ }+ return clipVisible(header, width);+}+/*** Only the verb carries the header's weight: `Ran find /workspace …` reads* as a bold action with its argument dimmed behind it, not one long banner.diff --git a/packages/eve/src/cli/dev/tui/transcript-parts.ts b/packages/eve/src/cli/dev/tui/transcript-parts.tsindex f83fe0b58..3518b3b5a 100644--- a/packages/eve/src/cli/dev/tui/transcript-parts.ts+++ b/packages/eve/src/cli/dev/tui/transcript-parts.ts@@ -1,5 +1,7 @@/** Pure pieces of the transcript projection: tool rows, task lines, and agent steps. */+import { agentToolSession } from "#client/conversation-state.js";+import type { TaskEntry } from "./task-activity.js";import type {ConversationState,ConversationTaskCall,@@ -17,6 +19,8 @@ import { formatTurnDuration } from "./stream-format.js";import { isTerminalToolCallPart } from "./terminal-tool-part.js";import { summarizeChildTools } from "./tool-block-groups.js";import {+ agentDisplayName,+ agentTaskLabel,presentPreparingTool,presentTool,type ToolPresentationContext,@@ -36,11 +40,96 @@ export interface TaskRecord {readonly toolName: string;readonly input: unknown;readonly label: string | undefined;+ readonly purpose?: string;readonly startedAtMs: number;settledAtMs?: number;ended: boolean;}+export interface AgentActivity {+ tools: Block[];+ rows: Block[];+ children?: TaskEntry[];+ omittedTasks?: number;+ omittedAttention?: boolean;+ step?: string;+ pending: boolean;+}++export function taskNeedsApproval(+ conversation: ConversationState,+ task: ConversationTask,+): boolean {+ if (+ Object.values(conversation.inputs).some(+ (input) =>+ input.taskId === task.taskId &&+ input.status === "open" &&+ input.request.kind === "tool-approval",+ )+ )+ return true;+ const agent = agentToolSession(conversation, task);+ const child =+ agent?.observation.status === "not-followed" ? undefined : agent?.observation.conversation;+ return (+ child !== undefined &&+ Object.values(child.inputs).some(+ (input) => input.status === "open" && input.request.kind === "tool-approval",+ )+ );+}++export function uniqueTaskName(baseName: string, records: Iterable<TaskRecord>): string {+ const taken = new Set(+ [...records].filter((record) => !record.ended).map((record) => record.name),+ );+ if (!taken.has(baseName)) return baseName;+ for (let ordinal = 2; ; ordinal += 1) {+ const candidate = `${baseName}:${ordinal}`;+ if (!taken.has(candidate)) return candidate;+ }+}++export function startLine(record: TaskRecord): Block {+ const presentation = presentTool(record.toolName, record.input, {+ ...labelContext(record.label),+ isSubagent: record.kind === "agent",+ });+ return {+ kind: "task",+ taskKind: record.kind,+ title: record.kind === "agent" ? `Delegate ${agentTaskLabel(record.name)}` : record.name,+ subtitle: stripTerminalControls(presentation.subtitle),+ live: false,+ };+}++export function nestedTaskRecord(+ callId: string,+ part: EveDynamicToolPart,+ task: ConversationTask,+ block: Block,+): TaskRecord {+ return {+ callId,+ kind: task.kind,+ name:+ task.kind === "agent"+ ? agentDisplayName(stripTerminalControls(part.toolName))+ : stripTerminalControls(part.toolName),+ toolName: part.toolName,+ input: part.input,+ label: undefined,+ purpose:+ task.kind === "agent"+ ? agentTaskSummary(part.input)+ : block.subtitle || (block.title === part.toolName ? undefined : block.title),+ startedAtMs: Date.now(),+ ended: false,+ };+}+export function toolState(part: EveDynamicToolPart,conversation: ConversationState,@@ -136,7 +225,7 @@ export function endLine(id: `task:${record.callId}:end`,kind: "task",taskKind: record.kind,- title: record.name,+ title: record.kind === "agent" ? agentTaskLabel(record.name) : record.name,live: false,};switch (call.status) {diff --git a/packages/eve/src/cli/dev/tui/transcript.test.ts b/packages/eve/src/cli/dev/tui/transcript.test.tsindex f5c36364f..c0977031b 100644--- a/packages/eve/src/cli/dev/tui/transcript.test.ts+++ b/packages/eve/src/cli/dev/tui/transcript.test.ts@@ -316,11 +316,11 @@ describe("ConversationTranscript", () => {id: "task:call_1:start",kind: "task",taskKind: "agent",- title: "summarize",+ title: "Delegate subagent(summarize)",live: false,}),]);- expect(turnActivity(working, transcript.tasks)).toBe("Waiting for summarize");+ expect(turnActivity(working, transcript.tasks)).toBe("Waiting for subagent(summarize)");// A root approval in the same step ends the turn while the task keeps working.expect(transcript.project(view(state, false), options)).toHaveLength(1);expect(transcript.tasks.map((task) => task.name)).toEqual(["summarize"]);@@ -358,7 +358,7 @@ describe("ConversationTranscript", () => {]);const transcript = new ConversationTranscript();expect(summarize(transcript.project(view(called, true), options))).toEqual([- ["task", "research", undefined],+ ["task", "Delegate subagent(research)", undefined],["subagent-step", "research", "Bob's notes found."],]);expect(transcript.tasks[0]).toMatchObject({ name: "research", step: "Bob's notes found." });@@ -376,10 +376,10 @@ describe("ConversationTranscript", () => {reported,);expect(summarize(transcript.project(view(ended, true), options))).toEqual([- ["task", "research", undefined],+ ["task", "Delegate subagent(research)", undefined],["subagent-step", "research", "Bob's notes found."],["assistant", undefined, "Bob found his notes."],- ["task", "research", "finished in 1min 12s"],+ ["task", "subagent(research)", "finished in 1min 12s"],]);expect(transcript.tasks).toEqual([]);@@ -410,13 +410,166 @@ describe("ConversationTranscript", () => {ended,);expect(summarize(transcript.project(view(continued, true), options)).slice(3)).toEqual([- ["task", "research", "finished in 1min 12s"],- ["task", "research", undefined],+ ["task", "subagent(research)", "finished in 1min 12s"],+ ["task", "Delegate subagent(research)", undefined],["subagent-step", "research", "Bob's summary is attached."],- ["task", "research", "failed · The agent's session ended."],+ ["task", "subagent(research)", "failed · The agent's session ended."],]);});+ it("follows nested background work without duplicating it as the owning agent's activity", () => {+ vi.useFakeTimers({ now: 0 });+ onTestFinished(() => void vi.useRealTimers());+ const started = conversation([+ turn,+ toolCall("call_1", "research"),+ taskStarted("call_1", "research"),+ agentStarted("call_1"),+ { type: "client.agent.following", data: { sessionId: "child_1" } },+ ...observe([+ createTurnStartedEvent({ sequence: 0, turnId: "child_turn" }),+ createMessageReceivedEvent({+ message: "Find Alice's notes",+ sequence: 0,+ turnId: "child_turn",+ }),+ createActionsRequestedEvent({+ actions: [+ {+ callId: "download",+ toolName: "download",+ kind: "tool-call",+ input: { file: "notes.md" },+ },+ ],+ sequence: 1,+ stepIndex: 0,+ turnId: "child_turn",+ }),+ createTaskStartedEvent({+ callId: "download",+ taskId: "download_task",+ name: "download",+ kind: "tool",+ turnId: "child_turn",+ }),+ ]),+ ]);+ const transcript = new ConversationTranscript();+ transcript.project(view(started, true), options);+ expect(transcript.tasks[0]).toMatchObject({+ name: "research",+ children: [{ name: "download", kind: "tool", startedAtMs: 0 }],+ });+ expect(transcript.tasks[0]!.childTools.size).toBe(0);+ vi.setSystemTime(12_000);+ transcript.project(view(started, true), options);+ expect(transcript.tasks[0]!.children![0]!.startedAtMs).toBe(0);+ const finished = conversation(+ observe([+ createTaskSettledEvent({+ callId: "download",+ taskId: "download_task",+ turnId: "child_turn",+ status: "completed",+ output: "saved",+ }),+ ]),+ started,+ );+ transcript.project(view(finished, true), options);+ expect(transcript.tasks[0]!.children).toEqual([]);+ expect([...transcript.tasks[0]!.childTools.values()]).toEqual([+ expect.objectContaining({ status: "done" }),+ ]);+ transcript.project(view(started, true), { ...options, tools: "hidden" });+ expect(transcript.tasks[0]!.children).toEqual([]);+ });++ it("shares one nested projection budget across roots and reports omitted work", () => {+ const root = conversation([+ turn,+ toolCall("call_1", "research"),+ taskStarted("call_1", "research"),+ agentStarted("call_1"),+ toolCall("call_2", "review"),+ taskStarted("call_2", "review", "task_2"),+ event(+ createAgentStartedEvent({+ callId: "call_2",+ name: "review",+ parentSessionId: "session_1",+ sessionId: "child_2",+ taskId: "task_2",+ turnId: "turn_1",+ }),+ ),+ ]);+ const child = conversation([+ turn,+ event(+ createMessageReceivedEvent({+ message: "Process Alice's files",+ sequence: 0,+ turnId: "turn_1",+ }),+ ),+ ...Array.from({ length: 80 }, (_, i) => [+ toolCall(`call_${i}`, "download"),+ event(+ createTaskStartedEvent({+ callId: `call_${i}`,+ taskId: `task_${i}`,+ kind: "tool",+ name: "download",+ turnId: "turn_1",+ }),+ ),+ ]).flat(),+ ]);+ const withApproval = conversation(+ [+ event(+ createInputRequestedEvent({+ requests: [+ {+ requestId: "approve_download",+ kind: "tool-approval",+ prompt: "Approve download?",+ action: { callId: "call_79", toolName: "download", input: {}, kind: "tool-call" },+ },+ ],+ turnId: "turn_1",+ sequence: 2,+ stepIndex: 0,+ }),+ ),+ ],+ child,+ );+ const observed = {+ ...withApproval,+ inputs: {+ ...withApproval.inputs,+ approve_download: { ...withApproval.inputs.approve_download!, taskId: "task_79" },+ },+ };+ const state: ConversationState = {+ ...root,+ agents: Object.fromEntries(+ Object.entries(root.agents).map(([id, agent]) => [+ id,+ { ...agent, observation: { status: "following", conversation: observed } },+ ]),+ ),+ };+ const transcript = new ConversationTranscript();+ transcript.project(view(state, true), options);+ expect(transcript.tasks.map((task) => task.children?.length)).toEqual([80, 48]);+ expect(transcript.tasks.map((task) => task.omittedTasks)).toEqual([0, 32]);+ expect(transcript.tasks[1]!.omittedAttention).toBe(true);+ });+it("names parallel calls apart, stops tasks a cancelled turn leaves working, and hides hidden ones", () => {const state = conversation([turn,@@ -426,10 +579,14 @@ describe("ConversationTranscript", () => {taskStarted("call_2", "research", "task_2"),]);const transcript = new ConversationTranscript();- transcript.project(view(state, true), options);- expect(transcript.tasks.map((task) => task.name)).toEqual(["research", "research #2"]);+ const starts = transcript.project(view(state, true), options);+ expect(starts.map((block) => block.title)).toEqual([+ "Delegate subagent(research)",+ "Delegate subagent(research:2)",+ ]);+ expect(transcript.tasks.map((task) => task.name)).toEqual(["research", "research:2"]);// An input request names the task that asked as its lines do.- expect(transcript.taskLabel(state, "task_2")).toBe("research #2");+ expect(transcript.taskLabel(state, "task_2")).toBe("subagent(research:2)");const cancelled = conversation([event(createTurnCancelledEvent({ sequence: 3, turnId: "turn_1" }))],@@ -439,8 +596,8 @@ describe("ConversationTranscript", () => {.project(view(cancelled, false), options).filter((block) => block.id?.endsWith(":end"));expect(ends.map((block) => [block.title, block.status, block.body])).toEqual([- ["research", "denied", "stopped"],- ["research #2", "denied", "stopped"],+ ["subagent(research)", "denied", "stopped"],+ ["subagent(research:2)", "denied", "stopped"],]);expect(transcript.tasks).toEqual([]);diff --git a/packages/eve/src/cli/dev/tui/transcript.ts b/packages/eve/src/cli/dev/tui/transcript.tsindex e392ae09b..828726b30 100644--- a/packages/eve/src/cli/dev/tui/transcript.ts+++ b/packages/eve/src/cli/dev/tui/transcript.ts@@ -22,6 +22,7 @@ import { signInLabel, waitingLabel, type TaskEntry } from "./task-activity.js";import { isTerminalToolCallPart } from "./terminal-tool-part.js";import {agentDisplayName,+ agentTaskLabel,isPanelRoutedTool,presentTool,readWriteFileInput,@@ -30,6 +31,9 @@ import {} from "./tool-presentation.js";import {activeToolSteps,+ taskNeedsApproval,+ uniqueTaskName,+ type AgentActivity,agentTaskSummary,authorizationTerminalMessage,childToolCallIds,@@ -39,6 +43,8 @@ import {isActive,isToolCallRow,labelContext,+ nestedTaskRecord,+ startLine,subagentSteps,taskCallsById,toolBlock,@@ -97,6 +103,7 @@ export class ConversationTranscript {#optimistic = new Map<string, string>();readonly #confirmed = new Set<string>();readonly #tasks = new Map<string, TaskRecord>();+ readonly #nestedTasks = new Map<string, TaskRecord>();#placed: PlacedBlock[] = [];readonly #placedIds = new Set<string>();#working: readonly TaskEntry[] = [];@@ -108,6 +115,7 @@ export class ConversationTranscript {this.#optimistic = new Map();this.#confirmed.clear();this.#tasks.clear();+ this.#nestedTasks.clear();this.#placed = [];this.#placedIds.clear();this.#working = [];@@ -130,9 +138,10 @@ export class ConversationTranscript {const calls = Object.values(task.calls);const call = calls.findLast((candidate) => candidate.status === "working") ?? calls.at(-1);const record = call === undefined ? undefined : this.#tasks.get(call.callId);- if (record !== undefined) return record.name;+ if (record !== undefined)+ return record.kind === "agent" ? agentTaskLabel(record.name) : record.name;return task.kind === "agent"- ? agentDisplayName(stripTerminalControls(task.name))+ ? agentTaskLabel(agentDisplayName(stripTerminalControls(task.name))): stripTerminalControls(task.name);}@@ -270,35 +279,17 @@ export class ConversationTranscript {record = {callId,kind: task.kind,- name: this.#uniqueName(baseName),+ name: uniqueTaskName(baseName, this.#tasks.values()),toolName: part.toolName,input: part.input,label,+ purpose: summary || label,startedAtMs: now,ended: false,};this.#tasks.set(callId, record);}- const { name } = record;- return this.#memoize(`task:${callId}:start`, [name, summary, task.kind], () => ({- kind: "task",- taskKind: task.kind,- title: name,- subtitle: summary,- live: false,- }));- }-- /** Parallel calls to one agent read `researcher`, `researcher #2`, …; a name is never renamed. */- #uniqueName(baseName: string): string {- const taken = new Set(- [...this.#tasks.values()].filter((record) => !record.ended).map((record) => record.name),- );- if (!taken.has(baseName)) return baseName;- for (let ordinal = 2; ; ordinal += 1) {- const candidate = `${baseName} #${String(ordinal)}`;- if (!taken.has(candidate)) return candidate;- }+ return this.#memoize(`task:${callId}:start`, [record], () => startLine(record));}/**@@ -321,12 +312,13 @@ export class ConversationTranscript {lastTurn?.status === "failed");const arrivals: Block[] = [];const entries: TaskEntry[] = [];+ const traversal = { remaining: 128 };for (const record of this.#tasks.values()) {if (record.ended) continue;const taskCall = taskCalls.get(record.callId);if (taskCall === undefined) continue;const { task, call } = taskCall;- const activity = this.#agentActivity(record, task, call, conversation, options);+ const activity = this.#agentActivity(record, task, call, conversation, options, traversal);if (options.subagents === "full") {for (const row of activity.rows) {if (!this.#placedIds.has(row.id!)) arrivals.push(row);@@ -358,6 +350,10 @@ export class ConversationTranscript {toolName: record.toolName,input: record.input,label: record.label,+ purpose: record.purpose,+ children: activity.children,+ omittedTasks: activity.omittedTasks,+ omittedAttention: activity.omittedAttention,startedAtMs: record.startedAtMs,childTools: new Map(activity.tools.map((block) => [block.id!, block])),};@@ -376,7 +372,9 @@ export class ConversationTranscript {call: ConversationTaskCall,conversation: ConversationState,options: TranscriptOptions,- ): { tools: Block[]; rows: Block[]; step?: string; pending: boolean } {+ traversal: { remaining: number },+ depth = 0,+ ): AgentActivity {const agent = task.kind === "agent" ? agentToolSession(conversation, task) : undefined;const child =agent === undefined || agent.observation.status === "not-followed"@@ -396,6 +394,9 @@ export class ConversationTranscript {const childTasks = taskCallsById(child);const ordered: Array<{ order: number; block: Block; settled: boolean }> = [];const tools: Block[] = [];+ const children: TaskEntry[] = [];+ let omittedTasks = 0;+ let omittedAttention = false;let order = 0;for (const message of messages) {for (const part of message.parts) {@@ -417,7 +418,44 @@ export class ConversationTranscript {live: false,};});- tools.push(block);+ const childVisible =+ childTask?.task.kind === "agent"+ ? options.subagents !== "hidden"+ : options.tools !== "hidden";+ if (childTask?.call.status === "working" && childVisible) {+ if (depth >= 8 || traversal.remaining <= 0) {+ omittedTasks += 1;+ omittedAttention ||=+ state.status === "approval" || taskNeedsApproval(child, childTask.task);+ continue;+ }+ traversal.remaining -= 1;+ const key = `${record.callId}/${part.toolCallId}`;+ let nested = this.#nestedTasks.get(key);+ if (nested === undefined) {+ nested = nestedTaskRecord(key, part, childTask.task, block);+ this.#nestedTasks.set(key, nested);+ }+ const activity = this.#agentActivity(+ nested,+ childTask.task,+ childTask.call,+ child,+ options,+ traversal,+ depth + 1,+ );+ children.push({+ ...nested,+ step: activity.step,+ children: activity.children,+ omittedTasks: activity.omittedTasks,+ omittedAttention: activity.omittedAttention,+ childTools: new Map(activity.tools.map((tool) => [tool.id!, tool])),+ });+ } else {+ tools.push(block);+ }ordered.push({ order, block, settled: !isActive(state.status) });}}@@ -444,9 +482,12 @@ export class ConversationTranscript {.sort((left, right) => left.order - right.order).map((row) => row.block);const latest = steps.at(-1);- const result: { tools: Block[]; rows: Block[]; step?: string; pending: boolean } = {+ const result: AgentActivity = {tools,rows,+ children,+ omittedTasks,+ omittedAttention,pending,};if (latest !== undefined) result.step = firstLine(latest.message) ?? "Thinking";diff --git a/packages/eve/test/tui-client/tui-subagents-weather.ts b/packages/eve/test/tui-client/tui-subagents-weather.tsindex b119abb85..0e7f25d09 100644--- a/packages/eve/test/tui-client/tui-subagents-weather.ts+++ b/packages/eve/test/tui-client/tui-subagents-weather.ts@@ -17,7 +17,7 @@ import { theme } from "./lib/theme.ts";* landing under `stepIndex: 0` and collapsing into one box.** Pass conditions:- * 1. A `※ stock-price` start line exists.+ * 1. A `Delegate subagent(stock-price)` start line exists.* 2. The task panel asks for approval of the child's `get_stock_price`* call, and the approval prompt accepts it.* 3. NO parent-level `get_stock_price` tool row exists (proves the@@ -70,7 +70,7 @@ run(WEATHER_SMOKE_TARGET, async (target) => {input.enter();// The task's start line appears once the parent delegates.- await waitForCondition(() => screen.snapshot().includes("※ stock-price"), {+ await waitForCondition(() => screen.snapshot().includes("Delegate subagent(stock-price)"), {timeoutMs: 120_000,label: "task start line",onTimeout: () => screen.snapshot(),@@ -94,7 +94,7 @@ run(WEATHER_SMOKE_TARGET, async (target) => {input.emit("data", Buffer.from("y"));console.log(theme.muted("[tui-weather] approved get_stock_price"));- await waitForCondition(() => screen.snapshot().includes("✓ stock-price"), {+ await waitForCondition(() => screen.snapshot().includes("✓ subagent(stock-price)"), {timeoutMs: 120_000,label: "task end line",onTimeout: () => screen.snapshot(),diff --git a/packages/eve/test/tui-client/tui-subagents.ts b/packages/eve/test/tui-client/tui-subagents.tsindex ed0e3e4e5..c79733780 100644--- a/packages/eve/test/tui-client/tui-subagents.ts+++ b/packages/eve/test/tui-client/tui-subagents.ts@@ -19,8 +19,8 @@ import { theme } from "./lib/theme.ts";* 1. Start the apps/fixtures/agent-tui-client server.* 2. Boot an `EveTUIRunner` with a mock terminal.* 3. Type the same delegation prompt the non-TUI subagent smoke uses.- * 4. Wait for the `※ echo-marker` start line to appear.- * 5. Wait for the `✓ echo-marker` end line once the task settles.+ * 4. Wait for the `Delegate subagent(echo-marker)` start line to appear.+ * 5. Wait for the `✓ subagent(echo-marker)` end line once the task settles.* 6. Verify the parent assistant message contains the token. The* rendering side-channel must not have broken the harness path.*/@@ -53,10 +53,10 @@ run({ app: "agent-tui-client", kind: "local-build" }, async (target) => {);input.enter();- await screen.waitForText("※ echo-marker", 90_000);+ await screen.waitForText("Delegate subagent(echo-marker)", 90_000);console.log(theme.muted("[tui-subagents] task start line appeared"));- await screen.waitForText("✓ echo-marker", 90_000);+ await screen.waitForText("✓ subagent(echo-marker)", 90_000);console.log(theme.muted("[tui-subagents] task end line appeared"));// The verbatim echo must land in a top-level `▲`-prefixed assistant