@zmzai/theme 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zmzai/theme",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "zmzai 全品牌设计系统 — Radix UI + framer-motion + Tailwind v4 + MiSans",
@@ -59,7 +59,8 @@ export function ToolCard({ call, sessionIdle = false }: { call: ToolCall; sessio
59
59
  /**
60
60
  * ToolGroup — 连续工具调用的折叠组(G1 防淹没)。
61
61
  *
62
- * 运行中/有失败/单条时自动展开;多条完成时折叠为一条摘要行。
62
+ * 仅运行中自动展开;失败/单条/历史组一律折叠为一条可点击的摘要行,
63
+ * 避免长会话里"运行了 1 个工具"头 + 展开卡的双倍瀑布。
63
64
  *
64
65
  * @example
65
66
  * <ToolGroup calls={toolCalls} sessionIdle={idle} />
@@ -69,9 +70,17 @@ export function ToolGroup({ calls, sessionIdle = false }: { calls: ToolCall[]; s
69
70
  const running = calls.filter((c) => c.state.status === "running" || c.state.status === "pending");
70
71
  const failed = calls.filter((c) => c.state.status === "error" || (sessionIdle && (c.state.status === "running" || c.state.status === "pending")));
71
72
  const done = calls.filter((c) => c.state.status === "completed");
72
- const autoExpand = running.length > 0 || failed.length > 0 || calls.length <= 1;
73
+ const autoExpand = running.length > 0;
73
74
  const open = expanded || autoExpand;
74
75
  const glyph = failed.length > 0 ? "cross" : running.length > 0 ? "chevron-down" : "check";
76
+ const single = calls.length === 1 ? calls[0] : undefined;
77
+ const singleTitle = single
78
+ ? single.state.status === "completed"
79
+ ? (single.state.title ?? single.tool)
80
+ : single.state.status === "error"
81
+ ? single.state.error
82
+ : single.tool
83
+ : null;
75
84
  const summary = [
76
85
  running.length > 0 && `${running.length} 个进行中`,
77
86
  failed.length > 0 && `${failed.length} 个失败`,
@@ -81,8 +90,8 @@ export function ToolGroup({ calls, sessionIdle = false }: { calls: ToolCall[]; s
81
90
  <div className="zmz-tool-group">
82
91
  <button type="button" className="zmz-tool-group-trigger" aria-expanded={open} onClick={() => setExpanded((value) => !value)} disabled={autoExpand}>
83
92
  <span className="tool-card-glyph" aria-hidden><Icon name={glyph} size={12} /></span>
84
- <span className="zmz-tool-group-label">运行了 {calls.length} 个工具</span>
85
- {!autoExpand && <small>{summary}</small>}
93
+ <span className="zmz-tool-group-label">{single ? singleTitle : `运行了 ${calls.length} 个工具`}</span>
94
+ <small>{single ? (single.state.status === "completed" ? "完成" : single.state.status === "error" ? "失败" : "进行中") : summary}</small>
86
95
  <Icon name="chevron-down" size={12} className={open ? "tool-card-chevron open" : "tool-card-chevron"} />
87
96
  </button>
88
97
  {open && (