refactor: simplify tool call display and path handling

- Remove displayName from tool calls, use name directly with icon
- Add medium font weight for tool call badges
- Strip workspace root from file paths at parsing level using Zod schema
- Add accentBorder to tool call badges and git diff file blocks
- Fix user message alignment and vertical spacing
- Deduplicate stripCwdPrefix into tool-call-parsers.ts

🤖 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-07 12:38:04 +07:00
co-authored by Claude Opus 4.5
parent 4f3b2317ab
commit 66881511b6
18 changed files with 475 additions and 445 deletions
@@ -752,3 +752,41 @@ export function extractKeyValuePairs(result: unknown): KeyValuePair[] {
value: stringifyValue(value),
}));
}
// ---- Principal Parameter Extraction ----
const PrincipalParamSchema = z.union([
z.object({ file_path: z.string() }).transform((d) => ({ type: "path" as const, value: d.file_path })),
z.object({ filePath: z.string() }).transform((d) => ({ type: "path" as const, value: d.filePath })),
z.object({ path: z.string() }).transform((d) => ({ type: "path" as const, value: d.path })),
z.object({ command: z.string() }).transform((d) => ({ type: "text" as const, value: d.command })),
z.object({ pattern: z.string() }).transform((d) => ({ type: "text" as const, value: d.pattern })),
z.object({ query: z.string() }).transform((d) => ({ type: "text" as const, value: d.query })),
z.object({ url: z.string() }).transform((d) => ({ type: "text" as const, value: d.url })),
]);
export function stripCwdPrefix(filePath: string, cwd?: string): string {
if (!cwd || !filePath) return filePath;
const normalizedCwd = cwd.replace(/\\/g, "/").replace(/\/+$/, "");
const normalizedPath = filePath.replace(/\\/g, "/");
const prefix = `${normalizedCwd}/`;
if (normalizedPath.startsWith(prefix)) {
return normalizedPath.slice(prefix.length);
}
if (normalizedPath === normalizedCwd) {
return ".";
}
return filePath;
}
export function extractPrincipalParam(args: unknown, cwd?: string): string | undefined {
const parsed = PrincipalParamSchema.safeParse(args);
if (!parsed.success) {
return undefined;
}
const { type, value } = parsed.data;
return type === "path" ? stripCwdPrefix(value, cwd) : value;
}