Skip to content

Commit 7376804

Browse files
committed
fix(demo/ctx): only apply path-shortening in toolCall when arg is a filesystem path
Made-with: Cursor
1 parent fcf19ae commit 7376804

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

demo/ctx/src/ui.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ export function phase(label: string, sub?: string) {
3939
// ─── Tool call — compact, no full paths ──────────────────────────────────────
4040
export function toolCall(name: string, input: Record<string, string>) {
4141
const arg = input.file_path ?? input.directory ?? Object.values(input)[0] ?? "";
42-
// show only the last 2 path segments to keep it readable
43-
const short = arg.split("/").slice(-2).join("/");
42+
const isPath = arg.startsWith("/") || arg.startsWith("./") || arg.startsWith("../") || /^[a-zA-Z]:[/\\]/.test(arg) || (arg.includes("/") && !/\s/.test(arg));
43+
const display = isPath
44+
? arg.split("/").slice(-2).join("/")
45+
: arg.length > 60 ? `${arg.slice(0, 57)}…` : arg;
4446
const color = name === "write_file" ? `${GR}` : `${D}`;
45-
console.log(` ${color}${name.padEnd(12)}${short}${R}`);
47+
console.log(` ${color}${name.padEnd(12)}${display}${R}`);
4648
}
4749

4850
// ─── File item (dry-run / update list) ───────────────────────────────────────

0 commit comments

Comments
 (0)