diff --git a/e2e/commit.spec.ts b/e2e/commit.spec.ts index 6420942f4..7f53349c7 100644 --- a/e2e/commit.spec.ts +++ b/e2e/commit.spec.ts @@ -1215,6 +1215,60 @@ async function stubEarlierAmend(page: Page) { }); } +test("Amend sizes the chooser for long subjects while keeping the last commit action distinct", async ({ + workbench: page, +}) => { + await stubEarlierAmend(page); + const tip = "Record regional settlement adjustments across the quarterly audit and reconciliation reports"; + const earlier = "Expand the warehouse reconciliation report with monthly ledger and inventory audit totals"; + await page.evaluate( + ({ tip, earlier }) => { + const handlers = window.__ipc.handlers; + const log = handlers.vcs_log!; + handlers.vcs_log = (args) => + (log(args) as { id: string; summary: string; message: string }[]).map((commit) => { + const subject = commit.id === "1111111" ? tip : commit.id === "aaaaaaa" ? earlier : commit.summary; + return { ...commit, summary: subject, message: subject }; + }); + }, + { tip, earlier }, + ); + await page.setViewportSize({ width: 1040, height: 700 }); + await page.keyboard.press("Meta+k"); + const panel = page.getByRole("region", { name: "Commit", exact: true }); + const choose = panel.getByRole("button", { name: "Choose Commit to Amend", exact: true }); + await choose.click(); + const list = page.getByRole("listbox", { name: "Choose Commit to Amend", exact: true }); + const popup = list.locator("xpath=ancestor::*[@data-popup]"); + const search = popup.getByRole("textbox", { name: "Search commits", exact: true }); + const last = list.getByRole("option", { name: /^Amend Last Commit/ }); + const previous = list.getByRole("option", { name: earlier, exact: true }); + + await expect(previous).toBeVisible(); + const wide = (await popup.boundingBox())!; + expect(wide.width).toBeGreaterThan(360); + expect(wide.width).toBeLessThanOrEqual(522); + await expect(last.getByText("Amend Last Commit", { exact: true })).toHaveCSS("font-weight", "600"); + await expect(last.getByText(tip, { exact: true })).toHaveAttribute("title", tip); + await expect(previous.getByText(earlier, { exact: true })).toHaveAttribute("title", earlier); + + await page.setViewportSize({ width: 440, height: 520 }); + await expect + .poll(async () => { + const box = (await popup.boundingBox())!; + return box.x >= 0 && box.x + box.width <= 440 && box.width < wide.width; + }) + .toBe(true); + await expect(search).toBeFocused(); + await search.fill("inventory audit"); + await expect(previous).toBeVisible(); + await search.press("Enter"); + await expect(list).toBeHidden(); + await page.setViewportSize({ width: 1040, height: 700 }); + await page.keyboard.press("Meta+k"); + await expect(panel.getByRole("textbox", { name: "Commit message" })).toHaveValue(earlier); +}); + test("Amend can select an earlier commit before protected history", async ({ workbench: page }) => { await stubEarlierAmend(page); await page.keyboard.press("Meta+k"); diff --git a/src/features/vcs/AmendTargetMenu.tsx b/src/features/vcs/AmendTargetMenu.tsx index b0573a90f..0cd4a6ed1 100644 --- a/src/features/vcs/AmendTargetMenu.tsx +++ b/src/features/vcs/AmendTargetMenu.tsx @@ -42,6 +42,7 @@ export function AmendTargetMenu({ root }: { root: string }) { { value: LAST_COMMIT, label: "Amend Last Commit", + emphasized: true, detail: available?.latest?.summary, verbatimDetail: true, }, diff --git a/src/features/vcs/CommitView.module.css b/src/features/vcs/CommitView.module.css index d440cec71..afe4d408b 100644 --- a/src/features/vcs/CommitView.module.css +++ b/src/features/vcs/CommitView.module.css @@ -143,9 +143,13 @@ text-overflow: ellipsis; } .amendPicker { - width: min(360px, calc(100vw - var(--space-4))); + width: max-content; + min-width: min(280px, calc(100vw - var(--space-4))); padding-block: var(--space-1); } +.amendPicker > * { + max-width: 520px; +} .amendPickerRows { max-height: calc(5 * var(--h-list-row)); } diff --git a/src/ui/Select.module.css b/src/ui/Select.module.css index 202c18549..bff59f332 100644 --- a/src/ui/Select.module.css +++ b/src/ui/Select.module.css @@ -113,6 +113,9 @@ text-overflow: ellipsis; white-space: nowrap; } +.emphasized { + font-weight: 600; +} /* The label keeps its width (up to most of the row); a long detail (a path) is cut instead. */ .withDetail { flex-shrink: 0; diff --git a/src/ui/Select.tsx b/src/ui/Select.tsx index e73c9cf46..c875c32e4 100644 --- a/src/ui/Select.tsx +++ b/src/ui/Select.tsx @@ -22,6 +22,8 @@ import styles from "./Select.module.css"; export interface SelectOption { value: V; label: string; + /** Give the label extra weight in the list. */ + emphasized?: boolean; /** User values are displayed as written. */ verbatim?: boolean; icon?: IconName | (string & {}); @@ -280,7 +282,7 @@ export function SelectListbox({ {o.tree && } {o.icon && } - {labelOf(o)} + {labelOf(o)} {o.detail && {detailOf(o)}} ))} @@ -315,7 +317,10 @@ export function SelectListbox({ {o.value === value && } {o.tree && } {o.icon && } - + {highlight(label)} {detail && (