diff --git a/e2e/consoleSettingsLayout.spec.ts b/e2e/consoleSettingsLayout.spec.ts new file mode 100644 index 000000000..292f8d17b --- /dev/null +++ b/e2e/consoleSettingsLayout.spec.ts @@ -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"); +}); diff --git a/src/features/settings/components/Form.module.css b/src/features/settings/components/Form.module.css index f93091ecd..327a1d5ab 100644 --- a/src/features/settings/components/Form.module.css +++ b/src/features/settings/components/Form.module.css @@ -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); diff --git a/src/features/settings/components/Form.tsx b/src/features/settings/components/Form.tsx index 9c2be511b..ed6eada39 100644 --- a/src/features/settings/components/Form.tsx +++ b/src/features/settings/components/Form.tsx @@ -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 ( -
+
void add()} /> diff --git a/src/features/settings/pages/execution.tsx b/src/features/settings/pages/execution.tsx index 2819b366b..0185fca81 100644 --- a/src/features/settings/pages/execution.tsx +++ b/src/features/settings/pages/execution.tsx @@ -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 /> ); @@ -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 }] }, ], }, { diff --git a/src/features/settings/pages/workflowControls.tsx b/src/features/settings/pages/workflowControls.tsx index 6c4e63472..a918cf188 100644 --- a/src/features/settings/pages/workflowControls.tsx +++ b/src/features/settings/pages/workflowControls.tsx @@ -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(toggleKey); const [n, setN] = useSetting(numberKey); @@ -72,7 +74,15 @@ export function ToggleNumber({ } /> - + {unit && {unit}} {hint && {hint}}