From 58a36a15604166d10743840a7a1b02cce9e23cfe Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 15 Aug 2026 14:21:07 -0400 Subject: [PATCH] fix(tui): preserve path suffix in prompt footer (#42800) --- packages/tui/src/component/prompt/index.tsx | 19 +++++++++++++++++-- packages/tui/test/ui/file-path.test.ts | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/tui/src/component/prompt/index.tsx b/packages/tui/src/component/prompt/index.tsx index 770216adc8e..e1481ab74c6 100644 --- a/packages/tui/src/component/prompt/index.tsx +++ b/packages/tui/src/component/prompt/index.tsx @@ -71,6 +71,7 @@ import { DialogImagePreview } from "../dialog-image-preview" import { useDirectoryRecents } from "../../prompt/directory-recents" import { directoryRecentValue } from "../../prompt/directory-completion" import { useWorkingDirectoryActions } from "../../ui/working-directory-actions" +import { truncateFilePath } from "../../ui/file-path" export type PromptProps = { sessionID?: string @@ -1555,6 +1556,12 @@ export function Prompt(props: PromptProps) { const branch = data.location.vcs.info(location)?.branch.current return branch ? `${directory}:${branch}` : directory }) + const [locationWidth, setLocationWidth] = createSignal(dimensions().width) + const locationLabelDisplay = createMemo(() => { + const label = locationLabel() + if (!label) return + return truncateFilePath(label, locationWidth()) + }) const locationActions = useWorkingDirectoryActions({ directory: () => footerLocation()?.directory, onMove: () => void move.open(), @@ -1840,7 +1847,15 @@ export function Prompt(props: PromptProps) { - + setLocationWidth(width)) + }} + > @@ -1877,7 +1892,7 @@ export function Prompt(props: PromptProps) { - }> + }> {(location) => ( { expect(truncateFilePath(path, 19)).toBe("…/dialog-select.tsx") }) + test("preserves the working directory and branch suffix", () => { + expect(truncateFilePath("~/code/experiments/category-theory:main", 30)).toBe("…/experi…/category-theory:main") + }) + test("uses remaining width for part of a long parent segment", () => { const path = "/private/var/folders/run-17f048ec-dbb2-4b36-860c-98637bb51a8d/files" expect(truncateFilePath(path, 40)).toBe("/…/run-17f048ec-dbb2-4b36-860c-98…/files")