From 20862a1f7bf4c3aaba10ec3af53a9eef50fad91d Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Mon, 23 Nov 2026 04:44:22 +0800 Subject: [PATCH] fix(vcs): show file names in staging diff headings --- e2e/stagedEditor.spec.ts | 3 +++ src/features/vcs/StagingDiff.tsx | 8 +++++++ src/features/vcs/ThreePaneDiff.module.css | 23 +++++++++++++++++++ src/features/vcs/ThreePaneDiff.tsx | 27 +++++++++++++++++------ 4 files changed, 54 insertions(+), 7 deletions(-) diff --git a/e2e/stagedEditor.spec.ts b/e2e/stagedEditor.spec.ts index ff8a1691c6..fff7452c5a 100644 --- a/e2e/stagedEditor.spec.ts +++ b/e2e/stagedEditor.spec.ts @@ -102,6 +102,9 @@ test("edits the staged version and keeps an unsaved draft when the index changes await expect(headPane).toContainText("val committed = 0"); await expect(indexPane).toContainText("val external = 3"); await expect(localPane).not.toBeEmpty(); + const indexHeading = page.getByTitle(`Staged (index) ${path}`, { exact: true }); + await expect(indexHeading.getByText("build.gradle.kts", { exact: true })).toBeVisible(); + await expect(indexHeading.getByText("Staged (index)", { exact: true })).toBeVisible(); const working = await localPane.textContent(); await page.getByRole("button", { name: "Unstage Change", exact: true }).click(); diff --git a/src/features/vcs/StagingDiff.tsx b/src/features/vcs/StagingDiff.tsx index 107f3270f0..0a81476473 100644 --- a/src/features/vcs/StagingDiff.tsx +++ b/src/features/vcs/StagingDiff.tsx @@ -187,6 +187,9 @@ export function StagingDiff({ return { ...loaded, index: base, model: compareThreeTexts([head, liveIndex, liveLocal]) }; }, [loaded, local, localText, indexDoc, indexState.base, indexState.text, metadataLoading]); const snapshot = useRangeSnapshot(data.stagingRange, full); + const headSide = snapshot?.head ?? versions?.left ?? data.left; + const headTitlePath = (headSide.type === "rev" && headSide.path) || data.path; + const indexTitlePath = snapshot?.indexPath ?? indexPath ?? data.path; const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const [selected, setSelected] = useState(-1); @@ -557,6 +560,11 @@ export function StagingDiff({ span, +.labelFile { + display: flex; + align-items: center; + gap: var(--space-1); +} +.labelFile { + min-width: 0; + color: var(--fg-strong); +} +.labelFile > svg { + flex: none; +} +.labelFilename { + overflow: hidden; + text-overflow: ellipsis; +} +.versionLabels .versionName { + flex: none; +} .absent { color: var(--fg-subtle); } diff --git a/src/features/vcs/ThreePaneDiff.tsx b/src/features/vcs/ThreePaneDiff.tsx index aec1bddf51..a6cd0dfcda 100644 --- a/src/features/vcs/ThreePaneDiff.tsx +++ b/src/features/vcs/ThreePaneDiff.tsx @@ -4,6 +4,7 @@ import { Decoration, EditorView, gutter } from "@codemirror/view"; import { Chunk } from "@codemirror/merge"; import { diffSideExtensions, embeddedEditorExtensions, remoteChange, type DocumentAttachment } from "@/editor/api"; import { tx } from "@/platform/i18n"; +import { Icon, fileIconName } from "@/ui"; import { documentTooltips, firstLineOf, languageFor, viewerBase } from "./cm"; import { diffDocument, exposeHunkButtons, HunkButtons, type HunkButton } from "./diffControls"; import { ideaDiffConfig } from "./diffOptions"; @@ -11,6 +12,7 @@ import { syncMergeScroll } from "./mergeScroll"; import { diffRangeView, setDiffRange } from "./diffRangeView"; import type { DiffRange } from "./stagingRange"; import type { StagedDocument } from "./stagedDocument"; +import { baseName } from "./model"; import diffStyles from "./DiffEditor.module.css"; import styles from "./ThreePaneDiff.module.css"; @@ -129,6 +131,7 @@ function present( export function ThreePaneDiff({ path, labels, + titlePaths, model, controls, onEditors, @@ -138,6 +141,7 @@ export function ThreePaneDiff({ }: { path: string; labels: ThreePanes; + titlePaths?: ThreePanes; model: ReturnType | null; controls?: (change: ThreePaneChange) => HunkControl[]; onEditors?: (views: ThreePanes | null) => void; @@ -222,13 +226,22 @@ export function ThreePaneDiff({ }, [labels, local, index, path, ready]); return (
-
- {labels.map((label, i) => ( - - {label} - {model?.texts[i] === null && {tx("(does not exist)")}} - - ))} +
+ {labels.map((label, i) => { + const file = titlePaths?.[i]; + return ( + + {file && ( + + + {baseName(file)} + + )} + {label} + {model?.texts[i] === null && {tx("(does not exist)")}} + + ); + })}
{model?.binary ? (
{tx("Binary content")}