Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai bd7613e149 fix(vcs): show readable commit message history previews 2026-11-23 02:31:15 +08:00
4 змінених файлів з 83 додано та 29 видалено

No files matched your search

+34 -10
Переглянути файл
@@ -1024,27 +1024,51 @@ test("the Commit tool window restores the draft and author options for the inclu
await expect(message).toHaveValue("Default draft");
});
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
test("commit message history shows compact message previews above the editor", async ({ workbench: page }) => {
await page.emulateMedia({ reducedMotion: "reduce" });
await stubRepository(page);
await page.keyboard.press("Meta+k");
const message = page.getByRole("textbox", { name: "Commit message" });
await expect(message).toBeVisible();
await page.evaluate((root) => {
localStorage.setItem(`openidea.vcs.commitMessages:${root}`, JSON.stringify(["Previous commit message"]));
localStorage.setItem(
`openidea.vcs.commitMessages:${root}`,
JSON.stringify([
"Update inventory\n\nReview settlement totals",
"Update inventory\n\nReconcile export records",
...Array.from({ length: 7 }, (_, index) => `Earlier message ${index + 1}`),
]),
);
}, ROOT);
await message.fill("Draft");
await page.getByRole("button", { name: "Commit Message History" }).click();
const history = page.getByRole("button", { name: "Commit Message History" });
await history.click();
const menu = page.getByRole("menu", { name: "Recent commit messages" });
const row = menu.getByRole("menuitem", { name: "Previous commit message" });
const row = menu.getByRole("menuitem", { name: /Update inventory.*Review settlement totals/ });
await expect(row).toBeVisible();
const messageBox = await message.boundingBox();
const menuBox = await menu.locator("..").boundingBox();
expect(messageBox).not.toBeNull();
expect(menuBox).not.toBeNull();
expect(menuBox!.y + menuBox!.height).toBeLessThan(messageBox!.y);
expect(Math.abs(menuBox!.x - messageBox!.x)).toBeLessThan(2);
const messageBox = (await message.boundingBox())!;
const menuBox = (await menu.locator("..").boundingBox())!;
const rowBox = (await row.boundingBox())!;
expect(messageBox.y - menuBox.y - menuBox.height).toBeCloseTo(3, 0);
expect(Math.abs(menuBox.x - messageBox.x)).toBeLessThan(2);
expect(menuBox.height).toBeLessThan(rowBox.height * 8);
await expect(row).toHaveCSS("font-family", await message.evaluate((el) => getComputedStyle(el).fontFamily));
await expect(row).toHaveCSS("font-size", await message.evaluate((el) => getComputedStyle(el).fontSize));
await expect(row.locator("span")).toHaveCount(1);
await row.press("Escape");
await expect(menu).toBeHidden();
await expect(message).toHaveValue("Draft");
await history.click();
await row.press("Home");
await expect(row).toBeFocused();
await page.keyboard.press("ArrowDown");
const second = menu.getByRole("menuitem", { name: /Update inventory.*Reconcile export records/ });
await expect(second).toBeFocused();
await page.keyboard.press("Enter");
await expect(message).toHaveValue("Update inventory\n\nReconcile export records");
await expect(message).toBeFocused();
});
test("Amend shows the original author and warns when the committer differs", async ({ workbench: page }) => {
+16
Переглянути файл
@@ -134,6 +134,22 @@
gap: var(--space-0-5) var(--space-1);
padding: var(--space-0-5) 6px var(--space-0-5) 12px;
}
.messageHistory {
--history-row-height: max(var(--h-list-row), calc(1em + var(--space-2)));
min-width: min(180px, calc(100vw - var(--space-3)));
max-height: calc(7 * var(--history-row-height) + var(--space-2) + 2px);
padding-block: var(--space-1);
overflow-x: hidden;
}
.messageHistory [role="menu"] {
max-width: calc(var(--history-columns) + var(--space-4) + var(--space-2));
font-size: inherit;
}
.messageHistory [role="menuitem"] {
height: var(--history-row-height);
margin-inline: var(--space-1);
padding-inline: var(--space-2);
}
.amendTarget {
min-width: 0;
max-width: 112px;
+32 -19
Переглянути файл
@@ -29,7 +29,8 @@ import {
EmptyState,
Icon,
IconButton,
Menu,
MenuList,
Popup,
Spinner,
SplitGroup,
SplitHandle,
@@ -1374,7 +1375,6 @@ export function CommitMessageField({
const amend = useCommit((s) => s.amend);
const focusTick = useCommit((s) => s.focusTick);
const ref = useRef<HTMLTextAreaElement>(null);
const barRef = useRef<HTMLDivElement>(null);
const [historyOpen, setHistoryOpen] = useState(false);
const historyTick = useCommit((s) => s.historyTick);
const { emptyError } = runner;
@@ -1393,6 +1393,11 @@ export function CommitMessageField({
const cfg = useWorkflowSettings((s) => s.vcs.commit);
const editor = useProject((s) => s.settings?.editor);
const { family, size } = resolveMonoFont(undefined, editor);
const messageFont = {
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
};
const first = message.split("\n")[0] ?? "";
const tooLong = cfg.limitSubject && first.length > cfg.subjectLimit;
const problems = messageProblems(message, cfg).filter((p) => !p.startsWith("Subject line"));
@@ -1402,7 +1407,7 @@ export function CommitMessageField({
return (
<>
<div ref={barRef} className={styles.commitBar}>
<div className={styles.commitBar}>
<Checkbox checked={amend} onChange={(v) => void setAmend(v)} label="Amend" />
{chooseAmendTarget && amendRoot && <AmendTargetMenu root={amendRoot} />}
<IconButton
@@ -1414,22 +1419,32 @@ export function CommitMessageField({
aria-expanded={historyOpen}
onClick={() => setHistoryOpen((o) => !o)}
/>
<Menu
<Popup
open={historyOpen}
onClose={() => setHistoryOpen(false)}
anchor={barRef}
anchor={ref}
placement="top-start"
iconColumn={false}
aria-label="Recent commit messages"
items={history.map((m, i) => ({
id: `h${i}`,
label: m.split("\n")[0]!.slice(0, 80),
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
offset={3}
role="presentation"
autoFocus={false}
className={styles.messageHistory}
style={{ ...messageFont, ["--history-columns" as string]: `${cfg.subjectLimit}ch` }}
>
<MenuList
onDone={() => setHistoryOpen(false)}
iconColumn={false}
aria-label={tx("Recent commit messages")}
items={history.map((m, i) => ({
id: `h${i}`,
label: m.replace(/\r\n?|\n/g, " ⏎ "),
verbatim: true,
run: () => {
useCommit.setState({ message: m });
ref.current?.focus();
},
}))}
/>
</Popup>
<CommitMessageActions />
<span className={styles.grow} />
{tooLong && (
@@ -1445,9 +1460,7 @@ export function CommitMessageField({
aria-invalid={emptyError || undefined}
style={{
["--guide" as string]: `${margin}ch`,
fontFamily: family,
fontSize: size,
fontWeight: fontWeightOf(editor?.fontWeight, 400),
...messageFont,
lineHeight: editor?.lineHeight ? `${editor.lineHeight}px` : undefined,
}}
value={message}
+1
Переглянути файл
@@ -28,6 +28,7 @@
"The Git operation changed. Review the current changes and try again.": "The Git operation changed. Review the current changes and try again.",
"Git operation has no current commit": "Git operation has no current commit",
"Invalid commit message": "Invalid commit message",
"Recent commit messages": "Recent commit messages",
"Invalid commit message file path": "Invalid commit message file path",
"Review staged changes": "Review staged changes",
"Commit and Continue": "Commit and Continue",