feat: render preview in status + auto-delivery note

This commit is contained in:
jay 2026-05-15 05:12:54 +02:00
parent 81e5cb83bc
commit b4df1a49b2
2 changed files with 19 additions and 17 deletions

View File

@ -272,19 +272,26 @@ export class FanoutController {
if (msg.stopReason) job.stopReason = msg.stopReason; if (msg.stopReason) job.stopReason = msg.stopReason;
if (msg.errorMessage) job.errorMessage = msg.errorMessage; if (msg.errorMessage) job.errorMessage = msg.errorMessage;
// Cache last assistant text output for live preview // Cache last assistant text output for live preview (capped to keep meta.json small)
let previewUpdated = false;
for (const part of msg.content) { for (const part of msg.content) {
if (part.type === "text") { if (part.type === "text") {
job.lastPreview = part.text; job.lastPreview = part.text.slice(0, 5000);
previewUpdated = true;
break; break;
} }
} }
this.persist(job);
// Persist cache to enable live previews after restart }
if (previewUpdated) { }
this.persist(job); // Also cache assistant text from tool result events
if (event.type === "tool_result_end" && event.message) {
const msg = event.message as Message;
if (msg.role === "assistant") {
for (const part of msg.content) {
if (part.type === "text") {
job.lastPreview = part.text.slice(0, 5000);
this.persist(job);
break;
}
} }
} }
} }

View File

@ -51,7 +51,7 @@ export default function (pi: ExtensionAPI) {
promptGuidelines: [ promptGuidelines: [
"Use fanout_dispatch to run multiple agents in parallel without blocking the main session.", "Use fanout_dispatch to run multiple agents in parallel without blocking the main session.",
"After dispatching, you may do other work. Check status later with fanout_status.", "After dispatching, you may do other work. Check status later with fanout_status.",
"When jobs complete, the system will send a follow-up message. Retrieve output with fanout_collect.", "Completed jobs deliver their output automatically via follow-up messages. Use fanout_collect if you need the full, untruncated result or to archive old jobs.",
], ],
execute: async ( execute: async (
@ -130,13 +130,8 @@ export default function (pi: ExtensionAPI) {
let jobLine = let jobLine =
`- ${j.id} | ${j.agent} | ${j.status}` + `- ${j.id} | ${j.agent} | ${j.status}` +
(j.exitCode !== undefined ? ` (exit ${j.exitCode})` : "") + (j.exitCode !== undefined ? ` (exit ${j.exitCode})` : "") +
(j.turns ? ` | ${j.turns} turns` : ""); (j.turns ? ` | ${j.turns} turns` : "") +
if (j.preview) { (j.preview ? `\n Preview: ${j.preview.slice(0, 120).replace(/\n/g, " ")}${j.preview.length > 120 ? "…" : ""}` : "");
jobLine += `\n \`\`\`\n${j.preview
.split("\n")
.map((line) => ` ${line}`)
.join("\n")}\n \`\`\``;
}
return jobLine; return jobLine;
}) })
.join("\n") .join("\n")