diff --git a/apps/web/tests/settings-appearance.e2e.ts b/apps/web/tests/settings-appearance.e2e.ts index 0a79e44440..ec2451dec4 100644 --- a/apps/web/tests/settings-appearance.e2e.ts +++ b/apps/web/tests/settings-appearance.e2e.ts @@ -1,6 +1,7 @@ /** Built settings controls share materials and adapt their geometry to the viewport and pointer. */ import { fileURLToPath } from 'node:url' import { join } from 'node:path' +import { mkdir } from 'node:fs/promises' import { chromium, type Locator } from 'playwright' import { expect, it, onTestFinished, vi } from 'vitest' import type { AccountView } from '@deepseek-ai/dsh-deepseek-account/types' @@ -43,6 +44,85 @@ function rowGeometry(control: Locator) { }) } +it('shows complete English settings navigation across sidebar and narrow layouts', async () => { + const scaffold = await launchWebScaffold({ developerTools: false }) + onTestFinished(() => scaffold.close()) + const browser = await chromium.launch() + onTestFinished(() => browser.close()) + const page = await browser.newPage({ viewport: { width: 1200, height: 1000 }, locale: 'en-US' }) + await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) + await openSettings(page, 'en') + const dialog = page.getByRole('dialog', { name: 'Settings', exact: true }) + const navigation = dialog.getByRole('navigation') + const entries = navigation.getByRole('button') + const pluginsEntry = 'Plugins' + const screenshots = process.env.DSH_SETTINGS_NAV_SCREENSHOTS + if (screenshots) await mkdir(screenshots, { recursive: true }) + + for (const palette of ['light', 'dark'] as const) { + await page.setViewportSize({ width: 1200, height: 1000 }) + await navigation.getByRole('button', { name: 'General', exact: true }).click() + await dialog.getByRole('button', { name: palette === 'light' ? 'Light' : 'Dark', exact: true }).click() + await expect.poll(() => page.evaluate(() => document.body.hasAttribute('data-ds-dark-theme'))).toBe(palette === 'dark') + const themeTops = await Promise.all(['Light', 'Dark', 'System'].map(name => + dialog.getByRole('button', { name, exact: true }).evaluate(button => button.getBoundingClientRect().top))) + expect(Math.max(...themeTops) - Math.min(...themeTops), `${palette} desktop appearance row`).toBeLessThan(1) + if (screenshots) await dialog.screenshot({ path: join(screenshots, `english-general-${palette}.png`) }) + await navigation.getByRole('button', { name: 'Remote connection', exact: true }).click() + const selected = await navigation.getByRole('button', { name: 'Remote connection', exact: true }).elementHandle() + + for (const width of [1200, 768, 767, 390]) { + await page.setViewportSize({ width, height: 1000 }) + expect(await selected!.evaluate(button => button.isConnected && button === document.activeElement)).toBe(true) + expect(await selected!.getAttribute('aria-current')).toBe('true') + if (screenshots) await dialog.screenshot({ path: join(screenshots, `english-${width}-${palette}.png`) }) + + const labels = await entries.evaluateAll(buttons => buttons.map((button) => { + const label = button.lastElementChild! + const range = document.createRange() + range.selectNodeContents(label) + const text = range.getBoundingClientRect() + const box = label.getBoundingClientRect() + const style = getComputedStyle(button) + const icon = button.querySelector('svg')!.getBoundingClientRect() + return { + label: label.textContent, available: label.clientWidth, full: label.scrollWidth, + fits: label.scrollWidth <= label.clientWidth && text.left >= box.left - 1 && text.right <= box.right + 1, + fontSize: style.fontSize, lineHeight: style.lineHeight, iconWidth: icon.width, iconHeight: icon.height, + } + })) + expect(labels.filter(label => !label.fits), `${palette} ${width}px: ${JSON.stringify(labels)}`).toEqual([]) + for (const label of labels) { + expect(label).toMatchObject({ fontSize: '14px', lineHeight: '22px', iconWidth: 16, iconHeight: 16 }) + const button = navigation.getByRole('button', { name: label.label, exact: true }) + if (label.label === pluginsEntry) await button.focus() + else { + await button.click() + expect(await button.getAttribute('aria-current'), label.label).toBe('true') + } + const reachable = await button.evaluate((node) => { + const nav = node.closest('nav')!.getBoundingClientRect() + const text = document.createRange() + text.selectNodeContents(node.lastElementChild!) + const box = text.getBoundingClientRect() + return box.left >= nav.left - 1 && box.right <= nav.right + 1 + }) + expect(reachable, `${palette} ${width}px ${label.label}`).toBe(true) + expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(width) + if (screenshots && label.label === 'Agent presets' && width === 1200) { + await dialog.screenshot({ path: join(screenshots, `english-presets-${palette}.png`) }) + } + } + await navigation.getByRole('button', { name: 'Remote connection', exact: true }).click() + } + } + await navigation.getByRole('button', { name: pluginsEntry, exact: true }).click() + await expect.poll(() => dialog.count()).toBe(0) + const plugins = page.getByRole('navigation', { includeHidden: true }) + .getByRole('button', { name: 'Plugins', exact: true, includeHidden: true }) + await expect.poll(() => plugins.getAttribute('aria-current')).toBe('page') +}) + it('stacks font fields at narrow widths while keeping font-size controls on the right', async () => { const scaffold = await launchWebScaffold({ developerTools: false }) onTestFinished(() => scaffold.close()) diff --git a/packages/client/ui-settings-general/README.i18n.yaml b/packages/client/ui-settings-general/README.i18n.yaml index a56b70ab37..9979ff80ad 100644 --- a/packages/client/ui-settings-general/README.i18n.yaml +++ b/packages/client/ui-settings-general/README.i18n.yaml @@ -12,8 +12,8 @@ en: cd94b4a8dae32670 zh: 333b8603e77f92d7 /deepseek-ai-dsh-client-ui-settings-general/table-of-contents: - en: 83760d53b3ee5fb8 - zh: 30dd8802d4ffdcb7 + en: c70d04baca0434f1 + zh: e0361f83e76dd846 /deepseek-ai-dsh-client-ui-settings-general/use-this-package: en: 3f25debd8877c4bd zh: 51f0c1d6924550f1 diff --git a/packages/client/ui-settings-general/README.md b/packages/client/ui-settings-general/README.md index a12ef36089..efa781c748 100644 --- a/packages/client/ui-settings-general/README.md +++ b/packages/client/ui-settings-general/README.md @@ -22,7 +22,7 @@ Use this package to give the dsh web client a Settings panel, connection-recover ----- -The Settings panel uses a shared 800 × 800 layout, bounded by the viewport. Longer sections scroll inside the content column; the Account entry uses the account icon. The panel portals beside `#root` rather than inside it, so a macOS window drag region a chrome row declares later in document order cannot swallow its controls. +The Settings panel uses a shared 824 × 800 layout, bounded by the viewport, with a 212px navigation column that fits the built-in English section names. Longer sections scroll inside the content column; the Account entry uses the account icon. The panel portals beside `#root` rather than inside it, so a macOS window drag region a chrome row declares later in document order cannot swallow its controls. In browsers below 768px viewport width, the panel fills the viewport and navigation becomes a horizontal strip: the title shares the first row with the header's action and close seats, the registered section cells scroll sideways on the second, and the active section fills the rest. Cells grow into spare width and hold a minimum width, and the strip scrolls instead of truncating, so a registrant's label length or a longer section roster cannot wrap or clip a name; the selected cell carries initial focus, which brings it into the strip's view. Section content keeps a 16px inline padding at that width, and the 48px gutter separating a preference label from its control narrows with it. diff --git a/packages/client/ui-settings-general/README.zh.md b/packages/client/ui-settings-general/README.zh.md index d3db7fcf87..a921a5cdb0 100644 --- a/packages/client/ui-settings-general/README.zh.md +++ b/packages/client/ui-settings-general/README.zh.md @@ -22,7 +22,7 @@ kind: "package-reference" ----- -设置面板采用各页面共享的 800 × 800 布局,并受视口大小约束。较长的页面在内容栏内部滚动;账号入口使用账号图标。面板挂载在 `#root` 之外而不是其内部,这样在文档序上更靠后的 chrome 行所声明的 macOS 窗口拖拽区不会吞掉它的控件。 +设置面板采用各页面共享的 824 × 800 布局,并受视口大小约束;212px 宽的导航栏可完整显示内置分区的英文名称。较长的页面在内容栏内部滚动;账号入口使用账号图标。面板挂载在 `#root` 之外而不是其内部,这样在文档序上更靠后的 chrome 行所声明的 macOS 窗口拖拽区不会吞掉它的控件。 浏览器视口宽度低于 768px 时,面板铺满视口,导航变为横向条带:标题与头部操作、关闭入口同处第一行,注册的分区单元在第二行横向滚动,当前分区占满其余空间。单元会在富余宽度中伸展并保有一个最小宽度,条带滚动而不截断,因此注册方的文案长度或更多的分区都不会换行或裁掉名称;选中的单元承接初始焦点,从而被带入条带的可视范围。该宽度下分区内容保留 16px 的行内边距,分隔偏好标签与其控件的 48px 间距也随之收窄。 diff --git a/packages/client/ui-settings-general/src/client/SettingsRoot.module.css b/packages/client/ui-settings-general/src/client/SettingsRoot.module.css index 4bc579e344..8cdc335339 100644 --- a/packages/client/ui-settings-general/src/client/SettingsRoot.module.css +++ b/packages/client/ui-settings-general/src/client/SettingsRoot.module.css @@ -95,7 +95,7 @@ backdrop-filter: var(--dsw-mask-blur); } -/* Settings uses a shared 800×800 panel; longer sections scroll +/* Settings uses a shared 824×800 panel; longer sections scroll inside the options column; the navigation scrolls independently. One height for every section, taken from the viewport rather than the content, because a content-sized panel would resize under the pointer on every nav click. @@ -110,12 +110,12 @@ position: relative; z-index: 1; display: grid; - grid-template-columns: 188px minmax(0, 1fr); + grid-template-columns: 212px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: 'title header' 'nav options'; - width: 800px; + width: 824px; height: min(800px, calc(100vh - 2 * max(24px, var(--dsh-frame-overlay-top, 24px)))); max-width: calc(100vw - 48px); border-radius: var(--dsw-radius-panel); @@ -135,7 +135,7 @@ outline: none; } -/* Nav rail (figma .Setting-nav 501:29958): the 188px track's cells, pad +/* Nav rail (figma .Setting-nav 501:29958): the track's cells, pad (12,0), no own fill — the panel white shows through. */ .nav { grid-area: nav; @@ -168,7 +168,7 @@ overflow-y: auto; } -/* Nav cell (figma .Setting-nav-cell 501:29962): 164x40, r12, pad +/* Nav cell (figma .Setting-nav-cell 501:29962): 40px high, r12, pad (12,9,16,9), gap 8; label 14/400 lh22; selected fill #EBEEF2. */ .navCell { display: flex; diff --git a/packages/client/ui-theme/src/client/AppearanceRow.module.css b/packages/client/ui-theme/src/client/AppearanceRow.module.css index d2b301c8da..ec6251d9d4 100644 --- a/packages/client/ui-theme/src/client/AppearanceRow.module.css +++ b/packages/client/ui-theme/src/client/AppearanceRow.module.css @@ -25,7 +25,7 @@ /* Appearance cube (figma '.Selector Cube' 276x82, pad 20/32, centered * icon-over-label column, gap 4); flexed down from the figma width so all - * three sit on one row in the 800 panel, wrapping when narrower. */ + * three sit on one row at the panel's default width, wrapping when narrower. */ .themeCube { box-sizing: border-box; flex: 1 1 180px;