fix(ui): summarise a chat tool run as one line instead of per-tool counts
This commit is contained in:
1 parent
57202110d4
commit
76ffa4e01c
2 files changed
+9
-7
No files matched your search
@@ -14,20 +14,22 @@ import ChatToolCall from "./ChatToolCall.vue";
|
||||
import type { ChatToolCall as ToolCall } from "./state";
|
||||
|
||||
/**
|
||||
* A run of consecutive tool calls as one counted line, "shell ×12, find ×1",
|
||||
* opened to the individual calls. A failure anywhere in the run opens it.
|
||||
* A run of consecutive tool calls as one line, opened to the individual
|
||||
* calls. A failure anywhere in the run opens it.
|
||||
*/
|
||||
const props = defineProps<{ tools: ToolCall[]; streaming?: boolean }>();
|
||||
|
||||
const toolName = (tool: ToolCall) => tool.name || tool.Name || tool.tool || "tool";
|
||||
const failed = (tool: ToolCall) => Boolean(tool.err || tool.Err || tool.failed);
|
||||
|
||||
const failures = computed(() => props.tools.filter(failed).length);
|
||||
const anyFailed = computed(() => failures.value > 0);
|
||||
const title = computed(() => {
|
||||
const counts = new Map<string, number>();
|
||||
for (const tool of props.tools) counts.set(toolName(tool), (counts.get(toolName(tool)) ?? 0) + 1);
|
||||
return [...counts].map(([name, n]) => `${name} ×${n}`).join(", ");
|
||||
const n = props.tools.length;
|
||||
if (props.streaming) return `Running ${toolName(props.tools[n - 1])}`;
|
||||
const calls = n === 1 ? `Used ${toolName(props.tools[0])}` : `Used ${n} tools`;
|
||||
return failures.value ? `${calls}, ${failures.value} failed` : calls;
|
||||
});
|
||||
const anyFailed = computed(() => props.tools.some(failed));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in new issue
Block a user