diff --git a/e2e/breakpointDialogLayout.spec.ts b/e2e/breakpointDialogLayout.spec.ts new file mode 100644 index 000000000..9d894dfba --- /dev/null +++ b/e2e/breakpointDialogLayout.spec.ts @@ -0,0 +1,50 @@ +import { expect, test } from "./fixtures"; + +test("keeps breakpoint details editable when the dialog gets narrow", async ({ workbench: page }) => { + await page.setViewportSize({ width: 500, height: 480 }); + await page.evaluate(async () => { + const actionsModule = "/src/platform/actions.ts"; + const storeModule = "/src/features/debugger/breakpoints/store.ts"; + const { executeAction } = await import(/* @vite-ignore */ actionsModule); + const { addBreakpoint } = await import(/* @vite-ignore */ storeModule); + addBreakpoint("/dev/acme-api/CheckInternationalSettlementBeforeDispatch.java", 7, { + condition: "amount > 100", + }); + addBreakpoint("/dev/acme-api/Receipt.java", 4); + await executeAction("debug.viewBreakpoints"); + }); + + const dialog = page.getByRole("dialog", { name: "Breakpoints" }); + const list = dialog.getByRole("listbox", { name: "All breakpoints" }); + const condition = dialog.locator('input[aria-label="Condition"]'); + await expect(condition).toHaveValue("amount > 100"); + await expect.poll(async () => (await condition.boundingBox())?.width ?? 0).toBeGreaterThanOrEqual(240); + await expect(dialog.getByRole("button", { name: "Done", exact: true })).toBeInViewport({ ratio: 1 }); + await condition.fill("amount > 250"); + await dialog.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check(); + await dialog.getByRole("textbox", { name: "Evaluate and log", exact: true }).fill("total: {amount}"); + const first = list.getByRole("option", { name: /CheckInternationalSettlementBeforeDispatch\.java:8/ }); + await expect(first.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 }); + await list.getByRole("option", { name: /Receipt\.java:5/ }).click(); + await expect(condition).toHaveValue(""); + await first.click(); + await expect(condition).toHaveValue("amount > 250"); + await expect(dialog.getByRole("textbox", { name: "Evaluate and log", exact: true })).toHaveValue("total: {amount}"); + + await page.setViewportSize({ width: 1080, height: 760 }); + const divider = dialog.locator('[data-separator][aria-orientation="vertical"]'); + await expect(divider).toBeInViewport(); + const oldWidth = (await list.boundingBox())!.width; + const handle = (await divider.boundingBox())!; + await page.mouse.move(handle.x + handle.width / 2, handle.y + handle.height / 2); + await page.mouse.down(); + await page.mouse.move(handle.x + 60, handle.y + handle.height / 2, { steps: 4 }); + await page.mouse.up(); + await expect.poll(async () => (await list.boundingBox())?.width ?? 0).toBeGreaterThan(oldWidth + 20); + await expect(condition).toHaveValue("amount > 250"); + const request = dialog.getByRole("textbox", { name: "Part of a request URL" }); + await request.scrollIntoViewIfNeeded(); + await expect(request).toBeInViewport({ ratio: 1 }); + await dialog.getByRole("button", { name: "Done", exact: true }).click(); + await expect(dialog).toBeHidden(); +}); diff --git a/src/features/debugger/__tests__/breakpointsDialog.test.tsx b/src/features/debugger/__tests__/breakpointsDialog.test.tsx index 9f6bf44f8..1db6f7dd4 100644 --- a/src/features/debugger/__tests__/breakpointsDialog.test.tsx +++ b/src/features/debugger/__tests__/breakpointsDialog.test.tsx @@ -24,7 +24,10 @@ describe("the Breakpoints dialog", () => { }); const dialog = () => screen.getByRole("dialog", { name: "Breakpoints" }); - const row = (name: string) => within(within(dialog()).getByLabelText("All breakpoints")).getByText(name); + const row = (location: string) => + within(within(dialog()).getByRole("listbox", { name: "All breakpoints" })).getByRole("option", { + name: (name) => name.includes(`Enable breakpoint at ${location}`), + }); const condition = () => within(dialog()).getByLabelText("Condition") as HTMLInputElement; /** A row's mouse click as the list sees it: mousedown selects, click (with its count) activates. */ const clickRow = (name: string, detail: number) => { @@ -37,8 +40,8 @@ describe("the Breakpoints dialog", () => { render(); clickRow("main.py:7", 1); expect(openFile).not.toHaveBeenCalled(); - // Its details show beside the list. - expect(within(dialog()).getAllByText("main.py:7")).toHaveLength(2); + expect(row("main.py:7").getAttribute("aria-selected")).toBe("true"); + expect(condition().value).toBe(""); clickRow("main.py:3", 2); expect(openFile).toHaveBeenCalledWith(path, { selection: { line: 2, col: 0 } }); }); diff --git a/src/features/debugger/js/EventBreakpoints.module.css b/src/features/debugger/js/EventBreakpoints.module.css index 8479a5d74..e331c8053 100644 --- a/src/features/debugger/js/EventBreakpoints.module.css +++ b/src/features/debugger/js/EventBreakpoints.module.css @@ -1,7 +1,4 @@ .section { - flex: none; - max-height: 40%; - overflow: auto; border-top: 1px solid var(--border-popup); padding: 6px 12px 8px; display: flex; diff --git a/src/features/debugger/ui/Overlays.module.css b/src/features/debugger/ui/Overlays.module.css index cae3559e5..7d96ea3e1 100644 --- a/src/features/debugger/ui/Overlays.module.css +++ b/src/features/debugger/ui/Overlays.module.css @@ -88,36 +88,46 @@ } /* breakpoints dialog */ -.bpDialog { - display: flex; - height: 420px; - min-height: 0; -} - -.bpListPane { - width: 360px; - flex: none; +.bpWindow [data-dialog-body] { display: flex; flex-direction: column; - border-right: 1px solid var(--border-popup); - min-height: 0; + overflow: hidden; +} + +.bpDialog { + flex: 1 1 420px; } .bpListHeader { - height: var(--h-header); + min-height: var(--h-header); flex: none; display: flex; + flex-wrap: wrap; align-items: center; + justify-content: space-between; gap: var(--space-1-5); - padding: 0 8px 0 12px; + padding: var(--space-0-5) var(--space-2); border-bottom: 1px solid var(--border-popup); } +.bpListActions { + display: flex; + gap: var(--space-1); + margin-inline-start: auto; +} + .bpList { - flex: 1; + flex: 1 0 calc(2 * var(--h-list-row)); min-height: 0; } +.bpAuxiliary { + flex: 0 1 auto; + max-height: 42%; + min-height: 0; + overflow: auto; +} + .bpRow, .chooserRow { display: flex; @@ -135,6 +145,31 @@ color: var(--fg-emphasis); } +.bpLocation { + display: inline-flex; + min-width: 0; + align-items: baseline; +} + +.bpRow .bpName, +.bpLocation .bpName { + flex: 0 1 auto; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + font-family: var(--font-ui); +} + +.bpLine { + flex: none; + white-space: nowrap; + font-variant-numeric: tabular-nums; +} + +.bpRow > svg { + flex: none; +} + .bpDir { flex: 1; min-width: 0; @@ -156,14 +191,29 @@ .bpDetail { flex: 1; min-width: 0; + min-height: 0; overflow: auto; } .detail { - padding: 12px 14px; + padding: var(--space-3); display: flex; flex-direction: column; - gap: 10px; + gap: var(--space-2); +} + +.detail .bpTitle { + flex-wrap: wrap; + gap: var(--space-1) var(--space-2); +} + +.detail :is(.bpFile, .bpLocation) { + flex: 1 1 12ch; + font-family: var(--font-ui); +} + +.detail .label { + font-size: var(--fs-ui); } .statusLine { @@ -245,9 +295,6 @@ } .exceptions { - flex: none; - max-height: 40%; - overflow: auto; border-top: 1px solid var(--border-popup); padding: 6px 12px 8px; display: flex; diff --git a/src/features/debugger/ui/Overlays.tsx b/src/features/debugger/ui/Overlays.tsx index eef942f23..90c6e8dd8 100644 --- a/src/features/debugger/ui/Overlays.tsx +++ b/src/features/debugger/ui/Overlays.tsx @@ -3,6 +3,7 @@ import { Fragment, useEffect, useId, + useLayoutEffect, useMemo, useRef, useState, @@ -13,7 +14,23 @@ import { basename, relativePath, useProject } from "@/platform/project"; import { executeAction, getAction } from "@/platform/actions"; import { call, commands, type AttachableProcess, type RunConfig, type Variable } from "@/platform/ipc"; import { maybeEditorService, notifications } from "@/workbench/contributions"; -import { Button, Checkbox, Dialog, Icon, IconButton, Input, Kbd, List, Menu, Popup, Toggle, T } from "@/ui"; +import { + Button, + Checkbox, + Dialog, + Icon, + IconButton, + Input, + Kbd, + List, + Menu, + Popup, + SplitGroup, + SplitHandle, + SplitPanel, + Toggle, + T, +} from "@/ui"; import { isConditional, suspends, type BreakpointEntry } from "../breakpoints/model"; import { removeAllBreakpoints, @@ -373,6 +390,15 @@ type DialogRow = | ({ type: "line"; key: string } & BpRow) | { type: "special"; key: string; bp: SpecialBreakpoint }; +function BreakpointLocation({ path, line }: { path: string; line: number }) { + return ( + + {basename(path)} + :{line + 1} + + ); +} + function BreakpointsDialog() { const state = useOverlays((s) => s.breakpoints); const byFile = useBreakpoints((s) => s.byFile); @@ -407,6 +433,18 @@ function BreakpointsDialog() { // Enter on Done and a click on a row don't blur them. const commitRef = useRef<(() => void) | null>(null); const open = !!state; + const layout = useRef(null); + const [stacked, setStacked] = useState(false); + useLayoutEffect(() => { + const el = layout.current; + if (!open || !el) return; + const update = () => setStacked(el.clientWidth > 0 && el.clientWidth < 560); + update(); + if (typeof ResizeObserver === "undefined") return; + const observer = new ResizeObserver(update); + observer.observe(el); + return () => observer.disconnect(); + }, [open]); const current = items.find((r) => r.key === (selected ?? state?.id)) ?? items[0]; const close = () => { commitRef.current?.(); @@ -430,28 +468,38 @@ function BreakpointsDialog() { open={open} onClose={close} title="Breakpoints" + className={styles.bpWindow} width={760} + minWidth={400} + minHeight={340} + resizable="both" aria-label="Breakpoints" buttons={[{ label: "Done", role: "default", onClick: close }]} > - - + + - - setSelected(addMethodBreakpoint("").id)} - /> - + + setSelected(addMethodBreakpoint("").id)} + /> + + - {specialTitle(r.bp)} + + {specialTitle(r.bp)} + {r.bp.path && ( {basename(r.bp.path)} @@ -520,9 +570,7 @@ function BreakpointsDialog() { } aria-hidden /> - - {basename(r.path)}:{r.bp.line + 1} - + {relativePath(root, r.path)} {isConditional(r.bp) && {suspends(r.bp) ? "if" : "log"}} {r.bp.temporary && ( @@ -534,17 +582,22 @@ function BreakpointsDialog() { ); }} /> - - - - - {current?.type === "line" ? ( - goTo(current)} commitRef={commitRef} /> - ) : current?.type === "special" ? ( - goTo(current)} commitRef={commitRef} /> - ) : null} - - + + + + + + + + + {current?.type === "line" ? ( + goTo(current)} commitRef={commitRef} /> + ) : current?.type === "special" ? ( + goTo(current)} commitRef={commitRef} /> + ) : null} + + + ); } @@ -610,10 +663,7 @@ function BreakpointDetail({ return ( - - {basename(path)}:{bp.line + 1} - - + Go to Source @@ -664,8 +714,9 @@ function SpecialDetail({ - {specialTitle(bp)} - + + {specialTitle(bp)} + {bp.path && ( Go to Source