From 8f252398fed97cdd48e49dce3402a60dfd0d06b5 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sun, 22 Nov 2026 10:35:18 +0800 Subject: [PATCH] fix(debugger): adapt frames and variables to side docks (#5102) The Debug tool window puts the call stack above Variables when docked on either side, giving both panes the full dock width; in the bottom dock the panes sit side by side. Each orientation remembers its divider position. --- e2e/debugStackLayout.spec.ts | 74 ++++++++++++++++++++ src/features/debugger/ui/DebugToolWindow.tsx | 25 ++++--- 2 files changed, 91 insertions(+), 8 deletions(-) diff --git a/e2e/debugStackLayout.spec.ts b/e2e/debugStackLayout.spec.ts index f1f1053d5..1df7c1287 100644 --- a/e2e/debugStackLayout.spec.ts +++ b/e2e/debugStackLayout.spec.ts @@ -77,3 +77,77 @@ test("keeps frame sources and the keyboard selection visible in a narrow debug d await expect(thread).toContainText("Order worker"); await expect(frames.getByRole("option", { selected: true })).toContainText("processOrder"); }); + +test("Debug stacks frames and variables in a side dock and remembers both divider positions", async ({ + workbench: page, +}) => { + await page.setViewportSize({ width: 1000, height: 690 }); + await stubDesktop(page); + await page.evaluate(async () => { + const debugModule = "/src/features/debugger/state.ts"; + const { adoptSession } = await import(/* @vite-ignore */ debugModule); + window.__ipc.handlers.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }]; + window.__ipc.handlers.debug_variables = () => [ + { name: "orderTotal", value: "47.74", typeName: "float", variablesReference: 0, evaluateName: "orderTotal" }, + ]; + adoptSession(91, { + name: "Order service", + adapter: "debugpy", + status: "paused", + selectedFrame: 11, + frames: [ + { id: 11, name: "applyDiscount", path: null, line: 8, column: 0, presentationHint: null }, + { id: 12, name: "processOrder", path: null, line: 18, column: 0, presentationHint: null }, + ], + }); + }); + const move = (anchor: "right" | "bottom") => + page.evaluate(async (anchor) => { + const path = "/src/workbench/toolwindows/store.ts"; + const { moveToolWindow, setToolWindowSize, showToolWindow } = await import(/* @vite-ignore */ path); + moveToolWindow("debug", anchor); + setToolWindowSize(anchor, 300); + showToolWindow("debug", true); + }, anchor); + await move("right"); + + const debug = page.getByRole("region", { name: "Debug", exact: true }); + await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click(); + const frames = debug.locator("#frames"); + const variables = debug.locator("#variables"); + const handle = debug.getByRole("separator"); + await expect(variables.getByText("47.74", { exact: true })).toBeVisible(); + await expect(handle).toHaveAttribute("aria-orientation", "horizontal"); + const stack = (await frames.boundingBox())!; + const locals = (await variables.boundingBox())!; + expect(locals.y).toBeGreaterThanOrEqual(stack.y + stack.height - 1); + expect(Math.abs(locals.width - stack.width)).toBeLessThan(2); + + const size = async () => Number(await handle.getAttribute("aria-valuenow")); + const resize = async (key: string) => { + const previous = await size(); + await handle.press(key); + await expect.poll(size).not.toBe(previous); + return size(); + }; + const sideSize = await resize("ArrowDown"); + await frames.getByRole("option", { name: /processOrder/ }).click(); + const selected = frames.getByRole("option", { selected: true }); + await expect(selected).toContainText("processOrder"); + + await move("bottom"); + await expect(handle).toHaveAttribute("aria-orientation", "vertical"); + await expect.poll(size).toBeCloseTo(34, 0); + await expect(selected).toContainText("processOrder"); + await expect(variables.getByText("47.74", { exact: true })).toBeVisible(); + const bottomStack = (await frames.boundingBox())!; + expect((await variables.boundingBox())!.x).toBeGreaterThanOrEqual(bottomStack.x + bottomStack.width - 1); + const bottomSize = await resize("ArrowLeft"); + + await move("right"); + await expect.poll(size).toBeCloseTo(sideSize, 0); + await move("bottom"); + await expect.poll(size).toBeCloseTo(bottomSize, 0); + await handle.dblclick(); + await expect.poll(size).toBeCloseTo(34, 0); +}); diff --git a/src/features/debugger/ui/DebugToolWindow.tsx b/src/features/debugger/ui/DebugToolWindow.tsx index 52f793b0c..7fab4ae7a 100644 --- a/src/features/debugger/ui/DebugToolWindow.tsx +++ b/src/features/debugger/ui/DebugToolWindow.tsx @@ -57,6 +57,7 @@ import { useExpressionCompletion } from "./ExpressionCompletion"; import { sortVariables } from "../values"; import { workflowSettings } from "@/platform/workflowSettings"; import { useToolWindowShown } from "@/workbench/contributions"; +import { useToolWindowLayout } from "@/workbench/toolwindows/store"; import styles from "./DebugToolWindow.module.css"; import { tx, useTx } from "@/platform/i18n"; @@ -200,10 +201,11 @@ export function DebugServiceView({ sessionId, console: consolePane }: { sessionI } export function DebugToolWindow() { - return ; + const sideDocked = useToolWindowLayout((s) => (s.placements.debug?.anchor ?? "bottom") !== "bottom"); + return ; } -function DebugView({ consolePane }: { consolePane?: ReactNode }) { +function DebugView({ consolePane, sideDocked = false }: { consolePane?: ReactNode; sideDocked?: boolean }) { const tx = useTx(); const active = useDebug((s) => (s.active != null ? s.sessions[s.active] : undefined)); const muted = useBreakpoints((s) => s.muted); @@ -330,7 +332,7 @@ function DebugView({ consolePane }: { consolePane?: ReactNode }) {
{tab === "variables" ? ( - + ) : tab === "memory" ? ( memoryPending ? (
@@ -356,19 +358,26 @@ const JVM_ADAPTERS = new Set(["java-debug", "kotlin-debug-adapter", "kotlin-lsp" // --- threads & frames ---------------------------------------------------------- -function ThreadsAndVariables({ session }: { session: DebugSession }) { +const DEFAULT_THREADS_VARIABLES_LAYOUT = { frames: 34, variables: 66 }; + +function ThreadsAndVariables({ session, sideDocked }: { session: DebugSession; sideDocked: boolean }) { return ( - + - +