Compare commits

...
Author SHA1 Message Date
l0ng-ai 98856fd5a1 Merge remote-tracking branch 'origin/main' into HEAD
# Conflicts:
#	e2e/debugVariablesLayout.spec.ts
2026-11-22 20:34:54 +08:00
l0ng-ai ca05825d7c fix(debugger): stabilize the inline variable editor 2026-11-22 17:50:58 +08:00
3 changed files with 186 additions and 105 deletions

No files matched your search

+114 -53
View File
@@ -4,63 +4,124 @@ const amountName = "regionalSettlementAmountFromExternalProcessorBeforeRounding"
const routingName = "settlementRoutingReferenceForCrossBorderReconciliation";
const routingText = "APR-2026 / eu-west / batch-701 / settlement complete";
const routingValue = "'" + routingText + "'";
const invalidValueMessage = "The settlement amount must be a valid decimal expression.";
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 },
);
test.describe("a paused session with editable values", () => {
test.beforeEach(async ({ workbench: page }) => {
await page.setViewportSize({ width: 1220, height: 760 });
await stubDesktop(page);
await page.evaluate(
async ({ amountName, routingName, routingValue, invalidValueMessage }) => {
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;
let amountValue = "47.74";
const amount = () => ({
name: amountName,
value: amountValue,
typeName: "float",
variablesReference: 0,
evaluateName: amountName,
});
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
h.debug_variables = () => [
amount(),
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
];
h.debug_set_variable = ({ value }) => {
if (value === "invalid") throw { kind: "invalid", message: invalidValueMessage, detail: null };
amountValue = String(value);
return amount();
};
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, invalidValueMessage },
);
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(routingText, { exact: true })).toBeVisible();
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
const debug = page.getByRole("region", { name: "Debug", exact: true });
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
});
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");
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
const debug = page.getByRole("region", { name: "Debug", exact: true });
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(routingText, { 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);
});
test("keeps the variable label and input in place when editing a value", async ({ workbench: page }) => {
const debug = page.getByRole("region", { name: "Debug", exact: true });
const row = debug.getByRole("treeitem").filter({ hasText: amountName });
const name = row.getByText(amountName, { exact: true });
await row.click();
const nameBefore = (await name.boundingBox())!;
const equal = row.getByText("=", { exact: true });
const equalBefore = (await equal.boundingBox())!;
const color = await name.evaluate((el) => getComputedStyle(el).color);
await page.keyboard.press("F2");
const input = row.getByRole("textbox", { name: `New value of ${amountName}` });
await expect(input).toBeFocused();
await expect(input).toHaveValue("47.74");
await expect(name).toHaveCSS("color", color);
expect((await name.boundingBox())!.x).toBeCloseTo(nameBefore.x, 0);
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
await expect(row.locator("svg")).toHaveCount(1);
await input.fill("invalid");
await input.press("Enter");
await expect(input).toHaveAttribute("aria-invalid", "true");
await expect(input).toHaveAttribute("title", invalidValueMessage);
await expect(input).toBeInViewport({ ratio: 1 });
expect((await input.boundingBox())!.width).toBeGreaterThan(60);
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
await input.press("Escape");
await expect(input).toBeHidden();
await expect(row).toContainText("47.74");
await page.keyboard.press("F2");
await expect(input).toHaveValue("47.74");
await input.fill("48.25");
await input.press("Enter");
await expect(input).toBeHidden();
await expect(row).toContainText("48.25");
});
await expect(show).toBeHidden();
await expect
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
.toBe(true);
});
test("keeps a decimal value legible beside a long runtime type", async ({ workbench: page }) => {
@@ -159,11 +159,17 @@
font-size: var(--fs-ui);
}
.editRow,
.editRow > .valueGroup {
height: 100%;
}
.editInput {
flex: 1;
min-width: min(80px, 40%);
height: 18px;
padding: 0 4px;
box-sizing: border-box;
flex: 1 1 0;
min-width: 0;
height: calc(100% - var(--space-1));
padding: 0 var(--space-1);
font: inherit;
font-family: var(--font-mono);
color: var(--fg-strong);
@@ -176,6 +182,10 @@
border-color: var(--danger);
}
.editError {
max-width: 33%;
}
/* Changed since the previous stop. */
.name.changed {
color: var(--debug-changed, var(--link));
+58 -48
View File
@@ -467,6 +467,7 @@ export function VariablesView({
editing?.key === n.key ? (
<VarEditRow
node={n}
changed={isChanged(n)}
value={editing.value}
error={editing.error}
onChange={(value) => setEditing({ ...editing, value, error: null })}
@@ -558,6 +559,7 @@ function ValueDialog({
function VarEditRow({
node,
changed,
value,
error,
onChange,
@@ -565,6 +567,7 @@ function VarEditRow({
onCancel,
}: {
node: VarNode;
changed: boolean;
value: string;
error: string | null;
onChange: (v: string) => void;
@@ -575,37 +578,36 @@ function VarEditRow({
// the global "Escape → focus editor" binding (`!popupOpen`) from firing.
useEffect(() => acquirePopup(), []);
return (
<span className={styles.row}>
<span className={styles.name} title={node.name}>
{node.name}
<span className={clsx(styles.row, styles.editRow)} title={node.name}>
<VarPrefix node={node} changed={changed} />
<span className={styles.valueGroup}>
<input
className={clsx(styles.editInput, error && styles.editInvalid)}
value={value}
autoFocus
spellCheck={false}
autoComplete="off"
aria-label={`New value of ${node.name}`}
aria-invalid={!!error || undefined}
title={error ?? undefined}
onFocus={(e) => e.currentTarget.select()}
onChange={(e) => onChange(e.target.value)}
onClick={(e) => e.stopPropagation()}
onDoubleClick={(e) => e.stopPropagation()}
onBlur={onCancel}
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter") {
e.preventDefault();
onCommit();
} else if (e.key === "Escape") {
e.preventDefault();
onCancel();
}
}}
/>
{error && <span className={clsx(styles.error, styles.editError)}>{oneLine(error)}</span>}
</span>
<span className={styles.eq}>=</span>
<input
className={clsx(styles.editInput, error && styles.editInvalid)}
value={value}
autoFocus
spellCheck={false}
autoComplete="off"
aria-label={`New value of ${node.name}`}
aria-invalid={!!error || undefined}
title={error ?? undefined}
onFocus={(e) => e.currentTarget.select()}
onChange={(e) => onChange(e.target.value)}
onClick={(e) => e.stopPropagation()}
onDoubleClick={(e) => e.stopPropagation()}
onBlur={onCancel}
onKeyDown={(e) => {
e.stopPropagation();
if (e.key === "Enter") {
e.preventDefault();
onCommit();
} else if (e.key === "Escape") {
e.preventDefault();
onCancel();
}
}}
/>
{error && <span className={styles.error}>{error}</span>}
</span>
);
}
@@ -616,6 +618,31 @@ function nodeIcon(node: VarNode): string {
return node.depth0 ? "variable" : "field";
}
function VarPrefix({ node, changed, showName = true }: { node: VarNode; changed: boolean; showName?: boolean }) {
const evaluation = node.kind === "eval";
return (
<>
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
{showName && (
<>
<span
className={clsx(
styles.name,
evaluation && styles.evalName,
node.kind === "var" && styles.varName,
changed && styles.changed,
)}
title={evaluation ? node.name : undefined}
>
{evaluation ? oneLine(node.name) : node.name}
</span>
<span className={styles.eq}>=</span>
</>
)}
</>
);
}
function VarRow({
node,
changed,
@@ -655,26 +682,9 @@ function VarRow({
);
const kind = node.error ? null : classifyValue(node.value, node.typeName);
const shown = shownValue(node.value, node.typeName);
const evaluation = node.kind === "eval";
return (
<span className={styles.row} title={node.name}>
<Icon name={nodeIcon(node)} size={16} className={styles.nodeIcon} />
{!shown.entry && (
<>
<span
className={clsx(
styles.name,
evaluation && styles.evalName,
node.kind === "var" && styles.varName,
changed && styles.changed,
)}
title={evaluation ? node.name : undefined}
>
{evaluation ? oneLine(node.name) : node.name}
</span>
<span className={styles.eq}>=</span>
</>
)}
<VarPrefix node={node} changed={changed} showName={!shown.entry} />
{node.error ? (
<span className={styles.error}>{oneLine(node.error)}</span>
) : (