@@ -229,6 +229,142 @@ export function renderHook(
229229
230230 // ─── Tool result — compact data ───────────────────────────────────────────────
231231
232+/**
233+ * Render a compact one-liner status for a tool result inside a subagent tree.
234+ * `indent` is the prefix string (spaces) for the current tree depth.
235+ */
236+function renderToolResultInline(
237+ toolName: string,
238+ result: unknown,
239+ isError: boolean,
240+ indent: string,
241+): void {
242+ if (isError) {
243+ const msg =
244+ typeof result === "string"
245+ ? result
246+ : result instanceof Error
247+ ? result.message
248+ : JSON.stringify(result);
249+ const oneLiner = msg.split("\n")[0] ?? msg;
250+ writeln(`${indent}${G.err} ${c.red(oneLiner)}`);
251+ return;
252+ }
253+
254+ if (toolName === "glob") {
255+ const r = result as { files: string[]; truncated: boolean };
256+ const n = r.files.length;
257+ writeln(
258+ `${indent}${G.info} ${c.dim(n === 0 ? "no matches" : `${n} file${n === 1 ? "" : "s"}${r.truncated ? " (capped)" : ""}`)}`,
259+ );
260+ return;
261+ }
262+
263+ if (toolName === "grep") {
264+ const r = result as { matches: unknown[]; truncated: boolean };
265+ const n = r.matches.length;
266+ writeln(
267+ `${indent}${G.info} ${c.dim(n === 0 ? "no matches" : `${n} match${n === 1 ? "" : "es"}${r.truncated ? " (capped)" : ""}`)}`,
268+ );
269+ return;
270+ }
271+
272+ if (toolName === "read") {
273+ const r = result as { totalLines: number; truncated: boolean };
274+ writeln(
275+ `${indent}${G.info} ${c.dim(`${r.totalLines} lines${r.truncated ? " (truncated)" : ""}`)}`,
276+ );
277+ return;
278+ }
279+
280+ if (toolName === "create") {
281+ const r = result as { path: string; created: boolean };
282+ const verb = r.created ? c.green("created") : c.dim("overwritten");
283+ writeln(`${indent}${G.ok} ${verb} ${r.path}`);
284+ return;
285+ }
286+
287+ if (toolName === "replace" || toolName === "insert") {
288+ const r = result as { path: string; deleted?: boolean };
289+ const verb =
290+ toolName === "insert" ? "inserted" : r.deleted ? "deleted" : "replaced";
291+ writeln(`${indent}${G.ok} ${c.dim(verb)} ${r.path}`);
292+ return;
293+ }
294+
295+ if (toolName === "shell") {
296+ const r = result as {
297+ exitCode: number;
298+ success: boolean;
299+ timedOut: boolean;
300+ };
301+ const badge = r.timedOut
302+ ? c.yellow("timeout")
303+ : r.success
304+ ? c.green(`✔ ${r.exitCode}`)
305+ : c.red(`✖ ${r.exitCode}`);
306+ writeln(`${indent}${badge}`);
307+ return;
308+ }
309+
310+ if (toolName === "subagent") {
311+ const r = result as { inputTokens?: number; outputTokens?: number };
312+ if (r.inputTokens || r.outputTokens) {
313+ writeln(
314+ `${indent}${G.ok} ${c.dim(`↑${r.inputTokens ?? 0} ↓${r.outputTokens ?? 0}`)}`,
315+ );
316+ }
317+ return;
318+ }
319+
320+ if (toolName.startsWith("mcp_")) {
321+ const content = Array.isArray(result) ? result : [result];
322+ const first = (content as Array<{ type?: string; text?: string }>)[0];
323+ if (first?.type === "text" && first.text) {
324+ const oneLiner = first.text.split("\n")[0] ?? "";
325+ if (oneLiner)
326+ writeln(
327+ `${indent}${G.info} ${c.dim(oneLiner.length > 80 ? `${oneLiner.slice(0, 77)}…` : oneLiner)}`,
328+ );
329+ }
330+ return;
331+ }
332+
333+ // Generic: one-line JSON
334+ const text = JSON.stringify(result);
335+ writeln(
336+ `${indent}${G.info} ${c.dim(text.length > 80 ? `${text.slice(0, 77)}…` : text)}`,
337+ );
338+}
339+
340+/** Render a subagent's activity tree, indented under its parent tool-call line. */
341+function renderSubagentActivity(
342+ activity: import("../tools/subagent.ts").SubagentToolEntry[],
343+ indent: string,
344+ maxDepth: number,
345+): void {
346+ for (const entry of activity) {
347+ writeln(`${indent}${toolCallLine(entry.toolName, entry.args)}`);
348+
349+ // For nested subagents, recurse one more level (capped at maxDepth)
350+ if (entry.toolName === "subagent" && maxDepth > 0) {
351+ const nested = entry.result as {
352+ activity?: import("../tools/subagent.ts").SubagentToolEntry[];
353+ };
354+ if (nested?.activity?.length) {
355+ renderSubagentActivity(nested.activity, `${indent} `, maxDepth - 1);
356+ }
357+ }
358+
359+ renderToolResultInline(
360+ entry.toolName,
361+ entry.result,
362+ entry.isError,
363+ `${indent} `,
364+ );
365+ }
366+}
367+
232368 export function renderToolResult(
233369 toolName: string,
234370 result: unknown,
@@ -383,12 +519,13 @@ export function renderToolResult(
383519 }
384520
385521 if (toolName === "subagent") {
386- // subagent result: { result: string, inputTokens, outputTokens }
387- const r = result as {
388- result?: string;
389- inputTokens?: number;
390- outputTokens?: number;
391- };
522+ const r = result as import("../tools/subagent.ts").SubagentOutput;
523+
524+ // Render the tool call tree before showing the result text
525+ if (r.activity?.length) {
526+ renderSubagentActivity(r.activity, " ", 1);
527+ }
528+
392529 if (r.result) {
393530 const lines = r.result.split("\n");
394531 const preview = lines.slice(0, 8);
@@ -397,7 +534,6 @@ export function renderToolResult(
397534 writeln(` ${c.dim(`│ … +${lines.length - 8} lines`)}`);
398535 }
399536 if (r.inputTokens || r.outputTokens) {
400- // TODO: missing total unique context size in tokens
401537 writeln(` ${c.dim(`↑${r.inputTokens ?? 0} ↓${r.outputTokens ?? 0}`)}`);
402538 }
403539 return;
@@ -485,6 +621,7 @@ export async function renderTurn(
485621 if (printPos < printQueue.length) {
486622 process.stdout.write(printQueue[printPos] as string);
487623 printPos++;
624+ // TODO: Tick is too fast, print is almost instant
488625 scheduleTick();
489626 } else {
490627 // Queue fully drained — reclaim memory.