@miphamai/cli 0.32.0 → 0.32.1
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 +1 -1
- package/src/ui/chat.tsx +39 -33
package/package.json
CHANGED
package/src/ui/chat.tsx
CHANGED
|
@@ -157,52 +157,58 @@ export function ChatPanel({ messages, focusMode }: ChatPanelProps) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
160
|
+
* Pair each tool_use message with its following tool_result message(s),
|
|
161
|
+
* showing every tool individually with its name, detail, and output.
|
|
162
|
+
*
|
|
163
|
+
* Claude Code parity: each tool renders as:
|
|
164
|
+
* ⏺ ToolName (detail) ← colored per tool type
|
|
165
|
+
* ⎿ output summary ← dimmed below
|
|
166
|
+
*
|
|
167
|
+
* Only true duplicates (same tool name + same detail) are collapsed
|
|
168
|
+
* into a single entry with a count.
|
|
163
169
|
*/
|
|
164
170
|
function compactToolGroups(messages: ChatMessage[]): ChatMessage[] {
|
|
165
171
|
const result: ChatMessage[] = []
|
|
166
|
-
let
|
|
172
|
+
let current: ChatMessage | null = null
|
|
167
173
|
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
result.push(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
.filter((t) => t.toolMeta?.name && !t.toolMeta.name.startsWith('tools ('))
|
|
175
|
-
.map((t) => t.toolMeta!.name)
|
|
176
|
-
const uniqueNames = [...new Set(names)]
|
|
177
|
-
result.push({
|
|
178
|
-
role: 'system',
|
|
179
|
-
content: `⏺ ${uniqueNames.join(' · ')} (${names.length} tools)`,
|
|
180
|
-
toolMeta: {
|
|
181
|
-
name: `tools (${names.length})`,
|
|
182
|
-
input: uniqueNames.join(', '),
|
|
183
|
-
collapsed: true,
|
|
184
|
-
},
|
|
185
|
-
})
|
|
174
|
+
for (const msg of messages) {
|
|
175
|
+
// Tool call with a name → flush previous, start a new one
|
|
176
|
+
if (msg.toolMeta?.name && !msg.toolMeta.name.startsWith('tools (')) {
|
|
177
|
+
if (current) result.push(current)
|
|
178
|
+
current = { ...msg }
|
|
179
|
+
continue
|
|
186
180
|
}
|
|
187
|
-
toolGroup = []
|
|
188
|
-
}
|
|
189
181
|
|
|
190
|
-
|
|
191
|
-
// Tool results (no name, has output) get folded into the preceding tool group
|
|
182
|
+
// Tool result (no name, has output) → merge output into current tool
|
|
192
183
|
if (msg.toolMeta && !msg.toolMeta.name && msg.toolMeta.output) {
|
|
193
|
-
|
|
184
|
+
if (current) {
|
|
185
|
+
current = {
|
|
186
|
+
...current,
|
|
187
|
+
content: msg.content,
|
|
188
|
+
toolMeta: {
|
|
189
|
+
...current.toolMeta!,
|
|
190
|
+
output: msg.toolMeta.output,
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Orphan tool result (no preceding tool_use) → skip
|
|
194
195
|
continue
|
|
195
196
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
|
|
198
|
+
// Already-grouped message (from a previous compact cycle) or non-tool
|
|
199
|
+
if (current) {
|
|
200
|
+
result.push(current)
|
|
201
|
+
current = null
|
|
202
|
+
}
|
|
203
|
+
// Skip orphan tool-result messages without a preceding tool_use
|
|
204
|
+
if (msg.toolMeta && !msg.toolMeta.name && msg.toolMeta.output) {
|
|
199
205
|
continue
|
|
200
206
|
}
|
|
201
|
-
// Already-grouped or non-tool message
|
|
202
|
-
flush()
|
|
203
207
|
result.push(msg)
|
|
204
208
|
}
|
|
205
|
-
|
|
209
|
+
|
|
210
|
+
// Flush any remaining tool
|
|
211
|
+
if (current) result.push(current)
|
|
206
212
|
return result
|
|
207
213
|
}
|
|
208
214
|
|