From 87986ddf6e23744af942575cbf5b3e4237c0e1f0 Mon Sep 17 00:00:00 2001 From: jay Date: Fri, 15 May 2026 05:11:32 +0200 Subject: [PATCH] feat: render preview in fanout_status output - Include job output preview as indented code block in fanout_status results - Preview text is already available in status().jobs[].preview via controller - Now displayed in the text content output alongside job metadata - Each preview line is indented for readability in markdown code blocks - Useful for quick inspection of job results without calling fanout_collect --- controller.ts | 18 +++++++++++++++++- index.ts | 15 +++++++++++---- types.ts | 2 ++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/controller.ts b/controller.ts index 5a1faef..49e139f 100644 --- a/controller.ts +++ b/controller.ts @@ -245,7 +245,8 @@ export class FanoutController { } private getJobPreview(job: FanoutJob, maxChars = 500): string { - const output = this.readJobOutput(job); + // Use cached preview if available (updated in processOutputLine) + const output = job.lastPreview || this.readJobOutput(job); if (!output) return ""; if (output.length <= maxChars) return output; return output.slice(0, maxChars) + "\n… (truncated)"; @@ -269,6 +270,21 @@ export class FanoutController { if (!job.modelUsed && msg.model) job.modelUsed = msg.model; if (msg.stopReason) job.stopReason = msg.stopReason; if (msg.errorMessage) job.errorMessage = msg.errorMessage; + + // Cache last assistant text output for live preview + let previewUpdated = false; + for (const part of msg.content) { + if (part.type === "text") { + job.lastPreview = part.text; + previewUpdated = true; + break; + } + } + + // Persist cache to enable live previews after restart + if (previewUpdated) { + this.persist(job); + } } } } diff --git a/index.ts b/index.ts index 078a5e0..46fc44f 100644 --- a/index.ts +++ b/index.ts @@ -126,12 +126,19 @@ export default function (pi: ExtensionAPI) { result.jobs.length > 0 ? "\n\n" + result.jobs - .map( - (j) => + .map((j) => { + let jobLine = `- ${j.id} | ${j.agent} | ${j.status}` + (j.exitCode !== undefined ? ` (exit ${j.exitCode})` : "") + - (j.turns ? ` | ${j.turns} turns` : ""), - ) + (j.turns ? ` | ${j.turns} turns` : ""); + if (j.preview) { + jobLine += `\n \`\`\`\n${j.preview + .split("\n") + .map((line) => ` ${line}`) + .join("\n")}\n \`\`\``; + } + return jobLine; + }) .join("\n") : ""; return { diff --git a/types.ts b/types.ts index 733ab4a..fa6bb46 100644 --- a/types.ts +++ b/types.ts @@ -26,6 +26,8 @@ export interface FanoutJob { usage: JobUsage; modelUsed?: string; stopReason?: string; + /** Last assistant text output seen while running (for live previews) */ + lastPreview?: string; } export interface DispatchResult {