From 5b99b8b5ab5dbe2a11d16d330cccbb7161467eb4 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Tue, 1 Dec 2026 06:51:40 +0800 Subject: [PATCH] fix(vcs): dim Git log metadata columns only for merge commits (#7119) The User, Date and Hash cells in the Git log always used the muted color, while the subject is only dimmed for merge commits (Highlight > Merge Commits) and for commits outside the cherry-pick selection. The metadata cells now use the same condition, so a row is dimmed as a whole or not at all. My Commits still shows the author in bold. Fixes #7112 --- e2e/gitLogMergeDimming.spec.ts | 90 ++++++++++++++++++++++++++++++ src/features/vcs/log/CommitRow.tsx | 3 +- 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 e2e/gitLogMergeDimming.spec.ts diff --git a/e2e/gitLogMergeDimming.spec.ts b/e2e/gitLogMergeDimming.spec.ts new file mode 100644 index 0000000000..85d8d33060 --- /dev/null +++ b/e2e/gitLogMergeDimming.spec.ts @@ -0,0 +1,90 @@ +/** + * Git log row colors: User, Date and Hash use the normal text color on a regular + * commit, and are dimmed together with the subject on a merge commit. + */ +import { expect, stubDesktop, test } from "./fixtures"; + +test("dims the metadata columns only on merge commits", async ({ workbench: page }) => { + await stubDesktop(page); + await page.evaluate(async () => { + const root = "/dev/acme-api"; + const id = (i: number) => i.toString(16).padStart(40, "0"); + const commit = (i: number, parents: number[], summary: string) => ({ + id: id(i), + shortId: id(i).slice(-8), + parents: parents.map(id), + refs: i === 0 ? ["HEAD", "main"] : [], + author: `Author ${i}`, + email: "author@example.com", + timeMs: 1_700_000_000_000 - i * 60_000, + summary, + message: summary, + }); + const commits = [ + commit(0, [1, 2], "Merge branch 'feature'"), + commit(1, [3], "Regular change"), + commit(2, [3], "Feature change"), + commit(3, [], "Initial"), + ]; + const h = window.__ipc.handlers; + h.vcs_log = ({ query }) => { + const { skip, limit, range } = query as { skip: number; limit: number; range?: string }; + return range ? [] : commits.slice(skip, limit ? skip + limit : undefined); + }; + h.vcs_log_refs = () => ({}); + h.vcs_branches = () => []; + h.vcs_branch_info = () => ({ + head: "main", + headCommit: id(0), + upstream: null, + ahead: 0, + behind: 0, + operation: null, + }); + h.vcs_config_get = () => null; + h.vcs_commit_files = () => []; + h.vcs_log_details_batch = ({ revisions }) => + (revisions as string[]).map(() => ({ + message: "", + containingBranches: [], + signature: "N", + signer: "", + key: "", + fingerprint: "", + })); + const storeModule = "/src/features/vcs/store.ts"; + const { useVcs } = await import(/* @vite-ignore */ storeModule); + useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: true }); + const contextModule = "/src/platform/context.ts"; + const { setContext } = await import(/* @vite-ignore */ contextModule); + setContext("vcsAvailable", true); + const optionsModule = "/src/features/vcs/logOptions.ts"; + const { useLogOptions } = await import(/* @vite-ignore */ optionsModule); + useLogOptions.setState({ showHash: true, highlightMerges: true }); + const actionsModule = "/src/platform/actions.ts"; + const { executeAction } = await import(/* @vite-ignore */ actionsModule); + await executeAction("vcs.showLog"); + }); + const list = page.getByRole("listbox", { name: "Commits" }); + await expect(list.getByRole("option")).toHaveCount(4); + + const colors = (summary: string) => + list + .getByRole("option") + .filter({ hasText: summary }) + .evaluate((row) => { + const color = (el: Element | null) => (el ? getComputedStyle(el).color : null); + const subject = row.querySelector("[class*=subjectText]"); + const author = row.querySelector('[title^="Author "]'); + const hash = [...row.querySelectorAll("span")].find((s) => /^0+[0-9a-f]$/.test(s.textContent ?? "")); + return { subject: color(subject), author: color(author), hash: color(hash ?? null) }; + }); + + const regular = await colors("Regular change"); + const merge = await colors("Merge branch 'feature'"); + expect(regular.author).toBe(regular.subject); + expect(regular.hash).toBe(regular.subject); + expect(merge.author).toBe(merge.subject); + expect(merge.hash).toBe(merge.subject); + expect(merge.author).not.toBe(regular.author); +}); diff --git a/src/features/vcs/log/CommitRow.tsx b/src/features/vcs/log/CommitRow.tsx index 8eab59f076..2424891536 100644 --- a/src/features/vcs/log/CommitRow.tsx +++ b/src/features/vcs/log/CommitRow.tsx @@ -217,7 +217,8 @@ function CommitRowView({ key={cid} className={clsx( styles.columnCell, - styles.muted, + // Dimmed with the subject: merge commits and commits outside the cherry-pick selection. + (merge || outsideUnpicked) && styles.muted, column.id === "author" && mine && styles.mine, column.id === "hash" && styles.hash, )}