feat(tool-call-sheet): improve MCP tool call display

- Extract key-value pairs from tool arguments and results
- Add Input/Output group headers with visual separation
- Fix Playwright MCP tool calls not being clickable (pass data.input as args)
- Increase default sheet height to 60%
- Add extractKeyValuePairs utility function using Zod

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Mohamed Boudra
2026-01-03 15:23:49 +07:00
co-authored by Claude Opus 4.5
parent 914cebc914
commit 8add1a6620
3 changed files with 178 additions and 39 deletions
@@ -704,3 +704,51 @@ export function extractCommandDetails(...sources: unknown[]): CommandDetails | n
}
return null;
}
// ---- Key-Value Extraction for Generic Tool Results ----
export interface KeyValuePair {
key: string;
value: string;
}
const WrappedOutputSchema = z
.object({ output: z.record(z.unknown()) })
.transform((data) => data.output);
const DirectRecordSchema = z.record(z.unknown());
const ToolResultRecordSchema = z.union([WrappedOutputSchema, DirectRecordSchema]);
function stringifyValue(value: unknown): string {
if (value === null) {
return "null";
}
if (value === undefined) {
return "undefined";
}
if (typeof value === "string") {
return value;
}
if (typeof value === "number" || typeof value === "boolean") {
return String(value);
}
try {
return JSON.stringify(value, null, 2);
} catch {
return String(value);
}
}
export function extractKeyValuePairs(result: unknown): KeyValuePair[] {
const parsed = ToolResultRecordSchema.safeParse(result);
if (!parsed.success) {
return [];
}
const record = parsed.data;
return Object.entries(record).map(([key, value]) => ({
key,
value: stringifyValue(value),
}));
}