fix(settings): align the Console settings layout (#4861)

fix(settings): align the Console settings layout
This commit is contained in:
l0ng-ai
2026-11-21 07:19:37 +08:00
committed by GitHub
parent 04bed01942
commit c0e888dd2f
5 changed files with 96 additions and 5 deletions
+71
View File
@@ -0,0 +1,71 @@
import type { Page } from "@playwright/test";
import { expect, test } from "./fixtures";
async function openConsoleSettings(page: Page) {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
const search = dialog.getByRole("textbox", { name: "Search settings" });
await search.fill("Fold console lines that contain");
await dialog.getByRole("treeitem", { name: "Console", exact: true }).click();
await search.clear();
return dialog;
}
test("Console settings put folding between the basic controls and log colors", async ({ workbench: page }) => {
await page.setViewportSize({ width: 1120, height: 740 });
const dialog = await openConsoleSettings(page);
const wrap = dialog.getByRole("checkbox", { name: "Use soft wraps in console", exact: true });
const override = dialog.getByRole("checkbox", { name: /^Override console cycle buffer size/ });
const size = dialog.getByRole("textbox", { name: "Override console cycle buffer size", exact: true });
const encoding = dialog.getByRole("button", { name: "Default encoding", exact: true });
const list = dialog.getByRole("listbox", { name: "Fold console lines that contain", exact: true });
const colors = dialog.getByRole("checkbox", { name: "Colour log lines by level", exact: true });
await expect(list).toBeVisible();
expect((await list.boundingBox())!.width).toBeGreaterThan(480);
const controls = [wrap, override, encoding, list, colors];
const positions = await Promise.all(controls.map(async (control) => (await control.boundingBox())!.y));
positions.forEach((y, index) => {
if (index > 0) expect(y).toBeGreaterThan(positions[index - 1]!);
});
for (const width of [580, 520]) {
await page.setViewportSize({ width, height: 740 });
for (const control of [...controls, size]) await expect(control).toBeInViewport({ ratio: 1 });
expect(await list.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
}
});
test("Console settings keep the stored buffer size and fold rules across Apply and reopen", async ({
workbench: page,
}) => {
const dialog = await openConsoleSettings(page);
const override = dialog.getByRole("checkbox", { name: /^Override console cycle buffer size/ });
const size = dialog.getByRole("textbox", { name: "Override console cycle buffer size", exact: true });
const list = dialog.getByRole("listbox", { name: "Fold console lines that contain", exact: true });
await override.check();
await expect(size).toBeEnabled();
await size.fill("2048");
await override.uncheck();
await expect(size).toBeDisabled();
await expect(size).toHaveValue("2048");
await dialog.getByRole("button", { name: "Add", exact: true }).click();
const pattern = list.getByRole("textbox", { name: "Pattern", exact: true });
await pattern.fill("at example.retry");
await pattern.press("Enter");
await expect(list.getByRole("option", { name: "at example.retry", exact: true })).toBeVisible();
const apply = dialog.getByRole("button", { name: "Apply", exact: true });
await apply.click();
await expect(apply).toBeDisabled();
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
await expect(dialog).toBeHidden();
await openConsoleSettings(page);
await expect(override).not.toBeChecked();
await expect(size).toBeDisabled();
await expect(size).toHaveValue("2048");
await expect(list.getByRole("option", { name: "at example.retry", exact: true })).toBeVisible();
await override.check();
await expect(size).toBeEnabled();
await expect(size).toHaveValue("2048");
});
@@ -203,11 +203,13 @@
display: flex;
flex-direction: column;
flex: 1;
max-width: 480px;
border-radius: var(--radius-small);
box-shadow: inset 0 0 0 1px var(--border-strong);
overflow: hidden;
}
.globCompact {
max-width: 480px;
}
.listToolbar {
display: flex;
gap: var(--space-0-5);
+3 -1
View File
@@ -313,6 +313,7 @@ export interface GlobListEditorProps {
emptyText?: string;
/** Accessible name of the inline editor. */
itemLabel?: string;
fullWidth?: boolean;
/** Entries are paths: + opens this chooser (Edit still takes typing). */
browse?: { directory: boolean; title: string };
}
@@ -324,6 +325,7 @@ export function GlobListEditor({
placeholder = "**/pattern",
emptyText = "No patterns",
itemLabel = "Pattern",
fullWidth,
browse,
...aria
}: GlobListEditorProps) {
@@ -404,7 +406,7 @@ export function GlobListEditor({
const rows = editing && editing.index >= value.length ? [...value, ""] : value;
return (
<div className={styles.globEditor}>
<div className={clsx(styles.globEditor, !fullWidth && styles.globCompact)}>
<div className={styles.listToolbar} role="toolbar" aria-controls={listId}>
<IconButton icon="plus" title="Add" size="small" onClick={() => void add()} />
<IconButton icon="minus" title="Remove" size="small" disabled={selected === null} onClick={remove} />
+8 -2
View File
@@ -50,6 +50,7 @@ function BufferRow() {
numberKey="console.bufferKb"
label="Override console cycle buffer size"
unit="KB"
disableWhenOff
hint="Older output is discarded"
{...L.bufferKb}
/>
@@ -81,6 +82,7 @@ function FoldPatterns() {
onChange={set}
placeholder="at org.example."
aria-label="Fold console lines that contain"
fullWidth
/>
</Row>
);
@@ -288,8 +290,8 @@ export const EXECUTION_PAGES: PageSpec[] = [
sections: [
{
options: [
{ kind: "custom", label: "Override console cycle buffer size", keywords: ["KB"], component: BufferRow },
{ kind: "toggle", key: "console.softWrap", label: "Use soft wraps in console" },
{ kind: "custom", label: "Override console cycle buffer size", keywords: ["KB"], component: BufferRow },
{
kind: "select",
key: "console.encoding",
@@ -297,6 +299,11 @@ export const EXECUTION_PAGES: PageSpec[] = [
options: CONSOLE_ENCODINGS,
hint: "Encoding of the output of processes started from Run configurations.",
},
],
},
{ options: [{ kind: "custom", label: "Fold console lines that contain", component: FoldPatterns }] },
{
options: [
{
kind: "custom",
label: "Colour log lines by level",
@@ -305,7 +312,6 @@ export const EXECUTION_PAGES: PageSpec[] = [
},
],
},
{ options: [{ kind: "custom", label: "Fold console lines that contain", component: FoldPatterns }] },
],
},
{
@@ -49,6 +49,7 @@ export function ToggleNumber({
min,
max,
hint,
disableWhenOff,
}: {
toggleKey: string;
numberKey: string;
@@ -57,6 +58,7 @@ export function ToggleNumber({
min: number;
max: number;
hint?: ReactNode;
disableWhenOff?: boolean;
}) {
const [on, setOn] = useSetting<boolean>(toggleKey);
const [n, setN] = useSetting<number>(numberKey);
@@ -72,7 +74,15 @@ export function ToggleNumber({
</>
}
/>
<NumberInput value={n} onChange={setN} min={min} max={max} integer aria-label={label} />
<NumberInput
value={n}
onChange={setN}
min={min}
max={max}
integer
disabled={disableWhenOff && !on}
aria-label={label}
/>
{unit && <span className={clsx(styles.unit, !on && styles.disabled)}>{unit}</span>}
{hint && <span className={styles.inlineHint}>{hint}</span>}
</div>