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

@ -271,20 +271,27 @@ 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;
// Cache last assistant text output for live preview (capped to keep meta.json small)
for (const part of msg.content) {
if (part.type === "text") {
job.lastPreview = part.text;
previewUpdated = true;
job.lastPreview = part.text.slice(0, 5000);
break;
}
}
// Persist cache to enable live previews after restart
if (previewUpdated) {
this.persist(job);
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: [
"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.",
"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 (
@ -130,13 +130,8 @@ export default function (pi: ExtensionAPI) {
let jobLine =
`- ${j.id} | ${j.agent} | ${j.status}` +
(j.exitCode !== undefined ? ` (exit ${j.exitCode})` : "") +
(j.turns ? ` | ${j.turns} turns` : "");
if (j.preview) {
jobLine += `\n \`\`\`\n${j.preview
.split("\n")
.map((line) => ` ${line}`)
.join("\n")}\n \`\`\``;
}
(j.turns ? ` | ${j.turns} turns` : "") +
(j.preview ? `\n Preview: ${j.preview.slice(0, 120).replace(/\n/g, " ")}${j.preview.length > 120 ? "…" : ""}` : "");
return jobLine;
})
.join("\n")