From 4340a96c59677ae028ddc0176593cecb6463a103 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sat, 21 Nov 2026 07:21:17 +0800 Subject: [PATCH] fix(settings): align the Terminal settings layout (#4882) Group the primary font, fallback font, and sizing controls above Application Settings. Let the start directory and default tab name use the available width. Keep the shell path, installed-shell menu, and Browse button together. Narrow windows place text fields below their labels and show the application checkboxes in one column. --- e2e/terminalSettingsLayout.spec.ts | 92 ++++++++ .../pages/TerminalSettings.module.css | 58 +++++ src/features/settings/pages/tools.tsx | 221 +++++++++--------- 3 files changed, 266 insertions(+), 105 deletions(-) create mode 100644 e2e/terminalSettingsLayout.spec.ts create mode 100644 src/features/settings/pages/TerminalSettings.module.css diff --git a/e2e/terminalSettingsLayout.spec.ts b/e2e/terminalSettingsLayout.spec.ts new file mode 100644 index 000000000..71078d0ae --- /dev/null +++ b/e2e/terminalSettingsLayout.spec.ts @@ -0,0 +1,92 @@ +import { expect, ipcCalls, stubDesktop, test } from "./fixtures"; + +test("Terminal settings keep shell controls and font groups readable as the window narrows", async ({ + workbench: page, +}) => { + await page.setViewportSize({ width: 1120, height: 900 }); + await stubDesktop(page); + const shellPath = "C:/Program Files/Shell/bin/bash.exe"; + await page.evaluate((path) => { + window.__ipc.handlers.settings_get_global = () => ({}); + window.__ipc.handlers.term_default_shell = () => "/bin/zsh"; + window.__ipc.handlers.term_available_shells = () => ["/bin/zsh", path]; + }, shellPath); + 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("Shell path"); + await dialog.getByRole("treeitem", { name: "Terminal", exact: true }).click(); + await search.clear(); + + const directory = dialog.getByRole("textbox", { name: /^Start directory:?$/ }); + const shell = dialog.getByRole("textbox", { name: /^Shell path:?$/ }); + const tab = dialog.getByRole("textbox", { name: /^Default Tab name:?$/ }); + const shells = dialog.getByRole("button", { name: "Installed Shells", exact: true }); + const browse = dialog.getByRole("button", { name: "Browse", exact: true }); + const font = dialog.getByRole("combobox", { name: "Terminal font", exact: true }); + const fallback = dialog.getByRole("combobox", { name: "Terminal fallback font", exact: true }); + const size = dialog.getByRole("textbox", { name: "Terminal font size", exact: true }); + const lineHeight = dialog.getByRole("textbox", { name: "Terminal line height", exact: true }); + const column = dialog.getByRole("textbox", { name: "Terminal column width", exact: true }); + const bell = dialog.getByRole("checkbox", { name: "Audible bell", exact: true }); + const shortcuts = dialog.getByRole("checkbox", { name: "Override IDE shortcuts", exact: true }); + await expect(shell).toHaveAttribute("placeholder", "/bin/zsh"); + + for (const width of [1120, 580, 520]) { + await page.setViewportSize({ width, height: 900 }); + await shell.scrollIntoViewIfNeeded(); + await expect(shells).toBeInViewport({ ratio: 1 }); + await expect(browse).toBeInViewport({ ratio: 1 }); + const [dir, command, name, menu, chooseFile, main, secondary, fontSize, line, col, left, right] = await Promise.all( + [directory, shell, tab, shells, browse, font, fallback, size, lineHeight, column, bell, shortcuts].map( + (control) => control.boundingBox(), + ), + ); + if ( + !dir || + !command || + !name || + !menu || + !chooseFile || + !main || + !secondary || + !fontSize || + !line || + !col || + !left || + !right + ) + throw new Error("Missing Terminal settings bounds"); + expect(command.y + command.height / 2).toBeCloseTo(menu.y + menu.height / 2, 0); + expect(menu.y).toBeCloseTo(chooseFile.y, 0); + expect(command.width).toBeGreaterThan(100); + expect(command.x).toBeCloseTo(name.x, 0); + expect(chooseFile.x + chooseFile.width).toBeCloseTo(name.x + name.width, 0); + expect(dir.x + dir.width).toBeCloseTo(name.x + name.width, 0); + expect(main.y).toBeLessThan(command.y); + if (width === 1120) { + expect(main.y).toBeCloseTo(secondary.y, 0); + expect(fontSize.y).toBeCloseTo(line.y, 0); + expect(fontSize.y).toBeCloseTo(col.y, 0); + expect(right.x).toBeGreaterThan(left.x); + } else { + expect(command.x).toBeCloseTo(dir.x, 0); + expect(secondary.y).toBeGreaterThan(main.y); + expect(right.x).toBeCloseTo(left.x, 0); + expect(right.y).toBeGreaterThan(left.y); + } + } + + await shells.click(); + await page.getByRole("menuitemcheckbox", { name: shellPath, exact: true }).click(); + await expect(shell).toHaveValue(`"${shellPath}"`); + await expect(font).toBeDisabled(); + await dialog.getByRole("checkbox", { name: "Use editor font", exact: true }).uncheck(); + await font.fill("Cascadia Mono"); + await size.fill("15"); + await expect(font).toHaveValue("Cascadia Mono"); + await expect(size).toHaveValue("15"); + await dialog.getByRole("button", { name: "Cancel", exact: true }).click(); + await expect(dialog).toBeHidden(); + expect(await ipcCalls(page, "settings_set")).toEqual([]); +}); diff --git a/src/features/settings/pages/TerminalSettings.module.css b/src/features/settings/pages/TerminalSettings.module.css new file mode 100644 index 000000000..bbe3c5653 --- /dev/null +++ b/src/features/settings/pages/TerminalSettings.module.css @@ -0,0 +1,58 @@ +.field, +.shellControls { + width: 100%; +} + +.shellControls { + display: flex; + align-items: center; + gap: var(--space-1); + min-width: 0; +} + +.shellControls > input { + flex: 1; + min-width: 0; +} + +.families { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(min(265px, 100%), 1fr)); + column-gap: var(--space-4); +} + +.fontPicker { + display: flex; + flex-direction: column; + gap: var(--space-1); + min-width: 0; +} + +.metrics { + display: flex; + flex-wrap: wrap; + column-gap: var(--space-4); +} + +.metrics > div { + margin-inline: 0; + padding-inline: 0; +} + +.options > div:first-child { + grid-template-columns: repeat(auto-fit, minmax(min(245px, 100%), 1fr)); +} + +@container settings-content (max-width: 440px) { + section .textRow[class] { + grid-template-columns: minmax(0, 1fr); + } + + .textRow > label { + padding-top: 0; + } + + .textRow > :last-child { + grid-column: 1; + } +} diff --git a/src/features/settings/pages/tools.tsx b/src/features/settings/pages/tools.tsx index 6d6acad71..013eb4a59 100644 --- a/src/features/settings/pages/tools.tsx +++ b/src/features/settings/pages/tools.tsx @@ -22,8 +22,9 @@ import { selectPage, setQuery } from "../model/staging"; import { MirrorPrefixRow } from "./DownloadSources"; import { MCP_SERVER_PAGE } from "./mcpServer"; import type { PageSpec } from "./spec"; -import { BoundToggle, Grid, Indented, PageLink, TableEditor } from "./workflowControls"; +import { BoundToggle, Grid, PageLink, TableEditor } from "./workflowControls"; import styles from "./Workflow.module.css"; +import terminalStyles from "./TerminalSettings.module.css"; import { tx } from "@/platform/i18n"; import { TERMINAL_MAX_FPS_OPTIONS } from "@/platform/workflowSettings"; @@ -62,29 +63,27 @@ const isMac = typeof navigator !== "undefined" && /Mac/i.test(navigator.platform // --------------------------------------------------------------------------- // Terminal -function TextSetting({ +function TerminalTextSetting({ k, label, placeholder, hint, - width = "wide", mono, }: { k: string; label: string; placeholder?: string; hint?: ReactNode; - width?: "wide" | "medium"; mono?: boolean; }) { const [value, set] = useSetting(k); const id = useId(); return ( - + set(e.target.value)} @@ -95,7 +94,7 @@ function TextSetting({ function StartDirectoryRow() { return ( - - set(e.target.value)} - /> - setOpen((o) => !o)} - /> +
+ set(e.target.value)} + /> + setOpen((o) => !o)} + /> + void browse()} + /> +
setOpen(false)} @@ -175,14 +184,6 @@ function ShellPathRow() { aria-label="Installed shells" items={shells.map((p) => ({ id: p, label: p, checked: quotePath(p) === value, run: () => set(quotePath(p)) }))} /> - void browse()} - /> ); } @@ -225,41 +226,45 @@ function TerminalKeybindingsLink() { function TerminalOptions() { return ( - - - - - - - - - } - right={ - <> - } - /> - - - - {isMac && } - - - } - /> + <> +
+ + + + + + + + + } + right={ + <> + } + /> + + + + {isMac && } + + } + /> +
+ + ); } @@ -285,9 +290,9 @@ function TerminalFont() { - - - +
+ + + + + +
+
- - - - - - - - - - + + + + + + +
); } @@ -636,11 +643,26 @@ export const TOOLS_PAGES: PageSpec[] = [ { kind: "custom", label: "Environment variables", keywords: ["env"], component: EnvRow }, ], }, + { + title: "Font", + options: [ + { + kind: "custom", + label: "Use editor font", + keywords: ["Font", "Show only monospaced fonts", "Size", "Line height", "Fallback font", "Column width"], + component: TerminalFont, + }, + ], + }, { title: "Application Settings", options: [ { kind: "custom", label: "Shell path", component: ShellPathRow }, - { kind: "text", key: "terminal.tabName", label: "Default Tab name", placeholder: "Local" }, + { + kind: "custom", + label: "Default Tab name", + component: () => , + }, { kind: "select", key: "terminal.appTitleAsTabName", @@ -673,17 +695,6 @@ export const TOOLS_PAGES: PageSpec[] = [ }, ], }, - { - title: "Font", - options: [ - { - kind: "custom", - label: "Use editor font", - keywords: ["Font", "Show only monospaced fonts", "Size", "Line height", "Fallback font", "Column width"], - component: TerminalFont, - }, - ], - }, ], }, {