工具调用行去掉动词前缀,状态列改为执行中/已执行/失败
Project CI / Repository checks (pull_request) Failing after 13s
Project CI / Backend tests (pull_request) Failing after 12s
Project CI / Frontend tests (pull_request) Failing after 2m14s
Project CI / Native shell tests (pull_request) Failing after 6m15s

- toolCallGroupPresentation:行文案不再拼 已运行/已编辑/已调用 前缀,只留工具摘要(状态由行尾状态列表达,避免重复)
- toolCallGroupPresentation:汇总文案在回合进行中只说数量(如 2 个命令),落定后才加 已执行
- ToolCallGroup:行尾状态固定显示 执行中(仅正在跑的回合)/ 已执行 / 失败,不再出现空状态
This commit is contained in:
2026-09-15 19:52:39 +08:00
parent 0d2010168e
commit 82ac6c160f
2 changed files with 21 additions and 17 deletions
@@ -69,7 +69,7 @@ export function ToolCallGroup({
const orderedCalls = [...calls].sort(
(left, right) => left.startedAt - right.startedAt,
);
const summary = toolCallGroupSummary(orderedCalls);
const summary = toolCallGroupSummary(orderedCalls, running);
const startedAt =
orderedCalls.find((call) => call.startedAt > 0)?.startedAt ?? 0;
// 进行中:用"现在 - 最早开始时间"(会随 tick 每秒变);已结束:用快照里的
@@ -174,15 +174,12 @@ function ToolCallRow({
const durationText = formatToolCallDuration(durationMs);
// "执行中"只在**正在跑的回合**里显示;已结束的回合里残留的 running 快照按已完成处理,
// 否则用户会看到一条永远停在"执行中"的记录。
const statusText = active
? call.status === 'running'
? '执行中'
: call.status === 'failed'
? '失败'
: ''
: call.status === 'failed'
const statusText =
call.status === 'failed'
? '失败'
: '';
: active && call.status === 'running'
? '执行中'
: '已执行';
const rowLabel = [
text,
statusText,
@@ -31,7 +31,7 @@ const TOOL_CALL_KIND_LABELS: Record<GameCreatorDirectToolCallKind, string> = {
};
/** 行文案动词:`已运行 {summary}` / `已编辑 {summary}` / …,`context_compaction` 不带 summary。 */
const TOOL_CALL_ROW_VERBS: Partial<
export const TOOL_CALL_ROW_VERBS: Partial<
Record<GameCreatorDirectToolCallKind, string>
> = {
command: '已运行',
@@ -42,7 +42,10 @@ const TOOL_CALL_ROW_VERBS: Partial<
};
/** 汇总文案:按 kind 计数、固定顺序拼成 `已执行 5 个命令、2 个文件变更`;空集合返回空串。 */
export function toolCallGroupSummary(calls: GameCreatorDirectToolCall[]) {
export function toolCallGroupSummary(
calls: GameCreatorDirectToolCall[],
running = false,
) {
const counts = new Map<string, number>();
for (const call of calls) {
counts.set(call.kind, (counts.get(call.kind) ?? 0) + 1);
@@ -66,17 +69,21 @@ export function toolCallGroupSummary(calls: GameCreatorDirectToolCall[]) {
for (const kind of [...counts.keys()]) {
append(kind);
}
return parts.length > 0 ? `已执行 ${parts.join('、')}` : '';
return parts.length > 0
? running
? parts.join('、')
: `已执行 ${parts.join('、')}`
: '';
}
/** 一行工具的文案:`已运行 npm run build` / `已整理上下文`。 */
/** 一行工具的文案:只用工具本身的摘要(不带"已运行"这类动词前缀),状态由行尾状态列表达。 */
export function toolCallRowText(call: GameCreatorDirectToolCall) {
// 行首不再写"已运行/已编辑"这类动词前缀:命令状态由行尾的状态列表达
// (执行中 / 已执行 / 失败),前缀会和它重复。
if (call.kind === 'context_compaction') {
return '已整理上下文';
return '整理上下文';
}
const summary = toolCallRowSummary(call);
const verb = TOOL_CALL_ROW_VERBS[call.kind] ?? '已执行';
return summary ? `${verb} ${summary}` : verb;
return toolCallRowSummary(call);
}
function toolCallRowSummary(call: GameCreatorDirectToolCall) {