From d19d74120be30ce007cc0e06f569aaf009e1a9a5 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Fri, 20 Nov 2026 06:00:12 +0800 Subject: [PATCH] fix(debugger): keep values visible in narrow variables panes (#4600) In narrow Variables panes the name and type kept their full width, so values were cut to nothing and the Show button could be pushed out. Names and types now truncate within caps, the value and its Show button share a group that keeps a minimum width, overflow is measured against that group, and full names and types are in tooltips. --- e2e/debugVariablesLayout.spec.ts | 63 +++++++++++++++++++ .../debugger/ui/VariablesView.module.css | 28 +++++++-- src/features/debugger/ui/VariablesView.tsx | 57 ++++++++++------- 3 files changed, 119 insertions(+), 29 deletions(-) create mode 100644 e2e/debugVariablesLayout.spec.ts diff --git a/e2e/debugVariablesLayout.spec.ts b/e2e/debugVariablesLayout.spec.ts new file mode 100644 index 000000000..c83fcb6c9 --- /dev/null +++ b/e2e/debugVariablesLayout.spec.ts @@ -0,0 +1,63 @@ +import { expect, stubDesktop, test } from "./fixtures"; + +const amountName = "regionalSettlementAmountFromExternalProcessorBeforeRounding"; +const routingName = "settlementRoutingReferenceForCrossBorderReconciliation"; +const routingValue = "'APR-2026 / eu-west / batch-701 / settlement complete'"; + +test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => { + await page.setViewportSize({ width: 1220, height: 760 }); + await stubDesktop(page); + await page.evaluate( + async ({ amountName, routingName, routingValue }) => { + const debugModule = "/src/features/debugger/state.ts"; + const layoutModule = "/src/workbench/toolwindows/store.ts"; + const servicesModule = "/src/workbench/contributions.ts"; + const { adoptSession } = await import(/* @vite-ignore */ debugModule); + const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule); + const { toolWindowService } = await import(/* @vite-ignore */ servicesModule); + const h = window.__ipc.handlers; + h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }]; + h.debug_variables = () => [ + { name: amountName, value: "47.74", typeName: "float", variablesReference: 0, evaluateName: amountName }, + { name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName }, + ]; + adoptSession(91, { + name: "Checkout", + adapter: "debugpy", + status: "paused", + selectedFrame: 11, + frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }], + }); + moveToolWindow("debug", "right"); + setToolWindowSize("right", 390); + toolWindowService().show("debug", true); + }, + { amountName, routingName, routingValue }, + ); + + const debug = page.getByRole("region", { name: "Debug", exact: true }); + await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click(); + const amount = debug.getByText("47.74", { exact: true }); + await expect + .poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1)) + .toBe(true); + const routing = debug.getByRole("treeitem").filter({ hasText: routingName }); + const show = routing.getByTitle("Show", { exact: true }); + await expect(show).toBeInViewport({ ratio: 1 }); + await show.click(); + const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` }); + await expect(dialog.getByText(routingValue, { exact: true })).toBeVisible(); + await page.keyboard.press("Escape"); + await expect(dialog).toBeHidden(); + + await page.setViewportSize({ width: 1640, height: 760 }); + await page.evaluate(async () => { + const layoutModule = "/src/workbench/toolwindows/store.ts"; + const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule); + moveToolWindow("debug", "bottom"); + }); + await expect(show).toBeHidden(); + await expect + .poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1)) + .toBe(true); +}); diff --git a/src/features/debugger/ui/VariablesView.module.css b/src/features/debugger/ui/VariablesView.module.css index 842e4ef17..a95c84e46 100644 --- a/src/features/debugger/ui/VariablesView.module.css +++ b/src/features/debugger/ui/VariablesView.module.css @@ -10,12 +10,12 @@ .row { display: flex; align-items: center; - gap: 5px; + gap: var(--space-1); min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; - font-family: var(--font-mono); + font-family: var(--font-ui); font-size: var(--fs-ui); white-space: pre; color: var(--fg); @@ -23,7 +23,10 @@ } .name { - flex: none; + min-width: 0; + max-width: 45%; + overflow: hidden; + text-overflow: ellipsis; color: var(--fg); } @@ -41,7 +44,6 @@ .nodeIcon { flex: none; - margin-right: 1px; } .eq { @@ -49,15 +51,28 @@ color: var(--fg-subtle); } +.valueGroup { + display: flex; + align-items: center; + gap: var(--space-1); + min-width: min(8ch, 45%); + flex: 1 1 0; +} + .value { min-width: 0; flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; + font-family: var(--font-mono); } .showValue { - flex: none; + flex: 0 0 auto; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; padding: 0; border: 0; background: none; @@ -112,6 +127,7 @@ .type { min-width: 0; + max-width: 25%; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; @@ -136,7 +152,7 @@ .editInput { flex: 1; - min-width: 80px; + min-width: min(80px, 40%); height: 18px; padding: 0 4px; font: inherit; diff --git a/src/features/debugger/ui/VariablesView.tsx b/src/features/debugger/ui/VariablesView.tsx index 054587fc8..214e69a92 100644 --- a/src/features/debugger/ui/VariablesView.tsx +++ b/src/features/debugger/ui/VariablesView.tsx @@ -415,7 +415,9 @@ function VarEditRow({ useEffect(() => acquirePopup(), []); return ( - {node.name} + + {node.name} + = (null); const [overflow, setOverflow] = useState(false); useLayoutEffect(() => { - const el = valueRef.current; - if (!el) { + const text = valueRef.current; + const group = text?.parentElement; + if (!text || !group) { setOverflow(false); return; } - const update = () => setOverflow(el.scrollWidth > el.clientWidth + 1); + // The group measures the space available before the Show button takes any of it. + const update = () => setOverflow(text.scrollWidth > group.clientWidth + 1); update(); if (typeof ResizeObserver === "undefined") return; const observer = new ResizeObserver(update); - observer.observe(el); + observer.observe(group); + observer.observe(text); return () => observer.disconnect(); - }, [node.value]); + }, [node.value, node.typeName, node.error]); if (node.kind === "message") return {node.name}; if (node.kind === "scope") return ( @@ -489,7 +494,7 @@ function VarRow({ const shown = shownValue(node.value, node.typeName); const evaluation = node.kind === "eval"; return ( - + {!shown.entry && ( <> @@ -511,23 +516,29 @@ function VarRow({ {oneLine(node.error)} ) : ( <> - {shown.label && {shown.label}} - - {oneLine(shown.text)} - - {overflow && ( - + {shown.label && ( + + {shown.label} + )} + + + {oneLine(shown.text)} + + {overflow && ( + + )} + )}