Compare commits

...
Author SHA1 Message Date
l0ng-ai 49d402e53d fix(vcs): keep commit subjects readable in the Amend chooser 2026-11-23 01:46:04 +08:00
5 changed files with 70 additions and 3 deletions

No files matched your search

+54
View File
@@ -1155,6 +1155,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");
+1
View File
@@ -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,
},
+5 -1
View File
@@ -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));
}
+3
View File
@@ -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;
+7 -2
View File
@@ -22,6 +22,8 @@ import styles from "./Select.module.css";
export interface SelectOption<V extends string = string> {
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<V extends string = string>({
<span className={styles.check} />
{o.tree && <TreeIndent {...o.tree} />}
{o.icon && <Icon name={o.icon} size={14} />}
<span>{labelOf(o)}</span>
<span className={o.emphasized ? styles.emphasized : undefined}>{labelOf(o)}</span>
{o.detail && <span className={styles.sizerDetail}>{detailOf(o)}</span>}
</div>
))}
@@ -315,7 +317,10 @@ export function SelectListbox<V extends string = string>({
<span className={styles.check}>{o.value === value && <Icon name="check" size={12} />}</span>
{o.tree && <TreeIndent {...o.tree} />}
{o.icon && <Icon name={o.icon} size={14} />}
<span className={clsx(styles.optionLabel, detail && styles.withDetail)} title={label}>
<span
className={clsx(styles.optionLabel, detail && styles.withDetail, o.emphasized && styles.emphasized)}
title={label}
>
{highlight(label)}
</span>
{detail && (