From f0cc99a4c74fa4f31620aa2f2d21c8bd1ce67f8c Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 22 Nov 2026 20:34:26 +0800 Subject: [PATCH] fix(vcs): give commit subjects room beside compact refs (#5191) Give Git Log commit subjects room beside long reference labels. Compact References View keeps labels within about a third of the available text column, with the full reference on hover. References in the log use the small UI font and the layout works on either side of the subject. --- e2e/gitLogScrollbar.spec.ts | 4 +- e2e/gitLogToolbarMenus.spec.ts | 51 ++++++++++++++++++++++++++ src/features/vcs/GitLog.module.css | 21 ++++++++++- src/features/vcs/log/CommitMessage.tsx | 2 +- src/features/vcs/log/CommitRow.tsx | 4 +- 5 files changed, 77 insertions(+), 5 deletions(-) diff --git a/e2e/gitLogScrollbar.spec.ts b/e2e/gitLogScrollbar.spec.ts index 4a8b6da11..e70fca87b 100644 --- a/e2e/gitLogScrollbar.spec.ts +++ b/e2e/gitLogScrollbar.spec.ts @@ -117,7 +117,7 @@ test("fits a wide graph and saved columns without horizontal scrolling", async ( expect(await list.evaluate((element) => element.scrollLeft)).toBe(0); }); -test("keeps ref names visible when a long commit subject competes for space", async ({ workbench: page }) => { +test("keeps expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => { const branch = "origin/feature/workspace-settings"; const tag = "v2.1"; const summary = "Keep workspace settings and commit references visible ".repeat(4).trim(); @@ -127,7 +127,7 @@ test("keeps ref names visible when a long commit subject competes for space", as const options = "/src/features/vcs/logOptions.ts"; const { useGitLog } = await import(/* @vite-ignore */ log); const { useLogOptions } = await import(/* @vite-ignore */ options); - useLogOptions.setState({ tagNames: true }); + useLogOptions.setState({ tagNames: true, compactRefs: false }); const [first, ...rest] = useGitLog.getState().commits; useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] }); }, diff --git a/e2e/gitLogToolbarMenus.spec.ts b/e2e/gitLogToolbarMenus.spec.ts index 403dba042..86d7f1a68 100644 --- a/e2e/gitLogToolbarMenus.spec.ts +++ b/e2e/gitLogToolbarMenus.spec.ts @@ -112,6 +112,57 @@ test("Git Log separates commit message typography from compact metadata", async await expect(author).toHaveCSS("font-size", "12px"); }); +test("compact Git Log refs give the subject room on either side", async ({ workbench: page }) => { + await page.setViewportSize({ width: 630, height: 720 }); + const refSubject = "Reconcile shipping credits"; + const longReference = "release-quarterly-settlement-and-backoffice-invoice-reconciliation"; + await page.evaluate( + async ({ refSubject, longReference }) => { + const optionsModule = "/src/features/vcs/logOptions.ts"; + const logModule = "/src/features/vcs/logStore.ts"; + const { setLogOptions } = await import(/* @vite-ignore */ optionsModule); + const { useGitLog } = await import(/* @vite-ignore */ logModule); + setLogOptions({ showBranches: false, showDetails: false }); + const [first, ...rest] = useGitLog.getState().commits; + useGitLog.setState({ + commits: [{ ...first, summary: refSubject, message: refSubject, refs: [longReference] }, ...rest], + }); + }, + { refSubject, longReference }, + ); + const row = page.getByRole("listbox", { name: "Commits" }).getByRole("option").filter({ hasText: refSubject }); + const subject = row.getByText(refSubject, { exact: true }); + const ref = row.getByTitle(longReference, { exact: true }); + const expectLayout = async () => { + await expect + .poll(() => + subject.evaluate((el) => { + const text = document.createRange(); + text.selectNodeContents(el); + return el.getBoundingClientRect().width + 0.02 >= text.getBoundingClientRect().width; + }), + ) + .toBe(true); + await expect + .poll(() => + ref.evaluate((el) => { + const refs = el.parentElement!; + return refs.clientWidth / refs.parentElement!.clientWidth; + }), + ) + .toBeLessThanOrEqual(0.34); + await expect(ref).toHaveCSS("font-size", "12px"); + await expect(subject).toHaveCSS("font-size", "13px"); + }; + await expectLayout(); + await expect.poll(async () => (await subject.boundingBox())!.x < (await ref.boundingBox())!.x).toBe(true); + + await page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "View Options" }).click(); + await page.getByRole("menuitemcheckbox", { name: "References on the Left" }).click(); + await expectLayout(); + await expect.poll(async () => (await subject.boundingBox())!.x > (await ref.boundingBox())!.x).toBe(true); +}); + test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => { const toolbar = page.getByRole("toolbar", { name: "Log filters" }); const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" }); diff --git a/src/features/vcs/GitLog.module.css b/src/features/vcs/GitLog.module.css index ad99eae69..9c8e59f5e 100644 --- a/src/features/vcs/GitLog.module.css +++ b/src/features/vcs/GitLog.module.css @@ -405,9 +405,12 @@ .subject { flex: 0 1 auto; min-width: var(--log-subject-min); + color: var(--fg); +} +.subjectText { + display: block; overflow: hidden; text-overflow: ellipsis; - color: var(--fg); } .headSubject { font-weight: 600; @@ -437,6 +440,22 @@ flex: none; max-width: calc(100% - var(--log-subject-min) - var(--space-1-5)); } +.commitText > .refsCompact { + flex: 0 1 auto; + max-width: calc(100% / 3); +} +.commitText:has(> .refsCompact) > .subject { + /* Protect a short subject while leaving room for compact reference names. */ + flex: 0 1000 max-content; + min-width: auto; + width: min(75%, 24ch); +} +.commitText > .refs .ref { + font-size: var(--fs-small); +} +.refsCompact .ref { + min-width: 11px; +} .refsLeft { margin-left: 0; } diff --git a/src/features/vcs/log/CommitMessage.tsx b/src/features/vcs/log/CommitMessage.tsx index 389b378bd..a177fb942 100644 --- a/src/features/vcs/log/CommitMessage.tsx +++ b/src/features/vcs/log/CommitMessage.tsx @@ -35,7 +35,7 @@ export function RefLabels({ }) { const labels = refLabels(refs, { compact, tagNames }, remoteNames); return ( - + {labels.map((l) => ( {l.text && {l.text}} diff --git a/src/features/vcs/log/CommitRow.tsx b/src/features/vcs/log/CommitRow.tsx index 6d18603cf..91c35aa00 100644 --- a/src/features/vcs/log/CommitRow.tsx +++ b/src/features/vcs/log/CommitRow.tsx @@ -134,7 +134,9 @@ function CommitRowView({ setTooltip(false); }} > - + + + {!opts.refsOnLeft && refs}