From abbf1465e2dba31bcd38610283dcddc40fee00ed Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Mon, 14 Sep 2026 15:00:46 +0800 Subject: [PATCH] =?UTF-8?q?GameAgent=20=E5=B7=A5=E5=85=B7=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E5=8D=A1=E7=89=87=EF=BC=9A=E5=9B=9E=E8=AF=BB=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E3=80=81=E6=8A=98=E5=8F=A0=E5=8D=A1=E7=89=87=E4=B8=8E?= =?UTF-8?q?=E6=97=A0=E9=9A=9C=E7=A2=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - app/types.ts:新增 GameCreatorDirectToolCall / Detail / Change 类型,并给 GameCreatorDirectTurnUpdateEvent 增加可选 toolCalls 字段(老事件 undefined 走原路径) - App.tsx:订阅 game-creator-direct-turn-update 时按 id 归并工具调用增量(completed 覆盖 running、startedAt 取最早),打开项目时整表替换为 read_direct_tool_calls 的回读结果 - App.tsx:只把「对话里已有该回合」或「当前正在跑的回合」的工具调用交给面板,避免旧卡片漂尾 - ProjectSupervisorView.tsx:新增 toolCalls / activeTurnId 属性,按回合把卡片插在 **同一回合最后一条 assistant 消息之后**,同回合内按 startedAt 升序;当前回合在 assistant 消息落盘前锚到最后一条 assistant 消息 - ToolCallCard.tsx(新增):Codex 风格可折叠卡片,` ) : null} - {visibleMessages.map((message, index) => ( -
- -
- ))} + {visibleMessages.map((message, index) => { + const anchoredToolCalls = message.messageId + ? (toolCallsByAnchor.get(message.messageId) ?? []) + : []; + return ( + +
+ +
+ {anchoredToolCalls.map((call) => ( + + ))} +
+ ); + })} {designReasoning ? (
显示思考过程 diff --git a/apps/ai-game-creator-shell/src/features/project-workspace/ToolCallCard.tsx b/apps/ai-game-creator-shell/src/features/project-workspace/ToolCallCard.tsx new file mode 100644 index 000000000..7548fd090 --- /dev/null +++ b/apps/ai-game-creator-shell/src/features/project-workspace/ToolCallCard.tsx @@ -0,0 +1,117 @@ +import { + ChevronDown, + FileText, + Globe, + Minimize2, + Terminal, + Wrench, +} from 'lucide-react'; +import { useId, useState } from 'react'; + +import type { GameCreatorDirectToolCall } from '../../app/types'; + +/** + * 工具调用卡片(Codex 风格): + * 折叠态一行摘要,展开态看命令与文件明细。契约见 + * `docs/technical/【技术方案】GameAgent对话工具调用卡片-2026-09-14.md`。 + * + * 无障碍:折叠/展开是一只 ` + + + ); +} + +function toolCallChangeKindLabel(kind: string) { + if (kind === 'add') { + return '新增'; + } + if (kind === 'delete') { + return '删除'; + } + return '修改'; +} + +function ToolCallIcon({ kind }: { kind: string }) { + switch (kind) { + case 'command': + return ; + case 'file_change': + return ; + case 'web_search': + return ; + case 'context_compaction': + return ; + default: + return ; + } +} diff --git a/apps/ai-game-creator-shell/src/styles.css b/apps/ai-game-creator-shell/src/styles.css index 379902e73..9645a4c9a 100644 --- a/apps/ai-game-creator-shell/src/styles.css +++ b/apps/ai-game-creator-shell/src/styles.css @@ -11239,3 +11239,164 @@ button.design-workspace-tree__entry:hover, min-height: 0; flex: 1 1 auto; } + +/* ============================================================ + 工具调用卡片(2026-09):Codex 风格可折叠卡片 + ============================================================ + 契约见 `docs/technical/【技术方案】GameAgent对话工具调用卡片-2026-09-14.md`: + 折叠态一行摘要(图标 / 标题 / 摘要 / 状态点 / 状态 / 折角),展开态看命令、文件明细与输出。 + 折叠由 `