diff --git a/e2e/conflictsDialogLayout.spec.ts b/e2e/conflictsDialogLayout.spec.ts new file mode 100644 index 000000000..b583314d7 --- /dev/null +++ b/e2e/conflictsDialogLayout.spec.ts @@ -0,0 +1,51 @@ +import { expect, test } from "./fixtures"; + +test("the conflict actions stay visible beside or below the file list as the dialog resizes", async ({ + workbench: page, +}) => { + await page.evaluate(async () => { + const storeModule = "/src/features/vcs/store.ts"; + const dialogModule = "/src/features/vcs/conflictsUi.tsx"; + const { useVcs } = await import(/* @vite-ignore */ storeModule); + const { showConflictsDialog } = await import(/* @vite-ignore */ dialogModule); + const root = "/dev/acme-api"; + useVcs.setState({ + root, + status: Array.from({ length: 24 }, (_, index) => { + const relPath = `services/payment-configuration/environments/env-${index + 1}.txt`; + return { path: `${root}/${relPath}`, relPath, staged: null, unstaged: "conflicted", renamedFrom: null }; + }), + }); + showConflictsDialog(); + }); + const dialog = page.getByRole("dialog", { name: "Conflicts", exact: true }); + const list = dialog.getByRole("listbox", { name: "Conflicted files" }); + const yours = dialog.getByRole("button", { name: "Accept Yours", exact: true }); + await expect(list).toBeFocused(); + const listBox = (await list.boundingBox())!; + const first = (await yours.boundingBox())!; + expect(first.x).toBeGreaterThan(listBox.x + listBox.width); + expect(first.y).toBeLessThan(listBox.y + listBox.height / 2); + + const grip = (await dialog.getByRole("separator", { name: "Resize", exact: true }).boundingBox())!; + await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2); + await page.mouse.down(); + await page.mouse.move(grip.x + 36, grip.y + 68, { steps: 5 }); + await page.mouse.up(); + await expect.poll(async () => (await list.boundingBox())!.height).toBeGreaterThan(listBox.height + 40); + + await page.setViewportSize({ width: 430, height: 530 }); + await expect(yours).toBeInViewport({ ratio: 1 }); + expect((await yours.boundingBox())!.y).toBeGreaterThan( + (await list.boundingBox())!.y + (await list.boundingBox())!.height, + ); + for (const name of ["Accept Theirs", "Merge…"]) + await expect(dialog.getByRole("button", { name, exact: true })).toBeInViewport({ ratio: 1 }); + await expect(dialog.locator("[data-dialog-footer]").getByRole("button", { name: "Close" })).toBeInViewport({ + ratio: 1, + }); + await list.press("End"); + await expect(list.getByRole("option", { selected: true })).toContainText("env-24.txt"); + await page.keyboard.press("Escape"); + await expect(dialog).toBeHidden(); +}); diff --git a/src/features/vcs/ConflictsDialog.module.css b/src/features/vcs/ConflictsDialog.module.css new file mode 100644 index 000000000..9387e031f --- /dev/null +++ b/src/features/vcs/ConflictsDialog.module.css @@ -0,0 +1,121 @@ +.dialog > [data-dialog-body] { + display: flex; + flex-direction: column; +} + +.content { + container: conflicts / inline-size; + display: flex; + flex: 1; + flex-direction: column; + gap: var(--space-3); + min-height: 0; + padding: var(--space-3) var(--space-4) 0; +} + +.summary { + display: flex; + flex-wrap: wrap; + align-items: baseline; + justify-content: space-between; + gap: var(--space-1) var(--space-3); + font-size: var(--fs-ui); + overflow-wrap: anywhere; +} + +.count { + color: var(--fg-subtle); + font-size: var(--fs-small); +} + +.workspace { + display: flex; + flex: 1; + gap: var(--space-3); + min-height: 0; +} + +.listFrame { + display: flex; + flex: 1; + flex-direction: column; + min-width: 0; + min-height: 0; + border: 1px solid var(--border); + border-radius: var(--radius-small); + overflow: hidden; +} + +.listHeader { + display: flex; + align-items: center; + min-height: var(--h-list-row); + padding-inline: var(--space-4); + border-bottom: 1px solid var(--border); + color: var(--fg-secondary); + font-size: var(--fs-small); +} + +.list { + flex: 1 1 300px; +} + +.row { + display: flex; + flex: 1; + align-items: center; + gap: var(--space-1-5); + min-width: 0; + font-size: var(--fs-ui); +} + +.fileName, +.fileDir { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; +} + +.fileName { + color: var(--vcs-conflict); +} + +.fileName:not(:last-child) { + flex: none; + max-width: 65%; +} + +.fileDir { + color: var(--fg-subtle); + font-size: var(--fs-small); +} + +.actions { + display: grid; + grid-template-columns: minmax(0, 1fr); + align-self: flex-start; + gap: var(--space-2); + max-width: min(40%, 180px); +} + +.actions button { + min-width: 0; + min-height: var(--h-button); + height: auto; + padding: var(--space-1) var(--space-2); + line-height: 1.3; + white-space: normal; + overflow-wrap: anywhere; +} + +@container conflicts (max-width: 430px) { + .workspace { + flex-direction: column; + } + + .actions { + align-self: stretch; + grid-template-columns: repeat(3, minmax(0, 1fr)); + max-width: none; + } +} diff --git a/src/features/vcs/conflictsUi.tsx b/src/features/vcs/conflictsUi.tsx index 480bcbef3..7ab3084c1 100644 --- a/src/features/vcs/conflictsUi.tsx +++ b/src/features/vcs/conflictsUi.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react"; import type { FileStatus } from "@/bindings"; import { activeEditor } from "@/editor/api"; import { call, commands } from "@/platform/ipc"; -import { Dialog, Icon, List, fileIconName, T } from "@/ui"; +import { Button, Dialog, Icon, List, fileIconName, T } from "@/ui"; import { editorService, notifications } from "@/workbench/contributions"; import { blockAt, parseConflicts, resolutionText, type Resolution } from "./conflicts"; import { openDialog } from "./dialogs"; @@ -13,9 +13,8 @@ import { controlLabel, controlOperation, inProgress, operationTitle, type InProg import { runOp, writeFileText } from "./ops"; import { executeAction } from "@/platform/actions"; import { conflictedFiles, useVcs } from "./store"; -import styles from "./common.module.css"; +import styles from "./ConflictsDialog.module.css"; import { tx } from "@/platform/i18n"; -import { useRowHeight } from "@/ui/density"; /** * The stopped rebase / cherry-pick / revert whose conflicts are being resolved from the @@ -65,7 +64,6 @@ export async function acceptSide(f: FileStatus, side: "ours" | "theirs") { } function ConflictsDialog({ onClose }: { onClose: () => void }) { - const rowHeight = useRowHeight(22); const files = useVcs((s) => s.status).filter((f) => f.unstaged === "conflicted"); const root = useVcs((s) => s.root) ?? ""; const op = useVcs((s) => inProgress(s.branch?.operation)); @@ -86,6 +84,10 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) { const head = useVcs((s) => s.branch?.head ?? null); const [active, setActive] = useState(0); const current = files[Math.min(active, files.length - 1)]; + const edit = (file: FileStatus) => { + onClose(); + openMergeEditor(file.path); + }; // Once everything is resolved the dialog concludes the stopped operation, as IDEA does. const conclude = op && !files.length @@ -98,8 +100,11 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) { open title="Conflicts" onClose={dismiss} - width={600} - footerStart={{op ? operationTitle(op, head) : ""}} + className={styles.dialog} + width={680} + resizable="both" + minWidth={360} + minHeight={320} buttons={[ ...(conclude ? [ @@ -114,58 +119,68 @@ function ConflictsDialog({ onClose }: { onClose: () => void }) { }, ] : []), - { label: "Accept Yours", disabled: !current, onClick: () => current && void acceptSide(current, "ours") }, - { label: "Accept Theirs", disabled: !current, onClick: () => current && void acceptSide(current, "theirs") }, - { - label: "Merge…", - role: conclude ? "extra" : "default", - autoFocus: !conclude, - disabled: !current, - onClick: () => { - if (!current) return; - onClose(); - openMergeEditor(current.path); - }, - }, { label: "Close", role: "cancel" }, ]} > -