diff --git a/src/features/background-agent/manager.ts b/src/features/background-agent/manager.ts index b9a2dd728..2d8a3d832 100644 --- a/src/features/background-agent/manager.ts +++ b/src/features/background-agent/manager.ts @@ -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:", { diff --git a/src/features/task-toast-manager/manager.ts b/src/features/task-toast-manager/manager.ts index d993e9d06..102946d68 100644 --- a/src/features/task-toast-manager/manager.ts +++ b/src/features/task-toast-manager/manager.ts @@ -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}`) } } diff --git a/src/tools/background-task/tools.ts b/src/tools/background-task/tools.ts index 76b048f23..8e7abaa8d 100644 --- a/src/tools/background-task/tools.ts +++ b/src/tools/background-task/tools.ts @@ -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