fix(coding-agent): avoid invalid footer home abbreviation

closes #4878
This commit is contained in:
Mario Zechner
2026-05-23 09:53:36 +02:00
parent c85dbb1620
commit 2e1f07bac2
3 changed files with 29 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ import { visibleWidth } from "@earendil-works/pi-tui";
import { beforeAll, describe, expect, it } from "vitest";
import type { AgentSession } from "../src/core/agent-session.ts";
import type { ReadonlyFooterDataProvider } from "../src/core/footer-data-provider.ts";
import { FooterComponent } from "../src/modes/interactive/components/footer.ts";
import { FooterComponent, formatCwdForFooter } from "../src/modes/interactive/components/footer.ts";
import { initTheme } from "../src/modes/interactive/theme/theme.ts";
type AssistantUsage = {
@@ -73,6 +73,17 @@ function createFooterData(providerCount: number): ReadonlyFooterDataProvider {
return provider;
}
describe("formatCwdForFooter", () => {
it("does not abbreviate sibling paths that share the home prefix", () => {
expect(formatCwdForFooter("/home/user2", "/home/user")).toBe("/home/user2");
});
it("abbreviates the home directory and descendants", () => {
expect(formatCwdForFooter("/home/user", "/home/user")).toBe("~");
expect(formatCwdForFooter("/home/user/project", "/home/user")).toBe("~/project");
});
});
describe("FooterComponent width handling", () => {
beforeAll(() => {
initTheme(undefined, false);