feat(ui): show pending/queued status in toast and background_output

This commit is contained in:
justsisyphus
2026-01-19 10:22:34 +09:00
parent 9710e10aca
commit 92942a562f
3 changed files with 31 additions and 11 deletions

View File

@@ -130,6 +130,18 @@ export class BackgroundManager {
log("[background-agent] Task queued:", { taskId: task.id, key, queueLength: queue.length })
const toastManager = getTaskToastManager()
if (toastManager) {
toastManager.addTask({
id: task.id,
description: input.description,
agent: input.agent,
isBackground: true,
status: "queued",
skills: input.skills,
})
}
// Trigger processing (fire-and-forget)
this.processKey(key)
@@ -227,13 +239,7 @@ export class BackgroundManager {
const toastManager = getTaskToastManager()
if (toastManager) {
toastManager.addTask({
id: task.id,
description: input.description,
agent: input.agent,
isBackground: true,
skills: input.skills,
})
toastManager.updateTask(task.id, "running")
}
log("[background-agent] Calling prompt (fire-and-forget) for launch with:", {

View File

@@ -137,7 +137,8 @@ export class TaskToastManager {
for (const task of queued) {
const bgIcon = task.isBackground ? "⏳" : "⏸️"
const skillsInfo = task.skills?.length ? ` [${task.skills.join(", ")}]` : ""
lines.push(`${bgIcon} ${task.description} (${task.agent})${skillsInfo}`)
const isNew = task.id === newTask.id ? " ← NEW" : ""
lines.push(`${bgIcon} ${task.description} (${task.agent})${skillsInfo} - Queued${isNew}`)
}
}

View File

@@ -128,7 +128,14 @@ function truncateText(text: string, maxLength: number): string {
}
function formatTaskStatus(task: BackgroundTask): string {
const duration = formatDuration(task.startedAt, task.completedAt)
let duration: string
if (task.status === "pending" && task.queuedAt) {
duration = formatDuration(task.queuedAt, undefined)
} else if (task.startedAt) {
duration = formatDuration(task.startedAt, task.completedAt)
} else {
duration = "N/A"
}
const promptPreview = truncateText(task.prompt, 500)
let progressSection = ""
@@ -152,7 +159,11 @@ ${truncated}
}
let statusNote = ""
if (task.status === "running") {
if (task.status === "pending") {
statusNote = `
> **Queued**: Task is waiting for a concurrency slot to become available.`
} else if (task.status === "running") {
statusNote = `
> **Note**: No need to wait explicitly - the system will notify you when this task completes.`
@@ -162,6 +173,8 @@ ${truncated}
> **Failed**: The task encountered an error. Check the last message for details.`
}
const durationLabel = task.status === "pending" ? "Queued for" : "Duration"
return `# Task Status
| Field | Value |
@@ -170,7 +183,7 @@ ${truncated}
| Description | ${task.description} |
| Agent | ${task.agent} |
| Status | **${task.status}** |
| Duration | ${duration} |
| ${durationLabel} | ${duration} |
| Session ID | \`${task.sessionID}\` |${progressSection}
${statusNote}
## Original Prompt