A local-first multi-agent app development platform, built on PenguinHarness
refactor(ui,web): W2 — the form controls move into the shared UI package (#897)
Yaowei Zheng4824e9e2f296
diff --git a/.agents/skills/penguin-harness-frontend/SKILL.md b/.agents/skills/penguin-harness-frontend/SKILL.mdindex e417c69a..3466c3be 100644--- a/.agents/skills/penguin-harness-frontend/SKILL.md+++ b/.agents/skills/penguin-harness-frontend/SKILL.md@@ -73,12 +73,12 @@ Two forms, and **a title decides between them, not taste**:> **The circled "?" may only appear beside a title. It must never stand alone on its own line.> Where it would stand alone, use the fold.**-- **A title is present** → `InfoPopover` (`components/ui/info-popover.tsx`). A circled "?"+- **A title is present** → `InfoPopover` (`@prismshadow/penguin-ui`). A circled "?"immediately after the section heading, the table column header, or the field label — the last ofthose via `Field`/`Input`/`Textarea`/`PasswordInput`'s `info` prop. The "?" is an *anchored*mark: it reads as help only because it modifies the title it sits against, and it borrows thattitle's meaning instead of restating it.-- **No title on the surface** → `HelpFold` (`components/ui/help-fold.tsx`). A compact row that+- **No title on the surface** → `HelpFold` (`@prismshadow/penguin-ui`). A compact row thatnames itself and expands its explanation inline underneath. This is the Agent settings tabs:their name lives in the tab bar and the panel does not repeat it, so a "?" at the top of thepanel would be a mark modifying nothing. A neighbouring `<Button>` does not rescue it — a@@ -103,7 +103,7 @@ siblings. Extend `TITLE_ELEMENTS` there if you add a component whose job is to bits first labelable descendant — so a "?" nested inside `Field`'s usual `<label>` would silentlyretarget the field's title from the input to the button. `Field` therefore has two layouts: without`info` it wraps in `<label>`; with `info` it splits the title out and associates it by `htmlFor`,-which is why the control needs an id. `test/info-popover.test.ts` guards this.+which is why the control needs an id. The UI package's `test/field.test.ts` guards this.## Icons@@ -137,9 +137,10 @@ the caret, the close cross or the collapse chevron.## Control sizes-One record: `sizeTextClass` in `components/ui/input.tsx`. Two rungs — `sm` is `text-xs`, `base` is-`text-base` — and `sizeClass` pairs each with its padding. `Select`'s menu rows, `OptionMenu`'s row-titles, `Textarea` and `FormPicker` all read it, so a rung moves the whole family at once.+One record: `sizeTextClass` in the UI package's `components/forms/input/input.tsx`. Two rungs —+`sm` is `text-xs`, `base` is `text-base` — and `sizeClass` pairs each with its padding. `Select`'s+menu rows, `OptionMenu`'s row titles, `Textarea` and `FormPicker` all read it, so a rung moves the+whole family at once.The rungs are **relative, not the pixel values their names suggest**. `FONT_SCALE_PX` (in`@prismshadow/penguin-ui/boot`, applied before first paint and by `theme.tsx`) sets the root font@@ -151,12 +152,12 @@ component's own rung are both single-class font-size utilities of equal specificwins depends on the order the CSS was generated in, not the order of classes in the string: thebuilt sheet emits `.text-base` before `.text-sm` before `.text-xs`, so a caller's `text-sm` silentlyloses to an `sm` control's `text-xs`, and a bracket value beats all three. (`input.tsx`'s-`errorClass` meets the same hazard on border and background and forces past it with `!`. A font-size has a `size` prop instead, so it does not need to.)+`errorClass` meets the same hazard on the border and the focus ring and forces past it with `!`. A+font size has a `size` prop instead, so it does not need to.)**No `text-[Npx]` on a control**: fixed px opts it out of the user's font-size setting altogether.-`rowDescClass.sm` (`option-menu.tsx`) is the single grandfathered exception — a row description sits-one step under a `text-xs` title, and there is no rung below `text-xs` to step down to.+There is no exception: an `OptionMenu` row's description at the `sm` tier shares the `text-xs` rung+with its title (there is no rung below it) and stands apart by its muted ink (`rowDescClass`).A form field takes `sm`: dense forms, dialogs and filter bars, which is near enough the whole app.`base` is for a standalone page holding two controls and nothing else, and is **passed by name** —@@ -208,7 +209,7 @@ exercise CJK behaviour. Comments, test names and every other string are English.## Popups: portal, do not absolutely positionAnything that overlays — a menu, a picker, an info popover — uses `usePortalPanel`-(`components/ui/use-portal-panel.ts`) and `createPortal` to `document.body`, positioned `fixed`+(`@prismshadow/penguin-ui`) and `createPortal` to `document.body`, positioned `fixed`against viewport coordinates. An in-place absolute panel is a DOM descendant of its trigger, so anyancestor with `overflow-x-auto` clips it vertically (the CSS spec forces the visible axis to `auto`when the other is not visible), and auditing every call site's ancestor chain is not a plan.diff --git a/changelog/unreleased/2026-09-30-ui-migration-w2.md b/changelog/unreleased/2026-09-30-ui-migration-w2.mdnew file mode 100644index 00000000..4a8805ca--- /dev/null+++ b/changelog/unreleased/2026-09-30-ui-migration-w2.md@@ -0,0 +1,33 @@+# The form controls move into the shared UI package++- **Date:** 2026-09-30+- **Type:** refactor+- **Scope:** `ui`, `web`, `ui-gallery`++[中文版](2026-09-30-ui-migration-w2.zh.md)++W2 of the UI-package migration moves the Web App's form controls into `@prismshadow/penguin-ui`, and adds the few controls the app kept spelling by hand.++## What moved++- **The shared menu panel** (`menuPanelClass`, `menuRowClass`, `menuRowTone`, `ChoiceCheck`): the panel, row states and check mark every menu and picker shares.+- **Fields and inputs:** `Field` with its label, hint and error, `RequiredMark`, `Input` and `Textarea` (with in-field affixes), `PasswordInput`.+- **Pickers:** `Select`, `OptionMenu`, `PickerList` (the search box over a keyboard-walkable list, lifted from the model picker), `Segmented`, `Switch`, `SwatchPicker` (the accent swatches), and the settings rows `PrefRow`, `SettingRow` and `SettingsSection`.+- **Overlays pulled forward from W3:** `usePortalPanel`, `InfoPopover` (the "?" beside a label) and `HelpFold`.+- **New controls:** `Checkbox` (with an indeterminate state), `Radio` and `RadioGroup`, `SearchInput` (field, panel and menu shapes with a clear button), and `ToggleRow` in place of eight hand-built switch rows.+- **On code that came from main during the migration:** the model picker dialog's search field and the sidebar's session search are `SearchInput` (a ref reaches its input, which the search shortcut uses); the built-in browser's clear-data and import dialogs use `Checkbox` and `Radio`.++## Details++- The package's own accessibility fallbacks gain show/hide-password, clear-search and "more info" strings, supplied by the Web App in the interface language.+- `FormPicker` stays in the Web App until W3 moves the dropdown it wraps.++## Visible changes in the default theme (Primer)++- Checkboxes and radio buttons are drawn by the theme (14 px, accent-filled) instead of the browser's native widgets.+- Search boxes share one look with a clear button; in the skill and machine pickers and the model picker dialog the first Esc clears the query and the second closes the picker.+- Menu rows: the hover and current-choice fill is one step fainter, and option ink one step darker.+- Field labels one step lighter; an error drops its red fill and keeps a red outline.+- Segmented controls have 4 px of padding (4 px taller); in dark the selected segment is darker.+- Swatches no longer grow on hover; they take a border instead.+- A handful of 11 px captions (option descriptions, the proxy probe URL, schedule id suffixes) become 12 px.diff --git a/changelog/unreleased/2026-09-30-ui-migration-w2.zh.md b/changelog/unreleased/2026-09-30-ui-migration-w2.zh.mdnew file mode 100644index 00000000..d6366208--- /dev/null+++ b/changelog/unreleased/2026-09-30-ui-migration-w2.zh.md@@ -0,0 +1,33 @@+# 表单控件迁入共享 UI 包++- **Date:** 2026-09-30+- **Type:** refactor+- **Scope:** `ui`, `web`, `ui-gallery`++[English](2026-09-30-ui-migration-w2.md)++UI 包迁移的 W2 把 Web App 的表单控件搬进 `@prismshadow/penguin-ui`,并补上应用里一直手写的几种控件。++## 迁入的内容++- **共享菜单面板**(`menuPanelClass`、`menuRowClass`、`menuRowTone`、`ChoiceCheck`):所有菜单与选择器共用的面板、行状态与勾选标记。+- **字段与输入框**:`Field` 及其标签、提示与错误,`RequiredMark`,`Input` 与 `Textarea`(支持框内前后缀),`PasswordInput`。+- **选择器**:`Select`、`OptionMenu`、`PickerList`(从模型选择器中抽出的「搜索框 + 可键盘遍历的列表」)、`Segmented`、`Switch`、`SwatchPicker`(强调色色块),以及设置行 `PrefRow`、`SettingRow` 与 `SettingsSection`。+- **从 W3 提前的浮层**:`usePortalPanel`、`InfoPopover`(标签旁的「?」)与 `HelpFold`。+- **新增控件**:`Checkbox`(含半选态)、`Radio` 与 `RadioGroup`、`SearchInput`(字段、面板、菜单三种形态,带清空按钮),以及取代八处手写开关行的 `ToggleRow`。+- **迁移期间 main 合入的代码**:模型选择对话框的搜索框与侧栏的会话搜索改用 `SearchInput`(ref 可直达其输入框,搜索快捷键依赖这一点);内置浏览器的清除数据与导入对话框改用 `Checkbox` 与 `Radio`。++## 细节++- 包自带的无障碍兜底文案新增「显示/隐藏密码」「清空搜索」「更多信息」,由 Web App 按界面语言提供。+- `FormPicker` 暂留在 Web App,等 W3 迁移它包裹的下拉组件。++## 通用主题下可见的变化++- 复选框与单选按钮由主题绘制(14 px,强调色填充),不再是浏览器原生控件。+- 搜索框统一样式并带清空按钮;技能与机器选择器以及模型选择对话框里第一次按 Esc 清空搜索词,第二次才关闭。+- 菜单行:悬停与当前项底色浅一档,选项文字深一档。+- 字段标签浅一档;出错时去掉红色底,只保留红色边框。+- 分段控件内边距改为 4 px(高 4 px);深色下选中段更深。+- 色块悬停不再放大,改为加一圈边框。+- 若干 11 px 的说明文字(选项描述、代理探测地址、定时任务的 id 后缀)改为 12 px。diff --git a/packages/ui-gallery/src/library/boards/dialogs.tsx b/packages/ui-gallery/src/library/boards/dialogs.tsxindex 36cc7bec..89066650 100644--- a/packages/ui-gallery/src/library/boards/dialogs.tsx+++ b/packages/ui-gallery/src/library/boards/dialogs.tsx@@ -1,9 +1,8 @@/** 对话框: Modal, ConfirmModal, Drawer and Sheet, each opened from a button and closed as the app closes it. */import { useState } from "react";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input } from "@prismshadow/penguin-ui";import { ConfirmModal } from "../../../../web/src/components/ui/confirm-modal";import { Drawer } from "../../../../web/src/components/ui/drawer";-import { Input } from "../../../../web/src/components/ui/input";import { Modal } from "../../../../web/src/components/ui/modal";import { Sheet } from "../../../../web/src/components/ui/sheet";import type { SheetSnap } from "../../../../web/src/components/ui/sheet";diff --git a/packages/ui-gallery/src/library/boards/inputs.tsx b/packages/ui-gallery/src/library/boards/inputs.tsxindex b1627dd8..f68dfdc2 100644--- a/packages/ui-gallery/src/library/boards/inputs.tsx+++ b/packages/ui-gallery/src/library/boards/inputs.tsx@@ -1,10 +1,21 @@-/** 输入与表单: Input, Textarea and PasswordInput on the shared field scaffolding, with hint, info and error. */+/**+ * 输入与表单: Input, Textarea and PasswordInput on the shared field scaffolding, with hint, info,+ * error and in-field affixes; the search box in its three shapes; checkboxes and radio groups.+ */import { useState } from "react";-import { Input, Textarea } from "../../../../web/src/components/ui/input";-import { PasswordInput } from "../../../../web/src/components/ui/password-input";+import {+ Checkbox,+ Input,+ PasswordInput,+ RadioGroup,+ SearchInput,+ Textarea,+} from "@prismshadow/penguin-ui";import { BoardGroup } from "../../foundations/shared";import { useGallery } from "../../state";+type ImportMode = "skip" | "overwrite" | "replace";+export function InputsBoard() {const { S } = useGallery();const t = S.library.inputs;@@ -13,6 +24,20 @@ export function InputsBoard() {const [prompt, setPrompt] = useState("");const [params, setParams] = useState(t.monoValue);const [password, setPassword] = useState("");+ const [context, setContext] = useState("200000");+ const [price, setPrice] = useState("15.00");+ const [fieldQuery, setFieldQuery] = useState("");+ const [iconQuery, setIconQuery] = useState("");+ const [panelQuery, setPanelQuery] = useState("");+ const [menuQuery, setMenuQuery] = useState("");+ const [clearKey, setClearKey] = useState(false);+ const [plugins, setPlugins] = useState<"none" | "some" | "all">("some");+ const [mode, setMode] = useState<ImportMode>("skip");+ const modes = [+ { value: "skip", label: t.radioSkip, hint: t.radioSkipHint },+ { value: "overwrite", label: t.radioOverwrite, hint: t.radioOverwriteHint },+ { value: "replace", label: t.radioReplace, hint: t.radioReplaceHint },+ ] as const;return (<div className="gf-board"><BoardGroup title={t.basics}>@@ -47,6 +72,26 @@ export function InputsBoard() {<Input label={t.small} size="sm" placeholder={t.small} /></div></BoardGroup>+ <BoardGroup title={t.affix}>+ <div className="lib-stack">+ <Input+ label={t.affixContext}+ inputMode="numeric"+ className="font-mono"+ affix={{ trailing: t.affixToken }}+ value={context}+ onChange={(event) => setContext(event.target.value)}+ />+ <Input+ label={t.affixPrice}+ inputMode="decimal"+ className="text-right font-mono"+ affix={{ leading: t.affixCurrency, trailing: t.affixUnit }}+ value={price}+ onChange={(event) => setPrice(event.target.value)}+ />+ </div>+ </BoardGroup><BoardGroup title={t.textarea}><div className="lib-stack"><Textarea@@ -75,6 +120,67 @@ export function InputsBoard() {/></div></BoardGroup>+ <BoardGroup title={t.search}>+ <div className="lib-stack">+ <SearchInput+ value={fieldQuery}+ onChange={setFieldQuery}+ placeholder={t.searchField}+ aria-label={t.searchField}+ />+ <SearchInput+ icon+ value={iconQuery}+ onChange={setIconQuery}+ placeholder={t.searchIcon}+ aria-label={t.searchIcon}+ />+ <SearchInput+ variant="panel"+ value={panelQuery}+ onChange={setPanelQuery}+ placeholder={t.searchPanel}+ aria-label={t.searchPanel}+ />+ <SearchInput+ variant="menu"+ value={menuQuery}+ onChange={setMenuQuery}+ placeholder={t.searchMenu}+ aria-label={t.searchMenu}+ />+ </div>+ </BoardGroup>+ <BoardGroup title={t.checkboxes}>+ <div className="lib-stack">+ <Checkbox+ checked={clearKey}+ onChange={setClearKey}+ label={t.checkboxLabel}+ hint={t.checkboxHint}+ />+ {/* A summary box: some → all → none → all, the way a "select all" row cycles. */}+ <Checkbox+ checked={plugins === "all"}+ indeterminate={plugins === "some"}+ onChange={(on) => setPlugins(on ? "all" : "none")}+ label={t.checkboxAll}+ />+ <Checkbox checked disabled onChange={() => {}} label={t.checkboxDisabled} />+ </div>+ </BoardGroup>+ <BoardGroup title={t.radios}>+ <div className="lib-stack">+ <RadioGroup label={t.radioLabel} options={modes} value={mode} onChange={setMode} />+ <RadioGroup+ label={t.radioInline}+ orientation="horizontal"+ options={modes.map(({ value, label }) => ({ value, label }))}+ value={mode}+ onChange={setMode}+ />+ </div>+ </BoardGroup></div>);}diff --git a/packages/ui-gallery/src/library/boards/pickers.tsx b/packages/ui-gallery/src/library/boards/pickers.tsxindex 6be95046..1a4d2a92 100644--- a/packages/ui-gallery/src/library/boards/pickers.tsx+++ b/packages/ui-gallery/src/library/boards/pickers.tsx@@ -1,21 +1,39 @@-/** 选择器: the app's Select, Segmented, Switch, OptionMenu and Dropdown, each holding its own choice. */+/**+ * 选择器: the package's Select, Segmented, Switch, ToggleRow, SwatchPicker and OptionMenu, and the+ * app's Dropdown, each holding its own choice.+ */import { useState } from "react";-import { Button, ChevronDown } from "@prismshadow/penguin-ui";+import {+ ACCENT_PRESETS,+ Button,+ ChevronDown,+ OptionMenu,+ Segmented,+ Select,+ SwatchPicker,+ Switch,+ ToggleRow,+} from "@prismshadow/penguin-ui";import { Dropdown, menuItemClass } from "../../../../web/src/components/ui/dropdown";-import { OptionMenu } from "../../../../web/src/components/ui/option-menu";-import { Segmented } from "../../../../web/src/components/ui/segmented";-import { Select } from "../../../../web/src/components/ui/select";-import { Switch } from "../../../../web/src/components/ui/switch";import { BoardGroup } from "../../foundations/shared";import { useGallery } from "../../state";export function PickersBoard() {- const { S } = useGallery();+ const { S, state } = useGallery();const t = S.library.pickers;const [model, setModel] = useState(t.options[0] ?? "");const [segment, setSegment] = useState(t.segments[0] ?? "");const [notify, setNotify] = useState(true);const [shortNames, setShortNames] = useState(false);+ const [launcher, setLauncher] = useState(true);+ const [proxy, setProxy] = useState(false);+ const [memory, setMemory] = useState(true);+ const swatches = ACCENT_PRESETS[state.theme].map((preset) => ({+ value: preset.id as string,+ color: preset.swatch,+ label: preset.id,+ }));+ const [swatch, setSwatch] = useState(swatches[0]?.value ?? "");const [permission, setPermission] = useState<string | null>(t.choices[1]?.value ?? null);const [menuOpen, setMenuOpen] = useState(false);return (@@ -60,6 +78,42 @@ export function PickersBoard() {</label></div></BoardGroup>+ <BoardGroup title={t.toggleRows}>+ <div className="lib-stack">+ {/* The three frames: a ruled settings list, a spaced stack, a panel's master switch. */}+ <div className="divide-y divide-line-muted">+ <ToggleRow+ label={t.toggleRowLabel}+ info={t.toggleRowInfo}+ checked={launcher}+ onChange={setLauncher}+ />+ <ToggleRow label={t.switchOff} checked={shortNames} onChange={setShortNames} />+ </div>+ <ToggleRow+ variant="plain"+ label={t.togglePlainLabel}+ hint={t.togglePlainHint}+ checked={proxy}+ onChange={setProxy}+ />+ <ToggleRow+ variant="card"+ label={t.toggleCardLabel}+ checked={memory}+ onChange={setMemory}+ />+ </div>+ </BoardGroup>+ <BoardGroup title={t.swatches}>+ <div className="lib-row">+ <SwatchPicker+ options={swatches}+ value={swatches.some((option) => option.value === swatch) ? swatch : ""}+ onChange={setSwatch}+ />+ </div>+ </BoardGroup><BoardGroup title={t.optionMenu}><div className="lib-stack"><OptionMenudiff --git a/packages/ui-gallery/src/strings-en.ts b/packages/ui-gallery/src/strings-en.tsindex 6bcbf4b8..14fdc8a5 100644--- a/packages/ui-gallery/src/strings-en.ts+++ b/packages/ui-gallery/src/strings-en.ts@@ -398,11 +398,12 @@ export const en: GalleryStrings = {inputs: {title: "Inputs and forms",description:- "Input, textarea, password and the field scaffolding: label, hint, info and error.",+ "Input, textarea, password, search, checkbox and radio on the field scaffolding: label, hint, info and error.",},pickers: {title: "Pickers",- description: "Select, segmented control, switch, option menu and dropdown.",+ description:+ "Select, segmented control, switch and toggle rows, swatches, option menu and dropdown.",},toasts: {title: "Toasts",@@ -512,6 +513,31 @@ export const en: GalleryStrings = {monoValue: "temperature: 0.2\nmax_tokens: 4096",password: "Password",passwordHint: "At least 12 characters.",+ affix: "In-field affixes",+ affixContext: "Context window",+ affixToken: "Token",+ affixPrice: "Output price",+ affixCurrency: "$",+ affixUnit: "/M tok",+ search: "Search boxes",+ searchField: "Search plugins",+ searchIcon: "Search sessions",+ searchPanel: "Filter files",+ searchMenu: "Search skills",+ checkboxes: "Checkboxes",+ checkboxLabel: "Clear the stored key",+ checkboxHint: "Applied when you save.",+ checkboxAll: "All plugins",+ checkboxDisabled: "Locked by the administrator",+ radios: "Radio groups",+ radioLabel: "When a name already exists",+ radioSkip: "Skip it",+ radioSkipHint: "Keep what is there; nothing is lost.",+ radioOverwrite: "Overwrite it",+ radioOverwriteHint: "Replace the files that share a name.",+ radioReplace: "Replace everything",+ radioReplaceHint: "Remove what the import does not contain.",+ radioInline: "On one line",},pickers: {select: "Select",@@ -523,6 +549,14 @@ export const en: GalleryStrings = {switchLabel: "Notify when done",switchHint: "A system notification when a Task ends.",switchOff: "Short tool names",+ toggleRows: "Toggle rows",+ toggleRowLabel: "Show the launcher",+ toggleRowInfo:+ "The round button in the workbench corner that fans out the terminal, files and preview.",+ togglePlainLabel: "Use the proxy for the app's requests",+ togglePlainHint: "Takes effect once saved.",+ toggleCardLabel: "Enable memory",+ swatches: "Swatches",optionMenu: "Option menu",optionLabel: "Permission",choices: [diff --git a/packages/ui-gallery/src/strings.ts b/packages/ui-gallery/src/strings.tsindex a8f14303..dff671b2 100644--- a/packages/ui-gallery/src/strings.ts+++ b/packages/ui-gallery/src/strings.ts@@ -400,9 +400,13 @@ export const zh = {},inputs: {title: "输入与表单",- description: "文本框、多行文本、密码框与字段脚手架:标签、提示、说明与错误。",+ description:+ "文本框、多行文本、密码框、搜索框、复选框与单选框,以及字段脚手架:标签、提示、说明与错误。",+ },+ pickers: {+ title: "选择器",+ description: "下拉选择、分段控件、开关与开关行、色板、选项菜单与下拉菜单。",},- pickers: { title: "选择器", description: "下拉选择、分段控件、开关、选项菜单与下拉菜单。" },toasts: {title: "提示弹窗",description: "完成操作后的弹出提示:成功、信息、注意与错误,按按钮触发。",@@ -493,6 +497,31 @@ export const zh = {monoValue: "temperature: 0.2\nmax_tokens: 4096",password: "密码",passwordHint: "至少 12 个字符。",+ affix: "字段内前后缀",+ affixContext: "上下文窗口",+ affixToken: "Token",+ affixPrice: "输出价格",+ affixCurrency: "¥",+ affixUnit: "/M tok",+ search: "搜索框",+ searchField: "搜索插件",+ searchIcon: "搜索会话",+ searchPanel: "筛选文件",+ searchMenu: "搜索技能",+ checkboxes: "复选框",+ checkboxLabel: "清除已保存的密钥",+ checkboxHint: "保存时生效。",+ checkboxAll: "全部插件",+ checkboxDisabled: "已被管理员锁定",+ radios: "单选组",+ radioLabel: "名称已存在时",+ radioSkip: "跳过",+ radioSkipHint: "保留原有内容,不会丢失任何东西。",+ radioOverwrite: "覆盖",+ radioOverwriteHint: "替换同名的文件。",+ radioReplace: "全部替换",+ radioReplaceHint: "删除导入中没有的内容。",+ radioInline: "单行排列",},pickers: {select: "下拉选择",@@ -504,6 +533,13 @@ export const zh = {switchLabel: "完成时通知",switchHint: "Task 结束时弹出系统通知。",switchOff: "工具短名",+ toggleRows: "开关行",+ toggleRowLabel: "显示启动球",+ toggleRowInfo: "工作台角落的圆形按钮,点开后展开终端、文件与预览。",+ togglePlainLabel: "为应用请求使用代理",+ togglePlainHint: "保存后生效。",+ toggleCardLabel: "开启记忆",+ swatches: "色板",optionMenu: "选项菜单",optionLabel: "权限",choices: [diff --git a/packages/ui/src/components/forms/checkbox/checkbox.tsx b/packages/ui/src/components/forms/checkbox/checkbox.tsxnew file mode 100644index 00000000..e1e8f539--- /dev/null+++ b/packages/ui/src/components/forms/checkbox/checkbox.tsx@@ -0,0 +1,130 @@+/**+ * The checkbox: a real `<input type="checkbox">` — keyboard, focus, form semantics and the+ * screen-reader state all stay the browser's — drawn as a small token box so it follows the theme+ * (the accent fill when on, the control line when off) instead of each browser's own widget.+ *+ * `indeterminate` is the "some but not all" state of a box that summarises others. HTML has no+ * attribute for it, only a DOM property, so the component sets the property on the element (which+ * is what assistive tech reads as "mixed") and draws the dash itself.+ *+ * With a `label` the box and its text sit in one `<label>`, so the whole row toggles and the text+ * names the control; a `hint` under the label is tied to the box by `aria-describedby`. Without a+ * label the caller names the box (`aria-label`).+ */+import { useCallback, useId } from "react";+import type { InputHTMLAttributes, ReactNode } from "react";+import { sizeTextClass } from "../input/input";+import type { ControlSize } from "../input/input";++export interface CheckboxProps extends Omit<+ InputHTMLAttributes<HTMLInputElement>,+ "type" | "size" | "checked" | "defaultChecked" | "onChange" | "children"+> {+ checked: boolean;+ onChange: (checked: boolean) => void;+ /** Some but not all of what this box stands for is on: draws a dash and reads as "mixed". */+ indeterminate?: boolean;+ /** The visible name; the whole row toggles. Omit it and name the box with `aria-label`. */+ label?: ReactNode;+ /** A line under the label, announced as the box's description. */+ hint?: ReactNode;+ /** The label's text rung; the box keeps one size and centres on the label's first line. */+ size?: ControlSize;+}++const BOX =+ "size-3.5 shrink-0 appearance-none rounded-sm border transition-colors duration-150 " ++ "disabled:cursor-not-allowed " ++ "focus-visible:[outline:var(--ui-focus-ring)] " ++ "focus-visible:[outline-offset:var(--ui-focus-ring-offset)]";++const BOX_OFF = "border-line-emphasis bg-surface hover:border-fg-subtle";+const BOX_ON = "border-accent bg-accent";++/**+ * The check and the dash, drawn at 12px on a 12px grid of their own inside the 14px box: like the+ * caret and the close cross, a two-stroke mark stays crisp only when its grid and its size agree.+ */+function BoxMark({ mixed }: { mixed: boolean }) {+ return (+ <svg+ width="12"+ height="12"+ viewBox="0 0 12 12"+ fill="none"+ stroke="currentColor"+ strokeWidth="1.5"+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden+ className="pointer-events-none absolute inset-0 m-auto text-accent-fg"+ >+ <path d={mixed ? "M3 6h6" : "M2.6 6.2l2.2 2.2 4.6-4.8"} />+ </svg>+ );+}++export function Checkbox({+ checked,+ onChange,+ indeterminate = false,+ label,+ hint,+ size = "sm",+ disabled,+ className = "",+ "aria-describedby": describedBy,+ ...rest+}: CheckboxProps) {+ const hintId = useId();+ // The property, not an attribute: there is no `indeterminate` attribute to render.+ const syncIndeterminate = useCallback(+ (el: HTMLInputElement | null) => {+ if (el !== null) el.indeterminate = indeterminate;+ },+ [indeterminate],+ );+ const on = checked || indeterminate;+ const describedByIds =+ [describedBy, hint != null ? hintId : undefined].filter(Boolean).join(" ") || undefined;+ // A bare box carries the caller's class and dims itself; with a label, the row does both.+ const bare = label === undefined;+ const box = (+ <span+ className={`relative inline-flex shrink-0 items-center ${+ bare ? `${disabled ? "opacity-60" : ""} ${className}` : ""+ }`}+ >+ <input+ ref={syncIndeterminate}+ type="checkbox"+ checked={checked}+ disabled={disabled}+ aria-describedby={describedByIds}+ onChange={(event) => onChange(event.target.checked)}+ className={`${BOX} ${on ? BOX_ON : BOX_OFF}`}+ {...rest}+ />+ {on && <BoxMark mixed={indeterminate} />}+ </span>+ );+ if (bare) return box;+ return (+ <label+ className={`inline-flex items-start gap-1.5 ${sizeTextClass[size]} ${+ disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"+ } ${className}`}+ >+ {/* One line tall, whatever the rung: the box centres on the label's first line. */}+ <span className="flex h-[1lh] shrink-0 items-center">{box}</span>+ <span className="min-w-0">+ <span className="block">{label}</span>+ {hint != null && (+ <span id={hintId} className="block text-fg-muted">+ {hint}+ </span>+ )}+ </span>+ </label>+ );+}diff --git a/packages/web/src/components/ui/field.tsx b/packages/ui/src/components/forms/field/field.tsxsimilarity index 53%rename from packages/web/src/components/ui/field.tsxrename to packages/ui/src/components/forms/field/field.tsxindex 89ff25e6..a64f2466 100644--- a/packages/web/src/components/ui/field.tsx+++ b/packages/ui/src/components/forms/field/field.tsx@@ -1,61 +1,26 @@/**- * Shared field scaffolding: the label / hint / error text and the wrapping- * <label>, plus the class strings for a control's "look" and a menu row. Every- * form control (Input, Textarea, Select, OptionMenu, PasswordInput) and every- * form that shows a field error builds on these, instead of the five-plus+ * Shared field scaffolding: the label / hint / error text and the wrapping `<label>`, plus the+ * class string for a control's look. Every form control (Input, Textarea, Select, OptionMenu,+ * PasswordInput) and every form that shows a field error builds on these, instead of the* near-identical copies that used to live in each control and call site.*/import type { ReactNode } from "react";-import { CheckIcon } from "@prismshadow/penguin-ui";-import { InfoPopover } from "./info-popover";+import { InfoPopover } from "../../overlays/info-popover/info-popover";/**- * The control "look" shared by Input, Select and OptionMenu: rounded box, gray- * border that darkens on hover, brand focus ring, dark-mode variants. Excludes- * layout (width/flex), text size, placeholder and disabled styling — each- * control appends what it needs.+ * The control look shared by Input, Select and OptionMenu: a rounded box on the surface whose line+ * darkens on hover and on focus, with the theme's input focus ring. Excludes layout (width/flex),+ * text size, placeholder and disabled styling — each control appends what it needs.+ *+ * The ring is the theme's own (`--ui-focus-ring-input`) rather than a Tailwind ring, so a theme+ * that draws focus differently — an inset accent line, a softer halo — reaches every text control+ * at once.*/export const controlBase =- "rounded-md border border-gray-300 bg-white text-gray-900 " ++ "rounded-md border border-line-emphasis bg-surface text-fg " +"transition-[border-color,box-shadow] duration-200 " +- "hover:border-gray-400 focus:border-gray-500 focus:outline-none focus:ring-2 focus:ring-gray-400/30 " +- "dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100 " +- "dark:hover:border-gray-600 dark:focus:border-gray-400 dark:focus:ring-gray-500/30";--/** Base padding/alignment/transition for a menu row (Select, OptionMenu, and the chat composer menus); callers add flex/block and the hover/selected colors. */-export const menuRowClass = "w-full px-3 py-1.5 text-left transition-colors duration-150";--/**- * The floating panel every picker and menu opens — Select's surface: a hairline box on the- * overlay layer, one shadow step, a little padding above the first row and below the last.- * Callers add position, width, z-layer and max height, and the `ui-glass` hook in the- * component that opens the panel (a hook belongs to its host component, not to a string).- */-export const menuPanelClass =- "anim-pop overflow-y-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900";--/**- * A menu row's ink and fill: an action row, or a choice that is not the current one, fills on- * hover; the current choice is filled and set in the medium weight (and carries ChoiceCheck).- * The same two states in every picker, so a choice reads the same wherever it is made.- */-export function menuRowTone(selected = false): string {- return selected- ? "bg-gray-100 font-medium text-gray-900 dark:bg-gray-800 dark:text-gray-100"- : "text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800";-}--/**- * The current choice's mark, Select's check. It sits in a fixed slot at the row's end, so the- * rows of one list align whether or not they carry it.- */-export function ChoiceCheck({ on }: { on: boolean }) {- return (- <span aria-hidden className="flex w-3 shrink-0 justify-center">- {on && <CheckIcon className="text-gray-500 dark:text-gray-400" />}- </span>- );-}+ "hover:border-fg-subtle focus:border-fg-muted focus:outline-none " ++ "focus:[box-shadow:var(--ui-focus-ring-input)]";/*** The red "*" that marks a field as required, and the only place it is spelled. A field is@@ -71,13 +36,13 @@ export function ChoiceCheck({ on }: { on: boolean }) {export function RequiredMark({ label }: { label?: string }) {if (label === undefined) {return (- <span className="ml-0.5 text-red-500 dark:text-red-400" aria-hidden>+ <span className="ml-0.5 text-tone-danger-fg" aria-hidden>*</span>);}return (- <span className="ml-0.5 text-red-500 dark:text-red-400">+ <span className="ml-0.5 text-tone-danger-fg"><span aria-hidden>*</span><span className="sr-only">{label}</span></span>@@ -101,7 +66,7 @@ export function FieldLabel({/** Own the line (the default). Off when the label shares a flex row with an info trigger. */block?: boolean;}) {- const className = `text-xs font-semibold text-gray-600 dark:text-gray-400${block ? " mb-1 block" : ""}`;+ const className = `text-xs font-semibold text-fg-muted${block ? " mb-1 block" : ""}`;const content = (<>{children}@@ -117,49 +82,26 @@ export function FieldLabel({);}+/** Formatting guidance under a control: read while typing, so it stays on screen. */export function FieldHint({ children }: { children: ReactNode }) {- return <span className="mt-1 block text-xs text-gray-500 dark:text-gray-500">{children}</span>;+ return <span className="mt-1 block text-xs text-fg-muted">{children}</span>;}/**- * Field-level error text: placed directly below the offending input (the input itself- * is highlighted red via the control's error/invalid state). role="alert" announces the- * message to assistive tech the moment it appears; `id` is the anchor the control's- * aria-describedby points at, so AT users can also find *what* is wrong from the input.+ * Field-level error text: placed directly below the offending input (the input itself is marked+ * red through the control's error/invalid state). role="alert" announces the message to assistive+ * tech the moment it appears; `id` is the anchor the control's aria-describedby points at, so AT+ * users can also find *what* is wrong from the input.*/export function FieldError({ id, children }: { id?: string; children: ReactNode }) {return (- <span id={id} role="alert" className="mt-1 block text-xs text-red-600 dark:text-red-400">+ <span id={id} role="alert" className="mt-1 block text-xs text-tone-danger-fg">{children}</span>);}-/**- * Standard vertical field layout: an optional bold label above the control, and- * below it a red error if present, otherwise a gray hint. Renders the bare- * control (no wrapper) when there's no label/hint/error, so a caller can drop it- * into a toolbar or table cell unchanged.- *- * Two layouts, and which one applies is decided by `info`. Without it the whole field is- * wrapped in a `<label>`, which associates the title with the control implicitly. With it the- * title has to move out of that wrapper: an info trigger is a `<button>`, a `<button>` is a- * labelable element, and the first labelable descendant is the one a wrapping `<label>` names —- * so nesting the trigger would silently retarget the title from the input to the "?" button.- * The info layout therefore drops the wrapper and associates the title by `htmlFor`, which is- * why it needs `controlId`.- */-export function Field({- label,- hint,- error,- errorId,- required,- info,- infoLabel,- controlId,- children,-}: {+export interface FieldProps {label?: ReactNode;hint?: ReactNode;error?: ReactNode;@@ -179,7 +121,32 @@ export function Field({/** id of the control `info`'s label points at; required for `info` to render. */controlId?: string;children: ReactNode;-}) {+}++/**+ * Standard vertical field layout: an optional bold label above the control, and below it a red+ * error if present, otherwise a hint. Renders the bare control (no wrapper) when there's no+ * label/hint/error, so a caller can drop it into a toolbar or table cell unchanged.+ *+ * Two layouts, and which one applies is decided by `info`. Without it the whole field is wrapped+ * in a `<label>`, which associates the title with the control implicitly. With it the title has+ * to move out of that wrapper: an info trigger is a `<button>`, a `<button>` is a labelable+ * element, and the first labelable descendant is the one a wrapping `<label>` names — so nesting+ * the trigger would silently retarget the title from the input to the "?" button. The info layout+ * therefore drops the wrapper and associates the title by `htmlFor`, which is why it needs+ * `controlId`.+ */+export function Field({+ label,+ hint,+ error,+ errorId,+ required,+ info,+ infoLabel,+ controlId,+ children,+}: FieldProps) {if (!label && !hint && !error && !info) return <>{children}</>;const below = error ? (<FieldError id={errorId}>{error}</FieldError>diff --git a/packages/web/src/components/ui/input.tsx b/packages/ui/src/components/forms/input/input.tsxsimilarity index 51%rename from packages/web/src/components/ui/input.tsxrename to packages/ui/src/components/forms/input/input.tsxindex 0efd08d9..100e39b9 100644--- a/packages/web/src/components/ui/input.tsx+++ b/packages/ui/src/components/forms/input/input.tsx@@ -1,17 +1,23 @@/**- * Text input component: optional label and hint/error text; rounded corners with- * a hover border darken and brand focus-ring transition. Shares the control look- * and the label/hint/error scaffolding with the other form controls via field.tsx.+ * Text controls: `Input` and `Textarea`, with an optional label and hint/error text, on the+ * shared control look (field.tsx). An `Input` may draw a short affix inside its box — a currency+ * symbol before the value, a unit after it — and reserves exactly the room the affix takes.*/-import { forwardRef, useId } from "react";-import type { InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from "react";-import { Field, controlBase } from "./field";+import { forwardRef, useCallback, useId, useState } from "react";+import type {+ CSSProperties,+ InputHTMLAttributes,+ ReactNode,+ RefCallback,+ TextareaHTMLAttributes,+} from "react";+import { Field, controlBase } from "../field/field";-// Adds width, placeholder and disabled styling on top of the shared control look; each of Input/Textarea appends its own font size and padding (see their size).+// Adds width, placeholder and disabled styling on top of the shared control look; each of+// Input/Textarea appends its own font size and padding (see their size).const baseClass =`w-full ${controlBase} ` +- "placeholder:text-gray-400 disabled:cursor-not-allowed disabled:opacity-60 " +- "dark:placeholder:text-gray-500";+ "placeholder:text-fg-subtle disabled:cursor-not-allowed disabled:opacity-60";/*** Size tier: sm is the form rung — dense forms, dialogs, filter bars, and what almost every@@ -29,8 +35,9 @@ export type ControlSize = "base" | "sm";/*** Font size per tier, and the only place a control's font size is spelled: Select's menu rows,* OptionMenu's row titles and Textarea all read it, so moving a rung moves the whole family.- * The rungs are relative (`--text-*` is in rem and theme.tsx sets the root size per font tier),- * so a control must never be given a `text-[Npx]` — that freezes it against the user's setting.+ * The rungs are relative (`--text-*` follows the theme's type scale and the root size the user's+ * font-size setting picks), so a control must never be given a `text-[Npx]` — that freezes it+ * against the user's setting.*/export const sizeTextClass: Record<ControlSize, string> = { base: "text-base", sm: "text-xs" };@@ -41,40 +48,16 @@ export const sizeClass: Record<ControlSize, string> = {sm: `${sizePadClass.sm} ${sizeTextClass.sm}`,};-export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {- label?: string;- hint?: string;- /**- * Semantic explanation — what the field means, what it affects, when it takes effect —- * disclosed by a "?" beside the label. A rule about the *shape* of the input ("one per line",- * "leave empty for unlimited") belongs in `hint`, which stays on screen while the user types.- */- info?: ReactNode;- /** Accessible name for that "?" (defaults to the generic "More info"). */- infoLabel?: string;- error?: string;- /**- * Marks the field red without rendering error text: use this when the input has a- * custom wrapper (prefix glyph, unit suffix, etc.) and the caller places the error- * text outside that wrapper — otherwise the text would get pulled into the- * absolutely-positioned reference frame and skew the prefix/suffix layout.- */- invalid?: boolean;- size?: ControlSize;-}-/**- * Error state: red border + light red background (a failed field is visible at a- * glance; the error text sits below the box). Shared with Select/OptionMenu so a- * failed dropdown reads exactly like a failed input.- * Forced with `!` — baseClass's border-gray-300 / bg-white are the same kind of- * border/background utility classes, and which one wins depends on the order the- * CSS was generated in, not the order of classes in the string (without `!important`- * this would get overridden).+ * Error state: the danger line around the box, held on hover and focus, with a danger focus ring+ * (the error text sits below the box). Shared with Select/OptionMenu so a failed dropdown reads+ * exactly like a failed input. The box keeps its surface fill: a tinted fill inside a line of the+ * same hue is the one-hue box the design refuses, and the line alone is the signal.+ *+ * Forced with `!` — the control look's own line and ring are the same kind of utility, and which+ * one wins depends on the order the CSS was generated in, not the order of classes in the string.*/-export const errorClass =- "!border-red-400 !bg-red-50 hover:!border-red-500 focus:!border-red-500 focus:!ring-red-400/30 " +- "dark:!border-red-800 dark:!bg-red-950/40 dark:hover:!border-red-700 dark:focus:!border-red-600";+export const errorClass = "!border-tone-danger-fg focus:!ring-2 focus:!ring-tone-danger-fg/30";/*** Autofill policy: a control opts OUT unless its caller declares a real credential role.@@ -82,7 +65,7 @@ export const errorClass =* price, and the browser's saved-login heuristics kept dropping the account's username and* password into them (a dialog's fields are unowned — no <form> element — so the browser* groups them with everything else on the page and picks a "username" box on its own).- * Only login.tsx and the password dialogs pass a role ("username" / "current-password" /+ * Only the login page and the password dialogs pass a role ("username" / "current-password" /* "new-password"), and those keep the browser's help.** `autocomplete="off"` alone does NOT cover a password box: Chrome and Safari ignore it@@ -105,38 +88,83 @@ export function autofillProps(autoComplete: string | undefined, secret: boolean)/*** The same opt-out as a spreadable constant, for the handful of raw `<input>`s that don't go- * through Input (menu search boxes, the Workspace path editor): `{...noAutofill}`.+ * through Input (the Workspace path editor, inline number editors): `{...noAutofill}`.*/export const noAutofill = autofillProps(undefined, false);/**- * The search box a menu or a side panel carries at its top — the one input in the app that does- * not go through `Input`, because it is not a form field: it owns the panel's keyboard while the- * panel is up, and it sits inside a container that already draws the border it would otherwise- * need. Four call sites had each written their own copy, and the copies had drifted apart on- * radius, padding, focus colour and whether the border transitions at all.- *- * Two shapes, because the containers differ:- *- * - `menuSearchClass` — the box sits directly under its menu's own divider and draws no border of- * its own (a second line a pixel below the first reads as a mistake). The model picker and the- * Skill picker.- * - `panelSearchClass` — the box stands inside a panel with room around it, so it draws its own.- * The Workspace browser and the machines picker.+ * Live width of one affix drawn inside an input, so the input can reserve exactly the room it+ * occupies. An affix is rendered text: its width follows the resolved font, the root font size+ * (the appearance setting scales it) and whatever the caller puts in it (a currency symbol that+ * follows a setting), none of which is known where the padding is written — which is why it is+ * measured rather than typed. The affix is absolutely positioned, so its size does not depend on+ * the padding derived from it.*- * Both take the `sm` rung, like every other control; padding is left to the caller, which is the- * one thing that legitimately differs (the Workspace browser reserves room on the right for its- * clear button, the way `Textarea` keeps its own padding over `sizeClass`'s).+ * Returns a callback ref for the affix element and its measured width (0 until measured).*/-const searchSharedClass =- `w-full bg-transparent ${sizeTextClass.sm} text-gray-700 ` +- "placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500";+export function useAffixWidth(): [RefCallback<HTMLElement>, number] {+ const [width, setWidth] = useState(0);+ const ref = useCallback((el: HTMLElement | null) => {+ if (el === null) return;+ // The observer reports the box LAYOUT size, which is what has to be reserved. A rect read+ // off the element would be wrong here: a dialog pops in under a scale transform, so a+ // measurement taken while that animation runs comes back short, and a transform never+ // notifies an observer that would correct it. Delivery is after layout and before paint,+ // so the unmeasured state is not painted; a font, language or font-size change resizes the+ // affix and re-runs this.+ const observer = new ResizeObserver(([entry]) => {+ if (entry) setWidth(entry.borderBoxSize[0]?.inlineSize ?? entry.contentRect.width);+ });+ observer.observe(el);+ return () => observer.disconnect();+ }, []);+ return [ref, width];+}++/**+ * Padding that clears an affix of the given rendered width: the 0.5rem the affix is inset from the+ * input edge (`left-2` / `right-2`), the affix itself, and 0.25rem of separation so the value does+ * not read as one run of text with it. An unmeasured width (0) still yields a padding no smaller+ * than the control's own, so nothing lands outside the box.+ */+function affixPadding(width: number): string {+ return `calc(${width}px + 0.75rem)`;+}++/** Muted text pinned inside the box, clear of the pointer so a click still lands in the field. */+const affixClass = "pointer-events-none absolute inset-y-0 flex items-center text-fg-subtle";-export const menuSearchClass = `${searchSharedClass} rounded border border-transparent`;+/** Short text drawn inside an Input's box, before or after the value. */+export interface InputAffix {+ /** Before the value — a currency symbol. */+ leading?: ReactNode;+ /** After the value — a unit. */+ trailing?: ReactNode;+}-export const panelSearchClass =- `${searchSharedClass} rounded-md border border-gray-200 transition-colors ` +- "focus:border-gray-400 dark:border-gray-700 dark:focus:border-gray-500";+export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {+ label?: string;+ hint?: string;+ /**+ * Semantic explanation — what the field means, what it affects, when it takes effect —+ * disclosed by a "?" beside the label. A rule about the *shape* of the input ("one per line",+ * "leave empty for unlimited") belongs in `hint`, which stays on screen while the user types.+ */+ info?: ReactNode;+ /** Accessible name for that "?" (defaults to the generic "More info"). */+ infoLabel?: string;+ error?: string;+ /**+ * Marks the field red without rendering error text: use this when the input has a custom+ * wrapper (a trailing menu button, say) and the caller places the error text outside that+ * wrapper — otherwise the text would get pulled into the absolutely-positioned reference frame+ * and skew the layout. An `affix` needs none of this: the Input keeps its error below the box.+ */+ invalid?: boolean;+ size?: ControlSize;+ /** Text drawn inside the box before and/or after the value; the value's padding clears it. */+ affix?: InputAffix;+}export function Input({label,@@ -151,6 +179,8 @@ export function Input({autoComplete,id,title,+ affix,+ style,...rest}: InputProps) {const bad = Boolean(error) || Boolean(invalid);@@ -159,9 +189,33 @@ export function Input({// (see Field), so an info field needs the control to carry an id.const generatedId = useId();const controlId = id ?? generatedId;+ const [leadingRef, leadingWidth] = useAffixWidth();+ const [trailingRef, trailingWidth] = useAffixWidth();+ const leading = affix?.leading;+ const trailing = affix?.trailing;+ const affixStyle: CSSProperties = {+ ...(leading != null ? { paddingLeft: affixPadding(leadingWidth) } : {}),+ ...(trailing != null ? { paddingRight: affixPadding(trailingWidth) } : {}),+ };// `required` drives the label's asterisk + aria-required only; the native `required`// attribute is intentionally not forwarded (the app validates on submit, so browser// validation bubbles would collide with the inline field errors).+ const control = (+ <input+ id={info !== undefined ? controlId : id}+ className={`${baseClass} ${sizeClass[size]} ${bad ? errorClass : ""} ${className ?? ""}`}+ style={affix === undefined ? style : { ...style, ...affixStyle }}+ aria-invalid={bad ? true : undefined}+ aria-required={required || undefined}+ aria-describedby={error ? errorId : undefined}+ // Secret while masked; PasswordInput's reveal toggle flips the type to text, and the+ // opt-out that matters was already read from the password state.+ {...autofillProps(autoComplete, rest.type === "password")}+ // A hover hint shows in the shared tooltip, never the browser's own `title`.+ data-tooltip={title}+ {...rest}+ />+ );return (<Fieldlabel={label}@@ -173,19 +227,23 @@ export function Input({infoLabel={infoLabel}controlId={controlId}>- <input- id={info !== undefined ? controlId : id}- className={`${baseClass} ${sizeClass[size]} ${bad ? errorClass : ""} ${className ?? ""}`}- aria-invalid={bad ? true : undefined}- aria-required={required || undefined}- aria-describedby={error ? errorId : undefined}- // Secret while masked; PasswordInput's reveal toggle flips the type to text, and the- // opt-out that matters was already read from the password state.- {...autofillProps(autoComplete, rest.type === "password")}- // A hover hint shows in the shared tooltip, never the browser's own `title`.- data-tooltip={title}- {...rest}- />+ {affix === undefined ? (+ control+ ) : (+ <span className="relative block">+ {leading != null && (+ <span ref={leadingRef} className={`${affixClass} left-2 ${sizeTextClass[size]}`}>+ {leading}+ </span>+ )}+ {control}+ {trailing != null && (+ <span ref={trailingRef} className={`${affixClass} right-2 ${sizeTextClass[size]}`}>+ {trailing}+ </span>+ )}+ </span>+ )}</Field>);}diff --git a/packages/web/src/components/ui/password-input.tsx b/packages/ui/src/components/forms/password-input/password-input.tsxsimilarity index 52%rename from packages/web/src/components/ui/password-input.tsxrename to packages/ui/src/components/forms/password-input/password-input.tsxindex 68bf5fdc..db020eb6 100644--- a/packages/web/src/components/ui/password-input.tsx+++ b/packages/ui/src/components/forms/password-input/password-input.tsx@@ -1,21 +1,26 @@/**- * Password input: a password variant of Input with an embedded show/hide toggle- * (eye icon button) on the right. The label/hint/error wrapper structure mirrors- * Input — the toggle button must be positioned relative to the **input element- * itself**; if label/hint were handed to the inner Input as well, the button would- * get pulled into the positioning reference frame along with the hint text and- * shift out of place. So error is only passed down as `invalid` (red border), and- * the error text is rendered below the box by this component.+ * Password input: a password variant of Input with an embedded show/hide toggle (an eye) on the+ * right. The label/hint/error wrapper mirrors Input's — the toggle must be positioned relative to+ * the **input element itself**; if label/hint were handed to the inner Input as well, the button+ * would be pulled into the positioning reference frame along with the hint text and shift out of+ * place. So the error only reaches the inner Input as `invalid` (the red line), and the error text+ * is rendered below the box by this component.*/import { useId, useState } from "react";-import { Input, type InputProps } from "./input";-import { Field } from "./field";-import { S } from "../../lib/strings";+import { useUiStrings } from "../../../strings";+import { GlyphIcon } from "../../icons/glyph-icon/glyph-icon";+import { ICONS } from "../../icons/icons";+import { Field } from "../field/field";+import { Input } from "../input/input";+import type { InputProps } from "../input/input";-/** Eye (click to show) and a crossed-out closed eye (click to hide). */-const EYE = "M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7-10-7-10-7zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z";-const EYE_OFF =- "M3 3l18 18M10.6 5.1A11 11 0 0 1 12 5c6.4 0 10 7 10 7a17.6 17.6 0 0 1-3.2 3.9M6.6 6.6C4 8.3 2 12 2 12s3.6 7 10 7a10 10 0 0 0 4.8-1.2M9.9 9.9a3 3 0 0 0 4.2 4.2";+export interface PasswordInputProps extends Omit<InputProps, "type" | "affix"> {+ /**+ * The reveal toggle's accessible name (and tooltip) in each state. The interface's own words+ * when omitted, so a caller passes these only to say something more specific.+ */+ toggleLabels?: { show: string; hide: string };+}export function PasswordInput({label,@@ -28,10 +33,13 @@ export function PasswordInput({size = "sm",className,id,+ toggleLabels,...rest-}: Omit<InputProps, "type">) {+}: PasswordInputProps) {+ const strings = useUiStrings();const [visible, setVisible] = useState(false);- const toggleLabel = visible ? S.auth.hidePassword : S.auth.showPassword;+ const labels = toggleLabels ?? { show: strings.showPassword, hide: strings.hidePassword };+ const toggleLabel = visible ? labels.hide : labels.show;// The error text renders in THIS component's Field (see the header comment), so the// association is wired here too: the inner Input only gets `invalid` and points its// aria-describedby at the outer FieldError.@@ -63,28 +71,18 @@ export function PasswordInput({/><buttontype="button"+ // The name says what a press does and changes with the state, so no aria-pressed:+ // a pressed state beside a name that flips would announce the change twice.aria-label={toggleLabel}data-tooltip={toggleLabel}// Skip in the tab order: Tab should move between fields, not land on the reveal toggle.tabIndex={-1}onClick={() => setVisible((v) => !v)}- className={`absolute inset-y-0 right-0 flex items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:hover:text-gray-300 ${+ className={`absolute inset-y-0 right-0 flex items-center justify-center text-fg-subtle transition-colors duration-150 hover:text-fg-muted ${size === "sm" ? "w-8" : "w-10"}`}>- <svg- width={size === "sm" ? 14 : 16}- height={size === "sm" ? 14 : 16}- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.7"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden- >- <path d={visible ? EYE_OFF : EYE} />- </svg>+ <GlyphIcon d={visible ? ICONS.eyeOff : ICONS.eye} size={size === "sm" ? 14 : 16} /></button></div></Field>diff --git a/packages/ui/src/components/forms/picker-list/picker-list.tsx b/packages/ui/src/components/forms/picker-list/picker-list.tsxnew file mode 100644index 00000000..c15a2509--- /dev/null+++ b/packages/ui/src/components/forms/picker-list/picker-list.tsx@@ -0,0 +1,112 @@+/**+ * A search box over a keyboard-walkable list: the candidate panel a picker opens (the agent+ * handoff picker, the schedule form's session picker; the model picker grew into a dialog of its+ * own). The search box, the internal scroll cap, the row chrome, the keyboard navigation and the+ * "current entry" check all live here, so the pickers built on it differ only in what a row+ * *contains* (an agent avatar, a session title) and in what they hang below the list (`footer`,+ * e.g. a "show all" expander).+ *+ * Keyboard navigation deliberately starts with **no** row highlighted: the search box is+ * autofocused, and pre-highlighting a row would repaint a panel that has looked the same since+ * before this control existed. ArrowDown/ArrowUp begin the navigation, and Enter/Tab commits — the+ * highlighted row if there is one, otherwise the top match, which is what makes "type a few+ * letters, press Enter" work. Escape is the host's: the search box empties itself on the first+ * press when it holds text, and the host closes its own panel at the window level (an IME-safe+ * handler for a switch picker, the dropdown's for a dropdown).+ */+import { useState } from "react";+import type { KeyboardEvent, ReactNode } from "react";+import { ChoiceCheck, menuRowClass, menuRowTone } from "../../overlays/menu-panel/menu-panel";+import { SearchInput } from "../search-input/search-input";++export function PickerList<T>({+ items,+ itemKey,+ isCurrent,+ query,+ onQueryChange,+ searchPlaceholder,+ emptyText,+ onPick,+ renderRow,+ footer,+}: {+ items: readonly T[];+ /** Stable React key AND identity for the highlighted row. */+ itemKey: (item: T) => string;+ /** Marks the entry already in effect: renders the check and the current row's fill. */+ isCurrent?: (item: T) => boolean;+ query: string;+ onQueryChange: (query: string) => void;+ /** The search box's placeholder, which is also its accessible name. */+ searchPlaceholder: string;+ /** Shown in place of the list when the query matches nothing. */+ emptyText: string;+ onPick: (item: T) => void;+ /** The row's own content, left of the check's slot. */+ renderRow: (item: T) => ReactNode;+ /** Pinned below the scroll area (mirroring the search box above it). */+ footer?: ReactNode;+}) {+ // -1 = nothing highlighted yet (see the note above); reset whenever the query changes.+ const [active, setActive] = useState(-1);+ const activeKey = active >= 0 && active < items.length ? itemKey(items[active]!) : null;+ const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {+ if (items.length === 0) return;+ if (e.key === "ArrowDown") {+ e.preventDefault();+ setActive((i) => (i + 1) % items.length);+ return;+ }+ if (e.key === "ArrowUp") {+ e.preventDefault();+ setActive((i) => (i <= 0 ? items.length - 1 : i - 1));+ return;+ }+ // An IME commit must not be read as a pick.+ if (((e.key === "Enter" && !e.shiftKey) || e.key === "Tab") && !e.nativeEvent.isComposing) {+ e.preventDefault();+ onPick(items[active >= 0 ? active : 0]!);+ }+ };+ return (+ <div className="contents" onKeyDown={onKeyDown}>+ {/* Quick search (autofocused: it also owns the keyboard while the panel is up) */}+ <div className="border-b border-line-muted px-2 pb-1.5 pt-0.5">+ <SearchInput+ variant="menu"+ autoFocus+ value={query}+ onChange={(next) => {+ onQueryChange(next);+ setActive(-1);+ }}+ placeholder={searchPlaceholder}+ aria-label={searchPlaceholder}+ />+ </div>+ <div className="max-h-56 overflow-y-auto">+ {items.length === 0 && <p className="px-3 py-1.5 text-xs text-fg-subtle">{emptyText}</p>}+ {items.map((item) => {+ const key = itemKey(item);+ const current = isCurrent?.(item) ?? false;+ return (+ <button+ key={key}+ type="button"+ ref={key === activeKey ? (el) => el?.scrollIntoView({ block: "nearest" }) : undefined}+ onClick={() => onPick(item)}+ className={`flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone(current)}${+ key === activeKey ? " bg-line-muted" : ""+ }`}+ >+ {renderRow(item)}+ <ChoiceCheck on={current} />+ </button>+ );+ })}+ </div>+ {footer}+ </div>+ );+}diff --git a/packages/ui/src/components/forms/pref-row/pref-row.tsx b/packages/ui/src/components/forms/pref-row/pref-row.tsxnew file mode 100644index 00000000..1aa8b78b--- /dev/null+++ b/packages/ui/src/components/forms/pref-row/pref-row.tsx@@ -0,0 +1,119 @@+/**+ * The settings page's row primitives: a labelled preference row — title on the left, the control+ * on the right — meant to be stacked inside a ruled (`divide-y`) container so rows separate with+ * rules rather than boxes; the plainer row of a settings list with a one-line description; and+ * the section frame with its ruled action row.+ *+ * A row titles a control it does not own, so its title is a `<p>`, never a `<label>`: a label+ * would name its first labelable descendant, which beside a "?" is the disclosure button rather+ * than the control. A switch row with that shape is `ToggleRow`.+ */+import type { ReactNode } from "react";+import { ICON_GAP } from "../../../icon-scale";+import { InfoPopover } from "../../overlays/info-popover/info-popover";++/**+ * The label slot a preference row and a toggle row share: the title with its "?" beside it, and+ * the hint under it.+ */+export function PrefRowLabel({+ label,+ hint,+ info,+}: {+ label: string;+ hint?: string;+ info?: ReactNode;+}) {+ return (+ <div data-slot="label" className="min-w-0">+ <p className={`flex items-center ${ICON_GAP.row} text-sm font-medium`}>+ {label}+ {info !== undefined && <InfoPopover label={label}>{info}</InfoPopover>}+ </p>+ {hint !== undefined && <p className="mt-0.5 text-xs text-fg-muted">{hint}</p>}+ </div>+ );+}++export function PrefRow({+ label,+ hint,+ info,+ children,+}: {+ label: string;+ /**+ * A line that stays on screen. For what the value must look like, and for a fact about the+ * current state (the running build's date) — never for what the row means, which goes in+ * `info` so a reader who already knows is not made to scroll past it again.+ */+ hint?: string;+ /** Semantic explanation, disclosed by a "?" beside the label. */+ info?: ReactNode;+ children: ReactNode;+}) {+ return (+ // ui-field: a theme may lay the label and the control out its own way (stacked, or as a+ // table row); the hint rides inside the label slot, under the label, in every theme.+ <div className="ui-field flex items-center justify-between gap-4 py-3.5 first:pt-0 last:pb-0">+ <PrefRowLabel label={label} hint={hint} info={info} />+ <div data-slot="control" className="shrink-0">+ {children}+ </div>+ </div>+ );+}++/**+ * One row of a settings list: a title plus a one-line description on the left, the control (if+ * any) on the right. Rows are separated by the parent container's `divide-y` rules (ruled+ * sections, not card boxes). Plainer than {@link PrefRow}: the title is set in the body weight,+ * the description in the subtle ink, and a row may carry no control at all (a fact, or why an+ * action is unavailable).+ */+export function SettingRow({+ title,+ description,+ children,+}: {+ title: ReactNode;+ description?: ReactNode;+ children?: ReactNode;+}) {+ return (+ <div className="flex items-center justify-between gap-4 py-3">+ <div className="min-w-0 flex-1">+ <p className="text-sm">{title}</p>+ {description !== undefined && (+ <p className="mt-0.5 text-xs text-fg-subtle">{description}</p>+ )}+ </div>+ {children !== undefined && <div className="flex shrink-0 items-center gap-2">{children}</div>}+ </div>+ );+}++/**+ * The frame of a settings page that saves explicitly: the body, and a trailing action row. The+ * dialog pane already draws the page heading and the "?" that discloses what the page is, so the+ * section adds no title, no explanatory line and no box of its own. Pages that apply on the spot+ * pass no actions and the row is not drawn, so nothing on screen suggests an unsaved edit is+ * waiting.+ */+export function SettingsSection({+ actions,+ children,+}: {+ actions?: ReactNode;+ children: ReactNode;+}) {+ return (+ <section>+ <div className="space-y-4">{children}</div>+ {actions !== undefined && (+ <div className="mt-5 flex justify-end gap-2 border-t border-line-muted pt-4">{actions}</div>+ )}+ </section>+ );+}diff --git a/packages/ui/src/components/forms/radio/radio.tsx b/packages/ui/src/components/forms/radio/radio.tsxnew file mode 100644index 00000000..2c48e3aa--- /dev/null+++ b/packages/ui/src/components/forms/radio/radio.tsx@@ -0,0 +1,164 @@+/**+ * Radio buttons: `Radio` is one native `<input type="radio">` drawn as a small token disc, and+ * `RadioGroup` is the usual way to use it — a `<fieldset>` whose `<legend>` names the choice, one+ * row per option, all sharing a `name` so the browser gives the group its arrow-key walk and+ * exactly one tab stop.+ *+ * A radio group is for a small, always-visible choice whose options each need a sentence (an+ * import mode and what it does to existing data). A short choice without explanations is a+ * `Segmented`; a long one is a `Select`.+ */+import { useId } from "react";+import type { InputHTMLAttributes, ReactNode } from "react";+import { sizeTextClass } from "../input/input";+import type { ControlSize } from "../input/input";++export interface RadioProps extends Omit<+ InputHTMLAttributes<HTMLInputElement>,+ "type" | "size" | "checked" | "defaultChecked" | "onChange" | "children"+> {+ checked: boolean;+ /** Called when this radio becomes the selected one. */+ onChange: () => void;+ /** The visible name; the whole row selects. Omit it and name the radio with `aria-label`. */+ label?: ReactNode;+ /** A line under the label, announced as the radio's description. */+ hint?: ReactNode;+ /** The label's text rung; the disc keeps one size and centres on the label's first line. */+ size?: ControlSize;+}++const DISC =+ "size-3.5 shrink-0 appearance-none rounded-full border transition-colors duration-150 " ++ "disabled:cursor-not-allowed " ++ "focus-visible:[outline:var(--ui-focus-ring)] " ++ "focus-visible:[outline-offset:var(--ui-focus-ring-offset)]";++const DISC_OFF = "border-line-emphasis bg-surface hover:border-fg-subtle";+const DISC_ON = "border-accent bg-accent";++export function Radio({+ checked,+ onChange,+ label,+ hint,+ size = "sm",+ disabled,+ className = "",+ "aria-describedby": describedBy,+ ...rest+}: RadioProps) {+ const hintId = useId();+ const describedByIds =+ [describedBy, hint != null ? hintId : undefined].filter(Boolean).join(" ") || undefined;+ const bare = label === undefined;+ const disc = (+ <span+ className={`relative inline-flex shrink-0 items-center ${+ bare ? `${disabled ? "opacity-60" : ""} ${className}` : ""+ }`}+ >+ <input+ type="radio"+ checked={checked}+ disabled={disabled}+ aria-describedby={describedByIds}+ onChange={(event) => {+ if (event.target.checked) onChange();+ }}+ className={`${DISC} ${checked ? DISC_ON : DISC_OFF}`}+ {...rest}+ />+ {checked && (+ <span+ aria-hidden+ className="pointer-events-none absolute inset-0 m-auto size-1.5 rounded-full bg-accent-fg"+ />+ )}+ </span>+ );+ if (bare) return disc;+ return (+ <label+ className={`inline-flex items-start gap-1.5 ${sizeTextClass[size]} ${+ disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"+ } ${className}`}+ >+ {/* One line tall, whatever the rung: the disc centres on the label's first line. */}+ <span className="flex h-[1lh] shrink-0 items-center">{disc}</span>+ <span className="min-w-0">+ <span className="block">{label}</span>+ {hint != null && (+ <span id={hintId} className="block text-fg-muted">+ {hint}+ </span>+ )}+ </span>+ </label>+ );+}++/** One choice of a {@link RadioGroup}. */+export interface RadioOption<T extends string> {+ value: T;+ label: ReactNode;+ /** What choosing it does, under the label. */+ hint?: ReactNode;+ disabled?: boolean;+}++export interface RadioGroupProps<T extends string> {+ /** The question the options answer: the fieldset's legend, in the field-label look. */+ label?: ReactNode;+ options: readonly RadioOption<T>[];+ value: T;+ onChange: (value: T) => void;+ /** The radios' shared `name`; a generated one when omitted. */+ name?: string;+ /** Options stacked (the default, for options that carry a hint) or on one wrapping line. */+ orientation?: "vertical" | "horizontal";+ size?: ControlSize;+ disabled?: boolean;+ className?: string;+}++export function RadioGroup<T extends string>({+ label,+ options,+ value,+ onChange,+ name,+ orientation = "vertical",+ size = "sm",+ disabled = false,+ className = "",+}: RadioGroupProps<T>) {+ const generatedName = useId();+ const groupName = name ?? generatedName;+ return (+ <fieldset className={`min-w-0 ${className}`} disabled={disabled}>+ {label != null && (+ <legend className="mb-1 text-xs font-semibold text-fg-muted">{label}</legend>+ )}+ <div+ className={+ orientation === "vertical" ? "flex flex-col gap-2" : "flex flex-wrap gap-x-4 gap-y-2"+ }+ >+ {options.map((option) => (+ <Radio+ key={option.value}+ name={groupName}+ value={option.value}+ checked={option.value === value}+ onChange={() => onChange(option.value)}+ label={option.label}+ hint={option.hint}+ size={size}+ disabled={disabled || option.disabled}+ />+ ))}+ </div>+ </fieldset>+ );+}diff --git a/packages/ui/src/components/forms/search-input/search-input.tsx b/packages/ui/src/components/forms/search-input/search-input.tsxnew file mode 100644index 00000000..a2251753--- /dev/null+++ b/packages/ui/src/components/forms/search-input/search-input.tsx@@ -0,0 +1,186 @@+/**+ * The search box: a `type="search"` field with a clear button, and optionally a magnifier before+ * the text. It filters what is already on screen, so it is not a form field — no label above it+ * (its `aria-label` names it), no hint, no error — and it never offers the browser's saved logins.+ *+ * Three shapes, because the containers differ:+ *+ * - `field` (the default) — a filter box on a page or a panel's toolbar, on the control look every+ * other text control wears.+ * - `panel` — a box standing inside a panel with room around it: a quieter line than a form+ * field's, so the panel's own border stays the stronger one (the Workspace browser, a picker).+ * - `menu` — the box sits directly under its menu's own divider and draws no line of its own (a+ * second line a pixel below the first reads as a mistake); tighter padding to match menu rows.+ *+ * Escape in a non-empty box clears it and goes no further, so one press empties the search rather+ * than also closing the dialog, dock or menu around it; in an empty box Escape passes through.+ * The right side always reserves the clear button's room, so the text never shifts when it+ * appears. A ref reaches the `<input>` itself, so a caller can put the caret back into the box.+ */+import { forwardRef, useCallback, useRef } from "react";+import type { InputHTMLAttributes, KeyboardEvent } from "react";+import { useUiStrings } from "../../../strings";+import { GlyphIcon } from "../../icons/glyph-icon/glyph-icon";+import { ICONS } from "../../icons/icons";+import { CloseIcon } from "../../icons/marks/marks";+import { controlBase } from "../field/field";+import { noAutofill, sizeTextClass } from "../input/input";+import type { ControlSize } from "../input/input";++export type SearchInputVariant = "field" | "panel" | "menu";++export interface SearchInputProps extends Omit<+ InputHTMLAttributes<HTMLInputElement>,+ "size" | "type" | "value" | "defaultValue" | "onChange"+> {+ value: string;+ onChange: (value: string) => void;+ /** The container it stands in (see above). */+ variant?: SearchInputVariant;+ size?: ControlSize;+ /** The clear button's name and tooltip; the interface's "clear search" when omitted. */+ clearLabel?: string;+ /** What clearing does; empties the box when omitted. */+ onClear?: () => void;+ /**+ * Keep the clear button, and Escape's clearing, while the box is empty — for a search that+ * closes itself when cleared, where the button is also the way out.+ */+ alwaysClearable?: boolean;+ /** Draw the magnifier before the text, where the placeholder alone would not say "search". */+ icon?: boolean;+}++const LOOK: Record<SearchInputVariant, string> = {+ field: `${controlBase} placeholder:text-fg-subtle`,+ panel:+ "rounded-md border border-line bg-transparent text-fg placeholder:text-fg-subtle " ++ "transition-colors duration-150 focus:border-fg-subtle focus:outline-none",+ menu:+ "rounded-sm border border-transparent bg-transparent text-fg placeholder:text-fg-subtle " ++ "focus:outline-none",+};++/** Padding and the two marks' positions, per shape and rung; written out, as classes must be. */+const GEOMETRY: Record<+ "box" | "menu",+ Record<ControlSize, { pad: string; padWithIcon: string; iconAt: string; clearAt: string }>+> = {+ box: {+ sm: {+ pad: "py-1 pl-2 pr-7",+ padWithIcon: "py-1 pl-7 pr-7",+ iconAt: "left-2",+ clearAt: "right-1",+ },+ base: {+ pad: "py-2 pl-3 pr-9",+ padWithIcon: "py-2 pl-9 pr-9",+ iconAt: "left-3",+ clearAt: "right-2",+ },+ },+ menu: {+ sm: {+ pad: "py-0.5 pl-1 pr-6",+ padWithIcon: "py-0.5 pl-6 pr-6",+ iconAt: "left-1",+ clearAt: "right-0",+ },+ base: {+ pad: "py-1 pl-2 pr-7",+ padWithIcon: "py-1 pl-7 pr-7",+ iconAt: "left-2",+ clearAt: "right-1",+ },+ },+};++const MARK_SIZE: Record<ControlSize, number> = { sm: 12, base: 14 };++export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(function SearchInput(+ {+ value,+ onChange,+ variant = "field",+ size = "sm",+ clearLabel,+ onClear,+ alwaysClearable = false,+ icon = false,+ className = "",+ onKeyDown,+ title,+ ...rest+ },+ ref,+) {+ const strings = useUiStrings();+ const input = useRef<HTMLInputElement | null>(null);+ // The box keeps its own handle (clearing puts the caret back) and hands the same element on.+ const setInput = useCallback(+ (element: HTMLInputElement | null) => {+ input.current = element;+ if (typeof ref === "function") ref(element);+ else if (ref !== null) ref.current = element;+ },+ [ref],+ );+ const clearName = clearLabel ?? strings.clearSearch;+ const clearable = value !== "" || alwaysClearable;+ const geometry = GEOMETRY[variant === "menu" ? "menu" : "box"][size];+ const clear = () => {+ if (onClear !== undefined) {+ onClear();+ return;+ }+ onChange("");+ // The box stays, so the caret stays in it: the next keystroke starts the next search.+ input.current?.focus();+ };+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {+ onKeyDown?.(event);+ if (event.defaultPrevented || event.key !== "Escape" || event.nativeEvent.isComposing) return;+ if (!clearable) return;+ event.preventDefault();+ event.stopPropagation();+ clear();+ };+ return (+ <div className={`relative ${className}`}>+ {icon && (+ <GlyphIcon+ d={ICONS.search}+ size={MARK_SIZE[size]}+ className={`pointer-events-none absolute top-1/2 -translate-y-1/2 ${geometry.iconAt} text-fg-subtle`}+ />+ )}+ <input+ ref={setInput}+ type="search"+ value={value}+ onChange={(event) => onChange(event.target.value)}+ onKeyDown={handleKeyDown}+ {...noAutofill}+ // A hover hint shows in the shared tooltip, never the browser's own `title`.+ data-tooltip={title}+ className={+ `block w-full appearance-none [&::-webkit-search-cancel-button]:appearance-none ` ++ `${LOOK[variant]} ${sizeTextClass[size]} ${icon ? geometry.padWithIcon : geometry.pad}`+ }+ {...rest}+ />+ {clearable && (+ <button+ type="button"+ aria-label={clearName}+ data-tooltip={clearName}+ onClick={clear}+ className={`absolute top-1/2 -translate-y-1/2 ${geometry.clearAt} flex items-center justify-center rounded-sm p-1 text-fg-subtle transition-colors duration-150 hover:bg-surface-muted hover:text-fg`}+ >+ <CloseIcon size={MARK_SIZE[size]} />+ </button>+ )}+ </div>+ );+});diff --git a/packages/web/src/components/ui/segmented.tsx b/packages/ui/src/components/forms/segmented/segmented.tsxsimilarity index 58%rename from packages/web/src/components/ui/segmented.tsxrename to packages/ui/src/components/forms/segmented/segmented.tsxindex ca1c3e2f..16e6aa1a 100644--- a/packages/web/src/components/ui/segmented.tsx+++ b/packages/ui/src/components/forms/segmented/segmented.tsx@@ -1,26 +1,32 @@/**- * Segmented control (for 2- to 5-way choices like theme/language/messaging channel): small- * grayscale style. Shared by the sidebar user menu, the login page and the binding editor.+ * Segmented control, for 2- to 5-way choices (theme, language, messaging channel): the options sit+ * in a well, and the chosen one is a raised chip in the surface colour — lighter than the well in+ * a light theme, the page's own darker surface in a dark one.** An option may carry a `badge`: a mini tag pinned at the top-right of its label, for a mark that- * qualifies the choice itself rather than reporting a state — company mode's 内测版 tag on the- * work-mode switch. It is positioned out of flow, so neither an option's height nor the control's- * overall size moves when one appears, and it is hidden from the accessible name; the badge's- * `name` is what the option's name gains instead, as ` · <name>`.+ * qualifies the choice itself rather than reporting a state (a beta tag on a work-mode choice). It+ * is positioned out of flow, so neither an option's height nor the control's overall size moves+ * when one appears, and it is hidden from the accessible name; the badge's `name` is what the+ * option's name gains instead, as ` · <name>`.+ *+ * The well is a pressable control's shape (`rounded-control`); the chips keep the small radius+ * inside it.*/import type { ReactNode } from "react";+export interface SegmentedOption<T extends string> {+ value: T;+ label: string;+ badge?: { node: ReactNode; name: string };+}+export function Segmented<T extends string>({options,value,onChange,cols = 3,}: {- options: ReadonlyArray<{- value: T;- label: string;- badge?: { node: ReactNode; name: string };- }>;+ options: ReadonlyArray<SegmentedOption<T>>;value: T;onChange: (v: T) => void;cols?: 2 | 3 | 4 | 5;@@ -29,7 +35,7 @@ export function Segmented<T extends string>({<div// Spelled out rather than interpolated: Tailwind scans for whole class names, and a// `grid-cols-${n}` built at runtime is never emitted into the stylesheet.- className={`grid ${cols === 2 ? "grid-cols-2" : cols === 4 ? "grid-cols-4" : cols === 5 ? "grid-cols-5" : "grid-cols-3"} gap-0.5 rounded-md bg-gray-100 p-0.5 dark:bg-gray-800`}+ className={`grid ${cols === 2 ? "grid-cols-2" : cols === 4 ? "grid-cols-4" : cols === 5 ? "grid-cols-5" : "grid-cols-3"} gap-1 rounded-control bg-line-muted p-1`}>{options.map((opt) => (<button@@ -39,10 +45,11 @@ export function Segmented<T extends string>({// An aria-label replaces every descendant in the accessible name, so it is only set// where there is a badge to fold in — otherwise the label's own text is the name.aria-label={opt.badge ? `${opt.label} · ${opt.badge.name}` : undefined}- className={`rounded px-1 py-1 text-xs transition-colors duration-150 ${+ aria-pressed={value === opt.value}+ className={`rounded-sm px-1 py-1 text-xs transition-colors duration-150 ${value === opt.value- ? "bg-white font-medium text-gray-900 shadow-sm dark:bg-gray-600 dark:text-gray-100"- : "text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-200"+ ? "bg-surface font-medium text-fg shadow-sm"+ : "text-fg-muted hover:text-fg"}`}>{opt.badge ? (diff --git a/packages/web/src/components/ui/option-menu.tsx b/packages/ui/src/components/forms/select/option-menu.tsxsimilarity index 63%rename from packages/web/src/components/ui/option-menu.tsxrename to packages/ui/src/components/forms/select/option-menu.tsxindex 9c4f6ac2..7de079f2 100644--- a/packages/web/src/components/ui/option-menu.tsx+++ b/packages/ui/src/components/forms/select/option-menu.tsx@@ -1,44 +1,41 @@/**- * Option menu (controlled): the trigger button shows a compact current value, and- * clicking it expands a panel where each row has a title + description text + a- * selected-state checkmark. Replaces select controls that show only an abbreviation- * and rely on the native `title` hover tooltip for details (tooltips are poorly- * discoverable — users have no idea they should hover before they've clicked once).+ * Option menu (controlled): the trigger button shows a compact current value, and clicking it+ * expands a panel where each row has a title + description text + a selected-state checkmark.+ * Replaces select controls that show only an abbreviation and rely on a hover tooltip for the+ * details (tooltips are poorly discoverable — users have no idea they should hover before they've+ * clicked once).*- * The trigger button shares the sizeClass size tier with Input/Select, and the panel- * row styling matches the Select menu (py-1.5, bold selected row + SVG checkmark),- * keeping visuals consistent when mixed with existing form controls.+ * The trigger button shares the sizeClass size tier with Input/Select, and the panel row styling+ * matches the Select menu (py-1.5, the current row filled and checked), keeping visuals+ * consistent when mixed with existing form controls.*- * The panel is mounted via createPortal to document.body and positioned with- * `position: fixed` against viewport coordinates — it does not reuse the Dropdown- * primitive's in-place absolute positioning. Reason: a Dropdown panel is a DOM- * descendant of its trigger button, so if an ancestor in the chain has a container- * like overflow-x-auto (e.g. this component used inside a tool table), the CSS spec- * says that when one axis has non-visible overflow and the other is visible, the- * visible axis gets forced to `auto` — making that ancestor clip vertically- * overflowing descendants, and absolute positioning is not exempt. A portaled node- * is outside that ancestor's DOM subtree, so it is fundamentally unaffected by its- * overflow, without having to audit every call site's ancestor chain.- * Positioning and close behavior live in use-portal-panel.ts.+ * The panel is mounted via createPortal to document.body and positioned with `position: fixed`+ * against viewport coordinates — it does not reuse a dropdown's in-place absolute positioning.+ * Reason: an in-place panel is a DOM descendant of its trigger button, so if an ancestor in the+ * chain has a container like overflow-x-auto (e.g. this component used inside a tool table), the+ * CSS spec says that when one axis has non-visible overflow and the other is visible, the visible+ * axis gets forced to `auto` — making that ancestor clip vertically overflowing descendants, and+ * absolute positioning is not exempt. A portaled node is outside that ancestor's DOM subtree, so+ * it is fundamentally unaffected by its overflow, without having to audit every call site's+ * ancestor chain. Positioning and close behaviour live in use-portal-panel.ts.*- * The panel uses z-[60] (above the modal overlay's z-50): a portaled node sits in- * the root stacking context, and this component may also be used inside a Modal- * form, where z-40 would get covered by the overlay.+ * The panel uses z-[60] (above the modal overlay's z-50): a portaled node sits in the root+ * stacking context, and this component may also be used inside a Modal form, where z-40 would+ * get covered by the overlay.*/import { useId, useState } from "react";import { createPortal } from "react-dom";-import { ChevronDown } from "@prismshadow/penguin-ui";-import { errorClass, sizeClass, sizeTextClass } from "./input";-import type { ControlSize } from "./input";+import { ChevronDown } from "../../icons/marks/marks";import {ChoiceCheck,- Field,- controlBase,menuPanelClass,menuRowClass,menuRowTone,-} from "./field";-import { usePortalPanel } from "./use-portal-panel";+} from "../../overlays/menu-panel/menu-panel";+import { usePortalPanel } from "../../overlays/portal-panel/use-portal-panel";+import { Field, controlBase } from "../field/field";+import { errorClass, sizeClass, sizeTextClass } from "../input/input";+import type { ControlSize } from "../input/input";export interface OptionMenuChoice<T extends string> {value: T;@@ -53,12 +50,13 @@ export interface OptionMenuChoice<T extends string> {const PANEL_WIDTH = 288; // w-72/**- * Descriptions keep one step below the row title at every tier, so the title/description- * hierarchy survives the sm tier's text-xs titles. The sm value is the one `text-[Npx]` the- * control family allows: there is no rung below text-xs to step down to. It is a fixed px and- * so does not scale with the user's font-size setting — do not copy the shape elsewhere.+ * A row description's font size per tier. Descriptions sit on the small rung: at the base tier+ * that is a step below the row title; at the sm tier the title is already on the small rung and+ * there is no rung below it, so the two share a size and the description stands apart by its+ * muted ink alone (a fixed `text-[Npx]` would ignore the user's font-size setting). Hand-built+ * menus that mimic this row (the protocol suffix menu) read it from here.*/-export const rowDescClass: Record<ControlSize, string> = { base: "text-xs", sm: "text-[11px]" };+export const rowDescClass: Record<ControlSize, string> = { base: "text-xs", sm: "text-xs" };export function OptionMenu<T extends string>({options,@@ -83,9 +81,9 @@ export function OptionMenu<T extends string>({mono?: boolean;/** Field title above the control (same typography as Input); omit to render a bare trigger button (e.g. for table cell usage). */label?: string;- /** Field-value error: red border + message below, exactly like Input. */+ /** Field-value error: the error border + message below, exactly like Input. */error?: string;- /** Renders a red "*" after the label. An optional field passes nothing — no counterpart mark, and no "optional" in the label. */+ /** Renders the required mark after the label. An optional field passes nothing — no counterpart mark, and no "optional" in the label. */required?: boolean;/** Stretch the trigger button to fill the container width, as a replacement for native Select in dense form areas. */fullWidth?: boolean;@@ -124,7 +122,7 @@ export function OptionMenu<T extends string>({<span className={`min-w-0 truncate ${mono ? "font-mono" : ""}`}>{current?.triggerLabel ?? placeholder ?? "—"}</span>- <ChevronDown className="text-gray-400" />+ <ChevronDown className="text-fg-subtle" /></button>{open &&position &&@@ -159,9 +157,7 @@ export function OptionMenu<T extends string>({<span className={sizeTextClass[size]}>{opt.label}</span><ChoiceCheck on={opt.value === value} /></span>- <span- className={`mt-0.5 block ${rowDescClass[size]} text-gray-500 dark:text-gray-400`}- >+ <span className={`mt-0.5 block ${rowDescClass[size]} text-fg-muted`}>{opt.description}</span></button>diff --git a/packages/web/src/components/ui/select.tsx b/packages/ui/src/components/forms/select/select.tsxsimilarity index 81%rename from packages/web/src/components/ui/select.tsxrename to packages/ui/src/components/forms/select/select.tsxindex 1851e7a8..b8d58483 100644--- a/packages/web/src/components/ui/select.tsx+++ b/packages/ui/src/components/forms/select/select.tsx@@ -1,31 +1,30 @@/**- * Dropdown select component: **custom-drawn** (not the native browser select),- * keeping the same API — parses `<option>` children and follows the- * `value` / `onChange(e.target.value)` convention. The menu is rendered via- * portal to body (fixed positioning from the shared usePortalPanel hook), so it- * is never clipped by a Modal or scroll container; it closes on outside click,- * Esc, a scroll that moves the trigger, or resize. Styling matches Input.+ * Dropdown select: **custom-drawn** (not the native browser select) but keeping the native API —+ * it parses `<option>` children and follows the `value` / `onChange(e.target.value)` convention.+ * The menu is rendered via portal to body (fixed positioning from the shared usePortalPanel hook),+ * so it is never clipped by a Modal or scroll container; it closes on outside click, Esc, a scroll+ * that moves the trigger, or resize. The trigger wears the control look Input wears, and the panel+ * is the menu panel every picker shares.*/import { Children, isValidElement, useId, useState } from "react";import type { ChangeEvent, ReactNode, SelectHTMLAttributes } from "react";import { createPortal } from "react-dom";-import { ChevronDown } from "@prismshadow/penguin-ui";-import { errorClass, sizeClass, sizeTextClass } from "./input";-import type { ControlSize } from "./input";+import { ChevronDown } from "../../icons/marks/marks";import {ChoiceCheck,- Field,- controlBase,menuPanelClass,menuRowClass,menuRowTone,-} from "./field";-import { usePortalPanel } from "./use-portal-panel";+} from "../../overlays/menu-panel/menu-panel";+import { usePortalPanel } from "../../overlays/portal-panel/use-portal-panel";+import { Field, controlBase } from "../field/field";+import { errorClass, sizeClass, sizeTextClass } from "../input/input";+import type { ControlSize } from "../input/input";export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "size"> {label?: string;hint?: string;- /** Field-value error: red border + message below, exactly like Input. */+ /** Field-value error: the error border + message below, exactly like Input. */error?: string;/** Same size tier as Input: sm is for filter bars, keeps the toolbar from growing taller. */size?: ControlSize;@@ -108,7 +107,7 @@ export function Select({<span className="min-w-0 flex-1 truncate">{selected?.label ?? options[0]?.label ?? ""}</span>- <ChevronDown className="text-gray-400" />+ <ChevronDown className="text-fg-subtle" /></button>{open &&position &&diff --git a/packages/ui/src/components/forms/swatch-picker/swatch-picker.tsx b/packages/ui/src/components/forms/swatch-picker/swatch-picker.tsxnew file mode 100644index 00000000..7a23615f--- /dev/null+++ b/packages/ui/src/components/forms/swatch-picker/swatch-picker.tsx@@ -0,0 +1,50 @@+/**+ * A row of round colour swatches, one pressed: the accent picker's shape. The swatches arrive as+ * data — each with its colour, its name and its value — so which colours a theme offers, and what+ * each is called, stays with the caller; the picker only paints them and says which one is in+ * effect.+ *+ * Each swatch is a toggle button named by its label (`aria-pressed` on the one in effect), with+ * the name in the shared tooltip as well, since a colour dot has no text of its own. The chosen+ * swatch carries a ring; hovering another draws its edge. Nothing scales: a swatch that grows+ * under the pointer is motion with no job.+ */+export interface SwatchOption<T extends string> {+ value: T;+ /** The swatch's fill: any CSS colour. */+ color: string;+ /** The swatch's accessible name and tooltip. */+ label: string;+}++export function SwatchPicker<T extends string>({+ options,+ value,+ onChange,+}: {+ options: ReadonlyArray<SwatchOption<T>>;+ /** The value in effect (not merely the stored one, when the two can differ). */+ value: T;+ onChange: (value: T) => void;+}) {+ return (+ <div className="flex items-center gap-1.5">+ {options.map((option) => (+ <button+ key={option.value}+ type="button"+ data-tooltip={option.label}+ aria-label={option.label}+ aria-pressed={value === option.value}+ onClick={() => onChange(option.value)}+ className={`h-5 w-5 rounded-full border transition-colors duration-150 ${+ value === option.value+ ? "border-fg-muted ring-2 ring-fg-subtle/50"+ : "border-transparent hover:border-line-emphasis"+ }`}+ style={{ backgroundColor: option.color }}+ />+ ))}+ </div>+ );+}diff --git a/packages/ui/src/components/forms/switch/switch.tsx b/packages/ui/src/components/forms/switch/switch.tsxnew file mode 100644index 00000000..c65d89b1--- /dev/null+++ b/packages/ui/src/components/forms/switch/switch.tsx@@ -0,0 +1,74 @@+/**+ * The on/off switch: a `button` with `role="switch"` + `aria-checked` (a native button is+ * keyboard-operable out of the box — Space/Enter activate it — and is labelable content, so+ * clicking an enclosing `<label>`'s text toggles it too). The on track is the accent (the same+ * source as the primary Button), the off track the theme's `switch-track`; the track's fill eases+ * between the two.+ *+ * Geometry (all in spacing units, so it scales with the theme's unit and never pushes the knob+ * out of the track): a size-4 knob in the w-9 × h-5 track, inset 0.5 on every side in both states,+ * and at either end concentric with the track's end-cap circle, so the gap along the arcs matches+ * the straight runs. The knob is painted from the theme's two knob tokens, one per track: the on+ * track is the accent, and an accent can be near-white (a dark theme's neutral accent, a lifted+ * preset), where a white knob would vanish — the theme picks a knob that stays apart from each+ * track at every accent. The track draws a 1px inset hairline in the ink at 10%; the knob's+ * hairline is a *border* — inside its own box — not an outer ring: an outer ring would fill the gap+ * on the near arc and stack on the track hairline as one heavier line, reading as unequal spacing.+ * No offset shadow (it reads as vertical asymmetry at this size); disabled dims and blocks. The+ * focus ring is accent-tinted and `focus-visible`-only, so keyboard focus shows it but a mouse+ * click doesn't leave a lingering halo.+ *+ * The knob travels by layout, not by a transform: it sits in the second column of a grid whose+ * first column grows from `0fr` (off) to `1fr` (on), and that grid carries `data-layout-motion`,+ * so the theme's layout motion moves it (Primer an ease over 200 ms, Frost a longer glide,+ * Console four steps; none under reduced motion). A transform transition is the motion files'+ * alone.+ */+import type { ButtonHTMLAttributes } from "react";++export interface SwitchProps extends Omit<+ ButtonHTMLAttributes<HTMLButtonElement>,+ "onChange" | "type" | "role"+> {+ checked: boolean;+ onChange: (checked: boolean) => void;+}++export function Switch({ checked, onChange, disabled, className, title, ...rest }: SwitchProps) {+ return (+ <button+ type="button"+ role="switch"+ aria-checked={checked}+ disabled={disabled}+ onClick={() => onChange(!checked)}+ className={+ "relative inline-flex h-5 w-9 shrink-0 items-center rounded-full px-0.5 " ++ "inset-ring inset-ring-fg/10 transition-colors duration-200 ease-out " ++ "focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 " ++ "disabled:cursor-not-allowed disabled:opacity-60 " ++ (checked ? "bg-accent" : "bg-switch-track") ++ ` ${className ?? ""}`+ }+ // A hover hint shows in the shared tooltip, never the browser's own `title`.+ data-tooltip={title}+ {...rest}+ >+ <span+ aria-hidden+ data-layout-motion+ className={`grid w-full ${checked ? "grid-cols-[1fr_auto]" : "grid-cols-[0fr_auto]"}`}+ >+ <span />+ <span+ className={`size-4 rounded-full border ${+ // The off knob sits on a pale track, so its edge is the theme's knob line (it+ // carries the 3:1 there); on the accent track the fill already contrasts and the+ // edge stays faint.+ checked ? "border-fg/10 bg-switch-knob-on" : "border-switch-knob-line bg-switch-knob"+ }`}+ />+ </span>+ </button>+ );+}diff --git a/packages/ui/src/components/forms/toggle-row/toggle-row.tsx b/packages/ui/src/components/forms/toggle-row/toggle-row.tsxnew file mode 100644index 00000000..b71b0f86--- /dev/null+++ b/packages/ui/src/components/forms/toggle-row/toggle-row.tsx@@ -0,0 +1,61 @@+/**+ * A label (with its "?") and hint beside a Switch: the one shape of an on/off setting.+ *+ * One row in three frames:+ *+ * - `row` (the default) is a preference row ({@link PrefRow}) in a ruled list — the settings+ * pages, where rows separate with rules;+ * - `plain` sits in a stack whose parent spaces its children (a settings section's body, a plugin's+ * fields) and draws nothing of its own;+ * - `card` stands alone at the head of a panel, in a hairline box (a feature's master switch).+ *+ * The switch is named by the row's label, since the title is a `<p>` beside it rather than a+ * `<label>` around it (a label would name the "?" button instead).+ */+import type { ReactNode } from "react";+import { PrefRow, PrefRowLabel } from "../pref-row/pref-row";+import { Switch } from "../switch/switch";++export type ToggleRowVariant = "row" | "plain" | "card";++const FRAME: Record<Exclude<ToggleRowVariant, "row">, string> = {+ plain: "flex items-center justify-between gap-3",+ card: "flex items-center justify-between gap-4 rounded-lg border border-line px-4 py-3",+};++export function ToggleRow({+ label,+ hint,+ info,+ checked,+ onChange,+ disabled,+ variant = "row",+}: {+ label: string;+ /** A line that stays on screen under the label: a state or a format, not what the row means. */+ hint?: string;+ /** Semantic explanation, disclosed by a "?" beside the label. */+ info?: ReactNode;+ checked: boolean;+ onChange: (checked: boolean) => void;+ disabled?: boolean;+ variant?: ToggleRowVariant;+}) {+ const control = (+ <Switch checked={checked} onChange={onChange} disabled={disabled} aria-label={label} />+ );+ if (variant === "row") {+ return (+ <PrefRow label={label} hint={hint} info={info}>+ {control}+ </PrefRow>+ );+ }+ return (+ <div className={FRAME[variant]}>+ <PrefRowLabel label={label} hint={hint} info={info} />+ <div className="shrink-0">{control}</div>+ </div>+ );+}diff --git a/packages/ui/src/components/icons/icons.ts b/packages/ui/src/components/icons/icons.tsindex 718daf17..bddce2ee 100644--- a/packages/ui/src/components/icons/icons.ts+++ b/packages/ui/src/components/icons/icons.ts@@ -229,6 +229,8 @@ export const ICONS = {rotateCw: "M23 4v6h-6M20.49 15a9 9 0 1 1-2.12-9.36L23 10",/** A plus. `PlusIcon` (marks.tsx) draws this path with a stroke weight of its own. */plus: "M12 5v14M5 12h14",+ /** A magnifier: a lens and its handle. The search box's leading mark and the toggle that opens one. */+ search: "M21 21l-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z",// --- Direction ----------------------------------------------------------------------------@@ -284,6 +286,9 @@ export const ICONS = {/** An info circle: the 9-radius status circle with a bar and a dot inside it. */info: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM12 11v5m0-8h.01",+ /** A question mark in the status circle: the "?" that discloses an explanation (InfoPopover). */+ helpCircle:+ "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.6 9.3a2.5 2.5 0 0 1 4.9.8c0 1.7-2.5 2.5-2.5 2.5M12 16.8h.01",/** A triangle with an exclamation mark (lucide triangle-alert): a warning worth acting on. */triangleAlert:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3zM12 9v4m0 4h.01",diff --git a/packages/web/src/components/ui/help-fold.tsx b/packages/ui/src/components/overlays/info-popover/help-fold.tsxsimilarity index 82%rename from packages/web/src/components/ui/help-fold.tsxrename to packages/ui/src/components/overlays/info-popover/help-fold.tsxindex 6ec66072..3f2305ed 100644--- a/packages/web/src/components/ui/help-fold.tsx+++ b/packages/ui/src/components/overlays/info-popover/help-fold.tsx@@ -18,14 +18,15 @@* The chevron is the app's one collapse indicator, the same glyph every other collapsible* rotates; a help fold that announced itself differently would be a second pattern for no reason.*- * A lone row reads "More info" and borrows its subject from `label`. Several stacked into an FAQ- * take `title` instead and say what each one holds, because a column of identical "More info" rows- * tells a reader nothing about which one answers their question.+ * A lone row reads "More info" (`UiStrings.moreInfo`) and borrows its subject from `label`.+ * Several stacked into an FAQ take `title` instead and say what each one holds, because a column+ * of identical "More info" rows tells a reader nothing about which one answers their question.*/import { useId, useState } from "react";import type { ReactNode } from "react";-import { Chevron, ICON_GAP, ICON_SIZE } from "@prismshadow/penguin-ui";-import { S } from "../../lib/strings";+import { ICON_GAP, ICON_SIZE } from "../../../icon-scale";+import { useUiStrings } from "../../../strings";+import { Chevron } from "../../icons/chevron/chevron";export function HelpFold({children,@@ -56,6 +57,7 @@ export function HelpFold({flush?: boolean;className?: string;}) {+ const strings = useUiStrings();const [open, setOpen] = useState(false);const panelId = useId();return (@@ -67,19 +69,19 @@ export function HelpFold({// The visible text is a prefix of the accessible name, so "label in name" holds and a// voice-control user can still say what they see.{...(title === undefined && label !== undefined- ? { "aria-label": S.common.moreInfoAbout(label) }+ ? { "aria-label": strings.moreInfoAbout(label) }: {})}onClick={() => setOpen((v) => !v)}- className={`flex items-center ${ICON_GAP.tight} rounded text-xs text-gray-500 transition-colors duration-150 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`}+ className={`flex items-center ${ICON_GAP.tight} rounded-sm text-xs text-fg-muted transition-colors duration-150 hover:text-fg`}><Chevron open={open} size={ICON_SIZE.chevronDense} />- {title ?? S.common.moreInfo}+ {title ?? strings.moreInfo}</button>{/* pl-4.5 = the chevron's 12px plus the row's gap, so the body lines up under the label. */}<divid={panelId}hidden={!open}- className={`mt-1.5 ${flush ? "" : "pl-4.5"} text-xs leading-relaxed text-gray-500 dark:text-gray-400`}+ className={`mt-1.5 ${flush ? "" : "pl-4.5"} text-xs leading-relaxed text-fg-muted`}>{children}</div>diff --git a/packages/web/src/components/ui/info-popover.tsx b/packages/ui/src/components/overlays/info-popover/info-popover.tsxsimilarity index 76%rename from packages/web/src/components/ui/info-popover.tsxrename to packages/ui/src/components/overlays/info-popover/info-popover.tsxindex 6b8befab..303e4cb8 100644--- a/packages/web/src/components/ui/info-popover.tsx+++ b/packages/ui/src/components/overlays/info-popover/info-popover.tsx@@ -14,17 +14,18 @@* there is captured and its propagation stopped, which is what lets one Esc dismiss this* popover while an enclosing Modal stays open. z-[60] for the same reason OptionMenu uses it:* a portaled node sits in the root stacking context and must clear the modal overlay's z-50.+ *+ * The trigger's accessible name is the interface's "More info" (`UiStrings.moreInfo`), with the+ * subject folded in when the caller names one (`UiStrings.moreInfoAbout`).*/import { useId, useState } from "react";import type { ReactNode } from "react";import { createPortal } from "react-dom";-import { ICON_SIZE } from "@prismshadow/penguin-ui";-import { S } from "../../lib/strings";-import { usePortalPanel } from "./use-portal-panel";--/** Circled question mark: the app's 9-radius status circle, with a mark and a dot inside it. */-const HELP_ICON =- "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18zM9.6 9.3a2.5 2.5 0 0 1 4.9.8c0 1.7-2.5 2.5-2.5 2.5M12 16.8h.01";+import { ICON_SIZE } from "../../../icon-scale";+import { useUiStrings } from "../../../strings";+import { GlyphIcon } from "../../icons/glyph-icon/glyph-icon";+import { ICONS } from "../../icons/icons";+import { usePortalPanel } from "../portal-panel/use-portal-panel";const PANEL_WIDTH = 288; // w-72, the OptionMenu panel width@@ -46,6 +47,7 @@ export function InfoPopover({size?: number;className?: string;}) {+ const strings = useUiStrings();const [open, setOpen] = useState(false);const panelId = useId();const { triggerRef, panelRef, position } = usePortalPanel({@@ -55,7 +57,7 @@ export function InfoPopover({estimatedHeight: 160,panelWidth: PANEL_WIDTH,});- const name = label !== undefined ? S.common.moreInfoAbout(label) : S.common.moreInfo;+ const name = label !== undefined ? strings.moreInfoAbout(label) : strings.moreInfo;return (<><button@@ -69,22 +71,9 @@ export function InfoPopover({// explanation on focus rather than only announcing that something expanded.aria-describedby={open ? panelId : undefined}onClick={() => setOpen((v) => !v)}- className={`inline-flex shrink-0 items-center justify-center rounded-full text-gray-400 transition-colors duration-150 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 ${className}`}+ className={`inline-flex shrink-0 items-center justify-center rounded-full text-fg-subtle transition-colors duration-150 hover:text-fg-muted ${className}`}>- <svg- width={size}- height={size}- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="1.7"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden- className="block shrink-0"- >- <path d={HELP_ICON} />- </svg>+ <GlyphIcon d={ICONS.helpCircle} size={size} /></button>{open &&position &&@@ -99,7 +88,7 @@ export function InfoPopover({bottom: position.bottomPx,left: position.left,}}- className="ui-glass anim-pop z-[60] max-h-[70vh] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-gray-200 bg-white px-3 py-2 text-xs leading-relaxed text-gray-600 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-300"+ className="ui-glass anim-pop z-[60] max-h-[70vh] w-72 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-md border border-line bg-overlay px-3 py-2 text-xs leading-relaxed text-fg-muted shadow-lg">{children}</div>,diff --git a/packages/ui/src/components/overlays/menu-panel/menu-panel.tsx b/packages/ui/src/components/overlays/menu-panel/menu-panel.tsxnew file mode 100644index 00000000..06ad861c--- /dev/null+++ b/packages/ui/src/components/overlays/menu-panel/menu-panel.tsx@@ -0,0 +1,43 @@+/**+ * The menu panel: the one look every picker and menu shares — Select's floating panel, its two+ * row states and its check mark — so a choice reads the same wherever it is made. Select,+ * OptionMenu, Dropdown and the pickers built on them spell their panels and rows from these; the+ * Menu family builds on them.+ */+import { CheckIcon } from "../../icons/marks/marks";++/**+ * The floating panel every picker and menu opens: a hairline box on the overlay layer, one shadow+ * step, a little padding above the first row and below the last. Callers add position, width,+ * z-layer and max height, and the `ui-glass` hook in the component that opens the panel (a hook+ * belongs to its host component, not to a string).+ */+export const menuPanelClass =+ "anim-pop overflow-y-auto rounded-md border border-line bg-overlay py-1 shadow-lg";++/**+ * A menu row's padding, alignment and colour transition. Callers add `flex` or `block` and the+ * row's ink and fill from {@link menuRowTone}.+ */+export const menuRowClass = "w-full px-3 py-1.5 text-left transition-colors duration-150";++/**+ * A menu row's ink and fill: an action row, or a choice that is not the current one, fills on+ * hover; the current choice is filled and set in the medium weight (and carries ChoiceCheck).+ * The same two states in every picker, so a choice reads the same wherever it is made.+ */+export function menuRowTone(selected = false): string {+ return selected ? "bg-surface-muted font-medium text-fg" : "text-fg hover:bg-surface-muted";+}++/**+ * The current choice's mark, Select's check. It sits in a fixed slot at the row's end, so the+ * rows of one list align whether or not they carry it.+ */+export function ChoiceCheck({ on }: { on: boolean }) {+ return (+ <span aria-hidden className="flex w-3 shrink-0 justify-center">+ {on && <CheckIcon className="text-fg-muted" />}+ </span>+ );+}diff --git a/packages/web/src/components/ui/use-portal-panel.ts b/packages/ui/src/components/overlays/portal-panel/use-portal-panel.tssimilarity index 55%rename from packages/web/src/components/ui/use-portal-panel.tsrename to packages/ui/src/components/overlays/portal-panel/use-portal-panel.tsindex 714127db..cd2138fd 100644--- a/packages/web/src/components/ui/use-portal-panel.ts+++ b/packages/ui/src/components/overlays/portal-panel/use-portal-panel.ts@@ -1,33 +1,28 @@/**- * Positioning and close behavior for a portaled popup panel (used by OptionMenu,- * shared for future popup controls): the panel is mounted via createPortal to- * document.body and positioned with `position: fixed` against viewport- * coordinates, so it isn't clipped by any ancestor's overflow (Modal content- * area overflow-y-auto, table overflow-x-auto, etc.).+ * Positioning and close behaviour for a portaled popup panel (Select, OptionMenu, InfoPopover+ * and the app's own panels open through it): the panel is mounted via createPortal to+ * document.body and positioned with `position: fixed` against viewport coordinates, so it isn't+ * clipped by any ancestor's overflow (a Modal's scrolling body, a table's overflow-x-auto, etc.).*- * Positioned once on expand: opens upward if there isn't enough room below and- * there's more room above, and the left edge is clamped within the viewport.- * Closes on: outside click / Esc / a scroll that moved the trigger / window- * resize. Esc uses capture and stops propagation — Modal also listens for Esc- * during the window bubble phase and registers earlier, so without stopping- * propagation it would close both the panel and the dialog together; scroll- * likewise uses capture (scroll doesn't bubble), and the panel collapses- * directly the moment its position would go stale from scrolling, rather than- * leaving it floating out of place.+ * Positioned once on expand: opens upward if there isn't enough room below and there's more room+ * above, and the left edge is clamped within the viewport. Closes on: outside click / Esc / a+ * scroll that moved the trigger / window resize. Esc uses capture and stops propagation — Modal+ * also listens for Esc during the window bubble phase and registers earlier, so without stopping+ * propagation it would close both the panel and the dialog together; scroll likewise uses capture+ * (scroll doesn't bubble), and the panel collapses directly the moment its position would go+ * stale from scrolling, rather than leaving it floating out of place.*- * "That moved the trigger" is not a nicety. Capture on `window` hears every- * scrolling element in the document, and the panel took each one as a reason to- * close — so a chat pane auto-following a streaming reply closed the context- * ring's panel, which sits in the composer toolbar over content that never moved,- * on every chunk that arrived. `scrollMovesAnchor` (lib/context-menu.ts, shared with the context- * menu's own dismissal) decides which scrolls those are, from the trigger this- * hook already holds. Closing rather than re-positioning stays the behavior: the- * panel is placed once and does not follow its trigger, so a scroll that DID move- * it leaves the panel pointing at nothing. A trigger the rule cannot see closes,- * as before — the panel must never become one that no scroll dismisses.+ * "That moved the trigger" is not a nicety. Capture on `window` hears every scrolling element in+ * the document, and the panel took each one as a reason to close — so a chat pane auto-following+ * a streaming reply closed the context ring's panel, which sits in the composer toolbar over+ * content that never moved, on every chunk that arrived. {@link scrollMovesAnchor} (shared with+ * the app's context menu and the dock launcher's dismissal) decides which scrolls those are, from+ * the trigger this hook already holds. Closing rather than re-positioning stays the behaviour: the+ * panel is placed once and does not follow its trigger, so a scroll that DID move it leaves the+ * panel pointing at nothing. A trigger the rule cannot see closes, as before — the panel must+ * never become one that no scroll dismisses.*/import { useEffect, useLayoutEffect, useRef, useState } from "react";-import { scrollMovesAnchor } from "../../lib/context-menu";export interface PortalPanelPosition {topPx?: number;@@ -40,6 +35,28 @@ export interface PortalPanelPosition {const PANEL_GAP = 4;const VIEWPORT_MARGIN = 16;+/**+ * Does a scroll of `target` move the content `owner` sits in — the question an anchored panel has+ * to answer before dismissing itself?+ *+ * The panel's scroll listener runs in the capture phase, because scroll events do not bubble. The+ * price is that it hears **every** scrolling element in the document, not only the ones the+ * anchor lies inside: a streaming conversation scrolls its message list on every chunk, and taking+ * each of those as a reason to dismiss wiped a context menu opened in the sidebar — a part of the+ * page that had not moved at all. Containment is the whole test, and the page itself needs no case+ * of its own, because a full-page scroll targets `document`, which contains every node in it.+ *+ * A caller that names no owner still dismisses on any scroll, which is what every anchored panel+ * did before this rule existed.+ */+export function scrollMovesAnchor(target: Node | null, owner: Node | null): boolean {+ if (owner === null || target === null) return true;+ // An Element and the Document both answer `contains`; a target that does not is not+ // something this rule can judge, so it dismisses rather than pin the panel to content+ // that may well have moved.+ return typeof target.contains === "function" ? target.contains(owner) : true;+}+export function usePortalPanel({open,onClose,@@ -56,7 +73,8 @@ export function usePortalPanel({const triggerRef = useRef<HTMLButtonElement>(null);const panelRef = useRef<HTMLDivElement>(null);const [position, setPosition] = useState<PortalPanelPosition | null>(null);- // Store onClose in a ref: callers mostly pass inline arrow functions, and putting it directly in the dependency array would re-attach the listener on every render.+ // Store onClose in a ref: callers mostly pass inline arrow functions, and putting it directly in+ // the dependency array would re-attach the listener on every render.const onCloseRef = useRef(onClose);onCloseRef.current = onClose;@@ -94,7 +112,8 @@ export function usePortalPanel({onCloseRef.current();}};- // The panel's own internal scroll (when the list exceeds max-h) must not trigger a close: only scrolling of an outer container invalidates the position.+ // The panel's own internal scroll (when the list exceeds max-h) must not trigger a close: only+ // scrolling of an outer container invalidates the position.const onScroll = (e: Event) => {if (panelRef.current?.contains(e.target as Node)) return;// ...and only a container that actually holds the trigger moved the position thisdiff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 82d33dc3..5f04ae0a 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -43,3 +43,29 @@ export * from "./components/actions/link/link";export * from "./components/actions/copy-button/copy-button";export * from "./components/actions/kbd/kbd";export * from "./components/actions/hidden-file-input/hidden-file-input";++// W2-0 — menu panel: the panel, row states and check mark every picker and menu shares.+export * from "./components/overlays/menu-panel/menu-panel";++// W2-A — forms: the field scaffolding, the text controls and their search box, checkboxes and+// radios.+export * from "./components/forms/field/field";+export * from "./components/forms/input/input";+export * from "./components/forms/password-input/password-input";+export * from "./components/forms/search-input/search-input";+export * from "./components/forms/checkbox/checkbox";+export * from "./components/forms/radio/radio";++// W2-B — pickers, switches and settings rows, with the portal panel and the "?" disclosure they+// open (moved up from W3).+export * from "./components/overlays/portal-panel/use-portal-panel";+export * from "./components/overlays/info-popover/info-popover";+export * from "./components/overlays/info-popover/help-fold";+export * from "./components/forms/select/select";+export * from "./components/forms/select/option-menu";+export * from "./components/forms/picker-list/picker-list";+export * from "./components/forms/switch/switch";+export * from "./components/forms/toggle-row/toggle-row";+export * from "./components/forms/segmented/segmented";+export * from "./components/forms/swatch-picker/swatch-picker";+export * from "./components/forms/pref-row/pref-row";diff --git a/packages/ui/src/strings.ts b/packages/ui/src/strings.tsindex 9dae4171..fa00c820 100644--- a/packages/ui/src/strings.ts+++ b/packages/ui/src/strings.ts@@ -23,6 +23,16 @@ export interface UiStrings {copied: string;/** A busy fallback a primitive may announce while its caller has named nothing. */loading: string;+ /** The name of a password field's reveal toggle while the value is masked (`PasswordInput`). */+ showPassword: string;+ /** The same toggle's name while the value is shown. */+ hidePassword: string;+ /** The name of a search box's clear button (`SearchInput`). */+ clearSearch: string;+ /** The "?" disclosure's name when it names no subject, and a help fold's row text. */+ moreInfo: string;+ /** The same name with the subject folded in ("More info: Vault"): InfoPopover, HelpFold. */+ moreInfoAbout: (subject: string) => string;}/** The English fallbacks, used wherever no provider is mounted (a test, a stand-alone page). */@@ -30,6 +40,11 @@ export const DEFAULT_UI_STRINGS: UiStrings = {close: "Close",copied: "Copied",loading: "Loading…",+ showPassword: "Show password",+ hidePassword: "Hide password",+ clearSearch: "Clear search",+ moreInfo: "More info",+ moreInfoAbout: (subject) => `More info: ${subject}`,};const UiStringsContext = createContext<UiStrings>(DEFAULT_UI_STRINGS);diff --git a/packages/ui/test/button.test.ts b/packages/ui/test/button.test.tsindex 5cd591cd..a86afafc 100644--- a/packages/ui/test/button.test.ts+++ b/packages/ui/test/button.test.ts@@ -7,7 +7,7 @@ import { createElement } from "react";import { describe, expect, it } from "vitest";import { Button, IconButton, buttonClass } from "../src/components/actions/button/button";import type { ButtonSize, ButtonVariant } from "../src/components/actions/button/button";-import { UiStringsProvider } from "../src/strings";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";import { classTokens, renderStatic } from "../src/testing";const VARIANTS: ButtonVariant[] = ["primary", "secondary", "danger", "ghost", "link"];@@ -69,7 +69,7 @@ describe("Button", () => {const injected = renderStatic(createElement(UiStringsProvider,- { strings: { close: "关闭", copied: "已复制", loading: "加载中…" } },+ { strings: { ...DEFAULT_UI_STRINGS, close: "关闭", copied: "已复制", loading: "加载中…" } },createElement(Button, { loading: true }, "保存"),),);diff --git a/packages/ui/test/checkbox.test.ts b/packages/ui/test/checkbox.test.tsnew file mode 100644index 00000000..59257246--- /dev/null+++ b/packages/ui/test/checkbox.test.ts@@ -0,0 +1,63 @@+/**+ * Checkbox (src/components/forms/checkbox/checkbox.tsx): a native checkbox drawn in tokens, whose+ * label toggles it and whose hint describes it, with a drawn dash for the indeterminate state.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { Checkbox } from "../src/components/forms/checkbox/checkbox";+import { classTokens, renderStatic } from "../src/testing";++const noop = () => {};+const box = (props: Partial<Parameters<typeof Checkbox>[0]> = {}) =>+ renderStatic(createElement(Checkbox, { checked: false, onChange: noop, ...props }));++describe("Checkbox", () => {+ it("is a real checkbox, named by the caller when it has no label", () => {+ const html = box({ "aria-label": "Clear the stored key" });+ expect(html).toMatch(/<input type="checkbox"[^>]*aria-label="Clear the stored key"/);+ expect(html).not.toContain("<label");+ expect(html).not.toContain("<svg");+ });++ it("fills with the accent and draws the check only while on", () => {+ const off = classTokens(box());+ expect(off).toEqual(expect.arrayContaining(["border-line-emphasis", "bg-surface"]));+ const on = box({ checked: true });+ expect(on).toContain('checked=""');+ expect(classTokens(on)).toEqual(+ expect.arrayContaining(["border-accent", "bg-accent", "text-accent-fg"]),+ );+ expect(on).toContain('d="M2.6 6.2l2.2 2.2 4.6-4.8"');+ });++ it("draws a dash, not a check, for the indeterminate state", () => {+ const html = box({ indeterminate: true });+ expect(html).toContain('d="M3 6h6"');+ expect(html).not.toContain('d="M2.6 6.2');+ expect(classTokens(html)).toContain("bg-accent");+ // Mixed wins over checked: a summary box is never both.+ expect(box({ indeterminate: true, checked: true })).toContain('d="M3 6h6"');+ });++ it("wraps the box and its text in one label, and describes the box with its hint", () => {+ const html = box({ label: "Enabled", hint: "Runs on schedule" });+ expect(html.startsWith("<label")).toBe(true);+ const described = /aria-describedby="([^"]+)"/.exec(html)?.[1];+ expect(described).toBeDefined();+ expect(html).toContain(`id="${described}"`);+ expect(html).toContain("Runs on schedule");+ expect(classTokens(html)).toEqual(expect.arrayContaining(["text-xs", "text-fg-muted"]));+ });++ it("keeps a caller's own description beside the hint", () => {+ const html = box({ label: "Enabled", hint: "h", "aria-describedby": "outside" });+ expect(html).toMatch(/aria-describedby="outside [^"]+"/);+ });++ it("dims the whole row and refuses the pointer when disabled", () => {+ const html = box({ label: "Enabled", disabled: true });+ expect(html).toContain('disabled=""');+ expect(classTokens(html)).toEqual(expect.arrayContaining(["opacity-60", "cursor-not-allowed"]));+ expect(classTokens(box({ label: "Enabled" }))).toContain("cursor-pointer");+ });+});diff --git a/packages/ui/test/close-button.test.ts b/packages/ui/test/close-button.test.tsindex f7ce4815..30f5ee7b 100644--- a/packages/ui/test/close-button.test.ts+++ b/packages/ui/test/close-button.test.ts@@ -5,7 +5,7 @@import { createElement } from "react";import { describe, expect, it } from "vitest";import { CloseButton } from "../src/components/actions/close-button/close-button";-import { UiStringsProvider } from "../src/strings";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";import { classTokens, renderStatic } from "../src/testing";const noop = () => {};@@ -18,7 +18,7 @@ describe("CloseButton", () => {});it("takes the injected word, and a caller's label over both", () => {- const strings = { close: "关闭", copied: "已复制", loading: "加载中…" };+ const strings = { ...DEFAULT_UI_STRINGS, close: "关闭", copied: "已复制", loading: "加载中…" };const injected = renderStatic(createElement(UiStringsProvider, { strings }, createElement(CloseButton, { onClose: noop })),);diff --git a/packages/ui/test/copy-button.test.ts b/packages/ui/test/copy-button.test.tsindex 248282d1..7d534013 100644--- a/packages/ui/test/copy-button.test.ts+++ b/packages/ui/test/copy-button.test.ts@@ -11,10 +11,10 @@ import {CopyCheckGlyph,} from "../src/components/actions/copy-button/copy-button";import { ICONS } from "../src/components/icons/icons";-import { UiStringsProvider } from "../src/strings";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";import { classTokens, renderStatic } from "../src/testing";-const ZH = { close: "关闭", copied: "已复制", loading: "加载中…" };+const ZH = { ...DEFAULT_UI_STRINGS, close: "关闭", copied: "已复制", loading: "加载中…" };describe("CopyButton", () => {it("names the action, shows no text, and keeps the live region as a sibling", () => {diff --git a/packages/ui/test/field.test.ts b/packages/ui/test/field.test.tsnew file mode 100644index 00000000..07b609fb--- /dev/null+++ b/packages/ui/test/field.test.ts@@ -0,0 +1,140 @@+/**+ * The field scaffolding (src/components/forms/field/field.tsx): the required mark, the label, hint+ * and error, the two layouts, and the control look in tokens.+ *+ * The layout trap is HTML's, not React's: an info trigger is a `<button>`, a `<button>` is a+ * labelable element, and a wrapping `<label>` names its FIRST labelable descendant. Nesting a+ * trigger inside `Field`'s usual `<label>` wrapper would therefore retarget the field's title from+ * the input to the "?" — silently, with no visual symptom.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import {+ Field,+ FieldError,+ FieldHint,+ FieldLabel,+ RequiredMark,+ controlBase,+} from "../src/components/forms/field/field";+import { Input } from "../src/components/forms/input/input";+import { classTokens, renderStatic } from "../src/testing";++const control = createElement("input", { id: "c" });++describe("RequiredMark", () => {+ it("is decorative beside a control, whose aria-required is what gets announced", () => {+ const html = renderStatic(createElement(RequiredMark));+ expect(html).toBe('<span class="ml-0.5 text-tone-danger-fg" aria-hidden="true">*</span>');+ });++ it("states itself where no control carries aria-required", () => {+ const html = renderStatic(createElement(RequiredMark, { label: "required" }));+ expect(html).toMatch(+ /^<span class="[^"]*text-tone-danger-fg[^"]*"><span aria-hidden="true">\*<\/span>/,+ );+ expect(html).toContain('<span class="sr-only">required</span>');+ });+});++describe("FieldLabel, FieldHint and FieldError", () => {+ it("is a real label when it knows the control's id, and a span inside a wrapping label", () => {+ expect(renderStatic(createElement(FieldLabel, { htmlFor: "c", children: "Name" }))).toMatch(+ /^<label for="c" class="[^"]*text-fg-muted[^"]*">Name<\/label>$/,+ );+ const span = renderStatic(createElement(FieldLabel, { required: true, children: "Name" }));+ expect(span).toMatch(/^<span class="[^"]*mb-1 block[^"]*">Name<span/);+ expect(span).toContain('aria-hidden="true">*</span>');+ });++ it("drops the block layout when the label shares a row", () => {+ const html = renderStatic(createElement(FieldLabel, { block: false, children: "Name" }));+ expect(classTokens(html)).not.toContain("block");+ });++ it("announces an error the moment it appears, under the id the control points at", () => {+ const html = renderStatic(createElement(FieldError, { id: "e", children: "Required" }));+ expect(html).toContain('id="e"');+ expect(html).toContain('role="alert"');+ expect(classTokens(html)).toContain("text-tone-danger-fg");+ expect(classTokens(renderStatic(createElement(FieldHint, { children: "ms" })))).toContain(+ "text-fg-muted",+ );+ });+});++describe("Field", () => {+ it("renders the bare control when there is nothing to put around it", () => {+ expect(renderStatic(createElement(Field, { children: control }))).toBe('<input id="c"/>');+ });++ it("wraps the control in its label, and shows the error in place of the hint", () => {+ const plain = renderStatic(createElement(Field, { label: "Name", children: control }));+ expect(plain.startsWith("<label")).toBe(true);+ expect(plain).not.toContain("<label for=");+ const failed = renderStatic(+ createElement(Field, {+ label: "Name",+ hint: "Letters only",+ error: "Required",+ errorId: "e",+ children: control,+ }),+ );+ expect(failed).toContain('<span id="e" role="alert"');+ expect(failed).not.toContain("Letters only");+ });++ describe("with an info popover", () => {+ const withInfo = renderStatic(+ createElement(Input, {+ label: "Timeout",+ info: "Per-request timeout.",+ infoLabel: "Timeout",+ hint: "milliseconds",+ value: "",+ readOnly: true,+ }),+ );++ it("associates the title by htmlFor instead of wrapping the control", () => {+ const forMatch = /<label for="([^"]+)"/.exec(withInfo);+ expect(forMatch, "the title must be a <label for=…>").not.toBeNull();+ expect(withInfo).toContain(`id="${forMatch?.[1]}"`);+ });++ it("never puts the trigger inside a label element", () => {+ expect(withInfo).toContain("<button");+ // Everything between a <label> open tag and its close must be free of <button>.+ for (const [, inner] of withInfo.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/g)) {+ expect(inner).not.toContain("<button");+ }+ });++ it("names the trigger after the field", () => {+ expect(withInfo).toContain('aria-label="More info: Timeout"');+ });++ it("keeps a formatting hint visible alongside the disclosed semantics", () => {+ // The split is the whole point: what the field MEANS is disclosed, what shape the value+ // must take stays on screen while the user types.+ expect(withInfo).toContain("milliseconds");+ expect(withInfo).not.toContain("Per-request timeout.");+ });+ });+});++describe("controlBase", () => {+ it("draws the control in tokens, with the theme's own input focus ring", () => {+ expect(controlBase.split(/\s+/)).toEqual(+ expect.arrayContaining([+ "border-line-emphasis",+ "bg-surface",+ "text-fg",+ "hover:border-fg-subtle",+ "focus:border-fg-muted",+ "focus:[box-shadow:var(--ui-focus-ring-input)]",+ ]),+ );+ });+});diff --git a/packages/web/test/help-fold.test.ts b/packages/ui/test/help-fold.test.tssimilarity index 61%rename from packages/web/test/help-fold.test.tsrename to packages/ui/test/help-fold.test.tsindex b9888bc6..73801c3b 100644--- a/packages/web/test/help-fold.test.ts+++ b/packages/ui/test/help-fold.test.ts@@ -1,28 +1,19 @@/**- * The inline help fold (src/components/ui/help-fold.tsx): the disclosure a surface uses when it- * has no title for a circled "?" to anchor to. `test/disclosure-anchor.test.ts` enforces when to- * reach for it; this covers what it renders.+ * The inline help fold (src/components/overlays/info-popover/help-fold.tsx): the disclosure a+ * surface uses when it has no title for a circled "?" to anchor to. The web app's+ * `disclosure-anchor.test.ts` enforces when to reach for it; this covers what it renders.*/-import { describe, expect, it } from "vitest";import { createElement } from "react";-import { renderToStaticMarkup } from "react-dom/server";-import { HelpFold } from "../src/components/ui/help-fold";-import { S } from "../src/lib/strings";-import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";+import { describe, expect, it } from "vitest";+import { HelpFold } from "../src/components/overlays/info-popover/help-fold";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";+import type { UiStrings } from "../src/strings";+import { renderStatic } from "../src/testing";const DESC = "The vault stores values that commands can read at run time.";-/** The module rendered below, found by scanning web and the shared UI package (see roots.ts). */-describe("the fold's source", () => {- it("scans every source root, and finds the fold in one place", () => {- const scan = scanSources();- expectEveryRootScanned(scan);- expectSingleHome(scan, "packages/web/src/components/ui/help-fold.tsx");- });-});-describe("HelpFold", () => {- const html = renderToStaticMarkup(createElement(HelpFold, { children: DESC }));+ const html = renderStatic(createElement(HelpFold, { children: DESC }));it("is a real button that starts collapsed and controls its panel", () => {expect(html).toContain("<button");@@ -42,8 +33,22 @@ describe("HelpFold", () => {expect(html).toContain(DESC);});- it("names itself, since it has no title beside it to borrow meaning from", () => {- expect(html).toContain(S.common.moreInfo);+ it("names itself in the interface's words, since it has no title beside it", () => {+ expect(html).toContain(DEFAULT_UI_STRINGS.moreInfo);+ const zh: UiStrings = {+ ...DEFAULT_UI_STRINGS,+ moreInfo: "说明",+ moreInfoAbout: (subject) => `说明:${subject}`,+ };+ const localized = renderStatic(+ createElement(+ UiStringsProvider,+ { strings: zh },+ createElement(HelpFold, { label: "Vault", children: DESC }),+ ),+ );+ expect(localized).toContain(">说明</button>");+ expect(localized).toContain('aria-label="说明:Vault"');});it("rotates the app's one collapse chevron rather than inventing an indicator", () => {@@ -56,27 +61,27 @@ describe("HelpFold", () => {// A block with its own left edge — a code box — has to line up with what sits above it, so// the chevron's indent is dropped; a run of prose keeps it.expect(html).toContain("pl-4.5");- const flush = renderToStaticMarkup(createElement(HelpFold, { flush: true, children: DESC }));+ const flush = renderStatic(createElement(HelpFold, { flush: true, children: DESC }));expect(flush).not.toContain("pl-4.5");});it("folds the subject into the accessible name, keeping the visible text a prefix of it", () => {// WCAG "label in name": a voice-control user must be able to say what they can see.- const named = renderToStaticMarkup(createElement(HelpFold, { label: "Vault", children: DESC }));- const accessible = S.common.moreInfoAbout("Vault");+ const named = renderStatic(createElement(HelpFold, { label: "Vault", children: DESC }));+ const accessible = DEFAULT_UI_STRINGS.moreInfoAbout("Vault");expect(named).toContain(`aria-label="${accessible}"`);- expect(accessible.startsWith(S.common.moreInfo)).toBe(true);+ expect(accessible.startsWith(DEFAULT_UI_STRINGS.moreInfo)).toBe(true);});it("lets a fold in a stack title itself, and then carries no second name", () => {// A column of identical "More info" rows says nothing about which one to open, so an FAQ// titles each fold. The visible title IS the accessible name — an aria-label beside it// would be a second name for one trigger, which is what breaks "label in name".- const titled = renderToStaticMarkup(+ const titled = renderStatic(createElement(HelpFold, { title: "Set up the bot", label: "Vault", children: DESC }),);expect(titled).toContain("Set up the bot");- expect(titled).not.toContain(S.common.moreInfo);+ expect(titled).not.toContain(DEFAULT_UI_STRINGS.moreInfo);expect(titled).not.toContain("aria-label=");});});diff --git a/packages/ui/test/info-popover.test.ts b/packages/ui/test/info-popover.test.tsnew file mode 100644index 00000000..5492580e--- /dev/null+++ b/packages/ui/test/info-popover.test.ts@@ -0,0 +1,68 @@+/**+ * The "?" disclosure (src/components/overlays/info-popover/info-popover.tsx): a real button that+ * names itself in the interface's words, folds the subject into that name, and keeps its panel+ * out of the tree until it is opened.+ *+ * Where it may appear — only beside a title — is the web app's `disclosure-anchor.test.ts`; the+ * field layout it forces is this package's `field.test.ts`.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { InfoPopover } from "../src/components/overlays/info-popover/info-popover";+import { ICONS } from "../src/components/icons/icons";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";+import type { UiStrings } from "../src/strings";+import { classTokens, renderStatic } from "../src/testing";++const ZH: UiStrings = {+ ...DEFAULT_UI_STRINGS,+ moreInfo: "说明",+ moreInfoAbout: (subject) => `说明:${subject}`,+};++describe("InfoPopover", () => {+ const html = renderStatic(+ createElement(InfoPopover, { children: "Values take effect from the next task." }),+ );++ it("is a real button carrying an accessible name, shown through the tooltip layer", () => {+ expect(html).toMatch(/^<button type="button"/);+ expect(html).toContain('aria-label="More info"');+ expect(html).toContain('data-tooltip="More info"');+ expect(html).not.toContain("title=");+ });++ it("starts collapsed, and points at the panel it will open", () => {+ expect(html).toContain('aria-expanded="false"');+ expect(html).toMatch(/aria-controls="[^"]+"/);+ // The panel is portaled and only mounted while open, so nothing of the text is in the tree.+ expect(html).not.toContain("Values take effect");+ expect(html).not.toContain('role="tooltip"');+ });++ it("folds the subject into its name rather than repeating it", () => {+ // A trigger inside a heading would otherwise make that heading announce its own title twice.+ const named = renderStatic(createElement(InfoPopover, { label: "Vault", children: "x" }));+ expect(named).toContain('aria-label="More info: Vault"');+ expect(named).not.toContain('aria-label="Vault"');+ });++ it("speaks the interface's words once the app provides them", () => {+ const zh = renderStatic(+ createElement(+ UiStringsProvider,+ { strings: ZH },+ createElement(InfoPopover, { label: "Vault", children: "x" }),+ ),+ );+ expect(zh).toContain('aria-label="说明:Vault"');+ expect(zh).not.toContain("More info");+ });++ it("draws the registry's circled question mark in token inks", () => {+ expect(html).toContain(`d="${ICONS.helpCircle}"`);+ expect(classTokens(html)).toEqual(+ expect.arrayContaining(["text-fg-subtle", "hover:text-fg-muted", "rounded-full"]),+ );+ });+});diff --git a/packages/ui/test/input.test.ts b/packages/ui/test/input.test.tsnew file mode 100644index 00000000..11fd193a--- /dev/null+++ b/packages/ui/test/input.test.ts@@ -0,0 +1,123 @@+/**+ * The text controls (src/components/forms/input/input.tsx): the size rungs, the error state, the+ * autofill opt-out, the hover hint and the in-field affixes.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import {+ Input,+ Textarea,+ autofillProps,+ errorClass,+ noAutofill,+ sizeClass,+ sizeTextClass,+} from "../src/components/forms/input/input";+import { classTokens, renderStatic } from "../src/testing";++const IGNORES = {+ "data-1p-ignore": "",+ "data-lpignore": "true",+ "data-bwignore": "",+ "data-form-type": "other",+};++const input = (props: Parameters<typeof Input>[0]) =>+ renderStatic(createElement(Input, { value: "", readOnly: true, ...props }));++describe("the size rungs", () => {+ it("spell a control's font size in one record, sm by default", () => {+ expect(sizeTextClass).toEqual({ base: "text-base", sm: "text-xs" });+ expect(sizeClass.sm).toBe("px-2 py-1 text-xs");+ expect(sizeClass.base).toBe("px-3 py-2 text-base");+ const tokens = classTokens(input({}));+ expect(tokens).toEqual(expect.arrayContaining(["px-2", "py-1", "text-xs", "w-full"]));+ expect(tokens).not.toContain("text-base");+ });+});++describe("Input", () => {+ it("marks a required field for assistive tech without the browser's own validation", () => {+ const html = input({ label: "Name", required: true });+ expect(html).toContain('aria-required="true"');+ expect(html).not.toMatch(/<input[^>]* required/);+ });++ it("ties the error text to the control and marks it invalid", () => {+ const html = input({ label: "Name", error: "Required" });+ const described = /aria-describedby="([^"]+)"/.exec(html);+ expect(described).not.toBeNull();+ expect(html).toContain(`id="${described?.[1]}" role="alert"`);+ expect(html).toContain('aria-invalid="true"');+ });++ it("can be marked invalid with the error text placed elsewhere", () => {+ const html = input({ invalid: true });+ expect(html).toContain('aria-invalid="true"');+ expect(html).not.toContain("aria-describedby");+ expect(classTokens(html)).toContain("!border-tone-danger-fg");+ });++ it("marks an error with the danger line alone, never a tinted box inside it", () => {+ const tokens = errorClass.split(/\s+/);+ expect(tokens).toContain("!border-tone-danger-fg");+ expect(tokens.some((t) => t.includes("tone-danger-bg"))).toBe(false);+ });++ it("shows its hover hint in the shared tooltip, never the browser's title", () => {+ const html = input({ title: "Milliseconds" });+ expect(html).toContain('data-tooltip="Milliseconds"');+ expect(html).not.toContain("title=");+ });++ it("opts out of autofill unless the caller declares a credential role", () => {+ const html = input({});+ expect(html).toMatch(/autocomplete="off"/i);+ expect(html).toContain("data-1p-ignore");+ expect(input({ type: "password" })).toMatch(/autocomplete="new-password"/i);+ expect(input({ autoComplete: "username" })).not.toContain("data-1p-ignore");+ });++ it("draws its affixes inside the box, clear of the pointer, and pads the value past them", () => {+ const html = input({ affix: { leading: "¥", trailing: "/M tok" } });+ expect(html).toMatch(+ /^<span class="relative block"><span class="[^"]*left-2[^"]*">¥<\/span><input/,+ );+ expect(html).toMatch(+ /<\/span><input[^>]*\/><span class="[^"]*right-2[^"]*">\/M tok<\/span><\/span>$/,+ );+ expect(classTokens(html)).toEqual(+ expect.arrayContaining(["pointer-events-none", "absolute", "text-fg-subtle"]),+ );+ // Unmeasured, the padding still clears the affix's inset: never less than the control's own.+ expect(html).toContain("padding-left:calc(0px + 0.75rem)");+ expect(html).toContain("padding-right:calc(0px + 0.75rem)");+ });++ it("reserves only the side an affix takes, and keeps its error below the box", () => {+ const html = input({ label: "Context", error: "Too large", affix: { trailing: "Token" } });+ expect(html).toContain("padding-right:calc(0px + 0.75rem)");+ expect(html).not.toContain("padding-left");+ expect(html).toMatch(/<\/span><span id="[^"]+" role="alert"/);+ });+});++describe("Textarea", () => {+ it("keeps the roomier padding at both rungs, with the extra leading at sm", () => {+ const html = renderStatic(createElement(Textarea, { value: "", readOnly: true, mono: true }));+ expect(classTokens(html)).toEqual(+ expect.arrayContaining(["px-3", "py-2", "text-xs", "leading-relaxed", "font-mono"]),+ );+ const base = renderStatic(createElement(Textarea, { value: "", readOnly: true, size: "base" }));+ expect(classTokens(base)).toContain("text-base");+ expect(classTokens(base)).not.toContain("leading-relaxed");+ });+});++describe("autofillProps", () => {+ it("opts an undeclared field out, and a secret one as new-password", () => {+ expect(autofillProps(undefined, false)).toEqual({ autoComplete: "off", ...IGNORES });+ expect(autofillProps("off", true)).toEqual({ autoComplete: "new-password", ...IGNORES });+ expect(noAutofill).toEqual(autofillProps(undefined, false));+ });+});diff --git a/packages/ui/test/menu-panel.test.ts b/packages/ui/test/menu-panel.test.tsnew file mode 100644index 00000000..eba10ea0--- /dev/null+++ b/packages/ui/test/menu-panel.test.ts@@ -0,0 +1,42 @@+/**+ * The menu panel (src/components/overlays/menu-panel/menu-panel.tsx): the panel, row states and+ * check mark every picker and menu shares, in tokens.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import {+ ChoiceCheck,+ menuPanelClass,+ menuRowClass,+ menuRowTone,+} from "../src/components/overlays/menu-panel/menu-panel";+import { renderStatic } from "../src/testing";++const tokens = (classes: string) => classes.split(/\s+/);++describe("menu panel", () => {+ it("draws the panel as a hairline box on the overlay layer, one shadow step", () => {+ expect(tokens(menuPanelClass)).toEqual(+ expect.arrayContaining(["border", "border-line", "bg-overlay", "shadow-lg", "py-1"]),+ );+ });++ it("fills the current choice and only hovers the rest", () => {+ const current = tokens(menuRowTone(true));+ const other = tokens(menuRowTone(false));+ expect(current).toEqual(expect.arrayContaining(["bg-surface-muted", "font-medium"]));+ expect(current.some((token) => token.startsWith("hover:"))).toBe(false);+ expect(other).toContain("hover:bg-surface-muted");+ expect(other).not.toContain("font-medium");+ expect(menuRowTone()).toBe(menuRowTone(false));+ expect(tokens(menuRowClass)).toContain("transition-colors");+ });++ it("keeps the check's slot whether or not the row is the current choice", () => {+ const on = renderStatic(createElement(ChoiceCheck, { on: true }));+ const off = renderStatic(createElement(ChoiceCheck, { on: false }));+ expect(on).toMatch(/^<span aria-hidden="true" class="[^"]*w-3[^"]*"><svg/);+ expect(on).toContain("text-fg-muted");+ expect(off).toMatch(/^<span aria-hidden="true" class="[^"]*w-3[^"]*"><\/span>$/);+ });+});diff --git a/packages/ui/test/option-menu.test.ts b/packages/ui/test/option-menu.test.tsnew file mode 100644index 00000000..1f204176--- /dev/null+++ b/packages/ui/test/option-menu.test.ts@@ -0,0 +1,47 @@+/**+ * OptionMenu (src/components/forms/select/option-menu.tsx): a compact trigger over a portaled+ * panel whose rows carry a title and a description. The panel mounts only while open, so the+ * trigger and the row-description record are what a static render can check.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { OptionMenu, rowDescClass } from "../src/components/forms/select/option-menu";+import { classTokens, renderStatic } from "../src/testing";++const options = [+ { value: "r", triggerLabel: "r", label: "Read only", description: "Reads the workspace." },+ { value: "rw", triggerLabel: "rw", label: "Read and write", description: "Changes files." },+] as const;++type Props = Parameters<typeof OptionMenu<"r" | "rw">>[0];++const render = (props: Partial<Props>) =>+ renderStatic(+ createElement(OptionMenu<"r" | "rw">, { options, value: null, onChange: () => {}, ...props }),+ );++describe("OptionMenu", () => {+ it("shows the current choice's compact label on a listbox trigger", () => {+ const html = render({ value: "rw", "aria-label": "Permission" });+ expect(html).toMatch(/^<button type="button" aria-label="Permission" aria-haspopup="listbox"/);+ expect(html).toContain(">rw</span>");+ expect(html).not.toContain("Read and write");+ });++ it("falls back to the placeholder, then to a dash, while nothing is chosen", () => {+ expect(render({ value: null, placeholder: "default" })).toContain(">default</span>");+ expect(render({ value: undefined })).toContain(">—</span>");+ });++ it("sets the trigger's value in mono only when asked, and stretches only when asked", () => {+ expect(classTokens(render({ value: "r" }))).not.toContain("font-mono");+ expect(classTokens(render({ value: "r", mono: true }))).toContain("font-mono");+ expect(classTokens(render({ value: "r", fullWidth: true }))).toEqual(+ expect.arrayContaining(["w-full", "justify-between"]),+ );+ });++ it("keeps a row description on a type rung, never a fixed pixel size", () => {+ for (const size of Object.values(rowDescClass)) expect(size).toMatch(/^text-(?:xs|sm)$/);+ });+});diff --git a/packages/ui/test/password-input.test.ts b/packages/ui/test/password-input.test.tsnew file mode 100644index 00000000..94fbec70--- /dev/null+++ b/packages/ui/test/password-input.test.ts@@ -0,0 +1,54 @@+/**+ * PasswordInput (src/components/forms/password-input/password-input.tsx): a masked Input with a+ * reveal toggle named in the interface's words, and its error text wired from outside the box.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { ICONS } from "../src/components/icons/icons";+import { PasswordInput } from "../src/components/forms/password-input/password-input";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";+import { renderStatic } from "../src/testing";++const field = (props: Parameters<typeof PasswordInput>[0] = {}) =>+ renderStatic(createElement(PasswordInput, { value: "", readOnly: true, ...props }));++describe("PasswordInput", () => {+ it("starts masked, and keeps the saved login out of an opted-out box", () => {+ const html = field();+ expect(html).toContain('type="password"');+ expect(html).toMatch(/autocomplete="new-password"/i);+ });++ it("names its reveal toggle in the package's words, and keeps it out of the tab order", () => {+ const html = field();+ expect(html).toMatch(+ /<button type="button" aria-label="Show password" data-tooltip="Show password" tabindex="-1"/,+ );+ expect(html).toContain(`d="${ICONS.eye}"`);+ expect(html).not.toContain("aria-pressed");+ });++ it("speaks the injected words, and a caller's labels over both", () => {+ const strings = { ...DEFAULT_UI_STRINGS, showPassword: "显示密码", hidePassword: "隐藏密码" };+ const injected = renderStatic(+ createElement(+ UiStringsProvider,+ { strings },+ createElement(PasswordInput, { value: "", readOnly: true }),+ ),+ );+ expect(injected).toContain('aria-label="显示密码"');+ const named = field({ toggleLabels: { show: "Show the key", hide: "Hide the key" } });+ expect(named).toContain('aria-label="Show the key"');+ });++ it("renders the error under the box and points the masked input at it", () => {+ const html = field({ label: "Password", error: "Too short" });+ const errorId = /<span id="([^"]+)" role="alert"/.exec(html)?.[1];+ expect(errorId).toBeDefined();+ expect(html).toMatch(new RegExp(`<input[^>]*aria-describedby="${errorId}"`));+ expect(html).toContain('aria-invalid="true"');+ // One error text: the inner Input only gets the invalid mark.+ expect(html.match(/role="alert"/g)).toHaveLength(1);+ });+});diff --git a/packages/ui/test/picker-list.test.ts b/packages/ui/test/picker-list.test.tsnew file mode 100644index 00000000..f0d6b319--- /dev/null+++ b/packages/ui/test/picker-list.test.ts@@ -0,0 +1,54 @@+/**+ * PickerList (src/components/forms/picker-list/picker-list.tsx): a search box over a list whose+ * rows differ only in content. The box is autofocused and named by its placeholder, nothing starts+ * highlighted, the entry in effect carries the check, and an empty result says so.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { PickerList } from "../src/components/forms/picker-list/picker-list";+import { classTokens, renderStatic } from "../src/testing";++const render = (items: string[], extra: { footer?: string } = {}) =>+ renderStatic(+ createElement(PickerList<string>, {+ items,+ itemKey: (item) => item,+ isCurrent: (item) => item === "beta",+ query: "",+ onQueryChange: () => {},+ searchPlaceholder: "Search models",+ emptyText: "No match",+ onPick: () => {},+ renderRow: (item) => createElement("span", { className: "row" }, item),+ ...(extra.footer !== undefined ? { footer: createElement("p", null, extra.footer) } : {}),+ }),+ );++describe("PickerList", () => {+ it("puts an autofocused search box, named by its placeholder, above the rows", () => {+ const html = render(["alpha", "beta"]);+ const input = /<input\b[^>]*>/.exec(html)?.[0] ?? "";+ expect(input).toContain('aria-label="Search models"');+ expect(input).toContain('placeholder="Search models"');+ expect(input).toContain("autofocus");+ expect(html.indexOf("<input")).toBeLessThan(html.indexOf("alpha"));+ });++ it("checks only the entry in effect, and fills that row", () => {+ const html = render(["alpha", "beta"]);+ const rows = html.split("<button").filter((chunk) => chunk.includes('class="row"'));+ expect(rows).toHaveLength(2);+ expect(rows[0]).not.toContain("<svg");+ expect(rows[1]).toContain("<svg");+ expect(classTokens(`<b${rows[1]!}`)).toContain("bg-surface-muted");+ // Nothing is highlighted before the keyboard asks for it.+ expect(classTokens(html)).not.toContain("bg-line-muted");+ });++ it("says so when nothing matches, and pins the footer below the list", () => {+ const html = render([], { footer: "Show all" });+ expect(html).toContain("No match");+ expect(classTokens(html)).toContain("text-fg-subtle");+ expect(html.indexOf("No match")).toBeLessThan(html.indexOf("Show all"));+ });+});diff --git a/packages/ui/test/portal-panel.test.ts b/packages/ui/test/portal-panel.test.tsnew file mode 100644index 00000000..7ebbacf3--- /dev/null+++ b/packages/ui/test/portal-panel.test.ts@@ -0,0 +1,63 @@+/**+ * The portal panel's scroll rule (src/components/overlays/portal-panel/use-portal-panel.ts).+ *+ * An anchored panel — a Select's list, an InfoPopover, the app's context menu — dismisses once+ * the content under its anchor moves, but the listener that decides this is capture-phase, and+ * therefore hears every scroller in the document. The reported failure was a Session row's menu+ * that "kept getting wiped": while a conversation streams, the message list scrolls itself on+ * every chunk, and each of those scrolls was closing a menu opened in the sidebar.+ *+ * The hook's wiring (that each consumer attaches `triggerRef`, that `onScroll` asks the rule) is+ * pinned by the web app's `portal-panel-dismiss.test.ts`, which scans both roots.+ */+import { describe, expect, it } from "vitest";+import { scrollMovesAnchor } from "../src/components/overlays/portal-panel/use-portal-panel";++describe("scrollMovesAnchor", () => {+ /** A stand-in for a DOM node, implementing the containment the rule reads off one. */+ interface FakeNode {+ parent: FakeNode | null;+ contains: (n: FakeNode | null) => boolean;+ }+ /** `contains` is inclusive, exactly as the DOM's is: a node contains itself. */+ const node = (parent: FakeNode | null): FakeNode => {+ const self: FakeNode = {+ parent,+ contains: (n) => {+ for (let at = n; at !== null; at = at.parent) if (at === self) return true;+ return false;+ },+ };+ return self;+ };+ // The suite is node-only, so the rule is fed stand-ins rather than real elements; it+ // reads nothing off a node but `contains`, which is what these implement.+ const asNode = (n: FakeNode) => n as unknown as Node;++ // The page as the bug found it: a sidebar that scrolls its Session list, a chat pane+ // that scrolls its messages, and no relation between the two but the document.+ const doc = node(null);+ const sidebarScroller = node(doc);+ const row = node(sidebarScroller);+ const messageList = node(doc);++ it("ignores a scroll in an unrelated container, so streaming output leaves the menu open", () => {+ expect(scrollMovesAnchor(asNode(messageList), asNode(row))).toBe(false);+ });++ it("dismisses when the container holding the anchored row scrolls", () => {+ expect(scrollMovesAnchor(asNode(sidebarScroller), asNode(row))).toBe(true);+ });++ it("dismisses when the anchored row is itself what scrolled", () => {+ expect(scrollMovesAnchor(asNode(row), asNode(row))).toBe(true);+ });++ it("dismisses on a page-level scroll, which targets the document and needs no case of its own", () => {+ expect(scrollMovesAnchor(asNode(doc), asNode(row))).toBe(true);+ });++ it("dismisses on any scroll when the caller names no owner, as anchored panels always did", () => {+ expect(scrollMovesAnchor(asNode(messageList), null)).toBe(true);+ });+});diff --git a/packages/ui/test/pref-row.test.ts b/packages/ui/test/pref-row.test.tsnew file mode 100644index 00000000..a26e0705--- /dev/null+++ b/packages/ui/test/pref-row.test.ts@@ -0,0 +1,72 @@+/**+ * The settings rows (src/components/forms/pref-row/pref-row.tsx): PrefRow, SettingRow and the+ * SettingsSection frame.+ *+ * A settings row titles a control it does not own, so its title is a `<p>` and the "?" is safe+ * beside it. An edit that made that title a `<label>` for the sake of click-to-toggle would hand+ * the row to the trigger instead — the same trap Field carries two layouts to avoid, on the one+ * row primitive that has no Field between it and the control.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { PrefRow, SettingRow, SettingsSection } from "../src/components/forms/pref-row/pref-row";+import { Switch } from "../src/components/forms/switch/switch";+import { classTokens, renderStatic } from "../src/testing";++describe("PrefRow", () => {+ const row = renderStatic(+ createElement(PrefRow, {+ label: "Theme",+ hint: "Applies at once.",+ info: "Light or dark look of the app.",+ children: createElement(Switch, { checked: true, onChange: () => {} }),+ }),+ );++ it("is a field row whose children are the label and control slots", () => {+ expect(row).toMatch(/^<div class="ui-field [^"]*"><div data-slot="label"/);+ expect(row).toContain('<div data-slot="control"');+ });++ it('keeps the row out of a label, so the "?" cannot toggle its control', () => {+ expect(row).not.toContain("<label");+ expect(row).toContain('role="switch"');+ });++ it("anchors the trigger to the row title and keeps the hint on screen", () => {+ expect(row).toContain('aria-label="More info: Theme"');+ expect(row).not.toContain("Light or dark look of the app.");+ expect(row).toContain("Applies at once.");+ });+});++describe("SettingRow", () => {+ it("draws its description in the subtle ink, and no control slot when it has none", () => {+ const bare = renderStatic(+ createElement(SettingRow, { title: "Delete project", description: "Not the last one." }),+ );+ expect(classTokens(bare)).toContain("text-fg-subtle");+ expect(bare).not.toContain("shrink-0");+ const withControl = renderStatic(+ createElement(SettingRow, { title: "Name" }, createElement("button", null, "Save")),+ );+ expect(withControl).toContain("<button>Save</button>");+ });+});++describe("SettingsSection", () => {+ it("draws the ruled action row only when there are actions", () => {+ const body = createElement("p", null, "Body");+ expect(renderStatic(createElement(SettingsSection, { children: body }))).not.toContain(+ "border-t",+ );+ const saved = renderStatic(+ createElement(SettingsSection, {+ actions: createElement("button", null, "Save"),+ children: body,+ }),+ );+ expect(classTokens(saved)).toEqual(expect.arrayContaining(["border-t", "border-line-muted"]));+ expect(saved.indexOf("Body")).toBeLessThan(saved.indexOf("Save"));+ });+});diff --git a/packages/ui/test/radio.test.ts b/packages/ui/test/radio.test.tsnew file mode 100644index 00000000..d8c6b014--- /dev/null+++ b/packages/ui/test/radio.test.ts@@ -0,0 +1,76 @@+/**+ * Radio and RadioGroup (src/components/forms/radio/radio.tsx): native radios drawn in tokens, in+ * a fieldset whose legend names the choice and whose radios share one name.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { Radio, RadioGroup } from "../src/components/forms/radio/radio";+import { classTokens, renderStatic } from "../src/testing";++const noop = () => {};++const OPTIONS = [+ { value: "skip", label: "Skip", hint: "Keep what is there" },+ { value: "overwrite", label: "Overwrite", hint: "Replace matching names" },+ { value: "replace", label: "Replace", disabled: true },+] as const;++const group = (props: Partial<Parameters<typeof RadioGroup<string>>[0]> = {}) =>+ renderStatic(+ createElement(RadioGroup<string>, {+ label: "When a name exists",+ options: OPTIONS,+ value: "skip",+ onChange: noop,+ ...props,+ }),+ );++describe("RadioGroup", () => {+ it("is a fieldset named by its legend, in the field-label look", () => {+ const html = group();+ expect(html).toMatch(+ /^<fieldset class="[^"]*"><legend class="[^"]*">When a name exists<\/legend>/,+ );+ expect(classTokens(html)).toEqual(expect.arrayContaining(["font-semibold", "text-fg-muted"]));+ });++ it("gives every radio one shared name, and checks only the current value", () => {+ const html = group({ name: "import-mode" });+ expect(html.match(/<input type="radio"/g)).toHaveLength(3);+ expect(html.match(/name="import-mode"/g)).toHaveLength(3);+ expect(html.match(/checked=""/g)).toHaveLength(1);+ expect(html).toMatch(/<input type="radio"[^>]*checked=""[^>]*value="skip"/);+ });++ it("describes each radio with its hint, and disables an option on its own", () => {+ const html = group();+ const described = [...html.matchAll(/aria-describedby="([^"]+)"/g)].map((m) => m[1]);+ expect(described).toHaveLength(2);+ for (const id of described) expect(html).toContain(`id="${id}"`);+ expect(html.match(/disabled=""/g)).toHaveLength(1);+ });++ it("lays the options out on one line when asked", () => {+ expect(classTokens(group())).toContain("flex-col");+ expect(classTokens(group({ orientation: "horizontal" }))).toContain("flex-wrap");+ });+});++describe("Radio", () => {+ it("fills with the accent and draws the inner disc only while selected", () => {+ const off = renderStatic(+ createElement(Radio, { checked: false, onChange: noop, "aria-label": "A" }),+ );+ expect(classTokens(off)).toEqual(+ expect.arrayContaining(["border-line-emphasis", "bg-surface"]),+ );+ expect(off).not.toContain("bg-accent-fg");+ const on = renderStatic(+ createElement(Radio, { checked: true, onChange: noop, "aria-label": "A" }),+ );+ expect(classTokens(on)).toEqual(+ expect.arrayContaining(["border-accent", "bg-accent", "bg-accent-fg", "rounded-full"]),+ );+ });+});diff --git a/packages/ui/test/search-input.test.ts b/packages/ui/test/search-input.test.tsnew file mode 100644index 00000000..0791c69e--- /dev/null+++ b/packages/ui/test/search-input.test.ts@@ -0,0 +1,86 @@+/**+ * SearchInput (src/components/forms/search-input/search-input.tsx): a search field that opts out+ * of autofill, with a clear button named in the interface's words, an optional magnifier and+ * three shapes for the three kinds of container.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { ICONS } from "../src/components/icons/icons";+import { SearchInput } from "../src/components/forms/search-input/search-input";+import type { SearchInputProps } from "../src/components/forms/search-input/search-input";+import { DEFAULT_UI_STRINGS, UiStringsProvider } from "../src/strings";+import { classTokens, renderStatic } from "../src/testing";++const noop = () => {};+const search = (props: Partial<SearchInputProps> = {}) =>+ renderStatic(+ createElement(SearchInput, { value: "", onChange: noop, "aria-label": "Search", ...props }),+ );++describe("SearchInput", () => {+ it("is a search field named by the caller, kept away from saved logins", () => {+ const html = search();+ expect(html).toMatch(/<input type="search"[^>]*value=""/);+ expect(html).toContain('aria-label="Search"');+ expect(html).toMatch(/autocomplete="off"/i);+ expect(html).toContain("data-1p-ignore");+ });++ it("offers the clear button only while there is something to clear", () => {+ expect(search()).not.toContain("<button");+ const filled = search({ value: "agent" });+ expect(filled).toMatch(+ /<button type="button" aria-label="Clear search" data-tooltip="Clear search"/,+ );+ });++ it("names the clear button in the injected words, and a caller's label over both", () => {+ const strings = { ...DEFAULT_UI_STRINGS, clearSearch: "清除搜索" };+ const injected = renderStatic(+ createElement(+ UiStringsProvider,+ { strings },+ createElement(SearchInput, { value: "a", onChange: noop, "aria-label": "搜索" }),+ ),+ );+ expect(injected).toContain('aria-label="清除搜索"');+ expect(search({ value: "a", clearLabel: "Clear the filter" })).toContain(+ 'aria-label="Clear the filter"',+ );+ });++ it("keeps the clear button in an empty box that closes when cleared", () => {+ expect(search({ alwaysClearable: true })).toContain("<button");+ });++ it("reserves the clear button's room either way, so the text never shifts", () => {+ expect(classTokens(search())).toContain("pr-7");+ expect(classTokens(search({ value: "a" }))).toContain("pr-7");+ });++ it("draws the magnifier before the text when asked, and pads past it", () => {+ const html = search({ icon: true });+ expect(html).toContain(`d="${ICONS.search}"`);+ expect(classTokens(html)).toContain("pl-7");+ expect(search()).not.toContain(`d="${ICONS.search}"`);+ });++ it("takes the shape of its container", () => {+ const field = classTokens(search());+ expect(field).toEqual(expect.arrayContaining(["border-line-emphasis", "bg-surface", "py-1"]));+ const panel = classTokens(search({ variant: "panel" }));+ expect(panel).toEqual(expect.arrayContaining(["border-line", "bg-transparent"]));+ expect(panel).not.toContain("border-line-emphasis");+ const menu = classTokens(search({ variant: "menu" }));+ expect(menu).toEqual(expect.arrayContaining(["border-transparent", "py-0.5"]));+ // The font size is the control rung's, never typed here.+ expect(classTokens(search({ size: "base" }))).toContain("text-base");+ });++ it("puts the caller's layout on the wrapper and the hover hint in the shared tooltip", () => {+ const html = search({ className: "w-44", title: "Filter by name" });+ expect(html).toMatch(/^<div class="relative w-44">/);+ expect(html).toContain('data-tooltip="Filter by name"');+ expect(html).not.toContain("title=");+ });+});diff --git a/packages/ui/test/segmented.test.ts b/packages/ui/test/segmented.test.tsnew file mode 100644index 00000000..a39ed013--- /dev/null+++ b/packages/ui/test/segmented.test.ts@@ -0,0 +1,54 @@+/**+ * Segmented (src/components/forms/segmented/segmented.tsx): options in a well, the chosen one a+ * pressed chip. A badge rides out of flow and reaches the option's name as ` · <name>`; the+ * web app's `company-beta.test.ts` covers the beta tag the work-mode switch hangs on it.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { Segmented } from "../src/components/forms/segmented/segmented";+import { classTokens, renderStatic } from "../src/testing";++const render = (cols?: 2 | 3 | 4 | 5, badge = false) =>+ renderStatic(+ createElement(Segmented<"light" | "dark">, {+ options: [+ { value: "light", label: "Light" },+ {+ value: "dark",+ label: "Dark",+ ...(badge ? { badge: { node: createElement("sup", null, "beta"), name: "Beta" } } : {}),+ },+ ],+ value: "dark",+ onChange: () => {},+ ...(cols !== undefined ? { cols } : {}),+ }),+ );++describe("Segmented", () => {+ it("presses the chosen option and only that one", () => {+ const html = render();+ expect(html.match(/aria-pressed="true"/g)).toHaveLength(1);+ expect(html).toMatch(/aria-pressed="true" class="[^"]*bg-surface[^"]*">Dark</);+ });++ it("spells its column count as a whole class, for every count it takes", () => {+ for (const cols of [2, 3, 4, 5] as const) {+ expect(classTokens(render(cols))).toContain(`grid-cols-${cols}`);+ }+ expect(classTokens(render())).toContain("grid-cols-3");+ });++ it("sits in a control-shaped well on the rhythm's steps", () => {+ expect(classTokens(render())).toEqual(+ expect.arrayContaining(["rounded-control", "bg-line-muted", "p-1", "gap-1"]),+ );+ });++ it("folds a badge into the option's name and keeps it out of flow", () => {+ const html = render(3, true);+ expect(html).toContain('aria-label="Dark · Beta"');+ expect(html).toMatch(/<span aria-hidden="true" class="absolute[^"]*"><sup>beta<\/sup>/);+ expect(render()).not.toContain("aria-label");+ });+});diff --git a/packages/ui/test/select.test.ts b/packages/ui/test/select.test.tsnew file mode 100644index 00000000..adeca72f--- /dev/null+++ b/packages/ui/test/select.test.ts@@ -0,0 +1,48 @@+/**+ * Select (src/components/forms/select/select.tsx): a custom-drawn trigger that keeps the native+ * select's API — `<option>` children, `onChange(e.target.value)` — and names itself like one. The+ * list is portaled and mounted only while open, so what renders statically is the trigger.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { Select } from "../src/components/forms/select/select";+import { classTokens, renderStatic } from "../src/testing";++const options = [+ createElement("option", { key: "a", value: "a" }, "Alpha"),+ createElement("option", { key: "b", value: "b" }, "Beta"),+];++describe("Select", () => {+ it("is a listbox trigger showing the chosen option, or the first while none matches", () => {+ const html = renderStatic(createElement(Select, { value: "b", onChange: () => {} }, options));+ expect(html).toMatch(/^<button type="button" aria-haspopup="listbox" aria-expanded="false"/);+ expect(html).toContain(">Beta</span>");+ expect(html).not.toContain('role="listbox"');+ const unmatched = renderStatic(createElement(Select, { value: "z" }, options));+ expect(unmatched).toContain(">Alpha</span>");+ });++ it("forwards its accessible name and its required and invalid states", () => {+ const html = renderStatic(+ createElement(+ Select,+ { value: "a", "aria-label": "Model", required: true, error: "Pick one" },+ options,+ ),+ );+ expect(html).toContain('aria-label="Model"');+ expect(html).toContain('aria-required="true"');+ expect(html).toContain('aria-invalid="true"');+ const describedBy = /aria-describedby="([^"]+)"/.exec(html)?.[1];+ expect(describedBy).toBeDefined();+ expect(html).toContain(`id="${describedBy}" role="alert"`);+ expect(html).toContain("Pick one");+ });++ it("draws its caret in the subtle ink", () => {+ expect(classTokens(renderStatic(createElement(Select, { value: "a" }, options)))).toContain(+ "text-fg-subtle",+ );+ });+});diff --git a/packages/ui/test/strings.test.ts b/packages/ui/test/strings.test.tsindex 942e1e90..74309cdd 100644--- a/packages/ui/test/strings.test.ts+++ b/packages/ui/test/strings.test.ts@@ -22,8 +22,27 @@ function Probe() {describe("UiStrings", () => {it("holds the accessibility fallbacks, in English", () => {- expect(Object.keys(DEFAULT_UI_STRINGS).sort()).toEqual(["close", "copied", "loading"]);- expect(DEFAULT_UI_STRINGS).toEqual({ close: "Close", copied: "Copied", loading: "Loading…" });+ expect(Object.keys(DEFAULT_UI_STRINGS).sort()).toEqual([+ "clearSearch",+ "close",+ "copied",+ "hidePassword",+ "loading",+ "moreInfo",+ "moreInfoAbout",+ "showPassword",+ ]);+ expect(DEFAULT_UI_STRINGS).toMatchObject({+ close: "Close",+ copied: "Copied",+ loading: "Loading…",+ showPassword: "Show password",+ hidePassword: "Hide password",+ clearSearch: "Clear search",+ moreInfo: "More info",+ });+ // The one formatter: the subject folds into the name, keeping "More info" its prefix.+ expect(DEFAULT_UI_STRINGS.moreInfoAbout("Vault")).toBe("More info: Vault");});it("falls back to the defaults when no provider is mounted", () => {@@ -33,7 +52,12 @@ describe("UiStrings", () => {});it("reads the nearest provider's words", () => {- const zh: UiStrings = { close: "关闭", copied: "已复制", loading: "加载中…" };+ const zh: UiStrings = {+ ...DEFAULT_UI_STRINGS,+ close: "关闭",+ copied: "已复制",+ loading: "加载中…",+ };const html = renderStatic(createElement(UiStringsProvider, { strings: zh }, createElement(Probe)),);diff --git a/packages/ui/test/swatch-picker.test.ts b/packages/ui/test/swatch-picker.test.tsnew file mode 100644index 00000000..42f14fef--- /dev/null+++ b/packages/ui/test/swatch-picker.test.ts@@ -0,0 +1,41 @@+/**+ * SwatchPicker (src/components/forms/swatch-picker/swatch-picker.tsx): round swatches from data,+ * each a toggle named by its label, the one in effect pressed and ringed, nothing that grows.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { SwatchPicker } from "../src/components/forms/swatch-picker/swatch-picker";+import { classTokens, renderStatic } from "../src/testing";++const html = renderStatic(+ createElement(SwatchPicker<"blue" | "rose">, {+ options: [+ { value: "blue", color: "rgb(37, 99, 235)", label: "Blue" },+ { value: "rose", color: "rgb(190, 18, 60)", label: "Rose" },+ ],+ value: "rose",+ onChange: () => {},+ }),+);+const buttons = html.split("<button").slice(1);++describe("SwatchPicker", () => {+ it("names each swatch by its label, in the tooltip too, and presses the one in effect", () => {+ expect(buttons).toHaveLength(2);+ expect(buttons[0]).toContain('data-tooltip="Blue" aria-label="Blue" aria-pressed="false"');+ expect(buttons[1]).toContain('data-tooltip="Rose" aria-label="Rose" aria-pressed="true"');+ });++ it("paints each swatch its own colour", () => {+ expect(buttons[0]).toContain('style="background-color:rgb(37, 99, 235)"');+ });++ it("rings the chosen swatch in token inks, and never scales one", () => {+ expect(classTokens(`<b${buttons[1]!}`)).toEqual(+ expect.arrayContaining(["ring-2", "border-fg-muted"]),+ );+ expect(classTokens(html).filter((token) => /scale|transition-transform/.test(token))).toEqual(+ [],+ );+ });+});diff --git a/packages/ui/test/switch.test.ts b/packages/ui/test/switch.test.tsnew file mode 100644index 00000000..974fb72f--- /dev/null+++ b/packages/ui/test/switch.test.ts@@ -0,0 +1,55 @@+/**+ * Switch (src/components/forms/switch/switch.tsx): a native button with the switch role, painted+ * from the theme's switch tokens, its geometry in spacing units, its hint in the shared tooltip.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { Switch } from "../src/components/forms/switch/switch";+import { classTokens, renderStatic } from "../src/testing";++const render = (checked: boolean, extra: Record<string, unknown> = {}) =>+ renderStatic(createElement(Switch, { checked, onChange: () => {}, ...extra }));++/** The class tokens of the knob: the sized span inside the button. */+const knob = (html: string) => classTokens(/<span class="size-4[^>]*>/.exec(html)?.[0] ?? "");++describe("Switch", () => {+ it("is a button with the switch role and its state", () => {+ expect(render(true)).toMatch(/^<button type="button" role="switch" aria-checked="true"/);+ expect(render(false)).toContain('aria-checked="false"');+ expect(render(false, { disabled: true })).toContain('disabled=""');+ });++ it("paints each track and knob from the theme's switch tokens", () => {+ const on = render(true);+ const off = render(false);+ expect(classTokens(on)).toContain("bg-accent");+ expect(knob(on)).toContain("bg-switch-knob-on");+ expect(classTokens(off)).toContain("bg-switch-track");+ expect(knob(off)).toEqual(+ expect.arrayContaining(["bg-switch-knob", "border-switch-knob-line"]),+ );+ });++ it("keeps its geometry in spacing units, and moves the knob by the theme's layout motion", () => {+ const on = render(true);+ const off = render(false);+ expect(classTokens(on)).toEqual(expect.arrayContaining(["h-5", "w-9", "px-0.5", "size-4"]));+ // The knob sits after a spacer column that grows from nothing to the rest of the track.+ const columns = (html: string) => /data-layout-motion="true" class="([^"]*)"/.exec(html)?.[1];+ expect(columns(off)).toContain("grid-cols-[0fr_auto]");+ expect(columns(on)).toContain("grid-cols-[1fr_auto]");+ // The component itself transitions colour only: no transform, no size of its own.+ expect(classTokens(on).filter((token) => token.startsWith("transition-"))).toEqual([+ "transition-colors",+ ]);+ expect(classTokens(on).some((token) => token.startsWith("translate-"))).toBe(false);+ });++ it("shows its hint through the tooltip layer, never a native title", () => {+ const html = render(false, { title: "Notify when done", "aria-label": "Notify" });+ expect(html).toContain('data-tooltip="Notify when done"');+ expect(html).toContain('aria-label="Notify"');+ expect(html).not.toContain("title=");+ });+});diff --git a/packages/ui/test/toggle-row.test.ts b/packages/ui/test/toggle-row.test.tsnew file mode 100644index 00000000..ea38d603--- /dev/null+++ b/packages/ui/test/toggle-row.test.ts@@ -0,0 +1,59 @@+/**+ * ToggleRow (src/components/forms/toggle-row/toggle-row.tsx): a label, its "?" and hint beside a+ * Switch, in three frames. The row is never a `<label>` (it would name the "?" rather than the+ * switch), so the switch is named by the row's label instead.+ */+import { createElement } from "react";+import { describe, expect, it } from "vitest";+import { ToggleRow } from "../src/components/forms/toggle-row/toggle-row";+import type { ToggleRowVariant } from "../src/components/forms/toggle-row/toggle-row";+import { classTokens, renderStatic } from "../src/testing";++const render = (variant?: ToggleRowVariant, extra: Record<string, unknown> = {}) =>+ renderStatic(+ createElement(ToggleRow, {+ label: "Notify when done",+ checked: true,+ onChange: () => {},+ ...(variant !== undefined ? { variant } : {}),+ ...extra,+ }),+ );++/** The class tokens of the row's own element, not its children's. */+const frame = (html: string) => classTokens(/^<[^>]+>/.exec(html)?.[0] ?? "");++describe("ToggleRow", () => {+ it("names its switch by the row's label, and never wraps the row in a label", () => {+ for (const variant of ["row", "plain", "card"] as const) {+ const html = render(variant, { info: "A system notification when a Task ends." });+ expect(html, variant).toContain('role="switch"');+ expect(html, variant).toContain('aria-label="Notify when done"');+ expect(html, variant).not.toContain("<label");+ // The "?" folds the subject into its own name and keeps its text until opened.+ expect(html, variant).toContain('aria-label="More info: Notify when done"');+ expect(html, variant).not.toContain("A system notification");+ }+ });++ it("keeps the hint on screen under the label", () => {+ const html = render("plain", { hint: "Takes effect once saved." });+ expect(html.indexOf("Notify when done")).toBeLessThan(html.indexOf("Takes effect once saved."));+ });++ it("is a preference row in a ruled list, a bare row in a stack, a hairline box alone", () => {+ expect(frame(render())).toEqual(expect.arrayContaining(["ui-field", "py-3.5"]));+ expect(render()).toContain('data-slot="label"');+ expect(render()).toContain('data-slot="control"');+ const plain = frame(render("plain"));+ expect(plain).not.toContain("ui-field");+ expect(plain).not.toContain("border");+ expect(frame(render("card"))).toEqual(+ expect.arrayContaining(["border", "border-line", "rounded-lg"]),+ );+ });++ it("passes the disabled state to the switch", () => {+ expect(render("row", { disabled: true })).toContain('disabled=""');+ });+});diff --git a/packages/web/src/components/account/change-password-dialog.tsx b/packages/web/src/components/account/change-password-dialog.tsxindex 54fab13a..784e60c2 100644--- a/packages/web/src/components/account/change-password-dialog.tsx+++ b/packages/web/src/components/account/change-password-dialog.tsx@@ -4,14 +4,13 @@* notice banner disappears once passwordIsInitial clears. Shared by the sidebar user menu and the notice banner.*/import { useEffect, useState } from "react";-import { Button } from "@prismshadow/penguin-ui";+import { Button, PasswordInput } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useAuth } from "../../state/auth";import { omitsOldPassword } from "../../lib/account-menu";-import { PasswordInput } from "../ui/password-input";import { Modal } from "../ui/modal";export function ChangePasswordDialog({ open, onClose }: { open: boolean; onClose: () => void }) {diff --git a/packages/web/src/components/layout/project-dialogs.tsx b/packages/web/src/components/layout/project-dialogs.tsxindex 17699b7f..0cb38f1c 100644--- a/packages/web/src/components/layout/project-dialogs.tsx+++ b/packages/web/src/components/layout/project-dialogs.tsx@@ -3,7 +3,6 @@* (member management and deletion, owner only). Invoked from the sidebar's Project switcher.*/import { useEffect, useState } from "react";-import type { ReactNode } from "react";import type {ApprovalMode,ChatDefaultsDto,@@ -13,7 +12,19 @@ import type {ModelRefDto,ModelsResponse,} from "@prismshadow/penguin-server/api";-import { Badge, Button, ICONS } from "@prismshadow/penguin-ui";+import {+ Badge,+ Button,+ FieldError,+ FieldHint,+ FieldLabel,+ ICONS,+ InfoPopover,+ Input,+ Select,+ SettingRow,+ Switch,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";@@ -33,14 +44,9 @@ import { ModelSelect, modelLabel } from "../../features/chat/model-select";import { SELECTABLE_THINKING_LEVELS } from "../../features/chat/thinking-level";import { WorkspaceSelect } from "../../features/chat/workspace-select";import { sameModelRef } from "../../features/models/model-grouping";-import { Input } from "../ui/input";-import { Select } from "../ui/select";-import { Switch } from "../ui/switch";-import { FieldError, FieldHint, FieldLabel } from "../ui/field";import { toastError, toastSuccess } from "../ui/toast";import { Modal } from "../ui/modal";import { ConfirmModal } from "../ui/confirm-modal";-import { InfoPopover } from "../ui/info-popover";import { SemanticIdField } from "../../features/semantic-id/semantic-id-field";/** Approval modes offered by the new-chat-defaults select, in the composer menu's order. */@@ -190,31 +196,6 @@ function TabIcon({ d }: { d: string }) {);}-/**- * One row of a settings page: title plus a one-line gray description on the left, the- * control on the right. Rows are separated by the parent container's divide-y hairlines- * (ruled sections, not card boxes).- */-function SettingRow({- title,- description,- children,-}: {- title: ReactNode;- description?: ReactNode;- children?: ReactNode;-}) {- return (- <div className="flex items-center justify-between gap-4 py-3">- <div className="min-w-0 flex-1">- <p className="text-sm">{title}</p>- {description !== undefined && <p className="mt-0.5 text-xs text-gray-400">{description}</p>}- </div>- {children !== undefined && <div className="flex shrink-0 items-center gap-2">{children}</div>}- </div>- );-}-/*** Project settings dialog: a left tab rail (General / Members / Defaults / Security* policy) with a row-styled content pane per tab; on narrow screens the rail degrades to adiff --git a/packages/web/src/components/layout/sidebar.tsx b/packages/web/src/components/layout/sidebar.tsxindex 2d081ab2..a2b27aea 100644--- a/packages/web/src/components/layout/sidebar.tsx+++ b/packages/web/src/components/layout/sidebar.tsx@@ -54,7 +54,10 @@ import {ChevronDown,ICONS,ICON_SIZE,+ Input,ScheduleMark,+ SearchInput,+ Segmented,SkeletonList,UpdateDot,UserAvatar,@@ -172,7 +175,6 @@ import { writeClipboard } from "../../lib/clipboard";import { Truncated } from "../ui/truncated";import { Modal } from "../ui/modal";import { ConfirmModal } from "../ui/confirm-modal";-import { Input, noAutofill } from "../ui/input";import { DRAFT_SESSION_ID } from "../../features/chat/chat-page";import { MessagingBindingModal } from "../../features/messaging/messaging-binding-modal";import { WorkspaceSelect } from "../../features/chat/workspace-select";@@ -189,7 +191,6 @@ import { UserMenu } from "./user-menu";import { navNoteFor, useUpdateBadges } from "../../lib/use-update-badges";import { pendingScheduleSessions } from "../../features/schedules/schedule-panel-state";import { useProjectSchedules } from "../../features/schedules/schedule-store";-import { Segmented } from "../ui/segmented";import { useCompany } from "../../state/company";import { NoOrganizationsSidebar, OrgSwitcher } from "../../features/company/org-switcher";import { BetaBadge } from "../../features/company/beta-badge";@@ -219,15 +220,9 @@ function EllipsisGlyph({ size = 16 }: { size?: number }) {);}-/** Magnifier (lucide search), the section header's search toggle. */-const SEARCH_ICON = "M21 21l-4.35-4.35M17 11a6 6 0 1 1-12 0 6 6 0 0 1 12 0z";-/** Horizontal sliders (lucide sliders-horizontal), the section header's list-settings menu. */const SLIDERS_ICON = "M21 5h-7M10 5H3M21 12h-9M8 12H3M21 19h-5M12 19H3M14 2v6M8 9v6M16 16v6";-/** Close cross (the expanded search field's clear button). */-const CLOSE_ICON = "M18 6L6 18M6 6l12 12";-/*** Private drag payload type of a manual session reorder. Deliberately NOT `text/plain`:* the composer is a controlled textarea with no drop guard, and a native text drop@@ -2110,39 +2105,22 @@ export function Sidebar({</span><div className="flex min-w-0 items-center justify-end gap-0.5">{searchOpen ? (- /* Expanded field: leading magnifier glyph + input + clear ×, one bordered+ /* Expanded field: the magnifier, the input and the clear ×, one borderedbox filling the row (its width rides the column tween). Esc and × both- collapse it and drop the filter. */- <div className="flex h-6 min-w-0 flex-1 items-center gap-1 rounded-md border border-gray-300 bg-white px-1.5 transition-colors duration-150 focus-within:border-gray-400 dark:border-gray-700 dark:bg-gray-900 dark:focus-within:border-gray-500">- <span aria-hidden className="shrink-0 text-gray-400 dark:text-gray-500">- <Icon d={SEARCH_ICON} size={12} />- </span>- <input- ref={searchInputRef}- autoFocus- value={searchQuery}- placeholder={S.chat.searchSessionsPlaceholder}- aria-label={S.chat.searchSessions}- {...noAutofill}- onChange={(e) => setSearchQuery(e.target.value)}- onKeyDown={(e) => {- if (e.key === "Escape") {- e.stopPropagation();- closeSearch();- }- }}- className="min-w-0 flex-1 bg-transparent text-xs text-gray-700 placeholder:text-gray-400 focus:outline-none dark:text-gray-200 dark:placeholder:text-gray-500"- />- <button- type="button"- data-tooltip={S.chat.searchClear}- aria-label={S.chat.searchClear}- onClick={closeSearch}- className="flex h-4 w-4 shrink-0 items-center justify-center text-gray-400 transition-colors duration-150 hover:text-gray-700 dark:hover:text-gray-300"- >- <Icon d={CLOSE_ICON} size={11} />- </button>- </div>+ collapse it and drop the filter, which is why the × stays while it is empty. */+ <SearchInput+ ref={searchInputRef}+ icon+ alwaysClearable+ autoFocus+ className="min-w-0 flex-1"+ value={searchQuery}+ onChange={setSearchQuery}+ onClear={closeSearch}+ placeholder={S.chat.searchSessionsPlaceholder}+ aria-label={S.chat.searchSessions}+ clearLabel={S.chat.searchClear}+ />) : (<buttontype="button"@@ -2151,7 +2129,7 @@ export function Sidebar({onClick={() => setSearchOpen(true)}className={headerControlClass(false)}>- <Icon d={SEARCH_ICON} size={14} />+ <Icon d={ICONS.search} size={14} /></button>)}<Dropdowndiff --git a/packages/web/src/components/ui/dropdown.tsx b/packages/web/src/components/ui/dropdown.tsxindex c945c03f..9411c7fb 100644--- a/packages/web/src/components/ui/dropdown.tsx+++ b/packages/web/src/components/ui/dropdown.tsx@@ -36,9 +36,13 @@import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";import { createPortal } from "react-dom";import type { CSSProperties, KeyboardEvent as ReactKeyboardEvent, ReactNode } from "react";+import {+ menuPanelClass,+ menuRowClass,+ menuRowTone,+ scrollMovesAnchor,+} from "@prismshadow/penguin-ui";import { FOCUSABLE_SELECTOR, isTopEscLayer, popEscLayer, pushEscLayer } from "./modal";-import { scrollMovesAnchor } from "../../lib/context-menu";-import { menuPanelClass, menuRowClass, menuRowTone } from "./field";/** Gap between the trigger and the portaled panel, and the panel's minimum distance from the viewport edge (px). */const PANEL_GAP = 4;diff --git a/packages/web/src/components/ui/form-picker.tsx b/packages/web/src/components/ui/form-picker.tsxindex cd28a550..b4975041 100644--- a/packages/web/src/components/ui/form-picker.tsx+++ b/packages/web/src/components/ui/form-picker.tsx@@ -12,11 +12,9 @@* and close on pick).*/import type { ReactNode } from "react";-import { ChevronDown } from "@prismshadow/penguin-ui";+import { ChevronDown, controlBase, sizeClass } from "@prismshadow/penguin-ui";+import type { ControlSize } from "@prismshadow/penguin-ui";import { Dropdown } from "./dropdown";-import { controlBase } from "./field";-import { sizeClass } from "./input";-import type { ControlSize } from "./input";/** The trigger's own props: everything FormPicker draws, minus the menu it hangs. */export interface FormPickerTriggerProps {diff --git a/packages/web/src/components/ui/paged-dialog.tsx b/packages/web/src/components/ui/paged-dialog.tsxindex 7729d78b..606fc322 100644--- a/packages/web/src/components/ui/paged-dialog.tsx+++ b/packages/web/src/components/ui/paged-dialog.tsx@@ -12,9 +12,8 @@* along with the second dimension (Tabs' convention).*/import type { ReactNode } from "react";-import { CloseButton, ICON_GAP } from "@prismshadow/penguin-ui";+import { CloseButton, ICON_GAP, InfoPopover } from "@prismshadow/penguin-ui";import { Modal } from "./modal";-import { InfoPopover } from "./info-popover";export interface PagedDialogItem<K extends string> {key: K;diff --git a/packages/web/src/components/ui/session-row-menu.tsx b/packages/web/src/components/ui/session-row-menu.tsxindex 8a4e4a64..c9087e14 100644--- a/packages/web/src/components/ui/session-row-menu.tsx+++ b/packages/web/src/components/ui/session-row-menu.tsx@@ -18,11 +18,10 @@* off the row entirely.*/import type { MouseEvent as ReactMouseEvent } from "react";-import { GlyphIcon, ICONS } from "@prismshadow/penguin-ui";+import { GlyphIcon, ICONS, menuRowClass, menuRowTone } from "@prismshadow/penguin-ui";import type { AnchorRect } from "../../lib/context-menu";import { S } from "../../lib/strings";import { Icon } from "./group-list";-import { menuRowClass, menuRowTone } from "./field";/** Compact overflow-menu row (session row menu + workspace group menu): small text, leading thin-line glyph. */export const overflowMenuRowClass = `flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone()}`;diff --git a/packages/web/src/components/ui/switch.tsx b/packages/web/src/components/ui/switch.tsxdeleted file mode 100644index 60d65ea0..00000000--- a/packages/web/src/components/ui/switch.tsx+++ /dev/null@@ -1,67 +0,0 @@-/**- * iOS-style toggle switch: a `button` with `role="switch"` + `aria-checked` (a native- * button is keyboard-operable out of the box — Space/Enter activate it — and is labelable- * content, so clicking an enclosing `<label>`'s text toggles it too). Sliding knob with an- * ease-out color/transform transition; the on-state follows the theme accent variable (same- * source as Button primary), the off-state is gray.- *- * Geometry (all integer pixels): a 16px knob in the 36x20px track, inset 2px on every side- * in both states (travel 2px -> 18px), and at either end concentric with the track's- * end-cap circle (center 10px in from the edge), so the gap along the arcs matches the- * straight runs. The knob is painted from the theme's two knob tokens, one per track: the on- * track is the accent, and an accent can be near-white (a dark theme's neutral accent, a lifted- * preset), where a white knob would vanish — the theme picks a knob that stays apart from each- * track at every accent. The track draws a 1px inset hairline; the knob's hairline is a *border* —- * inside its own 16px — not an outer ring: an outer ring would fill the gap on the near arc- * and stack on the track hairline as one heavier line, reading as unequal spacing. Net- * clearance between knob edge and outline is thus a uniform 1px all around. No offset- * shadow (it reads as vertical asymmetry at this size); the hairlines keep the edges- * defined on any surface; dark-mode aware; disabled dims and blocks. The focus ring is- * accent-tinted and `focus-visible`-only, so keyboard focus shows it but a mouse click- * doesn't leave a lingering halo. Sized for compact (sm) form rows, matching the dialogs'- * controls.- */-import type { ButtonHTMLAttributes } from "react";--export interface SwitchProps extends Omit<- ButtonHTMLAttributes<HTMLButtonElement>,- "onChange" | "type" | "role"-> {- checked: boolean;- onChange: (checked: boolean) => void;-}--export function Switch({ checked, onChange, disabled, className, title, ...rest }: SwitchProps) {- return (- <button- type="button"- role="switch"- aria-checked={checked}- disabled={disabled}- onClick={() => onChange(!checked)}- className={- "relative inline-flex h-5 w-9 shrink-0 items-center rounded-full " +- "inset-ring inset-ring-black/10 dark:inset-ring-white/10 " +- "transition-colors duration-200 ease-out " +- "focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/40 " +- "disabled:cursor-not-allowed disabled:opacity-60 " +- (checked ? "bg-accent" : "bg-gray-200 dark:bg-gray-700") +- ` ${className ?? ""}`- }- // A hover hint shows in the shared tooltip, never the browser's own `title`.- data-tooltip={title}- {...rest}- >- <span- aria-hidden- className={`inline-block size-4 rounded-full border transition-transform duration-200 ease-out ${- // The off knob sits on a pale track, so its edge is the theme's knob line (it carries the- // 3:1 there); on the accent track the fill already contrasts and the edge stays faint.- checked- ? "translate-x-4.5 border-black/10 bg-(--ui-switch-knob-on)"- : "translate-x-0.5 border-switch-knob-line bg-(--ui-switch-knob)"- }`}- />- </button>- );-}diff --git a/packages/web/src/features/admin/admin-users-page.tsx b/packages/web/src/features/admin/admin-users-page.tsxindex acece105..ba6e4818 100644--- a/packages/web/src/features/admin/admin-users-page.tsx+++ b/packages/web/src/features/admin/admin-users-page.tsx@@ -7,7 +7,7 @@*/import { useCallback, useEffect, useState } from "react";import type { UserInfo } from "@prismshadow/penguin-server/api";-import { Badge, Button } from "@prismshadow/penguin-ui";+import { Badge, Button, Input, PasswordInput } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";@@ -15,8 +15,6 @@ import { apiErrorText } from "../../lib/api-error";import { USERNAME_PATTERN } from "../../lib/semantic-id";import { formatDateTime } from "../../lib/format";import { useAuth } from "../../state/auth";-import { Input } from "../../components/ui/input";-import { PasswordInput } from "../../components/ui/password-input";import { Modal } from "../../components/ui/modal";export function AdminUsersSection() {diff --git a/packages/web/src/features/agents/agent-settings-page.tsx b/packages/web/src/features/agents/agent-settings-page.tsxindex 8bf054cb..b9c92cbc 100644--- a/packages/web/src/features/agents/agent-settings-page.tsx+++ b/packages/web/src/features/agents/agent-settings-page.tsx@@ -29,9 +29,15 @@ import {HiddenFileInput,ICONS,ICON_SIZE,+ InfoPopover,+ Input,+ OptionMenu,Skeleton,+ Switch,+ Textarea,UpdateDot,} from "@prismshadow/penguin-ui";+import type { OptionMenuChoice } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";@@ -40,9 +46,6 @@ import { useDocumentTitle } from "../../lib/use-document-title";import { useProject } from "../../state/project";import { Tabs } from "../../components/ui/tabs";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";-import { Input, Textarea } from "../../components/ui/input";-import { OptionMenu, type OptionMenuChoice } from "../../components/ui/option-menu";-import { Switch } from "../../components/ui/switch";import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal";import { SkillsTab } from "./skills-tab";import { HooksTab } from "./hooks-tab";@@ -53,7 +56,6 @@ import { SchedulesTab } from "./schedules-tab";import { McpServersSection } from "./mcp-servers-section";import { SNAPSHOT_ACCEPT, SNAPSHOT_BUTTON_CLASS, fileToBase64 } from "./snapshot-file";import { thinkingLevelOptionsFor } from "../chat/thinking-level";-import { InfoPopover } from "../../components/ui/info-popover";type TabKey =| "overview"diff --git a/packages/web/src/features/agents/agents-page.tsx b/packages/web/src/features/agents/agents-page.tsxindex 7e46b42e..108a2d4e 100644--- a/packages/web/src/features/agents/agents-page.tsx+++ b/packages/web/src/features/agents/agents-page.tsx@@ -32,12 +32,17 @@ import {Button,CloseIcon,EmptyState,+ FieldError,+ FieldHint,+ FieldLabel,GlyphIcon,HiddenFileInput,ICONS,ICON_SIZE,+ Input,Skeleton,SkeletonCard,+ Textarea,UpdatePill,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";@@ -52,8 +57,6 @@ import { bulkOutcome, failedList, firstFailure, noticeCounts } from "../../lib/bimport { useAuth } from "../../state/auth";import { useLocale } from "../../state/locale";import { agentDisplayName, useProject } from "../../state/project";-import { Input, Textarea } from "../../components/ui/input";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { FormPicker } from "../../components/ui/form-picker";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";diff --git a/packages/web/src/features/agents/hooks-tab.tsx b/packages/web/src/features/agents/hooks-tab.tsxindex de2c17ab..c5707b9a 100644--- a/packages/web/src/features/agents/hooks-tab.tsx+++ b/packages/web/src/features/agents/hooks-tab.tsx@@ -29,10 +29,12 @@ import {CopyCheckGlyph,DownloadIcon,GlyphIcon,+ HelpFold,HiddenFileInput,ICONS,SettingsEmpty,SkeletonList,+ Textarea,useCopied,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";@@ -42,8 +44,6 @@ import { apiErrorText } from "../../lib/api-error";import { useLocale } from "../../state/locale";import { agentDisplayName, useProject } from "../../state/project";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { HelpFold } from "../../components/ui/help-fold";-import { Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { toastError, toastSuccess } from "../../components/ui/toast";import { localizedText } from "../chat/skill-use";diff --git a/packages/web/src/features/agents/mcp-servers-section.tsx b/packages/web/src/features/agents/mcp-servers-section.tsxindex 86cd6650..2be95490 100644--- a/packages/web/src/features/agents/mcp-servers-section.tsx+++ b/packages/web/src/features/agents/mcp-servers-section.tsx@@ -18,17 +18,23 @@*/import { useState } from "react";import type { MCPServerConfig } from "@prismshadow/penguin-core/interfaces";-import { Button, SettingsEmpty } from "@prismshadow/penguin-ui";+import {+ Button,+ InfoPopover,+ Input,+ OptionMenu,+ Segmented,+ SettingsEmpty,+ Textarea,+} from "@prismshadow/penguin-ui";+import type { OptionMenuChoice } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import type { McpServerTestResponse } from "@prismshadow/penguin-server/api";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useProject } from "../../state/project";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { OptionMenu, type OptionMenuChoice } from "../../components/ui/option-menu";-import { Segmented } from "../../components/ui/segmented";import { toastError, toastSuccess } from "../../components/ui/toast";import {emptyMcpForm,@@ -43,7 +49,6 @@ import {type McpTransportKind,} from "./mcp-servers-form";import { toneInk } from "../../lib/tone";-import { InfoPopover } from "../../components/ui/info-popover";/** Maps a validation error code to its localized message. */function errorText(err: McpFormError | undefined): string | undefined {diff --git a/packages/web/src/features/agents/memory-tab.tsx b/packages/web/src/features/agents/memory-tab.tsxindex f3e2efa1..a3ccc68f 100644--- a/packages/web/src/features/agents/memory-tab.tsx+++ b/packages/web/src/features/agents/memory-tab.tsx@@ -36,10 +36,15 @@ import {CopyCheckGlyph,DownloadIcon,GlyphIcon,+ HelpFold,HiddenFileInput,ICONS,IconButton,+ InfoPopover,+ RadioGroup,SkeletonList,+ Textarea,+ ToggleRow,UploadIcon,buttonClass,useCopied,@@ -51,12 +56,7 @@ import { formatRelativeDate } from "../../lib/format";import { useAuth } from "../../state/auth";import { useLocale } from "../../state/locale";import { useProject } from "../../state/project";-import { InfoPopover } from "../../components/ui/info-popover";-import { HelpFold } from "../../components/ui/help-fold";import { Modal } from "../../components/ui/modal";-import { Textarea } from "../../components/ui/input";-import { rowDescClass } from "../../components/ui/option-menu";-import { Switch } from "../../components/ui/switch";import { Drawer } from "../../components/ui/drawer";import { Sheet, type SheetSnap } from "../../components/ui/sheet";import { ConfirmModal, useSaveConfirm } from "../../components/ui/confirm-modal";@@ -556,10 +556,13 @@ export function MemoryTab({{/* Tab-level description: no title in the panel to anchor a "?" to (see help-fold.tsx). */}<HelpFold label={S.agent.tabMemory}>{S.memory.desc}</HelpFold>- <div className="flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800">- <p className="text-sm font-medium text-gray-800 dark:text-gray-200">{S.memory.enable}</p>- <Switch checked={enabled} onChange={(v) => void toggleEnabled(v)} disabled={switchBusy} />- </div>+ <ToggleRow+ variant="card"+ label={S.memory.enable}+ checked={enabled}+ onChange={(v) => void toggleEnabled(v)}+ disabled={switchBusy}+ />{!templateHasMemory && (<NoticeStrip@@ -903,35 +906,29 @@ export function MemoryTab({<p className="break-all font-mono text-[11px] text-gray-500 dark:text-gray-400">{S.memory.importFile(importing.fileName, importing.doc.files.length)}</p>- <fieldset className="space-y-2">- <legend className="mb-1 text-xs font-medium text-gray-500 dark:text-gray-400">- {S.memory.importModeLabel}- </legend>- {(- [- ["skip", S.memory.importModeSkip, S.memory.importModeSkipHint],- ["overwrite", S.memory.importModeOverwrite, S.memory.importModeOverwriteHint],- ["replace", S.memory.importModeReplace, S.memory.importModeReplaceHint],- ] as [MemoryImportMode, string, string][]- ).map(([mode, label, hint]) => (- <label key={mode} className="flex cursor-pointer items-start gap-2 text-xs">- <input- type="radio"- name="memory-import-mode"- className="mt-1 shrink-0"- checked={importMode === mode}- onChange={() => setImportMode(mode)}- />- <span className="min-w-0">- <span className="text-gray-800 dark:text-gray-200">{label}</span>- {/* One step below the row title, the same pairing OptionMenu's rows use. */}- <span className={`block ${rowDescClass.sm} text-gray-500 dark:text-gray-400`}>- {hint}- </span>- </span>- </label>- ))}- </fieldset>+ <RadioGroup+ label={S.memory.importModeLabel}+ name="memory-import-mode"+ value={importMode}+ onChange={setImportMode}+ options={[+ {+ value: "skip",+ label: S.memory.importModeSkip,+ hint: S.memory.importModeSkipHint,+ },+ {+ value: "overwrite",+ label: S.memory.importModeOverwrite,+ hint: S.memory.importModeOverwriteHint,+ },+ {+ value: "replace",+ label: S.memory.importModeReplace,+ hint: S.memory.importModeReplaceHint,+ },+ ]}+ /><div className="flex justify-end"><Button size="sm" variant="primary" disabled={importBusy} onClick={submitImport}>{S.memory.importAction}diff --git a/packages/web/src/features/agents/prompt-injection-controls.tsx b/packages/web/src/features/agents/prompt-injection-controls.tsxindex 455097e5..ddb61497 100644--- a/packages/web/src/features/agents/prompt-injection-controls.tsx+++ b/packages/web/src/features/agents/prompt-injection-controls.tsx@@ -28,16 +28,13 @@ import type {AgentSkillsConfigDto,AgentVaultConfigDto,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, InfoPopover, Textarea, ToggleRow } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useProject } from "../../state/project";-import { Textarea } from "../../components/ui/input";-import { Switch } from "../../components/ui/switch";import { useSaveConfirm } from "../../components/ui/confirm-modal";import { toastError, toastSuccess } from "../../components/ui/toast";-import { InfoPopover } from "../../components/ui/info-popover";import { NoticeStrip } from "../../components/ui/notice-strip";export type PromptInjectionFeature = "skills" | "vault" | "schedules" | "hooks";@@ -205,20 +202,14 @@ export function usePromptInjection({});const toggleCard = state !== null && (- <div className="flex items-center justify-between gap-4 rounded-lg border border-gray-200 px-4 py-3 dark:border-gray-800">- {/* The "?" sits inside the label so it modifies a title rather than standing alone (see info-popover.tsx). */}- <p className="flex items-center gap-1.5 text-sm font-medium text-gray-800 dark:text-gray-200">- {strings.enable}- {strings.enableHint !== undefined && (- <InfoPopover label={strings.enable}>{strings.enableHint}</InfoPopover>- )}- </p>- <Switch- checked={state.enabled}- onChange={(v) => void toggleEnabled(v)}- disabled={switchBusy || !canEdit}- />- </div>+ <ToggleRow+ variant="card"+ label={strings.enable}+ info={strings.enableHint}+ checked={state.enabled}+ onChange={(v) => void toggleEnabled(v)}+ disabled={switchBusy || !canEdit}+ />);// Legacy templates get the migration wording (and the legacy strings always exist for thediff --git a/packages/web/src/features/agents/schedules-tab.tsx b/packages/web/src/features/agents/schedules-tab.tsxindex 43690a12..34605266 100644--- a/packages/web/src/features/agents/schedules-tab.tsx+++ b/packages/web/src/features/agents/schedules-tab.tsx@@ -24,7 +24,7 @@ import type {SchedulesResponse,ScheduleStatus,} from "@prismshadow/penguin-server/api";-import { Badge, Button, SettingsEmpty, SkeletonList } from "@prismshadow/penguin-ui";+import { Badge, Button, HelpFold, SettingsEmpty, SkeletonList } from "@prismshadow/penguin-ui";import type { BadgeStyle } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -38,7 +38,6 @@ import { ScheduleFormModal } from "../schedules/schedule-form-modal";import { ScheduleSuggestions, scheduleExamples } from "../schedules/schedule-suggestions";import { toggleBody } from "../schedules/schedule-upsert";import { usePromptInjection } from "./prompt-injection-controls";-import { HelpFold } from "../../components/ui/help-fold";/** Display status → badge. A finished one-off is settled: a neutral tag, solid so it still reads. */const STATUS_BADGE: Record<ScheduleStatus, BadgeStyle> = {diff --git a/packages/web/src/features/agents/skills-tab.tsx b/packages/web/src/features/agents/skills-tab.tsxindex 3deaea89..c07c9ede 100644--- a/packages/web/src/features/agents/skills-tab.tsx+++ b/packages/web/src/features/agents/skills-tab.tsx@@ -26,11 +26,14 @@ import {CopyCheckGlyph,DownloadIcon,GlyphIcon,+ HelpFold,HiddenFileInput,ICONS,IconButton,+ Input,SettingsEmpty,SkeletonList,+ Textarea,buttonClass,useCopied,} from "@prismshadow/penguin-ui";@@ -40,7 +43,6 @@ import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useLocale } from "../../state/locale";import { agentDisplayName, useProject } from "../../state/project";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";import { toastError, toastSuccess } from "../../components/ui/toast";@@ -50,7 +52,6 @@ import { useAiBridge } from "../ai-create";import { downloadArchive } from "./archive-download";import { buildImportPrompt } from "./skill-import-source";import { usePromptInjection } from "./prompt-injection-controls";-import { HelpFold } from "../../components/ui/help-fold";/** The Button look on the upload `<label>`; the Hooks tab's upload label borrows it. */export const UPLOAD_LABEL_CLASS = buttonClass("secondary", "sm");diff --git a/packages/web/src/features/agents/vault-tab.tsx b/packages/web/src/features/agents/vault-tab.tsxindex 140b665c..8dffd319 100644--- a/packages/web/src/features/agents/vault-tab.tsx+++ b/packages/web/src/features/agents/vault-tab.tsx@@ -15,18 +15,22 @@*/import { useCallback, useEffect, useState } from "react";import type { VaultEntryInfo, VaultUpdateRequest } from "@prismshadow/penguin-server/api";-import { Button, SettingsEmpty, SkeletonList } from "@prismshadow/penguin-ui";+import {+ Button,+ HelpFold,+ Input,+ PasswordInput,+ SettingsEmpty,+ SkeletonList,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useProject } from "../../state/project";-import { Input } from "../../components/ui/input";-import { PasswordInput } from "../../components/ui/password-input";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";import { toastError, toastSuccess } from "../../components/ui/toast";import { usePromptInjection } from "./prompt-injection-controls";-import { HelpFold } from "../../components/ui/help-fold";import { AiCreateModal, CreateButtons } from "../ai-create";import { NoticeStrip } from "../../components/ui/notice-strip";diff --git a/packages/web/src/features/ai-create/ai-create-panel.tsx b/packages/web/src/features/ai-create/ai-create-panel.tsxindex a503a3a2..cfd92bbc 100644--- a/packages/web/src/features/ai-create/ai-create-panel.tsx+++ b/packages/web/src/features/ai-create/ai-create-panel.tsx@@ -8,13 +8,10 @@import { useLayoutEffect, useRef } from "react";import type { ReactNode } from "react";import type { AgentSummary } from "@prismshadow/penguin-server/api";-import { CopyButton } from "@prismshadow/penguin-ui";+import { CopyButton, HelpFold, Select, Textarea } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { toneInk } from "../../lib/tone";import { agentDisplayName } from "../../state/project";-import { HelpFold } from "../../components/ui/help-fold";-import { Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";import { composeAiPrompt } from "./ai-create-prompt";export interface AiExample {diff --git a/packages/web/src/features/benchmark/benchmark-page.tsx b/packages/web/src/features/benchmark/benchmark-page.tsxindex f32ada79..9fe330d3 100644--- a/packages/web/src/features/benchmark/benchmark-page.tsx+++ b/packages/web/src/features/benchmark/benchmark-page.tsx@@ -26,6 +26,8 @@ import {ICONS,ICON_GAP,ICON_SIZE,+ Input,+ Select,Skeleton,SkeletonCard,} from "@prismshadow/penguin-ui";@@ -42,8 +44,6 @@ import type { MergedBenchmark } from "../../lib/benchmark-merge";import { nameOnMachine } from "../../lib/workspace-machines";import { useLocale } from "../../state/locale";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Input } from "../../components/ui/input";-import { Select } from "../../components/ui/select";import { toastError, toastSuccess } from "../../components/ui/toast";import { AiCreateModal, CreateButtons, pickDefaultAgent } from "../ai-create";import { latestWithDelta, matchesBenchmarkQuery, sparklineSeries } from "./benchmark-metrics";diff --git a/packages/web/src/features/benchmark/create-benchmark-modal.tsx b/packages/web/src/features/benchmark/create-benchmark-modal.tsxindex 9ae95324..c5030027 100644--- a/packages/web/src/features/benchmark/create-benchmark-modal.tsx+++ b/packages/web/src/features/benchmark/create-benchmark-modal.tsx@@ -8,15 +8,22 @@*/import { useRef, useState } from "react";import type { BenchmarkSummary } from "@prismshadow/penguin-server/api";-import { Button, GlyphIcon, ICONS, ICON_SIZE, PlusIcon } from "@prismshadow/penguin-ui";+import {+ Button,+ FieldLabel,+ GlyphIcon,+ ICONS,+ ICON_SIZE,+ InfoPopover,+ Input,+ PlusIcon,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { toneInk } from "../../lib/tone";-import { FieldLabel } from "../../components/ui/field";-import { InfoPopover } from "../../components/ui/info-popover";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { toastSuccess } from "../../components/ui/toast";import { SemanticIdField } from "../semantic-id/semantic-id-field";diff --git a/packages/web/src/features/benchmark/use-benchmark-modal.tsx b/packages/web/src/features/benchmark/use-benchmark-modal.tsxindex d1e4faf2..036cce23 100644--- a/packages/web/src/features/benchmark/use-benchmark-modal.tsx+++ b/packages/web/src/features/benchmark/use-benchmark-modal.tsx@@ -24,16 +24,22 @@ import type {ModelRefDto,ModelsResponse,} from "@prismshadow/penguin-server/api";-import { Button, GlyphIcon, ICONS } from "@prismshadow/penguin-ui";+import {+ Button,+ FieldHint,+ FieldLabel,+ GlyphIcon,+ ICONS,+ Input,+ Segmented,+ Select,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { formatScore } from "../../lib/format";import { agentDisplayName, useProject } from "../../state/project";-import { FieldHint, FieldLabel } from "../../components/ui/field";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";-import { Segmented } from "../../components/ui/segmented";-import { Select } from "../../components/ui/select";import { PromptFold, composeAiPrompt, pickDefaultAgent, useAiBridge } from "../ai-create";import { ModelSelect } from "../chat/model-select";import { defaultTargetScore, latestScoreOfAgent } from "./benchmark-metrics";diff --git a/packages/web/src/features/builtin-browser/address-bar.tsx b/packages/web/src/features/builtin-browser/address-bar.tsxindex 43b59194..e59633b4 100644--- a/packages/web/src/features/builtin-browser/address-bar.tsx+++ b/packages/web/src/features/builtin-browser/address-bar.tsx@@ -13,9 +13,9 @@ import { useEffect, useId, useRef, useState } from "react";import type { KeyboardEvent as ReactKeyboardEvent, Ref } from "react";import { createPortal } from "react-dom";import type { BuiltinBrowserHistoryEntry } from "@prismshadow/penguin-server/api";+import { noAutofill, sizeTextClass } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";-import { noAutofill, panelSearchClass } from "../../components/ui/input";import { displayAddress, normalizeAddress } from "./address";import { NO_HIGHLIGHT, moveHighlight } from "./suggestion-nav";@@ -26,6 +26,16 @@ const SUGGEST_DELAY_MS = 120;/** Gap between the field and the list (px). */const LIST_GAP = 4;+/**+ * The field's look: a box standing inside the toolbar with its own quiet line, on the control+ * size scale's sm rung. Not a SearchInput: it holds an address, Escape reverts its text rather+ * than clearing it, and it has no clear button.+ */+const fieldClass =+ `w-full rounded-md border border-gray-200 bg-transparent ${sizeTextClass.sm} text-gray-700 ` ++ "transition-colors placeholder:text-gray-400 focus:border-gray-400 focus:outline-none " ++ "dark:border-gray-700 dark:text-gray-200 dark:placeholder:text-gray-500 dark:focus:border-gray-500";+export function AddressBar({url,onNavigate,@@ -167,7 +177,7 @@ export function AddressBar({onFocus={(event) => event.target.select()}onBlur={stopEditing}onKeyDown={onKeyDown}- className={`${panelSearchClass} h-7 min-w-0 flex-1 px-2`}+ className={`${fieldClass} h-7 min-w-0 flex-1 px-2`}/>{listOpen &&createPortal(diff --git a/packages/web/src/features/builtin-browser/clear-data-dialog.tsx b/packages/web/src/features/builtin-browser/clear-data-dialog.tsxindex a4971a0b..1380f11b 100644--- a/packages/web/src/features/builtin-browser/clear-data-dialog.tsx+++ b/packages/web/src/features/builtin-browser/clear-data-dialog.tsx@@ -4,6 +4,7 @@* on each opening; the confirm stays disabled while none is.*/import { useEffect, useState } from "react";+import { Checkbox } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import type { BuiltinBrowserStorage } from "../../api/endpoints";import { apiErrorText } from "../../lib/api-error";@@ -74,18 +75,14 @@ export function ClearDataDialog({ open, onClose }: { open: boolean; onClose: ()<p className="text-sm text-gray-600 dark:text-gray-300">{S.builtinBrowser.clearBody}</p><div className="mt-3 flex flex-col gap-1.5">{KINDS.map((kind) => (- <label+ <Checkboxkey={kind}- className="flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300"- >- <input- type="checkbox"- checked={chosen.has(kind)}- disabled={busy}- onChange={(e) => toggle(kind, e.target.checked)}- />- {kindLabel(kind)}- </label>+ checked={chosen.has(kind)}+ disabled={busy}+ onChange={(on) => toggle(kind, on)}+ label={kindLabel(kind)}+ className="text-gray-700 dark:text-gray-300"+ />))}</div></ConfirmModal>diff --git a/packages/web/src/features/builtin-browser/homepage-dialog.tsx b/packages/web/src/features/builtin-browser/homepage-dialog.tsxindex 5f442b24..e53ecd9d 100644--- a/packages/web/src/features/builtin-browser/homepage-dialog.tsx+++ b/packages/web/src/features/builtin-browser/homepage-dialog.tsx@@ -9,11 +9,10 @@* opening starts from the homepage as saved.*/import { useState } from "react";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { apiErrorText } from "../../lib/api-error";import { S } from "../../lib/strings";-import { Input } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { toastError } from "../../components/ui/toast";import { homepageFromInput } from "./address";diff --git a/packages/web/src/features/builtin-browser/import-dialog.tsx b/packages/web/src/features/builtin-browser/import-dialog.tsxindex 6c0443ea..59100c12 100644--- a/packages/web/src/features/builtin-browser/import-dialog.tsx+++ b/packages/web/src/features/builtin-browser/import-dialog.tsx@@ -8,13 +8,11 @@ import type {BuiltinBrowserImportResult,BuiltinBrowserImportSource,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Checkbox, FieldLabel, Input, Radio } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { apiErrorText } from "../../lib/api-error";import { S } from "../../lib/strings";import { toneInk } from "../../lib/tone";-import { FieldLabel } from "../../components/ui/field";-import { Input } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import {groupSources,@@ -23,7 +21,8 @@ import {sourceImportable,} from "./import-options";-const optionClass = "flex items-center gap-1.5 text-xs text-gray-700 dark:text-gray-300";+/** The option rows' ink. */+const optionInk = "text-gray-700 dark:text-gray-300";export function ImportDialog({ open, onClose }: { open: boolean; onClose: () => void }) {const [sources, setSources] = useState<BuiltinBrowserImportSource[] | null>(null);@@ -127,21 +126,24 @@ export function ImportDialog({ open, onClose }: { open: boolean; onClose: () =>{group.browserName}</span>{group.sources.map((s) => (- <label key={s.id} className={`${optionClass} pl-3`}>- <input- type="radio"- name="builtin-browser-import-source"- checked={s.id === sourceId}- disabled={!sourceImportable(s) || running}- onChange={() => setSourceId(s.id)}- />- <span className="min-w-0 truncate">{s.profileName}</span>- {s.profileName !== s.profile && (- <span className="shrink-0 text-gray-400 dark:text-gray-500">- {s.profile}+ <Radio+ key={s.id}+ name="builtin-browser-import-source"+ checked={s.id === sourceId}+ disabled={!sourceImportable(s) || running}+ onChange={() => setSourceId(s.id)}+ className={`${optionInk} pl-3`}+ label={+ <span className="flex min-w-0 items-center gap-1.5">+ <span className="min-w-0 truncate">{s.profileName}</span>+ {s.profileName !== s.profile && (+ <span className="shrink-0 text-gray-400 dark:text-gray-500">+ {s.profile}+ </span>+ )}</span>- )}- </label>+ }+ />))}</div>))}@@ -150,24 +152,20 @@ export function ImportDialog({ open, onClose }: { open: boolean; onClose: () =><div role="group" aria-label={S.builtinBrowser.importWhat}><FieldLabel>{S.builtinBrowser.importWhat}</FieldLabel><div className="flex flex-col gap-1.5">- <label className={optionClass}>- <input- type="checkbox"- checked={cookies && source?.hasCookies === true}- disabled={source?.hasCookies !== true || running}- onChange={(e) => setCookies(e.target.checked)}- />- {S.builtinBrowser.importCookies}- </label>- <label className={optionClass}>- <input- type="checkbox"- checked={history && source?.hasHistory === true}- disabled={source?.hasHistory !== true || running}- onChange={(e) => setHistory(e.target.checked)}- />- {S.builtinBrowser.importHistory}- </label>+ <Checkbox+ checked={cookies && source?.hasCookies === true}+ disabled={source?.hasCookies !== true || running}+ onChange={setCookies}+ label={S.builtinBrowser.importCookies}+ className={optionInk}+ />+ <Checkbox+ checked={history && source?.hasHistory === true}+ disabled={source?.hasHistory !== true || running}+ onChange={setHistory}+ label={S.builtinBrowser.importHistory}+ className={optionInk}+ /></div></div>{/* Filters cookies only: history is small and not a credential. */}diff --git a/packages/web/src/features/chat/chat-input.tsx b/packages/web/src/features/chat/chat-input.tsxindex 03571897..4366bd03 100644--- a/packages/web/src/features/chat/chat-input.tsx+++ b/packages/web/src/features/chat/chat-input.tsx@@ -92,11 +92,17 @@ import {Button,CheckIcon,ChevronDown,+ ChoiceCheck,GlyphIcon,ICONS,ICON_GAP,ICON_SIZE,+ PickerList,ProviderLogo,+ menuPanelClass,+ menuRowClass,+ menuRowTone,+ noAutofill,} from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { formatBytes, humanizeTokens } from "../../lib/format";@@ -105,7 +111,6 @@ import { useAuth } from "../../state/auth";import { agentDisplayName } from "../../state/project";import { Dropdown } from "../../components/ui/dropdown";import { PermissionSelect } from "./permission-select";-import { noAutofill } from "../../components/ui/input";import { toastError, toastInfo } from "../../components/ui/toast";import { SkillIcon } from "../skills/skill-icon-view";import { SkillPickList } from "../skills/skill-pick-list";@@ -113,7 +118,7 @@ import { toggleSkillName } from "../skills/skill-selection";import { ZoomableImage } from "../../components/ui/image-zoom";import { sameModelRef } from "../models/model-grouping";import { filterAgents, stagedSendRoute } from "./agent-handoff";-import { ModelSelect, PickerList, modelLabel } from "./model-select";+import { ModelSelect, modelLabel } from "./model-select";import { ModelPickerModal } from "./model-picker-modal";import { matchSlash, removeSlashToken } from "./slash-token";import { SELECTABLE_THINKING_LEVELS, thinkingLevelLabel } from "./thinking-level";@@ -138,7 +143,6 @@ import { splitBySize } from "../../lib/upload-limits";import type { ComposerReference } from "../../lib/workspace-tree";import { ReferenceChip } from "./reference-chip";import { NoticeStrip } from "../../components/ui/notice-strip";-import { ChoiceCheck, menuPanelClass, menuRowClass, menuRowTone } from "../../components/ui/field";/*** Agent candidate panel for the `/agent` switch picker, on the shared PickerList (search, scrolldiff --git a/packages/web/src/features/chat/context-gauge.tsx b/packages/web/src/features/chat/context-gauge.tsxindex 758595f5..5a6b2081 100644--- a/packages/web/src/features/chat/context-gauge.tsx+++ b/packages/web/src/features/chat/context-gauge.tsx@@ -68,10 +68,9 @@ import { useEffect, useId, useRef, useState } from "react";import type { RefObject } from "react";import { createPortal } from "react-dom";import type { SessionContextResponse } from "@prismshadow/penguin-server/api";+import { Input, usePortalPanel } from "@prismshadow/penguin-ui";import { getSessionContext } from "../../api/endpoints";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Input } from "../../components/ui/input";-import { usePortalPanel } from "../../components/ui/use-portal-panel";import {MIN_COMPACTION_THRESHOLD,THRESHOLD_STEP,diff --git a/packages/web/src/features/chat/draft-view.tsx b/packages/web/src/features/chat/draft-view.tsxindex bf2ef699..a9ad0995 100644--- a/packages/web/src/features/chat/draft-view.tsx+++ b/packages/web/src/features/chat/draft-view.tsx@@ -51,7 +51,16 @@ import type {SkillMetadataItem,TaskInputPart,} from "@prismshadow/penguin-server/api";-import { AgentAvatar, Chevron, ICONS, ICON_GAP, PenguinLogo } from "@prismshadow/penguin-ui";+import {+ AgentAvatar,+ Chevron,+ ChoiceCheck,+ ICONS,+ ICON_GAP,+ PenguinLogo,+ menuRowClass,+ menuRowTone,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { UNCONFINED } from "../../lib/permission-level";@@ -94,7 +103,6 @@ import { newChatAgentId } from "./new-chat";import { effectiveThinkingLevel } from "./thinking-level";import { WorkspaceSelect, pillClass } from "./workspace-select";import { sameModelRef } from "../models/model-grouping";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";/** Coalescing window for writing body text to the cache: keystrokes are frequent, so a short batch accumulates before persisting (option changes are still written immediately). */const DRAFT_SAVE_DEBOUNCE_MS = 300;diff --git a/packages/web/src/features/chat/model-picker-modal.tsx b/packages/web/src/features/chat/model-picker-modal.tsxindex 1c44f51e..a0c849bc 100644--- a/packages/web/src/features/chat/model-picker-modal.tsx+++ b/packages/web/src/features/chat/model-picker-modal.tsx@@ -20,9 +20,9 @@* - **Keyboard**: the search field keeps focus the whole time and drives a highlight (the* combobox pattern, via `aria-activedescendant`), so typing always lands in it. ↑/↓ walk the* list or the rail, ←/→ or Tab switch between them, ⌥1–9 (Alt off macOS) jump to a group,- * Enter chooses, Escape closes (the Modal's esc layer, so a picker opened from a dialog closes- * alone). Rows and rail entries are not in the Tab order, and no click takes focus away- * from the search field.+ * Enter chooses, Escape empties a typed query first (the shared search box) and then closes+ * (the Modal's esc layer, so a picker opened from a dialog closes alone). Rows and rail+ * entries are not in the Tab order, and no click takes focus away from the search field.* - **Phone width**: the dialog fills the screen and the rail becomes a strip of group chips* scrolling sideways above the list.*@@ -32,11 +32,17 @@import { useEffect, useId, useMemo, useRef, useState } from "react";import type { KeyboardEvent as ReactKeyboardEvent } from "react";import type { ModelInfo, ModelRefDto } from "@prismshadow/penguin-server/api";-import { CloseButton, GlyphIcon, ICONS, ICON_SIZE, ProviderLogo } from "@prismshadow/penguin-ui";+import {+ ChoiceCheck,+ CloseButton,+ GlyphIcon,+ ICONS,+ ICON_SIZE,+ ProviderLogo,+ SearchInput,+} from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { Modal } from "../../components/ui/modal";-import { noAutofill, panelSearchClass } from "../../components/ui/input";-import { ChoiceCheck } from "../../components/ui/field";import { hasConfiguredKey, sameModelRef } from "../models/model-grouping";import { loadModelGroupOrder } from "../models/model-group-order";import { TAG_SHAPE } from "../models/model-tags";@@ -309,12 +315,13 @@ function ModelPickerBody({className="flex h-[calc(100dvh_-_env(safe-area-inset-bottom))] flex-col pt-[env(safe-area-inset-top)] sm:h-[min(32rem,80vh)] sm:pt-0"><div className="flex shrink-0 items-center gap-2 border-b border-gray-200 px-3 py-2.5 dark:border-gray-800">- <input+ <SearchInputref={inputRef}+ variant="panel"autoFocusvalue={query}- onChange={(e) => {- setQuery(e.target.value);+ onChange={(next) => {+ setQuery(next);setSearchRow(0);}}placeholder={S.models.searchPlaceholder}@@ -324,8 +331,7 @@ function ModelPickerBody({aria-controls={listId}aria-autocomplete="list"{...(highlighted ? { "aria-activedescendant": optionId(highlighted) } : {})}- {...noAutofill}- className={`${panelSearchClass} min-w-0 flex-1 px-2.5 py-1.5`}+ className="min-w-0 flex-1"/><CloseButton onClose={onClose} /></div>diff --git a/packages/web/src/features/chat/model-select.tsx b/packages/web/src/features/chat/model-select.tsxindex 5bb9f1e1..941e6baa 100644--- a/packages/web/src/features/chat/model-select.tsx+++ b/packages/web/src/features/chat/model-select.tsx@@ -1,133 +1,23 @@/**- * Model picker pieces, extracted from chat-input.tsx so every host offers the same picker:- * - PickerList: the generic candidate panel (search box, scroll cap, keyboard navigation,- * current-entry marker) used by chat-input's `/agent` handoff picker;- * - ModelSelect: the model picker's trigger (provider logo + name + chevron), pill or form- * style. Either opens the model-picker dialog (model-picker-modal.tsx), which the in-session- * `/model` switch opens too.+ * The model picker's trigger, extracted from chat-input.tsx so every host offers the same+ * picker: ModelSelect (provider logo + name + chevron), pill or form style. Either opens the+ * model-picker dialog (model-picker-modal.tsx), which the in-session `/model` switch opens too.+ * The composer's other switch picker, the `/agent` handoff, is the UI package's PickerList.*/import { useState } from "react";-import type { KeyboardEvent, ReactNode } from "react";import type { ModelInfo, ModelRefDto } from "@prismshadow/penguin-server/api";import { ChevronDown, ICON_SIZE, ProviderLogo } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { FormPickerTrigger } from "../../components/ui/form-picker";-import { menuSearchClass, noAutofill } from "../../components/ui/input";import { sameModelRef } from "../models/model-grouping";import { modelLabel } from "./model-picker-logic";import { ModelPickerModal } from "./model-picker-modal";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";// Re-exported for the pages that label models (the models page, the Project and company// dialogs); it lives beside the picker's pure logic so the dialog can share it without an// import cycle back to this module.export { modelLabel };-/**- * Searchable candidate panel for the composer's switch pickers (today the `/agent` handoff- * picker; the model picker grew into its own dialog): the search box, the internal scroll cap,- * the row chrome, the keyboard navigation and the "current entry" marker slot all live here,- * so a picker supplies only what a row *contains* and what hangs below the list (`footer`).- *- * Keyboard navigation deliberately starts with **no** row highlighted: the search box is- * autofocused, and pre-highlighting a row would repaint a panel that has looked the same since- * before this control existed. ArrowDown/ArrowUp begin the navigation, and Enter/Tab commits —- * the highlighted row if there is one, otherwise the top match, which is what makes "type a few- * letters, press Enter" work. Escape is NOT handled here: each host closes its own panel at the- * window level (an IME-safe handler for the switch pickers).- */-export function PickerList<T>({- items,- itemKey,- isCurrent,- query,- onQueryChange,- searchPlaceholder,- emptyText,- onPick,- renderRow,- footer,-}: {- items: T[];- /** Stable React key AND identity for the highlighted row. */- itemKey: (item: T) => string;- /** Marks the entry already in effect (the session's model / its Agent): renders the ✓ slot and the emphasized row style. */- isCurrent?: (item: T) => boolean;- query: string;- onQueryChange: (query: string) => void;- searchPlaceholder: string;- /** Shown in place of the list when the query matches nothing. */- emptyText: string;- onPick: (item: T) => void;- /** The row's own content, left of the ✓ slot. */- renderRow: (item: T) => ReactNode;- /** Pinned below the scroll area (mirroring the search box above it). */- footer?: ReactNode;-}) {- // -1 = nothing highlighted yet (see the note above); reset whenever the candidate set changes.- const [active, setActive] = useState(-1);- const activeKey = active >= 0 && active < items.length ? itemKey(items[active]!) : null;- const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {- if (items.length === 0) return;- if (e.key === "ArrowDown") {- e.preventDefault();- setActive((i) => (i + 1) % items.length);- return;- }- if (e.key === "ArrowUp") {- e.preventDefault();- setActive((i) => (i <= 0 ? items.length - 1 : i - 1));- return;- }- // Same guard as the composer's own Enter handling: an IME commit must not be read as a pick.- if (((e.key === "Enter" && !e.shiftKey) || e.key === "Tab") && !e.nativeEvent.isComposing) {- e.preventDefault();- onPick(items[active >= 0 ? active : 0]!);- }- };- return (- <div className="contents" onKeyDown={onKeyDown}>- {/* Quick search (autofocused: it also owns the keyboard while the panel is up) */}- <div className="border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800">- <input- autoFocus- value={query}- onChange={(e) => {- onQueryChange(e.target.value);- setActive(-1);- }}- placeholder={searchPlaceholder}- aria-label={searchPlaceholder}- {...noAutofill}- className={`${menuSearchClass} px-1 py-0.5`}- />- </div>- <div className="max-h-56 overflow-y-auto">- {items.length === 0 && <p className="px-3 py-1.5 text-xs text-gray-400">{emptyText}</p>}- {items.map((item) => {- const key = itemKey(item);- const current = isCurrent?.(item) ?? false;- return (- <button- key={key}- type="button"- ref={key === activeKey ? (el) => el?.scrollIntoView({ block: "nearest" }) : undefined}- onClick={() => onPick(item)}- className={`flex items-center gap-2 ${menuRowClass} text-xs ${menuRowTone(current)}${- key === activeKey ? " bg-gray-100 dark:bg-gray-800" : ""- }`}- >- {renderRow(item)}- <ChoiceCheck on={current} />- </button>- );- })}- </div>- {footer}- </div>- );-}-/*** Model selector (the chat composer's bottom-toolbar trigger, also hosted by the Project* settings' new-chat-defaults section, the schedule form, the company dialogs and the benchmarkdiff --git a/packages/web/src/features/chat/permission-select.tsx b/packages/web/src/features/chat/permission-select.tsxindex ab8f61ab..9a72493c 100644--- a/packages/web/src/features/chat/permission-select.tsx+++ b/packages/web/src/features/chat/permission-select.tsx@@ -16,7 +16,7 @@import { useState } from "react";import type { ReactNode } from "react";import type { ApprovalMode, SessionSandbox } from "@prismshadow/penguin-server/api";-import { GlyphIcon } from "@prismshadow/penguin-ui";+import { ChoiceCheck, GlyphIcon, menuRowClass, menuRowTone } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { Dropdown } from "../../components/ui/dropdown";import { toneInk } from "../../lib/tone";@@ -27,7 +27,6 @@ import {} from "../../lib/permission-level";import { useAuth } from "../../state/auth";import { SettingsDialog } from "../settings/settings-dialog";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";const FS_MODES: SessionSandbox["mode"][] = ["read-only", "workspace-write", "danger-full-access"];const NETWORK_MODES: SessionSandbox["network"][] = ["open", "local", "none"];diff --git a/packages/web/src/features/chat/shortcuts-folder.tsx b/packages/web/src/features/chat/shortcuts-folder.tsxindex 463fb483..2cb36dc2 100644--- a/packages/web/src/features/chat/shortcuts-folder.tsx+++ b/packages/web/src/features/chat/shortcuts-folder.tsx@@ -19,12 +19,19 @@* out of reach on a phone.*/import { useCallback, useEffect, useRef, useState } from "react";-import { Button, GlyphIcon, ICONS, ICON_SIZE, PlusIcon } from "@prismshadow/penguin-ui";+import {+ Button,+ GlyphIcon,+ ICONS,+ ICON_SIZE,+ Input,+ PlusIcon,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { toastError } from "../../components/ui/toast";import { ExampleFolderRow, exampleRowClass } from "./example-folder-row";diff --git a/packages/web/src/features/chat/workspace-browser.tsx b/packages/web/src/features/chat/workspace-browser.tsxindex 3e66ad30..4222136c 100644--- a/packages/web/src/features/chat/workspace-browser.tsx+++ b/packages/web/src/features/chat/workspace-browser.tsx@@ -57,8 +57,11 @@ import {HiddenFileInput,ICONS,ICON_SIZE,+ Input,+ SearchInput,SkeletonList,Spinner,+ noAutofill,useCopied,} from "@prismshadow/penguin-ui";import { REHYPE_PLUGINS, REMARK_PLUGINS } from "../../lib/markdown-plugins";@@ -117,7 +120,6 @@ import { isContextMenuKey, isLongPressPointer } from "../../lib/context-menu";import { ConfirmModal } from "../../components/ui/confirm-modal";import { useRowContextMenu } from "../../components/ui/context-menu";import { Dropdown } from "../../components/ui/dropdown";-import { Input, noAutofill, panelSearchClass } from "../../components/ui/input";import { ZoomableImage } from "../../components/ui/image-zoom";import { restoreSelection } from "../../components/ui/text-selection";import { Tooltip } from "../../components/ui/tooltip";@@ -1751,33 +1753,15 @@ export function WorkspaceBrowser({everything names the open file. Esc in a non-empty box clears it rather than reachingthe dock or a dialog above, which is what that key means here. */}<div className="flex shrink-0 items-center gap-1 border-b border-gray-100 px-2 py-1.5 dark:border-gray-800">- <div className="relative min-w-0 flex-1">- <input- value={query}- onChange={(e) => setQuery(e.target.value)}- onKeyDown={(e) => {- if (e.key !== "Escape" || query === "") return;- e.preventDefault();- e.stopPropagation();- setQuery("");- }}- placeholder={S.files.searchPlaceholder}- aria-label={S.files.searchPlaceholder}- {...noAutofill}- className={`${panelSearchClass} py-1 pl-2 pr-7`}- />- {query !== "" && (- <button- type="button"- aria-label={S.files.searchClear}- data-tooltip={S.files.searchClear}- onClick={() => setQuery("")}- className="absolute right-1.5 top-1/2 -translate-y-1/2 rounded p-0.5 text-gray-400 transition-colors duration-150 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-gray-200"- >- <CloseIcon size={12} />- </button>- )}- </div>+ <SearchInput+ variant="panel"+ className="min-w-0 flex-1"+ value={query}+ onChange={setQuery}+ placeholder={S.files.searchPlaceholder}+ aria-label={S.files.searchPlaceholder}+ clearLabel={S.files.searchClear}+ /><Tooltip label={S.files.refresh} placement="bottom" className="shrink-0"><buttontype="button"diff --git a/packages/web/src/features/chat/workspace-finder.tsx b/packages/web/src/features/chat/workspace-finder.tsxindex 515f470d..cce7ce85 100644--- a/packages/web/src/features/chat/workspace-finder.tsx+++ b/packages/web/src/features/chat/workspace-finder.tsx@@ -24,7 +24,15 @@ import type {ReactNode,} from "react";import type { DesktopPrivacyPane, DirListResponse } from "@prismshadow/penguin-server/api";-import { Button, CloseIcon, GlyphIcon, ICONS, ICON_GAP, ICON_SIZE } from "@prismshadow/penguin-ui";+import {+ Button,+ CloseIcon,+ GlyphIcon,+ ICONS,+ ICON_GAP,+ ICON_SIZE,+ noAutofill,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { writeClipboard } from "../../lib/clipboard";@@ -41,7 +49,6 @@ import { useSessions } from "../../state/sessions";import { Modal } from "../../components/ui/modal";import { useRowContextMenu } from "../../components/ui/context-menu";import { Dropdown } from "../../components/ui/dropdown";-import { noAutofill } from "../../components/ui/input";import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";import { toastError, toastSuccess } from "../../components/ui/toast";import {diff --git a/packages/web/src/features/company/calendar-page.tsx b/packages/web/src/features/company/calendar-page.tsxindex c57786b4..fdbe7404 100644--- a/packages/web/src/features/company/calendar-page.tsx+++ b/packages/web/src/features/company/calendar-page.tsx@@ -33,7 +33,13 @@ import {ICONS,ICON_GAP,ICON_SIZE,+ Input,+ Segmented,+ Select,Skeleton,+ Switch,+ Textarea,+ usePortalPanel,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -45,13 +51,8 @@ import { toneInk } from "../../lib/tone";import type { Tone } from "../../lib/tone";import { useAuth } from "../../state/auth";import { useCompany } from "../../state/company";-import { Segmented } from "../../components/ui/segmented";-import { Select } from "../../components/ui/select";-import { Switch } from "../../components/ui/switch";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { usePortalPanel } from "../../components/ui/use-portal-panel";import { toastAttention, toastError, toastSuccess } from "../../components/ui/toast";import { OrgPage, useOrg } from "./org-layout";import {diff --git a/packages/web/src/features/company/channel-composer.tsx b/packages/web/src/features/company/channel-composer.tsxindex b27feb0e..50b02a07 100644--- a/packages/web/src/features/company/channel-composer.tsx+++ b/packages/web/src/features/company/channel-composer.tsx@@ -43,10 +43,9 @@ import type {DragEvent as ReactDragEvent,KeyboardEvent as ReactKeyboardEvent,} from "react";-import { Button, ICON_GAP } from "@prismshadow/penguin-ui";+import { Button, ICON_GAP, noAutofill } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { Dropdown } from "../../components/ui/dropdown";-import { noAutofill } from "../../components/ui/input";import { PrincipalChip } from "./shared";import {mentionInsertId,diff --git a/packages/web/src/features/company/channel-dialogs.tsx b/packages/web/src/features/company/channel-dialogs.tsxindex 8ed1a9fe..1caeb9bd 100644--- a/packages/web/src/features/company/channel-dialogs.tsx+++ b/packages/web/src/features/company/channel-dialogs.tsx@@ -11,13 +11,12 @@*/import { useEffect, useState } from "react";import type { OrgChannelItem } from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input, Textarea } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { channelIdProblem } from "./channel-list";import type { ChannelIdProblem } from "./channel-list";diff --git a/packages/web/src/features/company/channel-header.tsx b/packages/web/src/features/company/channel-header.tsxindex 2ba36e96..fb181f5b 100644--- a/packages/web/src/features/company/channel-header.tsx+++ b/packages/web/src/features/company/channel-header.tsx@@ -25,7 +25,14 @@ import {ICONS,ICON_GAP,ICON_SIZE,+ InfoPopover,+ Input,UserAvatar,+ menuPanelClass,+ menuRowClass,+ menuRowTone,+ noAutofill,+ usePortalPanel,} from "@prismshadow/penguin-ui";import type { AvatarStackItem } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";@@ -34,10 +41,7 @@ import { apiErrorText } from "../../lib/api-error";import { useProject } from "../../state/project";import { ConfirmModal } from "../../components/ui/confirm-modal";import { Dropdown } from "../../components/ui/dropdown";-import { InfoPopover } from "../../components/ui/info-popover";-import { Input, noAutofill } from "../../components/ui/input";import { overflowMenuGlyph, overflowMenuRowClass } from "../../components/ui/session-row-menu";-import { usePortalPanel } from "../../components/ui/use-portal-panel";import { toastError, toastSuccess } from "../../components/ui/toast";import { Truncated } from "../../components/ui/truncated";import { ChannelTextDialog } from "./channel-dialogs";@@ -45,7 +49,6 @@ import { channelGlyph } from "./channel-sidebar";import { channelLabel, inviteCandidates, isAllHands } from "./channel-list";import type { InviteCandidate } from "./channel-list";import { parsePrincipal } from "./principals";-import { menuPanelClass, menuRowClass, menuRowTone } from "../../components/ui/field";/** Invite (lucide user-plus): the header's "add somebody to this channel" action. */const INVITE_ICON =diff --git a/packages/web/src/features/company/employee-dialogs.tsx b/packages/web/src/features/company/employee-dialogs.tsxindex 84e2fec0..d0f6f04a 100644--- a/packages/web/src/features/company/employee-dialogs.tsx+++ b/packages/web/src/features/company/employee-dialogs.tsx@@ -11,7 +11,17 @@*/import { useEffect, useState } from "react";import type { OrgEmployeeItem, OrgHireRequest } from "@prismshadow/penguin-server/api";-import { Button, ICONS } from "@prismshadow/penguin-ui";+import {+ Button,+ FieldError,+ FieldHint,+ FieldLabel,+ ICONS,+ Input,+ Segmented,+ Select,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";@@ -21,13 +31,9 @@ import { formatMoney } from "../../lib/format";import { useCompany } from "../../state/company";import { agentDisplayName, useProject } from "../../state/project";import { useTheme } from "../../state/theme";-import { Input, Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";-import { Segmented } from "../../components/ui/segmented";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";import { FormPicker } from "../../components/ui/form-picker";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { toastError, toastSuccess } from "../../components/ui/toast";import { SkillPickList } from "../skills/skill-pick-list";import type { PickableItem } from "../skills/skill-pick-list";diff --git a/packages/web/src/features/company/finance-page.tsx b/packages/web/src/features/company/finance-page.tsxindex 5110a8ce..4b570455 100644--- a/packages/web/src/features/company/finance-page.tsx+++ b/packages/web/src/features/company/finance-page.tsx@@ -44,6 +44,9 @@ import {ICONS,ICON_GAP,ICON_SIZE,+ InfoPopover,+ Segmented,+ noAutofill,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -57,9 +60,6 @@ import { useCompany } from "../../state/company";import { useTheme } from "../../state/theme";import type { Currency } from "../../state/theme";import { NAV_ICONS } from "../../lib/nav-icons";-import { InfoPopover } from "../../components/ui/info-popover";-import { noAutofill } from "../../components/ui/input";-import { Segmented } from "../../components/ui/segmented";import { toastError, toastSuccess } from "../../components/ui/toast";import { TrendChart } from "../usage/trend-chart";import { OrgPage, OrgPageSkeleton, useOrg } from "./org-layout";diff --git a/packages/web/src/features/company/handbook-page.tsx b/packages/web/src/features/company/handbook-page.tsxindex d57e8d2d..302f7da5 100644--- a/packages/web/src/features/company/handbook-page.tsx+++ b/packages/web/src/features/company/handbook-page.tsx@@ -26,7 +26,9 @@ import {GlyphIcon,ICON_GAP,ICON_SIZE,+ Input,Skeleton,+ Textarea,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -39,7 +41,6 @@ import { useShortcutLabel } from "../../lib/shortcuts/use-keymap";import { useDocumentTitle } from "../../lib/use-document-title";import { useLocale } from "../../state/locale";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Input, Textarea } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import type { TreeToggle } from "../../components/ui/file-tree";import { toastError, toastSuccess } from "../../components/ui/toast";diff --git a/packages/web/src/features/company/org-dialogs.tsx b/packages/web/src/features/company/org-dialogs.tsxindex ca4a1353..9b409d37 100644--- a/packages/web/src/features/company/org-dialogs.tsx+++ b/packages/web/src/features/company/org-dialogs.tsx@@ -38,7 +38,17 @@ import type {OrganizationPatchRequest,OrganizationSettings,} from "@prismshadow/penguin-server/api";-import { Button, ICON_GAP } from "@prismshadow/penguin-ui";+import {+ Button,+ FieldError,+ FieldHint,+ FieldLabel,+ ICON_GAP,+ InfoPopover,+ Input,+ Select,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";@@ -48,12 +58,8 @@ import { useAuth } from "../../state/auth";import { useCompany } from "../../state/company";import { projectDisplayName, useProject } from "../../state/project";import { useTheme } from "../../state/theme";-import { Input, Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { InfoPopover } from "../../components/ui/info-popover";import { toastError, toastSuccess } from "../../components/ui/toast";import { ModelSelect, modelLabel } from "../chat/model-select";import { WorkspaceSelect } from "../chat/workspace-select";diff --git a/packages/web/src/features/company/org-layout.tsx b/packages/web/src/features/company/org-layout.tsxindex c4fb818d..dd54c6cc 100644--- a/packages/web/src/features/company/org-layout.tsx+++ b/packages/web/src/features/company/org-layout.tsx@@ -33,12 +33,12 @@ import {ICONS,ICON_GAP,ICON_SIZE,+ InfoPopover,Skeleton,} from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { useCompany } from "../../state/company";import { useProject } from "../../state/project";-import { InfoPopover } from "../../components/ui/info-popover";import { orgKey, orgPagePath, resolveOrgLanding } from "./company-nav";import { CreateOrganizationDialog, useOrganizationCreated } from "./org-dialogs";import { ORG_EXAMPLES } from "./org-examples";diff --git a/packages/web/src/features/company/org-switcher.tsx b/packages/web/src/features/company/org-switcher.tsxindex 8ce32ca6..956978de 100644--- a/packages/web/src/features/company/org-switcher.tsx+++ b/packages/web/src/features/company/org-switcher.tsx@@ -24,6 +24,8 @@ import {ICON_SIZE,PlusIcon,SkeletonList,+ menuRowClass,+ menuRowTone,} from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { toneSurface } from "../../lib/tone";@@ -37,7 +39,6 @@ import {useOrganizationCreated,} from "./org-dialogs";import { OrgStatusDot, OrgStatusPill, orgStatusText } from "./shared";-import { menuRowClass, menuRowTone } from "../../components/ui/field";/** The switcher's rows: the shared menu row, a list of organizations and the actions under it. */const menuItemBase = `flex items-center ${ICON_GAP.menu} ${menuRowClass} text-sm`;diff --git a/packages/web/src/features/company/overview-page.tsx b/packages/web/src/features/company/overview-page.tsxindex d86bebf7..6aa01be4 100644--- a/packages/web/src/features/company/overview-page.tsx+++ b/packages/web/src/features/company/overview-page.tsx@@ -38,6 +38,7 @@ import {GlyphIcon,ICON_GAP,ICON_SIZE,+ Segmented,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -51,7 +52,6 @@ import { useLocale } from "../../state/locale";import { useLiveSessionStatuses } from "../../state/sessions";import { useTheme } from "../../state/theme";import { NAV_ICONS } from "../../lib/nav-icons";-import { Segmented } from "../../components/ui/segmented";import { toastError } from "../../components/ui/toast";import { STAT_ICONS } from "../../lib/stat-icons";import { orgChannelPath, orgKey, orgPagePath } from "./company-nav";diff --git a/packages/web/src/features/company/shared.tsx b/packages/web/src/features/company/shared.tsxindex 43718cc1..c0462a4e 100644--- a/packages/web/src/features/company/shared.tsx+++ b/packages/web/src/features/company/shared.tsx@@ -18,9 +18,13 @@ import {AgentAvatar,Badge,Button,+ FieldError,+ FieldHint,+ FieldLabel,GlyphIcon,ICON_GAP,ICON_SIZE,+ Input,} from "@prismshadow/penguin-ui";import type { BadgeStyle, ToneName } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";@@ -28,8 +32,6 @@ import { formatMoney, formatPercent } from "../../lib/format";import { toneDot, toneInk } from "../../lib/tone";import type { Tone } from "../../lib/tone";import type { Currency } from "../../state/theme";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";-import { Input } from "../../components/ui/input";import { toStoredUsd, unitLabel } from "./budget-input";import { budgetTone } from "./finance-tree";import { parsePrincipal } from "./principals";diff --git a/packages/web/src/features/company/ticket-dialog.tsx b/packages/web/src/features/company/ticket-dialog.tsxindex 53f9a24f..ab0eb19c 100644--- a/packages/web/src/features/company/ticket-dialog.tsx+++ b/packages/web/src/features/company/ticket-dialog.tsx@@ -41,9 +41,14 @@ import {Chevron,CloseButton,CopyButton,+ FieldLabel,ICON_GAP,ICON_SIZE,+ Input,+ Segmented,+ Select,Skeleton,+ Textarea,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -54,10 +59,6 @@ import { useAuth } from "../../state/auth";import { useCompany } from "../../state/company";import { useProject } from "../../state/project";import { useTheme } from "../../state/theme";-import { Input, Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";-import { Segmented } from "../../components/ui/segmented";-import { FieldLabel } from "../../components/ui/field";import { ConfirmModal } from "../../components/ui/confirm-modal";import { Modal } from "../../components/ui/modal";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";diff --git a/packages/web/src/features/company/tickets-page.tsx b/packages/web/src/features/company/tickets-page.tsxindex a6434dd5..e8b8b2f1 100644--- a/packages/web/src/features/company/tickets-page.tsx+++ b/packages/web/src/features/company/tickets-page.tsx@@ -35,7 +35,21 @@ import type {OrgTicketStatus,OrgTicketsResponse,} from "@prismshadow/penguin-server/api";-import { Button, CloseIcon, GlyphIcon, ICONS, ICON_SIZE, Skeleton } from "@prismshadow/penguin-ui";+import {+ Button,+ CloseIcon,+ FieldLabel,+ GlyphIcon,+ ICONS,+ ICON_SIZE,+ Input,+ SearchInput,+ Segmented,+ Select,+ Skeleton,+ Switch,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";@@ -43,12 +57,7 @@ import { useDocumentTitle } from "../../lib/use-document-title";import { toneDot, toneInk } from "../../lib/tone";import { useAuth } from "../../state/auth";import { useCompany } from "../../state/company";-import { Switch } from "../../components/ui/switch";-import { Segmented } from "../../components/ui/segmented";import { Modal } from "../../components/ui/modal";-import { Input, Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";-import { FieldLabel } from "../../components/ui/field";import { toastError, toastSuccess } from "../../components/ui/toast";import { OrgPage, useOrg } from "./org-layout";import {@@ -329,16 +338,14 @@ export function TicketsPage() {wideactions={<>- <div className="w-44">- <Input- size="sm"- type="search"- aria-label={S.company.tickets.searchPlaceholder}- placeholder={S.company.tickets.searchPlaceholder}- value={query}- onChange={(e) => setQuery(e.target.value)}- />- </div>+ <SearchInput+ size="sm"+ className="w-44"+ aria-label={S.company.tickets.searchPlaceholder}+ placeholder={S.company.tickets.searchPlaceholder}+ value={query}+ onChange={setQuery}+ /><label className="flex items-center gap-2 text-xs text-gray-600 dark:text-gray-300">{S.company.tickets.blockedOnly}<Switchdiff --git a/packages/web/src/features/dock/dock-launcher.tsx b/packages/web/src/features/dock/dock-launcher.tsxindex 17504d28..1154aaae 100644--- a/packages/web/src/features/dock/dock-launcher.tsx+++ b/packages/web/src/features/dock/dock-launcher.tsx@@ -36,13 +36,12 @@ import type {KeyboardEvent as ReactKeyboardEvent,ReactNode,} from "react";-import { GlyphIcon, ICONS, ICON_SIZE } from "@prismshadow/penguin-ui";+import { GlyphIcon, ICONS, ICON_SIZE, scrollMovesAnchor } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { NAV_ICONS } from "../../lib/nav-icons";import { toastInfo } from "../../components/ui/toast";import { usePrefersReducedMotion } from "../../components/ui/use-reduced-motion";import { toneDot, toneInk } from "../../lib/tone";-import { scrollMovesAnchor } from "../../lib/context-menu";import { SPRING_DEFAULT, SPRING_MOMENTUM, createSpringDriver } from "../../lib/spring";import type { SpringDriver } from "../../lib/spring";import { subscribeTerminals, terminalApiSupported } from "../terminal/terminal-list";diff --git a/packages/web/src/features/machines/machine-picker.tsx b/packages/web/src/features/machines/machine-picker.tsxindex c76c9645..d6e60dcc 100644--- a/packages/web/src/features/machines/machine-picker.tsx+++ b/packages/web/src/features/machines/machine-picker.tsx@@ -8,9 +8,14 @@* in-place panel.*/import { useState } from "react";-import { Button, ChevronDown } from "@prismshadow/penguin-ui";+import {+ Button,+ ChevronDown,+ ChoiceCheck,+ menuRowClass,+ menuRowTone,+} from "@prismshadow/penguin-ui";import { Dropdown } from "../../components/ui/dropdown";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";export interface MachineChoice {value: string;diff --git a/packages/web/src/features/machines/machines-page.tsx b/packages/web/src/features/machines/machines-page.tsxindex 6b7a89d3..26b38c8b 100644--- a/packages/web/src/features/machines/machines-page.tsx+++ b/packages/web/src/features/machines/machines-page.tsx@@ -31,6 +31,7 @@ import {GlyphIcon,ICONS,ICON_SIZE,+ SearchInput,Skeleton,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";@@ -43,7 +44,6 @@ import { formatDateTime, formatMessageTime } from "../../lib/format";import { toneDot, toneInk } from "../../lib/tone";import { Dropdown } from "../../components/ui/dropdown";import { toastError } from "../../components/ui/toast";-import { noAutofill, panelSearchClass } from "../../components/ui/input";import { NAV_ICONS } from "../../lib/nav-icons";import {MACHINE_PHASES,@@ -361,15 +361,13 @@ export function MachinesPage() {{/* The search row: matched characters bright and the rest dimmed — with asubsequence match, an unmarked row looks wrong. */}<div className="px-2 pt-2 pb-1">- <input- type="search"+ <SearchInput+ variant="panel"autoFocusvalue={query}- onChange={(event) => setQuery(event.target.value)}+ onChange={setQuery}placeholder={S.machines.search}aria-label={S.machines.search}- {...noAutofill}- className={`${panelSearchClass} px-2.5 py-1.5`}/></div><uldiff --git a/packages/web/src/features/machines/ssh-host-dialog.tsx b/packages/web/src/features/machines/ssh-host-dialog.tsxindex c6382ad6..ef21da53 100644--- a/packages/web/src/features/machines/ssh-host-dialog.tsx+++ b/packages/web/src/features/machines/ssh-host-dialog.tsx@@ -16,11 +16,10 @@ import type {SshHostRequest,SshHostResponse,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";-import { Input } from "../../components/ui/input";import { Modal } from "../../components/ui/modal";import { toastSuccess } from "../../components/ui/toast";import { NoticeStrip } from "../../components/ui/notice-strip";diff --git a/packages/web/src/features/messaging/messaging-binding-editor.tsx b/packages/web/src/features/messaging/messaging-binding-editor.tsxindex 84440b22..1de3c61a 100644--- a/packages/web/src/features/messaging/messaging-binding-editor.tsx+++ b/packages/web/src/features/messaging/messaging-binding-editor.tsx@@ -48,19 +48,22 @@ import type {MessagingRuntimeStatus,TelegramTestResponse,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import {+ Button,+ Checkbox,+ FieldLabel,+ HelpFold,+ InfoPopover,+ Input,+ PasswordInput,+ Segmented,+ Switch,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { formatDateTime } from "../../lib/format";import { toneInk, type Tone } from "../../lib/tone";-import { FieldLabel } from "../../components/ui/field";-import { HelpFold } from "../../components/ui/help-fold";-import { InfoPopover } from "../../components/ui/info-popover";-import { Input } from "../../components/ui/input";-import { PasswordInput } from "../../components/ui/password-input";-import { Segmented } from "../../components/ui/segmented";-import { Switch } from "../../components/ui/switch";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";import { QQScanConnect } from "./qq-scan-connect";import { WeChatScanConnect } from "./wechat-scan-connect";@@ -578,17 +581,7 @@ function StoredSecretRow({return (<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400"><span className="font-mono">{masked}</span>- <label- className={`flex items-center gap-1.5 ${enabled ? "cursor-not-allowed opacity-60" : ""}`}- >- <input- type="checkbox"- checked={checked}- disabled={enabled}- onChange={(e) => onChange(e.target.checked)}- />- {clearLabel}- </label>+ <Checkbox checked={checked} disabled={enabled} onChange={onChange} label={clearLabel} />{/* A disabled checkbox does not reliably fire hover, so the reason is on screen ratherthan in a title: a gated control that never says why is the bug this avoids. */}{enabled && (diff --git a/packages/web/src/features/messaging/wechat-scan-connect.tsx b/packages/web/src/features/messaging/wechat-scan-connect.tsxindex 9269c426..267efcda 100644--- a/packages/web/src/features/messaging/wechat-scan-connect.tsx+++ b/packages/web/src/features/messaging/wechat-scan-connect.tsx@@ -30,11 +30,10 @@ import type {WeChatBindingInfo,WeChatScanPollResponse,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { apiErrorText } from "../../lib/api-error";import { S } from "../../lib/strings";-import { Input } from "../../components/ui/input";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";import { QrCode } from "./qq-scan-connect";diff --git a/packages/web/src/features/models/models-page.tsx b/packages/web/src/features/models/models-page.tsxindex 9e5c8f1b..154cdd82 100644--- a/packages/web/src/features/models/models-page.tsx+++ b/packages/web/src/features/models/models-page.tsx@@ -29,16 +29,8 @@* Saving does a PUT full-table replace (models not present are deleted; an empty apiKey* means keep the existing value); only the owner can edit.*/-import {- Fragment,- useCallback,- useEffect,- useLayoutEffect,- useMemo,- useRef,- useState,-} from "react";-import type { DragEvent as ReactDragEvent, ReactNode, RefObject } from "react";+import { Fragment, useCallback, useEffect, useMemo, useRef, useState } from "react";+import type { DragEvent as ReactDragEvent, ReactNode } from "react";import type {CredentialInfo,ModelProtocolDetectRequest,@@ -51,15 +43,24 @@ import type {} from "@prismshadow/penguin-server/api";import {Button,+ Checkbox,Chevron,EmptyState,+ FieldError,+ FieldLabel,GlyphIcon,ICONS,ICON_SIZE,+ InfoPopover,+ Input,Link,+ PasswordInput,ProviderLogo,+ Segmented,+ Select,SkeletonList,Spinner,+ Switch,buttonClass,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";@@ -71,14 +72,8 @@ import { useProject } from "../../state/project";import { useAuth } from "../../state/auth";import { USD_TO_CNY, useTheme } from "../../state/theme";import type { Currency } from "../../state/theme";-import { Input } from "../../components/ui/input";-import { FieldError, FieldLabel } from "../../components/ui/field";-import { PasswordInput } from "../../components/ui/password-input";import { Modal } from "../../components/ui/modal";import { ConfirmModal } from "../../components/ui/confirm-modal";-import { Segmented } from "../../components/ui/segmented";-import { Select } from "../../components/ui/select";-import { Switch } from "../../components/ui/switch";import { AiCreateModal, CreateButtons } from "../ai-create";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";import { formatDateTime, humanizeTokens } from "../../lib/format";@@ -147,7 +142,6 @@ import { buildImportedRows } from "./group-import";import { tpsTone, ttftTone } from "./speed-test";import type { SpeedResult, SpeedTone } from "./speed-test";import { toneInk } from "../../lib/tone";-import { InfoPopover } from "../../components/ui/info-popover";import { KeyAuthDialog } from "./key-auth-dialog";import type { KeyAuthTexts } from "./key-auth-dialog";import { NoticeStrip } from "../../components/ui/notice-strip";@@ -2363,46 +2357,6 @@ const CONFIRM_BODY: Record<DialogAction, (name: string) => string> = {remove: (n) => S.models.confirmDelete(n),};-/**- * Live width of one affix drawn inside an input — the currency symbol, the "/M tok" price unit,- * the "Token" unit — so the input can reserve exactly the room it actually occupies. An affix is- * rendered text: its width follows the resolved font, the root font size (the appearance setting- * scales it) and, for the currency symbol, the selected currency, none of which is known where- * the padding is written, which is why it is measured rather than typed. The affix is absolutely- * positioned, so its size does not depend on the padding derived from it. One call covers every- * field drawing the same string at the same size; fields whose affixes differ take one each.- */-function useAffixWidth(): [RefObject<HTMLSpanElement | null>, number] {- const ref = useRef<HTMLSpanElement>(null);- const [width, setWidth] = useState(0);- useLayoutEffect(() => {- const el = ref.current;- if (!el) return;- // The observer reports the box LAYOUT size, which is what has to be reserved. A rect read- // off the element would be wrong here: the dialog pops in under `scale(0.96)`, so a- // measurement taken while that animation runs comes back 4% short, and a transform never- // notifies an observer that would correct it. Delivery is after layout and before paint,- // so the unmeasured state is not painted; a currency switch, a language switch and a- // font-size change all resize the affix and re-run this.- const ro = new ResizeObserver(([entry]) => {- if (entry) setWidth(entry.borderBoxSize[0]?.inlineSize ?? entry.contentRect.width);- });- ro.observe(el);- return () => ro.disconnect();- }, []);- return [ref, width];-}--/**- * Padding that clears an affix of the given rendered width: the 0.5rem the affix is inset- * from the input edge (`left-2` / `right-2`), the affix itself, and 0.25rem of separation so- * the value does not read as one run of text with it. An unmeasured width (0) still yields a- * padding no smaller than the control's own, so nothing lands outside the box.- */-function affixPadding(width: number): string {- return `calc(${width}px + 0.75rem)`;-}-function ModelDialog({projectId,row,@@ -2529,12 +2483,6 @@ function ModelDialog({const [visionDetecting, setVisionDetecting] = useState(false);/** Single-flight guard for the vision probe: it bills the user, so never twice at once. */const visionInFlight = useRef<Promise<void> | null>(null);- // Room each in-field affix needs (see useAffixWidth). The three price inputs share one- // currency symbol and one "/M tok" unit; the context-window and max-tokens inputs share the- // "Token" unit with each other, so each distinct string is measured once.- const [currencyRef, currencyWidth] = useAffixWidth();- const [priceUnitRef, priceUnitWidth] = useAffixWidth();- const [tokenUnitRef, tokenUnitWidth] = useAffixWidth();const isNew = row === null;const preset = row !== null && isPreset(row);/** The loaded row's running promotion, explained under the price fields. */@@ -3316,14 +3264,11 @@ function ModelDialog({</span>)}{canEdit && (- <label className="flex items-center gap-1.5">- <input- type="checkbox"- checked={form.clearApiKey}- onChange={(e) => set({ clearApiKey: e.target.checked })}- />- {S.models.clearApiKey}- </label>+ <Checkbox+ checked={form.clearApiKey}+ onChange={(on) => set({ clearApiKey: on })}+ label={S.models.clearApiKey}+ />)}</div>)}@@ -3348,8 +3293,10 @@ function ModelDialog({baseUrlRequired). The in-field suffix at the right edge shows the protocol path theclient appends to the base URL — the endpoint shape a custom URL must serve; itrenders for every model and stays while the field is empty (hints the shape before- typing). Reuses the unit-adornment idiom of the context window / max tokens fields- below; the error text sits outside the relative wrapper (see Input.invalid).+ typing). It looks like the unit affix of the context window / max tokens fields+ below, but it can be a menu button, which Input's `affix` does not take, so it is+ positioned by hand and the error text sits outside the relative wrapper (see+ Input.invalid).For custom / user-defined groups that suffix IS the protocol SELECTOR (seeprotocol-suffix.tsx): the path is one-to-one with the three generic protocol@@ -3454,68 +3401,47 @@ function ModelDialog({Agent's system_config value; empty inherits it (lets a small-context localmodel stay under its window). */}<div className="grid grid-cols-2 items-start gap-2">- <label className="block">- <FieldLabel>{S.models.contextWindow}</FieldLabel>- <span className="relative block">- <Input- size="sm"- value={form.contextWindow}- inputMode="numeric"- disabled={!canEdit}- invalid={Boolean(fieldErrors.contextWindow)}- onChange={(e) => set({ contextWindow: digitsOnly(e.target.value) })}- // Half-width cell: the placeholder is wider than the box in English, and an- // input clips at its padding box, so an unclipped one runs past the value area- // and collides with the unit. `truncate` ends it in an ellipsis instead, which- // reads as "there is more" rather than as text colliding; the title has it in full.- className="truncate font-mono"- style={{ paddingRight: affixPadding(tokenUnitWidth) }}- // The title mirrors the placeholder: at half width the (EN) copy can clip, hover reveals it in full.- title={- preset- ? S.models.contextWindowHint- : S.models.contextWindowDefaultHint(CUSTOM_CONTEXT_DEFAULT)- }- placeholder={- preset- ? S.models.contextWindowHint- : S.models.contextWindowDefaultHint(CUSTOM_CONTEXT_DEFAULT)- }- />- <span- // Both fields in this row draw the same unit at the same size, so one- // measurement sizes the reserve for the pair.- ref={tokenUnitRef}- className="pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400"- >- {S.models.tokenUnit}- </span>- </span>- {fieldErrors.contextWindow && <FieldError>{fieldErrors.contextWindow}</FieldError>}- </label>- <label className="block">- <FieldLabel>{S.models.maxTokens}</FieldLabel>- <span className="relative block">- <Input- size="sm"- value={form.maxTokens}- inputMode="numeric"- disabled={!canEdit}- invalid={Boolean(fieldErrors.maxTokens)}- onChange={(e) => set({ maxTokens: digitsOnly(e.target.value) })}- // Truncated for the same reason as the context window beside it.- className="truncate font-mono"- style={{ paddingRight: affixPadding(tokenUnitWidth) }}- // Short placeholder (fits the half-width box); the full explanation incl. the small-context advice is the hover title.- title={S.models.maxTokensTitle}- placeholder={S.models.maxTokensHint}- />- <span className="pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400">- {S.models.tokenUnit}- </span>- </span>- {fieldErrors.maxTokens && <FieldError>{fieldErrors.maxTokens}</FieldError>}- </label>+ <Input+ label={S.models.contextWindow}+ size="sm"+ value={form.contextWindow}+ inputMode="numeric"+ disabled={!canEdit}+ error={fieldErrors.contextWindow}+ onChange={(e) => set({ contextWindow: digitsOnly(e.target.value) })}+ // Half-width cell: the placeholder is wider than the box in English, and an input+ // clips at its padding box, so an unclipped one runs past the value area and collides+ // with the unit. `truncate` ends it in an ellipsis instead, which reads as "there is+ // more" rather than as text colliding; the title has it in full.+ className="truncate font-mono"+ affix={{ trailing: S.models.tokenUnit }}+ // The title mirrors the placeholder: at half width the (EN) copy can clip, hover reveals it in full.+ title={+ preset+ ? S.models.contextWindowHint+ : S.models.contextWindowDefaultHint(CUSTOM_CONTEXT_DEFAULT)+ }+ placeholder={+ preset+ ? S.models.contextWindowHint+ : S.models.contextWindowDefaultHint(CUSTOM_CONTEXT_DEFAULT)+ }+ />+ <Input+ label={S.models.maxTokens}+ size="sm"+ value={form.maxTokens}+ inputMode="numeric"+ disabled={!canEdit}+ error={fieldErrors.maxTokens}+ onChange={(e) => set({ maxTokens: digitsOnly(e.target.value) })}+ // Truncated for the same reason as the context window beside it.+ className="truncate font-mono"+ affix={{ trailing: S.models.tokenUnit }}+ // Short placeholder (fits the half-width box); the full explanation incl. the small-context advice is the hover title.+ title={S.models.maxTokensTitle}+ placeholder={S.models.maxTokensHint}+ /></div>{/* 4) Pricing: three fields side by side with self-contained labels (… price) — no@@ -3529,40 +3455,19 @@ function ModelDialog({["cacheWrite", S.models.priceCacheWrite, form.cacheWrite],["output", S.models.priceOutput, form.output],] as Array<[keyof FieldErrors & keyof RowState, string, string]>- ).map(([key, label, value], i) => (- <label key={key} className="block">- <FieldLabel>{label}</FieldLabel>- <span className="relative block">- <span- // The three fields draw the same symbol and the same unit at the same size,- // so only the first pair is measured and every field reserves from it.- ref={i === 0 ? currencyRef : undefined}- className="pointer-events-none absolute inset-y-0 left-2 flex items-center text-xs text-gray-400"- >- {CURRENCY_SYMBOL[currency]}- </span>- <Input- size="sm"- value={value}- inputMode="decimal"- disabled={!canEdit}- invalid={Boolean(fieldErrors[key])}- onChange={(e) => set({ [key]: decimalOnly(e.target.value) })}- className="text-right font-mono"- style={{- paddingLeft: affixPadding(currencyWidth),- paddingRight: affixPadding(priceUnitWidth),- }}- />- <span- ref={i === 0 ? priceUnitRef : undefined}- className="pointer-events-none absolute inset-y-0 right-2 flex items-center text-xs text-gray-400"- >- {S.models.priceUnitShort}- </span>- </span>- {fieldErrors[key] && <FieldError>{fieldErrors[key]}</FieldError>}- </label>+ ).map(([key, label, value]) => (+ <Input+ key={key}+ label={label}+ size="sm"+ value={value}+ inputMode="decimal"+ disabled={!canEdit}+ error={fieldErrors[key]}+ onChange={(e) => set({ [key]: decimalOnly(e.target.value) })}+ className="text-right font-mono"+ affix={{ leading: CURRENCY_SYMBOL[currency], trailing: S.models.priceUnitShort }}+ />))}</div>{/* The fields hold the list price, not the promotional price the card prints: thediff --git a/packages/web/src/features/models/protocol-suffix.tsx b/packages/web/src/features/models/protocol-suffix.tsxindex 62cf1e47..26e94977 100644--- a/packages/web/src/features/models/protocol-suffix.tsx+++ b/packages/web/src/features/models/protocol-suffix.tsx@@ -30,14 +30,19 @@* the call site — so no extra row appears in the happy path.*/import { useState } from "react";-import { ChevronDown, Spinner } from "@prismshadow/penguin-ui";+import {+ ChevronDown,+ ChoiceCheck,+ menuRowClass,+ menuRowTone,+ rowDescClass,+ sizeTextClass,+ Spinner,+} from "@prismshadow/penguin-ui";import { Dropdown } from "../../components/ui/dropdown";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";// This menu is an OptionMenu by hand (its trigger lives inside the base URL field, which// OptionMenu cannot do), so it takes its row typography from OptionMenu's own records rather// than re-spelling them — a change to the family reaches it.-import { rowDescClass } from "../../components/ui/option-menu";-import { sizeTextClass } from "../../components/ui/input";import { S } from "../../lib/strings";import { protocolPathForModel } from "./protocol-path";import { PROTOCOL_CLIENT_TYPES } from "./protocol-types";diff --git a/packages/web/src/features/plugins/plugins-page.tsx b/packages/web/src/features/plugins/plugins-page.tsxindex f09563ba..18dbba1a 100644--- a/packages/web/src/features/plugins/plugins-page.tsx+++ b/packages/web/src/features/plugins/plugins-page.tsx@@ -55,6 +55,8 @@ import {GlyphIcon,ICONS,ICON_SIZE,+ InfoPopover,+ SearchInput,Skeleton,SkeletonCard,StatusIcon,@@ -86,9 +88,7 @@ import { PluginDetailModal } from "./plugin-detail";import { SettingsDialog } from "../settings/settings-dialog";import { formatRelativeDate } from "../../lib/format";import { SkillTile } from "../skills/skill-icon-view";-import { InfoPopover } from "../../components/ui/info-popover";import { toneInk, toneSurface } from "../../lib/tone";-import { Input } from "../../components/ui/input";import { NoticeStrip } from "../../components/ui/notice-strip";/**@@ -686,13 +686,12 @@ export function PluginsPage() {) : (<div className="mt-6 md:grid md:grid-cols-[minmax(0,1fr)_12rem] md:gap-4"><div className="min-w-0 space-y-3">- <Input+ <SearchInputsize="sm"- type="search"value={query}placeholder={S.plugins.searchPlaceholder}aria-label={S.plugins.searchPlaceholder}- onChange={(e) => setQuery(e.target.value)}+ onChange={setQuery}/>{/* ONE list, one plugin per row, every kind in the same card: what is installedfirst — the library's plugins (they ship with the build and every Agent may usediff --git a/packages/web/src/features/schedules/schedule-form-modal.tsx b/packages/web/src/features/schedules/schedule-form-modal.tsxindex 70bc093e..fb8ce3a1 100644--- a/packages/web/src/features/schedules/schedule-form-modal.tsx+++ b/packages/web/src/features/schedules/schedule-form-modal.tsx@@ -20,18 +20,25 @@ import type {ScheduleUpsertRequest,SessionInfo,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import {+ Button,+ Checkbox,+ FieldError,+ FieldHint,+ FieldLabel,+ Input,+ PickerList,+ Select,+ Textarea,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useProject } from "../../state/project";-import { Input, Textarea } from "../../components/ui/input";-import { Select } from "../../components/ui/select";import { Modal } from "../../components/ui/modal";import { FormPicker } from "../../components/ui/form-picker";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { toastInfo, toastSuccess } from "../../components/ui/toast";-import { ModelSelect, PickerList } from "../chat/model-select";+import { ModelSelect } from "../chat/model-select";import { WorkspaceSelect } from "../chat/workspace-select";import { sameModelRef } from "../models/model-grouping";import { itemModelRef } from "./schedule-upsert";@@ -165,7 +172,7 @@ function SessionSelect({<span className="min-w-0 flex-1 truncate text-gray-800 dark:text-gray-200">{s.title ?? S.chat.defaultSessionTitle}</span>- <span className="shrink-0 font-mono text-[11px] text-gray-400 dark:text-gray-500">+ <span className="shrink-0 font-mono text-xs text-gray-400 dark:text-gray-500">{s.sessionId.slice(-6)}</span></>@@ -405,7 +412,7 @@ function ScheduleFormDialog({<FieldLabel>{S.schedule.target}</FieldLabel><p className="text-xs text-gray-600 dark:text-gray-300">{S.schedule.targetThisSession}- <span className="ml-1.5 font-mono text-[11px] text-gray-400 dark:text-gray-500">+ <span className="ml-1.5 font-mono text-xs text-gray-400 dark:text-gray-500">{lockedSessionId.slice(-6)}</span></p>@@ -478,14 +485,12 @@ function ScheduleFormDialog({value={form.prompt}onChange={(e) => set({ prompt: e.target.value })}/>- <label className="flex items-center gap-1.5 text-xs text-gray-600 dark:text-gray-300">- <input- type="checkbox"- checked={form.enabled}- onChange={(e) => set({ enabled: e.target.checked })}- />- {S.schedule.enabled}- </label>+ <Checkbox+ checked={form.enabled}+ onChange={(on) => set({ enabled: on })}+ label={S.schedule.enabled}+ className="text-gray-600 dark:text-gray-300"+ />{formError && <p className="text-xs text-red-600 dark:text-red-400">{formError}</p>}</div></Modal>diff --git a/packages/web/src/features/schedules/schedule-panel.tsx b/packages/web/src/features/schedules/schedule-panel.tsxindex 0aec3ae4..0e24140f 100644--- a/packages/web/src/features/schedules/schedule-panel.tsx+++ b/packages/web/src/features/schedules/schedule-panel.tsx@@ -26,8 +26,11 @@ import {GlyphIcon,ICONS,ICON_SIZE,+ SearchInput,+ Segmented,SettingsEmpty,SkeletonList,+ Switch,} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";@@ -38,14 +41,11 @@ import { useProject } from "../../state/project";import { ConfirmModal } from "../../components/ui/confirm-modal";import { Dropdown } from "../../components/ui/dropdown";import { Icon } from "../../components/ui/group-list";-import { Input } from "../../components/ui/input";-import { Segmented } from "../../components/ui/segmented";import {overflowMenuDangerClass,overflowMenuGlyph,overflowMenuRowClass,} from "../../components/ui/session-row-menu";-import { Switch } from "../../components/ui/switch";import { toastError, toastSuccess } from "../../components/ui/toast";import { CreateButtons } from "../ai-create";import { describeSchedule } from "./schedule-describe";@@ -254,14 +254,12 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePa/></div>- <Input+ <SearchInputsize="sm"- type="search"value={query}placeholder={S.schedule.panelSearchPlaceholder}aria-label={S.schedule.panelSearchPlaceholder}- autoComplete="off"- onChange={(e) => setQuery(e.target.value)}+ onChange={setQuery}/><Segmentedcols={4}diff --git a/packages/web/src/features/semantic-id/semantic-id-field.tsx b/packages/web/src/features/semantic-id/semantic-id-field.tsxindex 2137a6ed..c2654bb8 100644--- a/packages/web/src/features/semantic-id/semantic-id-field.tsx+++ b/packages/web/src/features/semantic-id/semantic-id-field.tsx@@ -27,13 +27,19 @@import { useId, useState } from "react";import type { KeyboardEvent } from "react";import type { SemanticIdKind } from "@prismshadow/penguin-server/api";-import { Button, GlyphIcon, ICON_SIZE } from "@prismshadow/penguin-ui";+import {+ Button,+ FieldError,+ FieldHint,+ FieldLabel,+ GlyphIcon,+ ICON_SIZE,+ Input,+} from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { toneInk } from "../../lib/tone";-import { Input } from "../../components/ui/input";-import { FieldError, FieldHint, FieldLabel } from "../../components/ui/field";import { toastError } from "../../components/ui/toast";import { idSuggestNotice, proposalValue } from "./id-suggest-notice";import type { IdSuggestNotice } from "./id-suggest-notice";diff --git a/packages/web/src/features/settings/account-section.tsx b/packages/web/src/features/settings/account-section.tsxindex 0c4d2e60..f5998185 100644--- a/packages/web/src/features/settings/account-section.tsx+++ b/packages/web/src/features/settings/account-section.tsx@@ -5,10 +5,9 @@* offersChangePassword for the full rule).*/import { useState } from "react";-import { Button } from "@prismshadow/penguin-ui";+import { Button, PrefRow } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { ChangePasswordDialog } from "../../components/account/change-password-dialog";-import { PrefRow } from "./setting-row";export function AccountSection() {const [changePasswordOpen, setChangePasswordOpen] = useState(false);diff --git a/packages/web/src/features/settings/appearance-section.tsx b/packages/web/src/features/settings/appearance-section.tsxindex 85e78e65..29bbd091 100644--- a/packages/web/src/features/settings/appearance-section.tsx+++ b/packages/web/src/features/settings/appearance-section.tsx@@ -12,13 +12,17 @@* browser.*/import { useEffect, useState, useSyncExternalStore } from "react";-import { THEME_IDS } from "@prismshadow/penguin-ui";+import {+ PrefRow,+ Segmented,+ Select,+ SwatchPicker,+ THEME_IDS,+ ToggleRow,+} from "@prismshadow/penguin-ui";import { FONT_CJK_OPTIONS, FONT_LATIN_OPTIONS, TEXT_SIZES } from "@prismshadow/penguin-ui/boot";import { S } from "../../lib/strings";import * as api from "../../api/endpoints";-import { Segmented } from "../../components/ui/segmented";-import { Select } from "../../components/ui/select";-import { Switch } from "../../components/ui/switch";import { isDesktopShellWindow } from "../../lib/account-menu";import {launcherHiddenVersion,@@ -27,7 +31,7 @@ import {writeLauncherHidden,} from "../dock/dock-launcher-state";import { useAuth } from "../../state/auth";-import { useTheme } from "../../state/theme";+import { accentSwatches, useTheme } from "../../state/theme";import type {FontCjk,FontLatin,@@ -37,7 +41,6 @@ import type {ThemeMode,} from "../../state/theme";import { FONT_FOLLOWS_THEME, effectiveAccent } from "../../state/theme-prefs";-import { AccentPicker, PrefRow } from "./setting-row";/*** A font select's choices: the theme's own face first — it is the default, and the named faces@@ -117,6 +120,7 @@ export function AppearanceSection() {setTerminalMode,toolAliases,setToolAliases,+ dark,} = useTheme();// The fan's "hide launcher" entry writes the same preference, so this row follows it.useSyncExternalStore(subscribeLauncherHidden, launcherHiddenVersion);@@ -178,8 +182,11 @@ export function AppearanceSection() {as the theme's own accent, which is what the page paints, and comes back with thetheme that lists it. */}<PrefRow label={S.settings.accent} info={S.settings.accentInfo}>- <AccentPicker- themeId={themeId}+ <SwatchPicker+ options={accentSwatches(themeId, dark).map((swatch) => ({+ ...swatch,+ label: S.settings.accentNames[swatch.value] ?? swatch.value,+ }))}value={effectiveAccent(themeId, accent)}onChange={setAccent}/>@@ -208,16 +215,25 @@ export function AppearanceSection() {<PrefRow label={S.settings.terminalTheme} info={S.settings.terminalThemeInfo}><Segmented options={terminalThemeOptions} value={terminalMode} onChange={setTerminalMode} /></PrefRow>- <PrefRow label={S.settings.launcher} info={S.settings.launcherInfo}>- <Switch checked={launcherShown} onChange={(shown) => writeLauncherHidden(!shown)} />- </PrefRow>- <PrefRow label={S.settings.toolAliases} info={S.settings.toolAliasesInfo}>- <Switch checked={toolAliases} onChange={setToolAliases} />- </PrefRow>+ <ToggleRow+ label={S.settings.launcher}+ info={S.settings.launcherInfo}+ checked={launcherShown}+ onChange={(shown) => writeLauncherHidden(!shown)}+ />+ <ToggleRow+ label={S.settings.toolAliases}+ info={S.settings.toolAliasesInfo}+ checked={toolAliases}+ onChange={setToolAliases}+ />{offersTrayIcon && (- <PrefRow label={S.settings.trayIcon} info={S.settings.trayIconInfo}>- <Switch checked={trayIcon} onChange={changeTrayIcon} />- </PrefRow>+ <ToggleRow+ label={S.settings.trayIcon}+ info={S.settings.trayIconInfo}+ checked={trayIcon}+ onChange={changeTrayIcon}+ />)}</div>);diff --git a/packages/web/src/features/settings/company-section.tsx b/packages/web/src/features/settings/company-section.tsxindex 8c40fa85..23e82185 100644--- a/packages/web/src/features/settings/company-section.tsx+++ b/packages/web/src/features/settings/company-section.tsx@@ -13,15 +13,14 @@* wherever the switch stands.*/import { useEffect, useState } from "react";+import { SettingsSection, ToggleRow } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { toneInk } from "../../lib/tone";import { useAuth } from "../../state/auth";-import { Switch } from "../../components/ui/switch";import { toastError } from "../../components/ui/toast";import { writeCompanyMode } from "./company-mode-write";-import { SectionShell } from "./section-shell";export function CompanySection() {const { refresh } = useAuth();@@ -74,17 +73,15 @@ export function CompanySection() {const hydrated = stored !== null;return (- <SectionShell>+ <SettingsSection><div>- <div className="flex items-center justify-between gap-3">- <span className="text-sm font-medium">{S.settings.companyModeServer}</span>- <Switch- checked={companyMode}- onChange={(next) => void toggle(next)}- disabled={!hydrated || busy}- aria-label={S.settings.companyModeServer}- />- </div>+ <ToggleRow+ variant="plain"+ label={S.settings.companyModeServer}+ checked={companyMode}+ onChange={(next) => void toggle(next)}+ disabled={!hydrated || busy}+ />{/* The reason the switch went back, under the switch it went back on. */}{error !== undefined && <p className={`mt-2 text-xs ${toneInk.danger}`}>{error}</p>}{/* The mode is a beta, and this switch signs a whole server up for it: the warning@@ -92,6 +89,6 @@ export function CompanySection() {click away and is read once. */}<p className="mt-2 text-xs text-gray-500 dark:text-gray-400">{S.company.betaNotice}</p></div>- </SectionShell>+ </SettingsSection>);}diff --git a/packages/web/src/features/settings/general-section.tsx b/packages/web/src/features/settings/general-section.tsxindex 5d18055a..c89eeaf1 100644--- a/packages/web/src/features/settings/general-section.tsx+++ b/packages/web/src/features/settings/general-section.tsx@@ -10,9 +10,8 @@* request answered rather than on what was clicked.*/import { useState, useSyncExternalStore } from "react";+import { PrefRow, Segmented, ToggleRow } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";-import { Segmented } from "../../components/ui/segmented";-import { Switch } from "../../components/ui/switch";import {enableNotifications,notificationHintFor,@@ -28,7 +27,6 @@ import { useLocale } from "../../state/locale";import type { LangPref } from "../../state/locale";import { useTheme } from "../../state/theme";import type { Currency } from "../../state/theme";-import { PrefRow } from "./setting-row";import { TraceImportRow } from "./trace-import-row";export function GeneralSection() {@@ -72,39 +70,35 @@ export function GeneralSection() {<PrefRow label={S.models.currency} info={S.settings.currencyInfo}><Segmented options={currencyOptions} value={currency} onChange={setCurrency} cols={2} /></PrefRow>- <PrefRow+ <ToggleRowlabel={S.settings.notifications}hint={notificationHint}info={S.settings.notificationsInfo}- >- <Switch- checked={notificationsOn}- disabled={access === "unsupported"}- onChange={(on) => {- if (!on) {- writeNotificationsEnabled(false);- return;- }- // Only a granted request stores the preference, so anything else leaves the- // switch where it was and turns the hint on instead.- void enableNotifications().then((answer) => {- setAccess(answer);- setAsked(true);- });- }}- />- </PrefRow>+ checked={notificationsOn}+ disabled={access === "unsupported"}+ onChange={(on) => {+ if (!on) {+ writeNotificationsEnabled(false);+ return;+ }+ // Only a granted request stores the preference, so anything else leaves the+ // switch where it was and turns the hint on instead.+ void enableNotifications().then((answer) => {+ setAccess(answer);+ setAsked(true);+ });+ }}+ />{/* The personal company-mode switch: off hides this user's mode switch and nothing else.Offered only while the server allows company mode at all — a switch that changesnothing would only invite the question of why. */}{serverEnabled && (- <PrefRow label={S.settings.companyModePersonal} info={S.settings.companyModePersonalInfo}>- <Switch- checked={personalEnabled}- onChange={setPersonalEnabled}- aria-label={S.settings.companyModePersonal}- />- </PrefRow>+ <ToggleRow+ label={S.settings.companyModePersonal}+ info={S.settings.companyModePersonalInfo}+ checked={personalEnabled}+ onChange={setPersonalEnabled}+ />)}<TraceImportRow /></div>diff --git a/packages/web/src/features/settings/plugins-section.tsx b/packages/web/src/features/settings/plugins-section.tsxindex 7679b23b..aa625723 100644--- a/packages/web/src/features/settings/plugins-section.tsx+++ b/packages/web/src/features/settings/plugins-section.tsx@@ -27,17 +27,22 @@ import { S } from "../../lib/strings";import { useLocale } from "../../state/locale";import { localizedText } from "../chat/skill-use";import { apiErrorText } from "../../lib/api-error";-import { Input, Textarea } from "../../components/ui/input";-import { PasswordInput } from "../../components/ui/password-input";-import { Select } from "../../components/ui/select";-import { Switch } from "../../components/ui/switch";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";import { toneInk } from "../../lib/tone";-import { SectionShell } from "./section-shell";import { useSessions } from "../../state/sessions";import { MachinePicker } from "../machines/machine-picker";import { NoticeStrip } from "../../components/ui/notice-strip";-import { Button, Spinner } from "@prismshadow/penguin-ui";+import {+ Button,+ Checkbox,+ Input,+ PasswordInput,+ Select,+ SettingsSection,+ Spinner,+ Textarea,+ ToggleRow,+} from "@prismshadow/penguin-ui";/** The picker's value for this server; a machine id is never this short. */const THIS_SERVER = "*";@@ -324,7 +329,7 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {</div>) : null;- if (entries === null) return <SectionShell>{picker}</SectionShell>;+ if (entries === null) return <SettingsSection>{picker}</SettingsSection>;const patch = (plugin: string, name: string, value: unknown) => {setDrafts((prev) => ({ ...prev, [plugin]: { ...(prev[plugin] ?? {}), [name]: value } }));@@ -390,19 +395,15 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {);case "boolean":return (- <div key={name} className="flex items-center justify-between gap-3">- <div className="min-w-0">- <p className="text-sm font-medium">{label}</p>- {hint !== undefined && (- <p className="mt-0.5 text-xs text-gray-500 dark:text-gray-400">{hint}</p>- )}- </div>- <Switch- checked={draft[name] === true}- onChange={(v) => patch(entry.name, name, v)}- disabled={disabled}- />- </div>+ <ToggleRow+ key={name}+ variant="plain"+ label={label}+ hint={hint}+ checked={draft[name] === true}+ onChange={(v) => patch(entry.name, name, v)}+ disabled={disabled}+ />);case "secret": {const masked = typeof entry.values[name] === "string" ? (entry.values[name] as string) : "";@@ -430,25 +431,22 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {}}/>{masked !== "" && typed === "" && (- <label className="flex items-center gap-x-3 text-xs text-gray-500 dark:text-gray-400">+ <div className="flex items-center gap-x-3 text-xs text-gray-500 dark:text-gray-400"><span className="font-mono">{masked}</span>- <span className="flex items-center gap-1.5">- <input- type="checkbox"- checked={clearing.has(key)}- disabled={disabled}- onChange={(e) =>- setClearing((prev) => {- const next = new Set(prev);- if (e.target.checked) next.add(key);- else next.delete(key);- return next;- })- }- />- {S.settings.pluginSecretClear}- </span>- </label>+ <Checkbox+ checked={clearing.has(key)}+ disabled={disabled}+ label={S.settings.pluginSecretClear}+ onChange={(on) =>+ setClearing((prev) => {+ const next = new Set(prev);+ if (on) next.add(key);+ else next.delete(key);+ return next;+ })+ }+ />+ </div>)}</div>);@@ -550,7 +548,7 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {const names = new Set(entries.map((e) => e.name));const cards = entries.filter((e) => e.parent === undefined || !names.has(e.parent));return (- <SectionShell>+ <SettingsSection>{picker}{machine !== null && loadError !== null && (<NoticeStrip tone="attention" as="p" className="rounded-md px-3 py-2 text-xs">@@ -594,6 +592,6 @@ export function PluginsSection({ focus }: { focus?: string } = {}) {</section>);})}- </SectionShell>+ </SettingsSection>);}diff --git a/packages/web/src/features/settings/profile-section.tsx b/packages/web/src/features/settings/profile-section.tsxindex 543f8fca..20f5c3ea 100644--- a/packages/web/src/features/settings/profile-section.tsx+++ b/packages/web/src/features/settings/profile-section.tsx@@ -31,6 +31,8 @@ import type { UpdateProfileRequest } from "@prismshadow/penguin-server/api";import {Button,HiddenFileInput,+ Input,+ PrefRow,USER_AVATAR_SIZE,UserAvatar,buttonClass,@@ -41,9 +43,7 @@ import { apiErrorText } from "../../lib/api-error";import { avatarDataUrlFromFile } from "../../lib/avatar-image";import { profileControls } from "../../lib/profile-form";import { useAuth } from "../../state/auth";-import { Input } from "../../components/ui/input";import { toastSuccess } from "../../components/ui/toast";-import { PrefRow } from "./setting-row";/** What the picker offers — the three formats the server stores, spelled the way `accept` wants. */const AVATAR_ACCEPT = "image/png,image/jpeg,image/webp";diff --git a/packages/web/src/features/settings/proxy-section.tsx b/packages/web/src/features/settings/proxy-section.tsxindex b3cff2c0..ac85d732 100644--- a/packages/web/src/features/settings/proxy-section.tsx+++ b/packages/web/src/features/settings/proxy-section.tsx@@ -38,16 +38,13 @@ import type {ProxyProbeTargetDto,ServerSettings,} from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input, SettingsSection, ToggleRow } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { toneInk } from "../../lib/tone";-import { Input } from "../../components/ui/input";-import { Switch } from "../../components/ui/switch";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";-import { SectionShell } from "./section-shell";/** Brand names: identical in every locale, so they are keyed off the server's provider id rather than doubled into both dictionaries. */const PROVIDER_LABEL: Record<ProxyProbeProvider, string> = {@@ -185,7 +182,7 @@ export function ProxySection() {return (<>- <SectionShell+ <SettingsSectionactions={<Buttonsize="sm"@@ -197,14 +194,20 @@ export function ProxySection() {</Button>}>- <div className="flex items-center justify-between gap-3">- <span className="text-sm font-medium">{S.settings.proxyForApp}</span>- <Switch checked={proxyForApp} onChange={setProxyForApp} disabled={!hydrated} />- </div>- <div className="flex items-center justify-between gap-3">- <span className="text-sm font-medium">{S.settings.proxyForAgent}</span>- <Switch checked={proxyForAgent} onChange={setProxyForAgent} disabled={!hydrated} />- </div>+ <ToggleRow+ variant="plain"+ label={S.settings.proxyForApp}+ checked={proxyForApp}+ onChange={setProxyForApp}+ disabled={!hydrated}+ />+ <ToggleRow+ variant="plain"+ label={S.settings.proxyForAgent}+ checked={proxyForAgent}+ onChange={setProxyForAgent}+ disabled={!hydrated}+ /><Inputlabel={S.settings.proxyAddress}size="sm"@@ -217,7 +220,7 @@ export function ProxySection() {if (addressError !== null) setAddressError(null);}}/>- </SectionShell>+ </SettingsSection><section className="mt-6"><div className="flex items-center justify-between gap-3"><div className="min-w-0 text-sm font-medium">{S.settings.proxyProbe}</div>@@ -270,7 +273,7 @@ export function ProxySection() {)}</span></div>- <div className="truncate font-mono text-[11px] text-gray-400 dark:text-gray-500">+ <div className="truncate font-mono text-xs text-gray-400 dark:text-gray-500">{t.url}</div></li>diff --git a/packages/web/src/features/settings/section-shell.tsx b/packages/web/src/features/settings/section-shell.tsxdeleted file mode 100644index ca852ae6..00000000--- a/packages/web/src/features/settings/section-shell.tsx+++ /dev/null@@ -1,21 +0,0 @@-/**- * Shared frame for a Settings page that saves explicitly: body, and a trailing- * action row. The dialog pane already draws the page heading and the "?" that discloses- * what the page is, so the shell adds no title, no explanatory line and no box of its own.- * Pages that apply on the spot pass no actions and the row is not drawn, so nothing on- * screen suggests an unsaved edit is waiting.- */-import type { ReactNode } from "react";--export function SectionShell({ actions, children }: { actions?: ReactNode; children: ReactNode }) {- return (- <section>- <div className="space-y-4">{children}</div>- {actions !== undefined && (- <div className="mt-5 flex justify-end gap-2 border-t border-gray-100 pt-4 dark:border-gray-800/60">- {actions}- </div>- )}- </section>- );-}diff --git a/packages/web/src/features/settings/setting-row.tsx b/packages/web/src/features/settings/setting-row.tsxdeleted file mode 100644index 2ecf9c94..00000000--- a/packages/web/src/features/settings/setting-row.tsx+++ /dev/null@@ -1,87 +0,0 @@-/**- * Row primitives for the Settings dialog's pages: a labelled preference row —- * title on the left, the control on the right — meant to be stacked inside a `divide-y`- * container so rows separate with rules rather than boxes. AccentPicker lives here too:- * the accent swatches moved out of the sidebar user menu together with the rows that used- * them.- */-import type { ReactNode } from "react";-import { ICON_GAP } from "@prismshadow/penguin-ui";-import { S } from "../../lib/strings";-import { InfoPopover } from "../../components/ui/info-popover";-import { accentSwatches, useTheme } from "../../state/theme";-import type { Accent, ThemeId } from "../../state/theme";--export function PrefRow({- label,- hint,- info,- children,-}: {- label: string;- /**- * A line that stays on screen. For what the value must look like, and for a fact about the- * current state (the running build's date) — never for what the row means, which goes in- * `info` so a reader who already knows is not made to scroll past it again.- */- hint?: string;- /** Semantic explanation, disclosed by a "?" beside the label. */- info?: ReactNode;- children: ReactNode;-}) {- return (- // ui-field: a theme may lay the label and the control out its own way (stacked, or as a- // table row); the hint rides inside the label slot, under the label, in every theme.- <div className="ui-field flex items-center justify-between gap-4 py-3.5 first:pt-0 last:pb-0">- <div data-slot="label" className="min-w-0">- <p className={`flex items-center ${ICON_GAP.row} text-sm font-medium`}>- {label}- {info !== undefined && <InfoPopover label={label}>{info}</InfoPopover>}- </p>- {hint !== undefined && (- <p className="mt-0.5 text-xs text-gray-500 dark:text-gray-400">{hint}</p>- )}- </div>- <div data-slot="control" className="shrink-0">- {children}- </div>- </div>- );-}--/**- * Accent color picker: a row of swatches — the theme's own accent, then the active theme's- * presets — with a ring on the one in effect.- */-export function AccentPicker({- themeId,- value,- onChange,-}: {- themeId: ThemeId;- /** The accent in effect under `themeId`, not merely the stored one. */- value: Accent;- onChange: (a: Accent) => void;-}) {- const { dark } = useTheme();- return (- <div className="flex items-center gap-1.5">- {accentSwatches(themeId, dark).map((s) => (- <button- key={s.value}- type="button"- data-tooltip={S.settings.accentNames[s.value]}- aria-label={S.settings.accentNames[s.value]}- aria-pressed={value === s.value}- onClick={() => onChange(s.value)}- className={`h-5 w-5 rounded-full border transition-transform duration-150 hover:scale-110 ${- value === s.value- ? "border-gray-500 ring-2 ring-gray-400/50 dark:border-gray-300"- : "border-transparent"- }`}- style={{ backgroundColor: s.color }}- />- ))}- </div>- );-}diff --git a/packages/web/src/features/settings/shortcuts-section.tsx b/packages/web/src/features/settings/shortcuts-section.tsxindex 21a97c43..f48aa81b 100644--- a/packages/web/src/features/settings/shortcuts-section.tsx+++ b/packages/web/src/features/settings/shortcuts-section.tsx@@ -8,7 +8,7 @@* tab never receives ⌘W; ⌘P takes over the browser's Print; the desktop menu also carries ⌘R).*/import { useState } from "react";-import { Button, GlyphIcon, ICON_SIZE } from "@prismshadow/penguin-ui";+import { Button, GlyphIcon, ICON_SIZE, SettingsSection } from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { ConfirmModal } from "../../components/ui/confirm-modal";import { conflictsOf, findConflicts, type Conflict } from "../../lib/shortcuts/conflicts";@@ -19,7 +19,6 @@ import { isOverridden, resetAll, resetBinding, setBinding } from "../../lib/shorimport type { Chord, CommandId, ShortcutCommand } from "../../lib/shortcuts/types";import { useKeymap } from "../../lib/shortcuts/use-keymap";import { toneInk } from "../../lib/tone";-import { SectionShell } from "./section-shell";import { ShortcutRecorder } from "./shortcut-recorder";/** Counter-clockwise arrow: back to the default. */@@ -124,7 +123,7 @@ export function ShortcutsSection() {})).filter(({ commands }) => commands.length > 0);return (- <SectionShell+ <SettingsSectionactions={<Buttonsize="sm"@@ -168,6 +167,6 @@ export function ShortcutsSection() {{S.shortcuts.resetAllBody(overriddenCount)}</ConfirmModal>)}- </SectionShell>+ </SettingsSection>);}diff --git a/packages/web/src/features/settings/trace-import-row.tsx b/packages/web/src/features/settings/trace-import-row.tsxindex 677d8386..416ffe98 100644--- a/packages/web/src/features/settings/trace-import-row.tsx+++ b/packages/web/src/features/settings/trace-import-row.tsx@@ -19,15 +19,13 @@import { useEffect, useState } from "react";import type { ChangeEvent } from "react";import type { AgentSummary, ProjectSummary } from "@prismshadow/penguin-server/api";-import { HiddenFileInput, UploadIcon } from "@prismshadow/penguin-ui";+import { HiddenFileInput, PrefRow, Select, UploadIcon } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";-import { Select } from "../../components/ui/select";import { toastError, toastSuccess } from "../../components/ui/toast";import { agentDisplayName, projectDisplayName, useProject } from "../../state/project";import { useSessions } from "../../state/sessions";-import { PrefRow } from "./setting-row";/** Client-side pre-check before reading the picked file (the same cap as the server's import route). */const MAX_TRACE_BYTES = 14 * 1024 * 1024;diff --git a/packages/web/src/features/settings/uploads-section.tsx b/packages/web/src/features/settings/uploads-section.tsxindex 21b11403..7ca4f037 100644--- a/packages/web/src/features/settings/uploads-section.tsx+++ b/packages/web/src/features/settings/uploads-section.tsx@@ -14,15 +14,13 @@*/import { useEffect, useState } from "react";import type { ServerSettings } from "@prismshadow/penguin-server/api";-import { Button } from "@prismshadow/penguin-ui";+import { Button, Input, SettingsSection } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { ApiError } from "../../api/client";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";import { useAuth } from "../../state/auth";-import { Input } from "../../components/ui/input";import { toastError, toastInfo, toastSuccess } from "../../components/ui/toast";-import { SectionShell } from "./section-shell";export function UploadsSection() {const { uploadLimits, refresh } = useAuth();@@ -111,7 +109,7 @@ export function UploadsSection() {const hydrated = settings !== null;return (- <SectionShell+ <SettingsSectionactions={<Buttonsize="sm"@@ -169,6 +167,6 @@ export function UploadsSection() {if (limitError !== null) setLimitError(null);}}/>- </SectionShell>+ </SettingsSection>);}diff --git a/packages/web/src/features/skills/skill-pick-list.tsx b/packages/web/src/features/skills/skill-pick-list.tsxindex 06f8a267..8de3dc13 100644--- a/packages/web/src/features/skills/skill-pick-list.tsx+++ b/packages/web/src/features/skills/skill-pick-list.tsx@@ -18,13 +18,17 @@*/import { useState } from "react";import type { SkillMetadataItem } from "@prismshadow/penguin-server/api";-import { ICON_SIZE } from "@prismshadow/penguin-ui";+import {+ ChoiceCheck,+ ICON_SIZE,+ SearchInput,+ menuRowClass,+ menuRowTone,+} from "@prismshadow/penguin-ui";import { S } from "../../lib/strings";import { useLocale } from "../../state/locale";-import { menuSearchClass, noAutofill } from "../../components/ui/input";import { filterSkills, localizedShortText } from "../chat/skill-use";import { SkillIcon } from "./skill-icon-view";-import { ChoiceCheck, menuRowClass, menuRowTone } from "../../components/ui/field";/** A bulk-row action: a plain text button, sized to sit inside the panel's chrome without competing with the rows. */const bulkActionClass =@@ -64,14 +68,13 @@ export function SkillPickList({<>{/* Quick search: filters by skill name and localized description */}<div className="border-b border-gray-100 px-2 pb-1.5 pt-0.5 dark:border-gray-800">- <input+ <SearchInput+ variant="menu"autoFocusvalue={query}- onChange={(e) => setQuery(e.target.value)}+ onChange={setQuery}placeholder={searchLabel}aria-label={searchLabel}- {...noAutofill}- className={`${menuSearchClass} px-1 py-0.5`}/></div>{bulk && skills.length > 0 && (@@ -79,7 +82,7 @@ export function SkillPickList({<span className="min-w-0 truncate text-xs text-gray-400 dark:text-gray-500">{S.skills.selectedCount(selected.length)}</span>- <span className="flex shrink-0 items-center gap-0.5">+ <span className="flex shrink-0 items-center gap-1"><buttontype="button"className={bulkActionClass}diff --git a/packages/web/src/features/traces/trace-event-row.tsx b/packages/web/src/features/traces/trace-event-row.tsxindex e22acbb2..93924719 100644--- a/packages/web/src/features/traces/trace-event-row.tsx+++ b/packages/web/src/features/traces/trace-event-row.tsx@@ -12,7 +12,7 @@* aren't highlighted together).*/import { Fragment, useState } from "react";-import { Badge, ICONS } from "@prismshadow/penguin-ui";+import { Badge, ICONS, RequiredMark } from "@prismshadow/penguin-ui";import type { BadgeStyle } from "@prismshadow/penguin-ui";import ReactMarkdown from "react-markdown";import { REHYPE_PLUGINS, REMARK_PLUGINS } from "../../lib/markdown-plugins";@@ -20,7 +20,6 @@ import { S } from "../../lib/strings";import type { OmniMessage } from "@prismshadow/penguin-core/omnimessage";import { formatTime, humanizeTokens } from "../../lib/format";import { stopReasonTone } from "../../lib/stop-reason-tone";-import { RequiredMark } from "../../components/ui/field";import { ZoomableImage } from "../../components/ui/image-zoom";/** An event type as a badge: the session header stands out as a neutral solid tag. */diff --git a/packages/web/src/features/usage/usage-page.tsx b/packages/web/src/features/usage/usage-page.tsxindex a3f0aa32..2942360b 100644--- a/packages/web/src/features/usage/usage-page.tsx+++ b/packages/web/src/features/usage/usage-page.tsx@@ -28,7 +28,7 @@import { useCallback, useEffect, useMemo, useState } from "react";import { useSearchParams } from "react-router";import type { ModelRefDto, UsageBucket, UsageResponse } from "@prismshadow/penguin-server/api";-import { Skeleton } from "@prismshadow/penguin-ui";+import { Input, Select, Skeleton } from "@prismshadow/penguin-ui";import * as api from "../../api/endpoints";import { S } from "../../lib/strings";import { apiErrorText } from "../../lib/api-error";@@ -41,8 +41,6 @@ import { formatMoney, humanizeTokens } from "../../lib/format";import { catalogEntryFor } from "@prismshadow/penguin-core/model-catalog";import { useProject } from "../../state/project";import { useTheme } from "../../state/theme";-import { Input } from "../../components/ui/input";-import { Select } from "../../components/ui/select";import { TrendChart } from "./trend-chart";import { RequestsChart, TokenBarChart, TokenLegend, type TokenLegendKey } from "./usage-charts";import {diff --git a/packages/web/src/lib/context-menu.ts b/packages/web/src/lib/context-menu.tsindex fac070c9..f8ab47ee 100644--- a/packages/web/src/lib/context-menu.ts+++ b/packages/web/src/lib/context-menu.ts@@ -58,29 +58,6 @@ export function contextMenuAnchor(e: ContextMenuEventLike, row: AnchorRect): Ancreturn isPointerContextMenu(e) ? pointerAnchor(e.clientX, e.clientY) : row;}-/**- * Does a scroll of `target` move the content `owner` sits in — the question a- * pointer-anchored panel has to answer before dismissing itself?- *- * The panel's scroll listener runs in the capture phase, because scroll events do not- * bubble. The price is that it hears **every** scrolling element in the document, not only- * the ones the anchor lies inside: a streaming conversation scrolls its message list on- * every chunk, and taking each of those as a reason to dismiss wiped a context menu opened- * in the sidebar — a part of the page that had not moved at all. Containment is the whole- * test, and the page itself needs no case of its own, because a full-page scroll targets- * `document`, which contains every node in it.- *- * A caller that names no owner still dismisses on any scroll, which is what every anchored- * panel did before this rule existed.- */-export function scrollMovesAnchor(target: Node | null, owner: Node | null): boolean {- if (owner === null || target === null) return true;- // An Element and the Document both answer `contains`; a target that does not is not- // something this rule can judge, so it dismisses rather than pin the panel to content- // that may well have moved.- return typeof target.contains === "function" ? target.contains(owner) : true;-}-/*** Shift+F10 — the platform chord for "open the context menu for the focused element".* Handled explicitly rather than left to the browser: Windows and Linux browsersdiff --git a/packages/web/src/lib/ui-strings.ts b/packages/web/src/lib/ui-strings.tsindex a023d98e..23a43976 100644--- a/packages/web/src/lib/ui-strings.ts+++ b/packages/web/src/lib/ui-strings.ts@@ -17,6 +17,11 @@ export function uiStringsOf(dict: Strings): UiStrings {close: dict.common.close,copied: dict.common.copied,loading: dict.common.loading,+ showPassword: dict.auth.showPassword,+ hidePassword: dict.auth.hidePassword,+ clearSearch: dict.chat.searchClear,+ moreInfo: dict.common.moreInfo,+ moreInfoAbout: dict.common.moreInfoAbout,};}diff --git a/packages/web/src/pages/login.tsx b/packages/web/src/pages/login.tsxindex 74793e90..977d264d 100644--- a/packages/web/src/pages/login.tsx+++ b/packages/web/src/pages/login.tsx@@ -10,7 +10,7 @@*/import { useEffect, useState } from "react";import { useNavigate, useSearchParams } from "react-router";-import { Button, PenguinLogo } from "@prismshadow/penguin-ui";+import { Button, Input, PasswordInput, PenguinLogo, Segmented } from "@prismshadow/penguin-ui";import { S } from "../lib/strings";import { apiErrorText } from "../lib/api-error";import { useDocumentTitle } from "../lib/use-document-title";@@ -19,10 +19,7 @@ import { useLocale } from "../state/locale";import type { LangPref } from "../state/locale";import { useTheme } from "../state/theme";import type { ThemeMode } from "../state/theme";-import { Input } from "../components/ui/input";-import { PasswordInput } from "../components/ui/password-input";import { Modal } from "../components/ui/modal";-import { Segmented } from "../components/ui/segmented";import { LoginCircuit } from "./login-circuit";/** Which advice a failed claim asks for; the server decides it from the deployment, not from the token. */diff --git a/packages/web/test/autofill.test.ts b/packages/web/test/autofill.test.tsindex 4c0ca911..e351cbf3 100644--- a/packages/web/test/autofill.test.ts+++ b/packages/web/test/autofill.test.ts@@ -1,11 +1,11 @@/**- * Autofill policy of the shared form controls (autofillProps in components/ui/input.tsx):+ * Autofill policy of the shared form controls (autofillProps in the UI package's forms/input):* fields opt out by default, a declared credential role passes through, and an opted-out* password box goes out as "new-password" — plain "off" is ignored by Chrome/Safari there,* which is how the account's saved login used to land in an API-key field.*/import { describe, it, expect } from "vitest";-import { autofillProps } from "../src/components/ui/input";+import { autofillProps } from "@prismshadow/penguin-ui";import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";const IGNORES = {@@ -19,7 +19,7 @@ describe("autofill sources", () => {it("scan every source root, and find the policy in one place", () => {const scan = scanSources();expectEveryRootScanned(scan);- expectSingleHome(scan, "packages/web/src/components/ui/input.tsx");+ expectSingleHome(scan, "packages/ui/src/components/forms/input/input.tsx");});});diff --git a/packages/web/test/company-beta.test.ts b/packages/web/test/company-beta.test.tsindex 11fa6883..f7e035dd 100644--- a/packages/web/test/company-beta.test.ts+++ b/packages/web/test/company-beta.test.ts@@ -12,13 +12,13 @@import { describe, expect, it } from "vitest";import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";+import { Segmented } from "@prismshadow/penguin-ui";import {BETA_NOTICE_KEY,BetaBadge,markBetaNoticeShown,shouldShowBetaNotice,} from "../src/features/company/beta-badge";-import { Segmented } from "../src/components/ui/segmented";import { zh } from "../src/lib/strings";import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";@@ -50,7 +50,7 @@ describe("the beta marks' sources", () => {const scan = scanSources();expectEveryRootScanned(scan);expectSingleHome(scan, "packages/web/src/features/company/beta-badge.tsx");- expectSingleHome(scan, "packages/web/src/components/ui/segmented.tsx");+ expectSingleHome(scan, "packages/ui/src/components/forms/segmented/segmented.tsx");});});diff --git a/packages/web/test/context-menu.test.ts b/packages/web/test/context-menu.test.tsindex c35f7990..c01a69f3 100644--- a/packages/web/test/context-menu.test.ts+++ b/packages/web/test/context-menu.test.ts@@ -11,7 +11,9 @@** **Dismissal** is the third: the panel listens for scroll in the capture phase, which* reaches every scrolling container in the document, so the rule that closes a menu whose- * anchor point has moved must not close one anchored somewhere that did not move.+ * anchor point has moved must not close one anchored somewhere that did not move. That rule,+ * `scrollMovesAnchor`, is the UI package's (its cases are in the package's+ * portal-panel.test.ts); what is pinned here is the menu consulting it.** The last part pins **suppression scope** against the source text. Preventing the* browser's own menu is correct on the row and wrong everywhere else, and nothing in a@@ -33,7 +35,6 @@ import {longPressMoved,pointerAnchor,reduceHold,- scrollMovesAnchor,withinSettleWindow,} from "../src/lib/context-menu";import type { HoldEvent } from "../src/lib/context-menu";@@ -228,63 +229,6 @@ describe("reduceHold", () => {});});-/**- * Scroll dismissal (`components/ui/dropdown.tsx`). A pointer anchor is a position rather- * than an element, so once the content under it moves the panel dismisses instead of- * following — but the listener that decides this is capture-phase, and therefore hears- * every scroller in the document. The reported failure was a Session row's menu that- * "kept getting wiped": while a conversation streams, the message list scrolls itself on- * every chunk, and each of those scrolls was closing a menu opened in the sidebar.- */-describe("scrollMovesAnchor", () => {- /** A stand-in for a DOM node, implementing the containment the rule reads off one. */- interface FakeNode {- parent: FakeNode | null;- contains: (n: FakeNode | null) => boolean;- }- /** `contains` is inclusive, exactly as the DOM's is: a node contains itself. */- const node = (parent: FakeNode | null): FakeNode => {- const self: FakeNode = {- parent,- contains: (n) => {- for (let at = n; at !== null; at = at.parent) if (at === self) return true;- return false;- },- };- return self;- };- // The suite is node-only, so the rule is fed stand-ins rather than real elements; it- // reads nothing off a node but `contains`, which is what these implement.- const asNode = (n: FakeNode) => n as unknown as Node;-- // The page as the bug found it: a sidebar that scrolls its Session list, a chat pane- // that scrolls its messages, and no relation between the two but the document.- const doc = node(null);- const sidebarScroller = node(doc);- const row = node(sidebarScroller);- const messageList = node(doc);-- it("ignores a scroll in an unrelated container, so streaming output leaves the menu open", () => {- expect(scrollMovesAnchor(asNode(messageList), asNode(row))).toBe(false);- });-- it("dismisses when the container holding the anchored row scrolls", () => {- expect(scrollMovesAnchor(asNode(sidebarScroller), asNode(row))).toBe(true);- });-- it("dismisses when the anchored row is itself what scrolled", () => {- expect(scrollMovesAnchor(asNode(row), asNode(row))).toBe(true);- });-- it("dismisses on a page-level scroll, which targets the document and needs no case of its own", () => {- expect(scrollMovesAnchor(asNode(doc), asNode(row))).toBe(true);- });-- it("dismisses on any scroll when the caller names no owner, as anchored panels always did", () => {- expect(scrollMovesAnchor(asNode(messageList), null)).toBe(true);- });-});-/** Every .ts/.tsx under web and the shared UI package (test/helpers/roots.ts). */const SCAN = scanSources([".ts", ".tsx"]);@@ -325,9 +269,9 @@ describe("sourceFiles", () => {describe("anchored dismissal wiring", () => {it("asks scrollMovesAnchor before dismissing an anchored panel", () => {- // The rule's own cases are covered above against stand-in nodes. What a node-only suite- // cannot reach is the component consulting it at all, and that is where this silently- // breaks: drop the call and every assertion above still passes while the reported bug —+ // The rule's own cases are covered in the package against stand-in nodes. What a node-only+ // suite cannot reach is the component consulting it at all, and that is where this silently+ // breaks: drop the call and every assertion there still passes while the reported bug —// a streaming message list wiping a menu opened in the sidebar — comes straight back.const dropdown = sourceFiles().find(([path]) => path === DROPDOWN);expect(dropdown).toBeDefined();diff --git a/packages/web/test/control-size.test.ts b/packages/web/test/control-size.test.tsindex fa0e2182..8b129b86 100644--- a/packages/web/test/control-size.test.ts+++ b/packages/web/test/control-size.test.ts@@ -1,5 +1,6 @@/**- * The form-control size scale (src/components/ui/input.tsx's `sizeTextClass`).+ * The form-control size scale (the UI package's `sizeTextClass`, in+ * packages/ui/src/components/forms/input/input.tsx).** A control's font size comes from its `size` prop and nowhere else. A `text-*` in a caller's* `className` does not reliably override the component's own — both are single-class font-size@@ -30,8 +31,24 @@ const CONTROLS = new Set(["OptionMenu","PasswordInput","FormPicker",+ "SearchInput",+ "Checkbox",+ "Radio",+ "RadioGroup",]);+/**+ * The control family's modules by file name, each at the repo-relative id of its home. A module+ * that moves changes its own entry here and nothing else in this file.+ */+const FAMILY: Record<string, string> = {+ "input.tsx": "packages/ui/src/components/forms/input/input.tsx",+ "select.tsx": "packages/ui/src/components/forms/select/select.tsx",+ "option-menu.tsx": "packages/ui/src/components/forms/select/option-menu.tsx",+ "form-picker.tsx": "packages/web/src/components/ui/form-picker.tsx",+ "search-input.tsx": "packages/ui/src/components/forms/search-input/search-input.tsx",+};+/*** Font-size utilities only. `text-gray-500`, `text-left` and `text-red-600` are colour and* alignment and stay a caller's business; the bracket form is included because it is the one that@@ -135,8 +152,6 @@ const DIALOG_BODY_MODULES = new Set(["features/settings/credits-section.tsx","features/settings/general-section.tsx","features/settings/proxy-section.tsx",- "features/settings/section-shell.tsx",- "features/settings/setting-row.tsx","features/settings/shortcut-recorder.tsx","features/settings/shortcuts-section.tsx","features/settings/trace-import-row.tsx",@@ -207,9 +222,7 @@ function findSpelledSizes(): string[] {describe("control font size", () => {it("scans every source root, and finds the control family and its dialog bodies", () => {expectEveryRootScanned(SCAN);- for (const name of ["input.tsx", "select.tsx", "option-menu.tsx", "form-picker.tsx"]) {- expectSingleHome(SCAN, `packages/web/src/components/ui/${name}`);- }+ for (const id of Object.values(FAMILY)) expectSingleHome(SCAN, id);// A listed module that was renamed or moved would silently drop out of the dialog-body rule.for (const rel of DIALOG_BODY_MODULES) sourceFile(SCAN, `packages/web/src/${rel}`);});@@ -219,7 +232,7 @@ describe("control font size", () => {findSpelledSizes(),"A control's font size comes from its `size` prop (sm for a form field, base for a " +"standalone page like login). A text-* class beside it either does nothing or freezes " +- "the control against the user's font-size setting — see components/ui/input.tsx.",+ "the control against the user's font-size setting — see the UI package's forms/input/input.tsx.",).toEqual([]);});@@ -294,12 +307,12 @@ describe("control font size", () => {// same two rungs, which is how they drifted.//// text-[Npx] is fixed px: it ignores the root font size theme.tsx sets per tier, so a control- // carrying one stops responding to the user's font-size setting. `rowDescClass.sm` is the sole- // exception — an OptionMenu row's description has to sit one step under a text-xs title, and- // there is no rung below text-xs to step down to.+ // carrying one stops responding to the user's font-size setting. There is no exception: an+ // OptionMenu row's description at the sm tier shares the text-xs rung with its title (there is+ // no rung below it) and stands apart by its muted ink.// String literals only: a comment naming the shape it forbids must not trip its own guard.const spelled = (name: string): string[] => {- const source = parse(sourceFile(SCAN, `packages/web/src/components/ui/${name}`));+ const source = parse(sourceFile(SCAN, FAMILY[name]!));const found = new Set<string>();for (const chunk of literalChunks(source)) {for (const hit of chunk.matchAll(new RegExp(FONT_SIZE_CLASS, "g"))) found.add(hit[0]);@@ -307,19 +320,15 @@ describe("control font size", () => {return [...found].sort();};expect(- Object.fromEntries(- ["input.tsx", "select.tsx", "option-menu.tsx", "form-picker.tsx"].map((name) => [- name,- spelled(name),- ]),- ),+ Object.fromEntries(Object.keys(FAMILY).map((name) => [name, spelled(name)])),"A font size inside the control family lives in input.tsx's `sizeTextClass` or " +"option-menu.tsx's `rowDescClass`; a third copy is how the rungs drifted apart before.",).toEqual({"input.tsx": ["text-base", "text-xs"], // sizeTextClass- "option-menu.tsx": ["text-[11px]", "text-xs"], // rowDescClass+ "option-menu.tsx": ["text-xs"], // rowDescClass"select.tsx": [],"form-picker.tsx": [],+ "search-input.tsx": [],});});});diff --git a/packages/web/test/deslop.test.ts b/packages/web/test/deslop.test.tsindex ab769729..46681759 100644--- a/packages/web/test/deslop.test.ts+++ b/packages/web/test/deslop.test.ts@@ -66,12 +66,8 @@ const ALLOWLIST: DeslopAllowlist = {},"components/ui/confirm-modal.tsx": { 7: [1, "W3"] },"components/ui/group-list.tsx": { 12: [1, "W4"], 13: [3, "W4"], 14: [2, "W4"] },- "components/ui/input.tsx": { 9: [1, "W2"] },- "components/ui/option-menu.tsx": { 13: [1, "W2"] },"components/ui/paged-dialog.tsx": { 13: [1, "W3"], 14: [2, "W3"] },- "components/ui/segmented.tsx": { 12: [2, "W2"] },"components/ui/sheet.tsx": { 19: [1, "W3"] },- "components/ui/switch.tsx": { 1: [1, "W2"] },"components/ui/toast.tsx": { 9: [4, "W4"] },"features/agents/agent-settings-page.tsx": { 12: [3, "W4"] },"features/agents/hooks-tab.tsx": { 12: [1, "W4"], 13: [2, "W4"] },@@ -109,7 +105,7 @@ const ALLOWLIST: DeslopAllowlist = {"features/chat/work-group.tsx": { 13: [1, "W6"] },"features/chat/workspace-browser.tsx": {1: [1, "W7"],- 12: [4, "W7"],+ 12: [3, "W7"],13: [1, "W7"],18: [1, "W7"],},@@ -149,14 +145,10 @@ const ALLOWLIST: DeslopAllowlist = {13: [11, "W4"],14: [2, "W4"],},- "features/schedules/schedule-form-modal.tsx": { 13: [2, "W2"] },"features/schedules/schedule-panel.tsx": { 12: [1, "W4"] },"features/schedules/schedule-suggestions.tsx": { 12: [1, "W4"], 13: [1, "W4"] },- "features/settings/proxy-section.tsx": { 13: [1, "W2"] },- "features/settings/setting-row.tsx": { 1: [1, "W2"], 2: [1, "W2"] },"features/settings/shortcut-recorder.tsx": { 12: [1, "W10"], 13: [1, "W10"] },"features/settings/shortcuts-section.tsx": { 13: [1, "W10"] },- "features/skills/skill-pick-list.tsx": { 12: [1, "W2"] },"features/terminal/terminal-appearance.ts": { 9: [1, "W10"] },"features/terminal/terminal-keybar.tsx": { 12: [1, "W10"] },"features/traces/timeline-chart.tsx": { 6: [2, "W8"], 13: [10, "W8"] },diff --git a/packages/web/test/disclosure-anchor.test.ts b/packages/web/test/disclosure-anchor.test.tsindex c1f5261f..7f8143fd 100644--- a/packages/web/test/disclosure-anchor.test.ts+++ b/packages/web/test/disclosure-anchor.test.ts@@ -1,6 +1,6 @@/**- * The rule that decides which disclosure a site gets (src/components/ui/info-popover.tsx and- * help-fold.tsx): **the circled "?" may only appear beside a title.**+ * The rule that decides which disclosure a site gets (the UI package's InfoPopover and+ * HelpFold): **the circled "?" may only appear beside a title.**** A "?" is an anchored mark — it reads as help because it modifies the title next to it. Standing* alone at the top of a panel it modifies nothing, and a reader has to click it to find out what@@ -89,15 +89,15 @@ function findOrphans(): string[] {describe("disclosure anchoring", () => {it("scans every source root, and finds the two disclosures in one place each", () => {expectEveryRootScanned(SCAN);- expectSingleHome(SCAN, "packages/web/src/components/ui/info-popover.tsx");- expectSingleHome(SCAN, "packages/web/src/components/ui/help-fold.tsx");+ expectSingleHome(SCAN, "packages/ui/src/components/overlays/info-popover/info-popover.tsx");+ expectSingleHome(SCAN, "packages/ui/src/components/overlays/info-popover/help-fold.tsx");});it("never leaves an InfoPopover standing without a title beside it", () => {expect(findOrphans(),'A circled "?" must sit after a title. Where the surface has no title — an Agent settings ' +- "tab, whose name lives in the tab bar — use HelpFold (components/ui/help-fold.tsx) instead.",+ "tab, whose name lives in the tab bar — use HelpFold instead.",).toEqual([]);});diff --git a/packages/web/test/icon-registry.test.ts b/packages/web/test/icon-registry.test.tsindex d9253cec..a8315602 100644--- a/packages/web/test/icon-registry.test.ts+++ b/packages/web/test/icon-registry.test.ts@@ -26,8 +26,7 @@ const WEB = SCAN.files.filter((file) => file.root === "web");/** Glyph paths outside the registry, by path under `packages/web/src`: `[count, wave]`. */const ALLOWLIST: Readonly<Record<string, readonly [number, string]>> = {"components/layout/app-layout.tsx": [3, "W7"],- "components/layout/sidebar.tsx": [6, "W7"],- "components/ui/info-popover.tsx": [1, "W3"],+ "components/layout/sidebar.tsx": [4, "W7"],"features/chat/attached-files-banner.tsx": [1, "W6"],"features/chat/chat-input.tsx": [5, "W6"],"features/chat/conversation-outline.tsx": [1, "W6"],diff --git a/packages/web/test/info-popover.test.ts b/packages/web/test/info-popover.test.tsdeleted file mode 100644index 840346b4..00000000--- a/packages/web/test/info-popover.test.ts+++ /dev/null@@ -1,130 +0,0 @@-/**- * The "?" disclosure (src/components/ui/info-popover.tsx) and the field layout it forces.- *- * The trap these guard is HTML's, not React's: an info trigger is a `<button>`, a `<button>` is- * a labelable element, and a wrapping `<label>` names its FIRST labelable descendant. Nesting a- * trigger inside `Field`'s usual `<label>` wrapper would therefore retarget the field's title- * from the input to the "?" — silently, with no visual symptom.- */-import { describe, expect, it } from "vitest";-import { createElement } from "react";-import { renderToStaticMarkup } from "react-dom/server";-import { InfoPopover } from "../src/components/ui/info-popover";-import { Field } from "../src/components/ui/field";-import { Input } from "../src/components/ui/input";-import { Switch } from "../src/components/ui/switch";-import { PrefRow } from "../src/features/settings/setting-row";-import { S } from "../src/lib/strings";-import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";--/**- * The modules rendered below, found by scanning web and the shared UI package: a component that- * moves must be re-pointed here, and a copy left behind would otherwise stay the one under test.- */-describe("the popover's sources", () => {- it("scan every source root, and find each rendered module in one place", () => {- const scan = scanSources();- expectEveryRootScanned(scan);- for (const id of [- "packages/web/src/components/ui/info-popover.tsx",- "packages/web/src/components/ui/field.tsx",- "packages/web/src/features/settings/setting-row.tsx",- ]) {- expectSingleHome(scan, id);- }- });-});--describe("InfoPopover", () => {- const html = renderToStaticMarkup(- createElement(InfoPopover, { children: "Values take effect from the next task." }),- );-- it("is a real button carrying an accessible name", () => {- expect(html).toContain("<button");- expect(html).toContain('type="button"');- expect(html).toContain(`aria-label="${S.common.moreInfo}"`);- expect(html).toContain(`data-tooltip="${S.common.moreInfo}"`);- });-- it("starts collapsed, and points at the panel it will open", () => {- expect(html).toContain('aria-expanded="false"');- expect(html).toMatch(/aria-controls="[^"]+"/);- // The panel is portaled and only mounted while open, so nothing of the text is in the tree.- expect(html).not.toContain("Values take effect");- expect(html).not.toContain('role="tooltip"');- });-- it("folds the subject into its name rather than repeating it", () => {- // A trigger inside a heading would otherwise make that heading announce its own title twice.- const named = renderToStaticMarkup(- createElement(InfoPopover, { label: "Vault", children: "x" }),- );- expect(named).toContain(`aria-label="${S.common.moreInfoAbout("Vault")}"`);- expect(named).not.toContain('aria-label="Vault"');- });-});--describe("Field with an info popover", () => {- const withInfo = renderToStaticMarkup(- createElement(Input, {- label: "Timeout",- info: "Per-request timeout.",- hint: "milliseconds",- value: "",- readOnly: true,- }),- );-- it("associates the title by htmlFor instead of wrapping the control", () => {- const forMatch = /<label for="([^"]+)"/.exec(withInfo);- expect(forMatch, "the title must be a <label for=…>").not.toBeNull();- expect(withInfo).toContain(`id="${forMatch?.[1]}"`);- });-- it("never puts the trigger inside a label element", () => {- // Everything between a <label> open tag and its close must be free of <button>.- for (const [, inner] of withInfo.matchAll(/<label\b[^>]*>([\s\S]*?)<\/label>/g)) {- expect(inner).not.toContain("<button");- }- });-- it("keeps a formatting hint visible alongside the disclosed semantics", () => {- // The split is the whole point: what the field MEANS is disclosed, what shape the value must- // take stays on screen while the user types.- expect(withInfo).toContain("milliseconds");- expect(withInfo).not.toContain("Per-request timeout.");- });-- it("keeps the plain wrapping-label layout when there is no info", () => {- const plain = renderToStaticMarkup(- createElement(Field, { label: "Name", children: createElement("input", {}) }),- );- expect(plain.startsWith("<label")).toBe(true);- expect(plain).not.toContain("<label for=");- });-});--describe("PrefRow with an info popover", () => {- // A Settings row titles a control it does not own, so its title is a <p> and the "?"- // is safe beside it. An edit that made that title a <label> for the sake of click-to-toggle- // would hand the row to the trigger instead — the same trap Field carries two layouts to- // avoid, on the one row primitive that has no Field between it and the control.- const row = renderToStaticMarkup(- createElement(PrefRow, {- label: "Theme",- info: "Light or dark look of the app.",- children: createElement(Switch, { checked: true, onChange: () => {} }),- }),- );-- it('keeps the row out of a label, so the "?" cannot toggle its control', () => {- expect(row).not.toContain("<label");- expect(row).toContain('role="switch"');- });-- it("anchors the trigger to the row title", () => {- expect(row).toContain(`aria-label="${S.common.moreInfoAbout("Theme")}"`);- expect(row).not.toContain("Light or dark look of the app.");- });-});diff --git a/packages/web/test/menu-style.test.ts b/packages/web/test/menu-style.test.tsindex cc6e8fd5..d83ff2cc 100644--- a/packages/web/test/menu-style.test.ts+++ b/packages/web/test/menu-style.test.ts@@ -1,24 +1,36 @@/**- * One look for every picker and menu: Select's panel, row states and check mark- * (components/ui/field.tsx: `menuPanelClass`, `menuRowTone`, `ChoiceCheck`), shared by Select,- * OptionMenu, Dropdown and the pickers built on Dropdown. Checked as source, because the web- * suite renders no DOM.+ * One look for every picker and menu: Select's panel, row states and check mark, which the UI+ * package owns (`menuPanelClass`, `menuRowClass`, `menuRowTone`, `ChoiceCheck` in+ * components/overlays/menu-panel/menu-panel.tsx), shared by Select, OptionMenu, Dropdown and the+ * pickers built on Dropdown. The pieces themselves are tested in the package; this suite checks+ * how the app uses them, as source, because the web suite renders no DOM.*/-import { renderToStaticMarkup } from "react-dom/server";-import { createElement } from "react";import { describe, expect, it } from "vitest";-import { ChoiceCheck, menuRowTone } from "../src/components/ui/field";-import { scanSources, sourceFile } from "./helpers/roots";+import { expectSingleHome, scanSources, sourceFile } from "./helpers/roots";const SCAN = scanSources();-const text = (id: string) => sourceFile(SCAN, `packages/web/src/${id}`).text;+const text = (id: string) => sourceFile(SCAN, id).text;+const MENU_PANEL = "packages/ui/src/components/overlays/menu-panel/menu-panel.tsx";describe("menus and pickers", () => {+ it("take the panel, rows and check from the UI package, never a second copy", () => {+ expectSingleHome(SCAN, MENU_PANEL);+ const copies = SCAN.files+ .filter((file) => file.id !== MENU_PANEL)+ .filter((file) =>+ /\b(?:const|function)\s+(?:menuPanelClass|menuRowClass|menuRowTone|ChoiceCheck)\b/.test(+ file.text,+ ),+ )+ .map((file) => file.id);+ expect(copies).toEqual([]);+ });+it("open Select's panel", () => {for (const id of [- "components/ui/select.tsx",- "components/ui/option-menu.tsx",- "components/ui/dropdown.tsx",+ "packages/ui/src/components/forms/select/select.tsx",+ "packages/ui/src/components/forms/select/option-menu.tsx",+ "packages/web/src/components/ui/dropdown.tsx",]) {expect(text(id), id).toContain("${menuPanelClass}");}@@ -30,13 +42,5 @@ describe("menus and pickers", () => {.filter((file) => /["'`]✓["'`]/.test(file.text)).map((file) => file.id);expect(typed).toEqual([]);- expect(renderToStaticMarkup(createElement(ChoiceCheck, { on: true }))).toContain("<svg");- expect(renderToStaticMarkup(createElement(ChoiceCheck, { on: false }))).not.toContain("<svg");- });-- it("fill the current choice and only hover the rest", () => {- expect(menuRowTone(true)).toContain("font-medium");- expect(menuRowTone(true)).not.toContain("hover:");- expect(menuRowTone(false)).toContain("hover:bg-gray-100");});});diff --git a/packages/web/test/messaging-binding-editor.test.ts b/packages/web/test/messaging-binding-editor.test.tsindex 741930a0..302755c7 100644--- a/packages/web/test/messaging-binding-editor.test.ts+++ b/packages/web/test/messaging-binding-editor.test.ts@@ -25,7 +25,9 @@ import {type MessagingChannelFacts,} from "../src/features/messaging/messaging-binding-editor";import { emptyMessagingForm } from "../src/features/messaging/messaging-binding-form";+import { UiStringsProvider } from "@prismshadow/penguin-ui";import { S, setActiveStrings, zh } from "../src/lib/strings";+import { uiStringsOf } from "../src/lib/ui-strings";import { en } from "../src/lib/strings-en";import { formatDateTime } from "../src/lib/format";@@ -82,8 +84,15 @@ function stateOf(};}+// The "?" labels read the package's UiStrings, which the app provides from the active dictionary.const render = (state: MessagingBindingEditorState) =>- renderToStaticMarkup(createElement(MessagingBindingBody, { b: state }));+ renderToStaticMarkup(+ createElement(+ UiStringsProvider,+ { strings: uiStringsOf(S) },+ createElement(MessagingBindingBody, { b: state }),+ ),+ );describe("MessagingBindingBody", () => {it("opens on the fields: no explanatory prose above the first input", () => {@@ -140,7 +149,7 @@ describe("MessagingBindingBody", () => {const dark = render(stateOf("feishu", { feishu: saved }));expect(dark).toContain("abcd…7890");expect(dark).toContain(S.feishu.clearSecret);- expect(dark).toContain('type="checkbox"/>');+ expect(dark).toMatch(/<input[^>]*type="checkbox"[^>]*\/>/);expect(dark).not.toContain(S.messaging.disableBeforeClearHint);// Enabled: clearing would leave a live connection running on a credential the store nodiff --git a/packages/web/test/modal-focus.test.ts b/packages/web/test/modal-focus.test.tsindex 98364b8f..65f8ce80 100644--- a/packages/web/test/modal-focus.test.ts+++ b/packages/web/test/modal-focus.test.ts@@ -8,11 +8,11 @@* `nextFocusIndex` is the arithmetic and is exercised directly. The wiring around it cannot* be: this suite is `environment: "node"` with no jsdom, and Modal renders through* `createPortal(…, document.body)`, so it cannot even be handed to `renderToStaticMarkup` the- * way info-popover.test.ts renders Field. So the wiring is asserted against the source, the- * way portal-panel-dismiss.test.ts asserts its hook's listeners — thin, but it pins the parts- * that are silent when they break: an aria attribute that reappears inside the `headerless`- * branch names only half the dialogs, and a restore target read one commit too late is a- * dialog that hands focus back to itself.+ * way the UI package's field.test.ts renders Field. So the wiring is asserted against the+ * source, the way portal-panel-dismiss.test.ts asserts its hook's listeners — thin, but it pins+ * the parts that are silent when they break: an aria attribute that reappears inside the+ * `headerless` branch names only half the dialogs, and a restore target read one commit too late+ * is a dialog that hands focus back to itself.*/import { describe, expect, it } from "vitest";import { nextFocusIndex } from "../src/components/ui/modal";diff --git a/packages/web/test/portal-panel-dismiss.test.ts b/packages/web/test/portal-panel-dismiss.test.tsindex 85747f0e..9c99cb4f 100644--- a/packages/web/test/portal-panel-dismiss.test.ts+++ b/packages/web/test/portal-panel-dismiss.test.ts@@ -1,6 +1,7 @@/**- * Scroll dismissal for the shared portal panel (src/components/ui/use-portal-panel.ts),- * which OptionMenu, Select, InfoPopover and the composer toolbar's context ring all open through.+ * Scroll dismissal for the shared portal panel (the UI package's+ * src/components/overlays/portal-panel/use-portal-panel.ts), which OptionMenu, Select,+ * InfoPopover and the composer toolbar's context ring all open through.** The panel listens for scroll in the capture phase because scroll does not bubble, and the* price of capture on `window` is that it hears every scrolling element in the document. The@@ -9,8 +10,8 @@* streaming reply closes a panel opened in the composer toolbar, over content that never* moved.*- * `scrollMovesAnchor` itself is exercised in context-menu.test.ts; what cannot be reached- * from a node-only suite (`environment: "node"`, no jsdom) is the wiring, and the wiring is+ * `scrollMovesAnchor` itself is exercised in the package's portal-panel.test.ts; what cannot be+ * reached from a node-only suite (`environment: "node"`, no jsdom) is the wiring, and the wiring is* where this silently breaks: the rule is answered with the trigger element, so a consumer* that never attaches `triggerRef` hands it a null owner and quietly gets the old* close-on-any-scroll behavior back for its own panel. So the scan below discovers the@@ -22,7 +23,7 @@ import { expectEveryRootScanned, expectSingleHome, scanSources, sourceFile } fro/** Every .ts/.tsx under web and the shared UI package: a consumer is covered on either side. */const SCAN = scanSources([".ts", ".tsx"]);-const HOOK = "packages/web/src/components/ui/use-portal-panel.ts";+const HOOK = "packages/ui/src/components/overlays/portal-panel/use-portal-panel.ts";/** The body of a handler declared as `const <name> = ...` up to its closing `};`. */function handler(src: string, name: string): string {diff --git a/packages/web/test/required-mark.test.ts b/packages/web/test/required-mark.test.tsindex d61ca0e0..f92874b4 100644--- a/packages/web/test/required-mark.test.ts+++ b/packages/web/test/required-mark.test.ts@@ -1,7 +1,7 @@/**- * The field-marker contract (src/components/ui/field.tsx): **a required field carries the red- * "*", an optional field carries nothing at all, and no label or placeholder writes the word- * "optional".**+ * The field-marker contract (the UI package's forms/field/field.tsx): **a required field carries+ * the red "*", an optional field carries nothing at all, and no label or placeholder writes the+ * word "optional".**** The absence of the mark is the whole signal, so it only reads if the mark is spelled one way* everywhere and never competes with a second, wordier convention — the same reason@@ -14,8 +14,7 @@ import { describe, expect, it } from "vitest";import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";import ts from "typescript";-import { Input } from "../src/components/ui/input";-import { RequiredMark } from "../src/components/ui/field";+import { Input, RequiredMark } from "@prismshadow/penguin-ui";import { zh } from "../src/lib/strings";import { en } from "../src/lib/strings-en";import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/roots";@@ -23,7 +22,7 @@ import { expectEveryRootScanned, expectSingleHome, scanSources } from "./helpers/** Web and the shared UI package: a hand-rolled mark is a second spelling on either side. */const SCAN = scanSources();/** The one place the mark is allowed to be spelled. */-const FIELD = "packages/web/src/components/ui/field.tsx";+const FIELD = "packages/ui/src/components/forms/field/field.tsx";/*** Every string literal reachable from a node, joined. `className` is written four ways here —@@ -64,6 +63,9 @@ function childText(node: ts.JsxElement): string {.trim();}+/** A red ink, as a palette class (the web app) or the danger tone's token (the package). */+const RED_INK = /\btext-(?:red-|tone-danger-)/;+/*** Every element that paints a lone "*" in a red ink class — i.e. a hand-rolled required mark — as* "id:line".@@ -75,7 +77,7 @@ function marksIn(id: string, text: string): string[] {// The children test is cheap and rejects all but a handful of the tree's ~2200 elements,// so it runs before the attribute walk.if (ts.isJsxElement(node) && childText(node) === "*") {- if (classNameOf(node.openingElement).includes("text-red-")) {+ if (RED_INK.test(classNameOf(node.openingElement))) {const line = source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1;found.push(`${id}:${line}`);}@@ -139,7 +141,7 @@ describe("required mark", () => {createElement(Input, { label: "Name", required: true, value: "", readOnly: true }),);expect(required).toContain("*");- expect(required).toContain("text-red-500");+ expect(required).toContain("text-tone-danger-fg");// Decorative to assistive tech — aria-required on the control is what gets announced.expect(required).toMatch(/<span[^>]*aria-hidden[^>]*>\*<\/span>/);expect(required).toContain('aria-required="true"');@@ -161,14 +163,14 @@ describe("required mark", () => {// Scoped to the mark's own shape: a bare `toContain("*")` over the markup would also trip// on a Tailwind `*:` variant landing in any class the control renders.expect(optional).not.toMatch(/<span[^>]*>\*<\/span>/);- expect(optional).not.toContain("text-red-");+ expect(optional).not.toMatch(RED_INK);expect(optional).not.toContain("aria-required");});it("is spelled in exactly one place", () => {expect(handRolledMarks(),- "A red '*' belongs to RequiredMark (components/ui/field.tsx). Pass `required` to " ++ "A red '*' belongs to RequiredMark (the UI package's forms/field). Pass `required` to " +"Field/Input/Textarea/Select/OptionMenu, use <FieldLabel required> for a custom label " +"row, or render <RequiredMark /> directly.",).toEqual([]);@@ -182,6 +184,7 @@ describe("required mark", () => {"const b = <span className={`ml-0.5 text-red-500`}>*</span>;",'const c = <span className={dim ? "text-red-500" : ""}>*</span>;','const d = <span className="text-red-500">{"*"}</span>;',+ 'const e = <span className="ml-0.5 text-tone-danger-fg">*</span>;',];expect(marksIn(probe, shapes.join("\n"))).toHaveLength(shapes.length);expect(marksIn(probe, '<span className="text-gray-500">*</span>')).toEqual([]);diff --git a/packages/web/test/ui-strings.test.ts b/packages/web/test/ui-strings.test.tsindex 1cec341d..e23c11bb 100644--- a/packages/web/test/ui-strings.test.ts+++ b/packages/web/test/ui-strings.test.ts@@ -20,7 +20,10 @@ describe("uiStringsFor", () => {const strings = uiStringsFor(locale);expect(Object.keys(strings).sort(), locale).toEqual(KEYS);for (const [key, value] of Object.entries(strings)) {- expect(typeof value === "string" && value.trim() !== "", `${locale}.${key}`).toBe(true);+ // A formatter (`moreInfoAbout`) is checked by what it says about a subject.+ const text = typeof value === "function" ? value("Vault") : value;+ expect(typeof text === "string" && text.trim() !== "", `${locale}.${key}`).toBe(true);+ if (typeof value === "function") expect(text, `${locale}.${key}`).toContain("Vault");}}});diff --git a/scripts/ui-migrate.json b/scripts/ui-migrate.jsonindex cbbc9f41..4ae00730 100644--- a/scripts/ui-migrate.json+++ b/scripts/ui-migrate.json@@ -262,6 +262,137 @@"names": ["HiddenFileInput"]}]+ },+ "W2": {+ "packages/web/src/components/ui/field": [+ {+ "owner": "W2-0",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/overlays/menu-panel/menu-panel.tsx",+ "names": ["menuPanelClass", "menuRowClass", "menuRowTone", "ChoiceCheck"]+ },+ {+ "owner": "W2-A",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/field/field.tsx",+ "names": ["Field", "FieldLabel", "FieldHint", "FieldError", "RequiredMark", "controlBase"]+ }+ ],+ "packages/web/src/components/ui/input": [+ {+ "owner": "W2-A",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/input/input.tsx",+ "names": [+ "Input",+ "InputProps",+ "Textarea",+ "TextareaProps",+ "ControlSize",+ "sizeTextClass",+ "sizeClass",+ "errorClass",+ "autofillProps",+ "noAutofill"+ ]+ }+ ],+ "packages/web/src/components/ui/password-input": [+ {+ "owner": "W2-A",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/password-input/password-input.tsx",+ "names": ["PasswordInput"]+ }+ ],+ "packages/web/src/components/ui/use-portal-panel": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/overlays/portal-panel/use-portal-panel.ts",+ "names": ["usePortalPanel", "PortalPanelPosition"]+ }+ ],+ "packages/web/src/lib/context-menu": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/overlays/portal-panel/use-portal-panel.ts",+ "names": ["scrollMovesAnchor"]+ }+ ],+ "packages/web/src/components/ui/info-popover": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/overlays/info-popover/info-popover.tsx",+ "names": ["InfoPopover"]+ }+ ],+ "packages/web/src/components/ui/help-fold": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/overlays/info-popover/help-fold.tsx",+ "names": ["HelpFold"]+ }+ ],+ "packages/web/src/components/ui/select": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/select/select.tsx",+ "names": ["Select", "SelectProps"]+ }+ ],+ "packages/web/src/components/ui/option-menu": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/select/option-menu.tsx",+ "names": ["OptionMenu", "OptionMenuChoice", "rowDescClass"]+ }+ ],+ "packages/web/src/features/chat/model-select": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/picker-list/picker-list.tsx",+ "names": ["PickerList"]+ }+ ],+ "packages/web/src/components/ui/switch": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/switch/switch.tsx",+ "names": ["Switch", "SwitchProps"]+ }+ ],+ "packages/web/src/components/ui/segmented": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/segmented/segmented.tsx",+ "names": ["Segmented"]+ }+ ],+ "packages/web/src/features/settings/setting-row": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/pref-row/pref-row.tsx",+ "names": ["PrefRow"]+ }+ ],+ "packages/web/src/features/settings/section-shell": [+ {+ "owner": "W2-B",+ "target": "@prismshadow/penguin-ui",+ "dest": "packages/ui/src/components/forms/pref-row/pref-row.tsx",+ "names": ["SectionShell→SettingsSection"]+ }+ ]}}}