refactor: optimize task handling in message list

This commit is contained in:
Henry Li 2026-02-07 18:42:24 +08:00
parent de8ff9d336
commit 5d4cecbb84
1 changed files with 7 additions and 5 deletions

View File

@ -92,18 +92,20 @@ export function MessageList({
</div> </div>
); );
} else if (group.type === "assistant:subagent") { } else if (group.type === "assistant:subagent") {
const tasks: Subtask[] = []; const tasks = new Set<Subtask>();
for (const message of group.messages) { for (const message of group.messages) {
if (message.type === "ai") { if (message.type === "ai") {
for (const toolCall of message.tool_calls ?? []) { for (const toolCall of message.tool_calls ?? []) {
if (toolCall.name === "task") { if (toolCall.name === "task") {
updateSubtask({ const task: Subtask = {
id: toolCall.id!, id: toolCall.id!,
subagent_type: toolCall.args.subagent_type, subagent_type: toolCall.args.subagent_type,
description: toolCall.args.description, description: toolCall.args.description,
prompt: toolCall.args.prompt, prompt: toolCall.args.prompt,
status: "in_progress", status: "in_progress",
}); };
updateSubtask(task);
tasks.add(task);
} }
} }
} else if (message.type === "tool") { } else if (message.type === "tool") {
@ -152,13 +154,13 @@ export function MessageList({
/>, />,
); );
} }
if (tasks.length > 1) { if (tasks.size > 1) {
results.push( results.push(
<div <div
key="subtask-count" key="subtask-count"
className="text-muted-foreground font-norma pt-2 text-sm" className="text-muted-foreground font-norma pt-2 text-sm"
> >
{t.subtasks.executing(tasks.length)} {t.subtasks.executing(tasks.size)}
</div>, </div>,
); );
} }