refactor: centralize home path shortening

This commit is contained in:
Peter Steinberger
2026-01-03 12:42:27 +01:00
parent 1ec3512925
commit 7a80e8fe77
3 changed files with 35 additions and 20 deletions

View File

@@ -1,3 +1,5 @@
import { shortenHomeInString, shortenHomePath } from "../utils.js";
export const TOOL_RESULT_DEBOUNCE_MS = 500;
export const TOOL_RESULT_FLUSH_COUNT = 5;
@@ -23,17 +25,8 @@ function resolveToolEmoji(toolName?: string): string {
return "🧩";
}
function shortenHomeInString(input: string): string {
const home = process.env.HOME;
if (!home) return input;
return input.split(home).join("~");
}
export function shortenPath(p: string): string {
const home = process.env.HOME;
if (home && (p === home || p.startsWith(`${home}/`)))
return p.replace(home, "~");
return p;
return shortenHomePath(p);
}
export function shortenMeta(meta: string): string {