Skip to content

Your lightweight open-source personal agent.

feat(webui): add reading text size preferences (#6325)

chengyongru282839cc6502
diff --git a/docs/webui.md b/docs/webui.md
index 9dc302881..5cd6cc15c 100644
--- a/docs/webui.md
+++ b/docs/webui.md
@@ -294,7 +294,7 @@ Settings is the control surface for browser-local and gateway-backed runtime con
Some settings take effect immediately. Runtime settings that affect the gateway or agent process may require a restart; the WebUI shows that requirement next to the relevant control.
-Browser-only display preferences, such as file edit display mode, take effect immediately for the current browser and do not change gateway configuration.
+Browser-only display preferences take effect immediately and persist in the current browser. In **Appearance → Local preferences**, **Reading text size** offers three A buttons: small, standard (default), and large. They adjust conversation text, Markdown and code, with a coordinated message input size; navigation and toolbars keep their interface size. Browser zoom remains available. These preferences, including file edit display mode, do not change gateway configuration.
To add a model, follow [Configure Your Model](./quick-start.md#2-configure-your-model).
diff --git a/webui/COMPONENTS.md b/webui/COMPONENTS.md
index 00e304016..13a3424dd 100644
--- a/webui/COMPONENTS.md
+++ b/webui/COMPONENTS.md
@@ -49,6 +49,14 @@ Supporting hooks and display-model helpers stay near the feature that owns them.
`onChat` provides live events to task and model observers. `useNanobotStream` uses `onTranscript` as the single transcript owner, receiving queued events once followed by live events.
+## Typography
+
+Use the text roles in `tailwind.config.js` for shared metrics: `text-ui` for navigation, `text-control-label` for controls, `text-ui-label` for compact labels, `text-caption` for auxiliary text, and `text-title` / `text-ui-heading` for interface headings. These roles stay independent of reading preferences. Register new size utilities in `src/lib/utils.ts` so `cn()` distinguishes them from text colors.
+
+`text-reading` and `.markdown-content` own reading typography; Markdown headings retain relative sizes, and tables, inline code and fenced code preserve their own hierarchy. Browser preferences select small / standard / large body sizes of 16 / 18 / 20px on desktop and 15 / 16 / 18px below 640px. Latin body line height is 1.625; Chinese, Japanese and Korean retain 1.8. `text-code` and `text-code-dense` share the mono stack and scale to 0.875 and 0.75 of body size. Avoid local font-size or line-height overrides for these roles.
+
+The Composer shares `text-composer` between its textarea and mention overlay, with a 16px minimum and 1.5 line height. Preserve identical text metrics, padding and literal CJK/Latin spacing in both layers. Reading preferences are projected by `useReadingTypography` through document tokens, without changing the root font size, the rem spacing grid or browser zoom.
+
## Choose an existing component
- Check the gallery and current callers before creating a control. Different labels, colors, or sizes usually call for an existing component's options. `Button` already has appearance and size variants; `Input` and `SearchInput` share the input implementation.
diff --git a/webui/browser/fixture.tsx b/webui/browser/fixture.tsx
index 419758f68..1e5797eb6 100644
--- a/webui/browser/fixture.tsx
+++ b/webui/browser/fixture.tsx
@@ -22,6 +22,7 @@ import { installSkeletonPreviewApi, SkeletonAdditionsFixture } from "./skeleton-
import { NewChatSkeletonFixture } from "./new-chat-skeleton-fixture";
import "../src/globals.css";
import { DiagramFixture } from "./diagram-fixture";
+import { TypographyFixture } from "./typography-fixture";
import { HistoryBoundaryFixture } from "./history-boundary-fixture";
const history: UIMessage[] = [
@@ -144,7 +145,9 @@ function AppsFixture() {
if (parameters.get("case") === "skeleton-additions") installSkeletonPreviewApi();
await initializeI18n();
createRoot(document.getElementById("root")!).render(<TooltipProvider>
- {parameters.get("case") === "history-boundary"
+ {parameters.get("case") === "typography"
+ ? <ClientProvider client={railClient} token="fixture"><TypographyFixture /></ClientProvider>
+ : parameters.get("case") === "history-boundary"
? <ClientProvider client={railClient} token="fixture" webuiCapabilities={["webui.prompt-navigation.v1"]}><HistoryBoundaryFixture local={parameters.has("local")} navigate={parameters.has("navigate")} /></ClientProvider>
: parameters.get("case") === "diagrams"
? <DiagramFixture parameters={parameters} />
diff --git a/webui/browser/skeleton-additions.spec.ts b/webui/browser/skeleton-additions.spec.ts
index 225ab84cc..c91cfe774 100644
--- a/webui/browser/skeleton-additions.spec.ts
+++ b/webui/browser/skeleton-additions.spec.ts
@@ -76,11 +76,13 @@ for (const width of [390, 1440]) for (const locale of ["en", "zh-CN"]) {
const notificationDetails = section === "notifications" ? ", .settings-list-inset > .border-t, section > p" : "";
const loaded = await boxes(target.locator(selector + notificationDetails));
const loadedControls = section === "notifications" ? await boxes(target.getByRole("switch")) : null;
+ const readingControl = section === "appearance" ? await boxes(target.getByRole("radiogroup")) : null;
await page.goto(fixture("settings", "loading", extra));
await settle(page);
const skeletonSelector = section === "overview" ? "[data-overview-skeleton-row]" : section === "models" ? "[data-model-preset-skeleton], .settings-footer" : section === "about" ? ".settings-list-row" : "[data-settings-skeleton-row]";
const skeleton = await boxes(target.locator(skeletonSelector + notificationDetails));
sameBoxes(skeleton, loaded);
+ if (readingControl) sameBoxes(await boxes(target.locator("[data-skeleton-reading-size]")), readingControl);
if (loadedControls) {
const skeletonControls = await boxes(target.locator("[data-skeleton-switch]"));
sameBoxes(skeletonControls, loadedControls);
diff --git a/webui/browser/skeleton-fixture.tsx b/webui/browser/skeleton-fixture.tsx
index 93ad032d6..e8b78e861 100644
--- a/webui/browser/skeleton-fixture.tsx
+++ b/webui/browser/skeleton-fixture.tsx
@@ -9,6 +9,7 @@ import { ChannelsSettings } from "@/components/settings/system/ChannelsSettings"
import { McpManagementDialog } from "@/components/settings/system/McpManagementDialog";
import { WorkspaceProjectPicker } from "@/components/thread/WorkspaceControls";
import { settings } from "@/dev/gallery/settings";
+import { useReadingTypography } from "@/hooks/useReadingTypography";
import { fetchWorkspaceDirectories } from "@/lib/api";
import type { McpPresetInfo, NanobotFeatureInfo } from "@/lib/types";
@@ -22,6 +23,7 @@ const preset: McpPresetInfo = {
};
export function SkeletonFixture({ surface, loading }: { surface: string; loading: boolean }) {
+ useReadingTypography();
const [model, setModel] = useState("");
const [previewLoading, setPreviewLoading] = useState(loading);
const feature: NanobotFeatureInfo = {
diff --git a/webui/browser/skeleton-layout.spec.ts b/webui/browser/skeleton-layout.spec.ts
index d3fda637f..42e333a15 100644
--- a/webui/browser/skeleton-layout.spec.ts
+++ b/webui/browser/skeleton-layout.spec.ts
@@ -187,8 +187,12 @@ for (const width of [390, 1440]) {
} finally { release(); }
});
- test("file preview skeletons follow code gutters and Markdown controls", async ({ page }) => {
+ for (const readingTextSize of ["small", "standard", "large"] as const) test(`file preview skeletons follow code gutters and Markdown controls: ${readingTextSize}`, async ({ page }) => {
+ await page.addInitScript((size) => {
+ localStorage.setItem("nanobot-webui.settings-preferences", JSON.stringify({ schemaVersion: 1, readingTextSize: size }));
+ }, readingTextSize);
await page.goto(fixture("file"));
+ await expect(page.locator("html")).toHaveAttribute("data-reading-text-size", readingTextSize);
await expect(page.getByTestId("viewport-code-rows")).toBeVisible();
const source = await box(page.locator("pre"));
const code = await box(page.locator("[data-highlighted]"));
@@ -202,7 +206,8 @@ for (const width of [390, 1440]) {
const controls = await box(page.getByTestId("file-preview-panel").locator(":scope > div").first());
await page.goto(fixture("markdown", true));
sameBox(await box(status(page).locator("[aria-hidden] > .flex").first()), controls);
- const title = await box(status(page).locator(".h-7 > div"));
+ const title = await box(status(page).locator("[data-file-preview-heading-skeleton]"));
+ sameBox(title, heading);
expect(title.x).toBe(heading.x);
expect(title.y + title.height / 2).toBe(heading.y + heading.height / 2);
await noOverflow(page);
diff --git a/webui/browser/typography-fixture.tsx b/webui/browser/typography-fixture.tsx
new file mode 100644
index 000000000..2374d983f
--- /dev/null
+++ b/webui/browser/typography-fixture.tsx
@@ -0,0 +1,105 @@
+import { useEffect, useState } from "react";
+
+import { MessageBubble } from "@/components/MessageBubble";
+import { AppearanceSettingsView } from "@/components/settings/overview/AppearanceSettingsView";
+import { ThreadComposer } from "@/components/thread/ThreadComposer";
+import { DiffSyntaxHighlight } from "@/components/thread/activity/DiffSyntaxHighlight";
+import { ThemeProvider, useTheme } from "@/hooks/useTheme";
+import { useReadingTypography } from "@/hooks/useReadingTypography";
+import { readLocalPreferences, writeLocalPreferences } from "@/lib/local-preferences";
+import type { ChatSummary, UIMessage } from "@/lib/types";
+
+const session: ChatSummary = {
+ key: "websocket:typography", channel: "websocket", chatId: "typography",
+ createdAt: null, updatedAt: null, title: "排版讨论 Typography", preview: "",
+ handle: { id: "handle_12345678901234567890123456789012", name: "typography" },
+};
+const content = `# 阅读,让思路自然延续
+
+排版应当帮助理解,而不是抢走注意力。中文与 English、API identifiers 混排时,也需要清楚的层级与自然的节奏。字号、行高和列宽一起决定阅读体验。
+
+## 保留层级,减少干扰
+
+普通正文使用稳定的字重,**重点内容保持清晰**。Inline code 如 \`readingTextSize\` 仍应与句子协调。A comfortable reading rhythm leaves enough room for the next thought, without making every line feel disconnected.
+
+> 好的工具让人专注于内容。Reading is a conversation between the reader and the page.
+
+### 可执行的检查清单
+
+1. 即时切换字号,保留其他界面偏好。
+2. 长段落和 long-unbroken-identifiers-without-spaces-abcdefghijklmnopqrstuvwxyz0123456789 可以换行。
+3. 操作仍然可达,导航尺寸保持稳定。
+ - 嵌套列表保留清楚的缩进。
+ - 中文、English 与数字 12345 的组合。
+
+- [x] 已完成的任务与正文一致
+- [ ] 接下来确认视觉舒适度
+
+| 内容角色 | 示例 | 设计意图 |
+| --- | --- | --- |
+| 正文 Body | 中文 English 混排 | 舒适、连续的阅读节奏 |
+| 标题 Heading | 清楚的内容层级 | 保留结构,而非所有文字同大 |
+| Code | configuration.readingTextSize | 完整显示,必要时在局部滚动 |
+
+\`\`\`typescript
+// 中文注释与 English code
+const preference = { readingTextSize: "standard" };
+function welcome(name: string) {
+ return \`你好,\${name} — keep exploring.\`;
+}
+\`\`\`
+
+#### 进一步阅读
+
+The quick brown fox jumps over the lazy dog. 继续探索,保持好奇。
+
+<details><summary>展开查看补充说明</summary>
+
+这里的正文与折叠标题也应保持协调,不因字号变化发生裁切。
+
+</details>
+`;
+const stressContent = `
+
+## 长内容阅读 Long content
+
+${Array.from({ length: 30 }, (_, index) => `${index + 1}. 第 ${index + 1} 项:中文与 English 混排的长列表内容,保持自然换行和清楚的编号。`).join("\n")}
+
+\`\`\`typescript
+const longIdentifier = "${"long-path-segment/".repeat(20)}";
+${Array.from({ length: 80 }, (_, index) => `const item${index} = "第 ${index + 1} 行 — readable code";`).join("\n")}
+\`\`\`
+`;
+const messages: UIMessage[] = [
+ { id: "typography-user", role: "user", content: "请用中文与 English 解释这套排版,保持标题、引用和代码清楚。", createdAt: 1 },
+ { id: "typography-answer", role: "assistant", content, createdAt: 2 },
+];
+
+export function TypographyFixture() {
+ useReadingTypography();
+ const { theme, toggle } = useTheme();
+ const [preferences, setPreferences] = useState(readLocalPreferences);
+ const [sent, setSent] = useState<UIMessage[]>([]);
+ const previewMessages = new URLSearchParams(window.location.search).has("stress")
+ ? messages.map((message) => message.role === "assistant" ? { ...message, content: content + stressContent } : message)
+ : messages;
+ useEffect(() => writeLocalPreferences(preferences), [preferences]);
+ return <ThemeProvider theme={theme}>
+ <main className="h-full overflow-y-auto">
+ <div className="settings-grid mx-auto py-6">
+ <AppearanceSettingsView theme={theme} onToggleTheme={toggle} localPrefs={preferences}
+ onChangeLocalPrefs={setPreferences} />
+ </div>
+ <section className="mx-auto max-w-[var(--content-column-width)] space-y-6 px-4 pb-8" aria-label="Reading preview">
+ {[...previewMessages, ...sent].map((message) => <MessageBubble key={message.id} message={message} />)}
+ <div className="overflow-x-auto"><DiffSyntaxHighlight language="typescript" lines={[
+ { kind: "delete", content: "const size = 16;", old_lineno: 1, new_lineno: null },
+ { kind: "add", content: "const size = preferences.readingTextSize;", old_lineno: null, new_lineno: 1 },
+ ]} /></div>
+ <ThreadComposer compactWhenIdle sessions={[session]} modelLabel="Fixture" persistDraft={false} onSend={(text) => {
+ setSent((current) => [...current, { id: `sent-${current.length}`, role: "user", content: text, createdAt: 3 + current.length }]);
+ }} />
+ </section>
+ </main>
+ </ThemeProvider>;
+}
diff --git a/webui/browser/typography.spec.ts b/webui/browser/typography.spec.ts
new file mode 100644
index 000000000..bef0192ba
--- /dev/null
+++ b/webui/browser/typography.spec.ts
@@ -0,0 +1,207 @@
+import { expect, test, type Locator } from "@playwright/test";
+
+async function readMetrics(element: Locator) {
+ return element.evaluate((node) => {
+ if (!node.isConnected) return null;
+ const style = getComputedStyle(node);
+ return {
+ size: parseFloat(style.fontSize), line: parseFloat(style.lineHeight), weight: style.fontWeight,
+ family: style.fontFamily, letterSpacing: style.letterSpacing,
+ padding: style.padding, autospace: style.getPropertyValue("text-autospace"),
+ };
+ });
+}
+
+async function metrics(element: Locator): Promise<NonNullable<Awaited<ReturnType<typeof readMetrics>>>> {
+ let value: Awaited<ReturnType<typeof readMetrics>> = null;
+ // Streamdown may replace a paragraph while settling its first render.
+ await expect.poll(async () => {
+ value = await readMetrics(element);
+ return value !== null && Number.isFinite(value.size) && Number.isFinite(value.line);
+ }).toBe(true);
+ return value!;
+}
+
+for (const narrow of [false, true]) {
+ for (const dark of [false, true]) {
+ test(`reading hierarchy and stable controls: ${narrow ? "narrow" : "desktop"}, ${dark ? "dark" : "light"}`, async ({ page }, info) => {
+ await page.setViewportSize(narrow ? { width: 390, height: 844 } : { width: 1440, height: 1000 });
+ await page.addInitScript((theme) => {
+ localStorage.setItem("nanobot.locale", "zh-CN");
+ localStorage.setItem("nanobot-webui.theme", theme);
+ }, dark ? "dark" : "light");
+ await page.goto("/browser/fixture.html?case=typography");
+ const group = page.getByRole("radiogroup", { name: "阅读字号", exact: true });
+ await expect(group.getByRole("radio", { name: "阅读字号:标准", exact: true })).toBeChecked();
+ const heights = await group.evaluate((control) => {
+ const row = control.closest(".settings-row")!;
+ const nextRow = row.nextElementSibling!;
+ return {
+ readingRow: row.getBoundingClientRect().height,
+ otherRow: nextRow.getBoundingClientRect().height,
+ readingControl: control.getBoundingClientRect().height,
+ otherControl: nextRow.querySelector(".segmented-control")!.getBoundingClientRect().height,
+ };
+ });
+ expect(heights.readingRow).toBe(heights.otherRow);
+ expect(heights.readingControl).toBe(heights.otherControl);
+ const stable = await metrics(page.locator(".settings-row").first().locator(".text-control-label"));
+ const observations = [];
+ for (const [size, label, bodySize] of [
+ ["small", "阅读字号:小", narrow ? 15 : 16],
+ ["standard", "阅读字号:标准", narrow ? 16 : 18],
+ ["large", "阅读字号:大", narrow ? 18 : 20],
+ ] as const) {
+ await group.getByRole("radio", { name: label, exact: true }).click();
+ await expect(page.locator("html")).toHaveAttribute("data-reading-text-size", size);
+ const paragraph = page.locator(".markdown-content p").first();
+ await expect(paragraph).toHaveCSS("font-size", `${bodySize}px`);
+ const body = await metrics(paragraph);
+ expect(body.size).toBe(bodySize);
+ expect(body.line).toBeCloseTo(bodySize * 1.8);
+ expect(body.weight).toBe("400");
+ expect((await metrics(page.locator("[data-user-text-bubble] p"))).size).toBe(bodySize);
+ for (const selector of ["blockquote", "ol > li", ".task-list-item"]) {
+ expect((await metrics(page.locator(`.markdown-content ${selector}`).first())).size).toBe(bodySize);
+ }
+ for (const [selector, ratio] of [["h1", 1.5], ["h2", 1.25], ["h3", 1.125], ["h4", 1]] as const) {
+ const heading = await metrics(page.locator(`.markdown-content ${selector}`));
+ expect(heading.size).toBeCloseTo(bodySize * ratio);
+ expect(heading.weight).toBe("600");
+ }
+ for (const selector of ["table", "th", "td"]) {
+ expect((await metrics(page.locator(`.markdown-content ${selector}`).first())).size).toBeCloseTo(bodySize * 0.875);
+ }
+ expect((await metrics(page.locator(".code-content pre"))).size).toBeCloseTo(bodySize * 0.875);
+ expect((await metrics(page.locator(".markdown-inline-code"))).size).toBeCloseTo(bodySize * 0.875);
+ expect((await metrics(page.locator("textarea"))).size).toBe(Math.max(16, bodySize));
+ expect(await metrics(page.locator(".settings-row").first().locator(".text-control-label"))).toEqual(stable);
+ const widths = await group.getByRole("radio").evaluateAll((nodes) => nodes.map(node => node.getBoundingClientRect().width));
+ expect(Math.max(...widths) - Math.min(...widths)).toBeLessThan(1);
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
+ observations.push({ size, body, widths });
+ await page.locator(".markdown-content h1").evaluate(node => node.scrollIntoView({ block: "start" }));
+ await page.screenshot({ path: info.outputPath(`${size}.png`) });
+ }
+ await info.attach("text-metrics", { body: JSON.stringify(observations, null, 2), contentType: "application/json" });
+ await page.getByRole("button", { name: "复制代码", exact: true }).click();
+ await expect(page.getByRole("button", { name: "已复制", exact: true })).toBeVisible();
+ await page.locator("summary").click();
+ await expect(page.getByText("这里的正文与折叠标题也应保持协调,不因字号变化发生裁切。")).toBeVisible();
+ });
+ }
+}
+
+test("keyboard, tooltip, persistence and unchanged preferences", async ({ page }) => {
+ await page.addInitScript(() => {
+ localStorage.setItem("nanobot.locale", "en");
+ if (!localStorage.getItem("nanobot-webui.settings-preferences")) {
+ localStorage.setItem("nanobot-webui.settings-preferences", JSON.stringify({
+ schemaVersion: 1, codeWrap: false, brandLogos: false, activityMode: "expanded", notificationSound: true,
+ }));
+ }
+ });
+ await page.goto("/browser/fixture.html?case=typography");
+ const standard = page.getByRole("radio", { name: "Standard reading text", exact: true });
+ await standard.focus();
+ await expect(page.getByRole("tooltip")).toHaveText("Standard reading text");
+ expect(await standard.evaluate(node => node.matches(":focus-visible"))).toBe(true);
+ await page.keyboard.press("ArrowRight");
+ const large = page.getByRole("radio", { name: "Large reading text", exact: true });
+ await expect(large).toBeFocused();
+ await expect(large).toBeChecked();
+ await expect(page.locator(".markdown-content p").first()).toHaveCSS("line-height", `${20 * 1.625}px`);
+ await page.reload();
+ await expect(page.getByRole("radio", { name: "Large reading text", exact: true })).toBeChecked();
+ expect(await page.evaluate(() => JSON.parse(localStorage.getItem("nanobot-webui.settings-preferences")!))).toMatchObject({
+ readingTextSize: "large", codeWrap: false, brandLogos: false, activityMode: "expanded", notificationSound: true,
+ });
+});
+
+test("touch composer keeps literal mention metrics and a safe editable minimum", async ({ browser, baseURL }, info) => {
+ const context = await browser.newContext({ baseURL, viewport: { width: 390, height: 844 }, hasTouch: true, isMobile: true });
+ try {
+ const page = await context.newPage();
+ await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
+ await page.goto("/browser/fixture.html?case=typography");
+ const readingGroup = page.getByRole("radiogroup", { name: "Reading text size", exact: true });
+ await expect(readingGroup.getByRole("radio")).toHaveCount(3);
+ const heights = await readingGroup.evaluate((control) => {
+ const row = control.closest(".settings-row")!;
+ const nextRow = row.nextElementSibling!;
+ return [row.getBoundingClientRect().height, nextRow.getBoundingClientRect().height];
+ });
+ expect(heights[0]).toBe(heights[1]);
+ const radios = await readingGroup.getByRole("radio").all();
+ for (const [index, radio] of radios.entries()) {
+ await radio.scrollIntoViewIfNeeded();
+ const target = await radio.boundingBox();
+ expect(target!.width).toBeGreaterThanOrEqual(44);
+ // The shared switch pattern extends the hit area without growing the pill.
+ for (const edge of [-21, 21]) {
+ await radios[(index + 1) % radios.length].tap();
+ await page.touchscreen.tap(target!.x + target!.width / 2, target!.y + target!.height / 2 + edge);
+ await expect(radio).toBeChecked();
+ }
+ }
+ const input = page.getByRole("textbox", { name: "Message input", exact: true });
+ await input.fill("中文 English @typography 混排\n多行内容与光标保持一致,继续输入 more text.\n最后一行。");
+ for (const label of ["Small reading text", "Standard reading text", "Large reading text"]) {
+ await page.getByRole("radio", { name: label, exact: true }).click();
+ await input.focus();
+ const overlay = page.locator(".thread-composer-input > div[aria-hidden]");
+ await expect(overlay).toContainText("@typography");
+ const text = await metrics(input);
+ expect(text.size).toBeGreaterThanOrEqual(16);
+ expect(await metrics(overlay)).toEqual(text);
+ expect(text.autospace).toBe("no-autospace");
+ expect(await input.evaluate(node => node.scrollHeight <= node.clientHeight + 1)).toBe(true);
+ expect(await page.evaluate(() => visualViewport?.scale)).toBe(1);
+ }
+ await input.fill([...Array.from({ length: 18 }, (_, i) => `第 ${i + 1} 行 中文 English @typography 光标与装饰层。`), "最后一行。"].join("\n"));
+ for (const label of ["Small reading text", "Standard reading text", "Large reading text"]) {
+ await page.getByRole("radio", { name: label, exact: true }).click();
+ await input.focus();
+ await input.press("Control+End");
+ const overlay = page.locator(".thread-composer-input > div[aria-hidden]");
+ expect(await input.evaluate(node => node.scrollHeight > node.clientHeight)).toBe(true);
+ await expect.poll(async () => Math.abs(await input.evaluate(node => node.scrollTop) - await overlay.evaluate(node => node.scrollTop))).toBeLessThanOrEqual(1);
+ expect(await metrics(overlay)).toEqual(await metrics(input));
+ }
+ await page.keyboard.press("End");
+ await page.keyboard.type("追加文字");
+ await expect(input).toHaveValue(/最后一行。追加文字$/);
+ await page.screenshot({ path: info.outputPath("touch-mention-caret.png") });
+ await page.getByRole("button", { name: "Send message", exact: true }).click();
+ await expect(page.locator("[data-user-text-bubble]").last()).toContainText("最后一行。追加文字");
+ } finally {
+ await context.close();
+ }
+});
+
+
+test("large narrow reading keeps long lists and code reachable", async ({ page }) => {
+ await page.setViewportSize({ width: 390, height: 844 });
+ await page.addInitScript(() => {
+ localStorage.setItem("nanobot.locale", "en");
+ localStorage.setItem("nanobot-webui.settings-preferences", JSON.stringify({ schemaVersion: 1, readingTextSize: "large" }));
+ });
+ await page.goto("/browser/fixture.html?case=typography&stress");
+ const lastItem = page.getByText("第 30 项:中文与 English 混排的长列表内容,保持自然换行和清楚的编号。", { exact: true });
+ await lastItem.click();
+ await expect(lastItem).toBeVisible();
+ await expect(lastItem).toHaveCSS("font-size", "18px");
+ const pre = page.locator(".code-content pre").last();
+ await expect(pre).toContainText('const item79 = "第 80 行 — readable code";');
+ await expect(pre).toHaveCSS("font-size", "15.75px");
+ const finalLine = pre.getByText('"第 80 行 — readable code"', { exact: true });
+ await finalLine.click();
+ await expect(finalLine).toBeVisible();
+ expect(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth)).toBe(true);
+ await page.getByRole("button", { name: "Copy code", exact: true }).last().click();
+ await expect(page.getByRole("button", { name: "Copied", exact: true })).toBeVisible();
+ const input = page.getByRole("textbox", { name: "Message input", exact: true });
+ await input.fill("读完长内容后仍然可以发送。Still usable.");
+ await page.getByRole("button", { name: "Send message", exact: true }).click();
+ await expect(page.locator("[data-user-text-bubble]").last()).toContainText("Still usable.");
+});
diff --git a/webui/src/App.tsx b/webui/src/App.tsx
index c49804e6c..373a1dfa4 100644
--- a/webui/src/App.tsx
+++ b/webui/src/App.tsx
@@ -59,6 +59,7 @@ import { useMediaQuery } from "@/hooks/useMediaQuery";
import { useAppViewport } from "@/hooks/useAppViewport";
import type { SendAttachment, SendOptions } from "@/hooks/useNanobotStream";
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
+import { useReadingTypography } from "@/hooks/useReadingTypography";
import { logoFallbackUrls } from "@/lib/provider-brand";
import { cn } from "@/lib/utils";
import {
@@ -940,6 +941,7 @@ function resolveRuntimeSurface(
export default function App() {
useAppViewport();
useBrowserNotificationLifecycle();
+ useReadingTypography();
const { t } = useTranslation();
const [state, setState] = useState<BootState>({ status: "loading" });
const bootstrapSecretRef = useRef("");
diff --git a/webui/src/components/ChatList.tsx b/webui/src/components/ChatList.tsx
index 468cffca7..bcf9541f8 100644
--- a/webui/src/components/ChatList.tsx
+++ b/webui/src/components/ChatList.tsx
@@ -992,7 +992,7 @@ export const ChatList = memo(function ChatList({
actionMenus.openFromContextMenu(event, actionMenuId)
)}
className={cn(
- "group flex min-w-0 max-w-full items-center gap-1 rounded-control px-2 text-[13px] font-normal leading-5",
+ "group flex min-w-0 max-w-full items-center gap-1 rounded-control px-2 text-ui",
SIDEBAR_SELECTION_ITEM_CLASS,
compact ? "min-h-7" : "min-h-8",
topicActive
@@ -1451,7 +1451,7 @@ function ActivePaneRows({
actionMenus.openFromContextMenu(event, actionMenuId)
)}
className={cn(
- "group/pane flex min-w-0 max-w-full items-center gap-1 rounded-control px-2 text-[13px] font-normal leading-5",
+ "group/pane flex min-w-0 max-w-full items-center gap-1 rounded-control px-2 text-ui",
SIDEBAR_SELECTION_ITEM_CLASS,
compact ? "min-h-7" : "min-h-8",
active
@@ -1674,7 +1674,7 @@ function TemporaryChatSection({
data-temporary-chat-row={session.key}
data-chat-row={session.key}
className={cn(
- "group flex min-h-8 min-w-0 max-w-full items-center gap-2 rounded-control px-2 text-[13px] font-normal leading-5",
+ "group flex min-h-8 min-w-0 max-w-full items-center gap-2 rounded-control px-2 text-ui",
SIDEBAR_SELECTION_ITEM_CLASS,
active
? "text-sidebar-accent-foreground"
diff --git a/webui/src/components/CodeBlock.tsx b/webui/src/components/CodeBlock.tsx
index cc30222e5..0d581af56 100644
--- a/webui/src/components/CodeBlock.tsx
+++ b/webui/src/components/CodeBlock.tsx
@@ -28,18 +28,6 @@ interface HighlightedCodeProps {
viewportHighlight: boolean;
}
-const CODE_FONT_STACK = [
- '"JetBrains Mono"',
- '"SFMono-Regular"',
- '"SF Mono"',
- '"Fira Code"',
- '"Cascadia Code"',
- '"Source Code Pro"',
- "Menlo",
- "Consolas",
- "monospace",
-].join(", ");
-
const ANSI_LANGUAGES = new Set(["ansi", "ansi-output"]);
const LazyHighlightedCode = lazy(async () => {
@@ -69,9 +57,9 @@ const LazyHighlightedCode = lazy(async () => {
background: "transparent",
margin: 0,
padding: chrome === "none" ? "0.75rem 1rem" : "1rem 3.5rem 1rem 1.25rem",
- fontFamily: CODE_FONT_STACK,
- fontSize: "13px",
- lineHeight: chrome === "none" ? 1.55 : 1.6,
+ fontFamily: "inherit",
+ fontSize: "inherit",
+ lineHeight: "inherit",
tabSize: 2,
// FilePreviewPanel owns both scroll axes. Replacing this <pre>
// during progressive highlighting must not reset horizontal scroll.
@@ -80,7 +68,8 @@ const LazyHighlightedCode = lazy(async () => {
codeTagProps={{
style: {
background: "transparent",
- fontFamily: CODE_FONT_STACK,
+ fontFamily: "inherit",
+ fontSize: "inherit",
...(viewportHighlight ? { lineHeight: "inherit" } : {}),
},
}}
@@ -88,7 +77,7 @@ const LazyHighlightedCode = lazy(async () => {
minWidth: "2.6em",
paddingRight: "1.15rem",
color: "var(--code-comment)",
- fontFamily: CODE_FONT_STACK,
+ fontFamily: "inherit",
userSelect: "none",
}}
PreTag="pre"
@@ -136,16 +125,15 @@ function CodeTextBlock({
return (
<pre
className={cn(
- "m-0 bg-transparent font-mono text-[13px] text-foreground/90",
+ "m-0 bg-transparent font-mono text-code text-foreground/90",
compact ? "overflow-visible" : "overflow-x-auto",
showLineNumbers ? "whitespace-pre" : "whitespace-pre-wrap",
chrome === "default"
- ? "py-4 pl-5 pr-14 leading-[1.6]"
- : compact ? "px-4 py-3 leading-[1.55]" : "p-3 leading-[1.55]",
+ ? "py-4 pl-5 pr-14"
+ : compact ? "px-4 py-3" : "p-3",
className,
)}
data-testid={testId}
- style={compact ? { fontFamily: CODE_FONT_STACK } : undefined}
>
<code className="text-inherit">
{showLineNumbers && compact ? (
@@ -246,7 +234,7 @@ export const CodeBlock = memo(function CodeBlock({
<div
ref={rootRef}
className={cn(
- "not-prose relative code-content",
+ "not-prose relative code-content font-mono text-code",
useViewportHighlight ? "overflow-visible" : "overflow-hidden",
hasChrome && "rounded-floating bg-secondary/70",
className,
diff --git a/webui/src/components/FilePreviewPanelView.tsx b/webui/src/components/FilePreviewPanelView.tsx
index f38620de0..5dc7de6d2 100644
--- a/webui/src/components/FilePreviewPanelView.tsx
+++ b/webui/src/components/FilePreviewPanelView.tsx
@@ -58,17 +58,17 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
<div className="aspect-[8/5] w-full max-w-sm rounded-compact bg-muted/40" />
</div> : <>
{previewKind === "markdown" ? <div className="flex justify-end px-4 py-2">
- <div className="inline-flex min-h-8 items-center gap-1 rounded-full bg-muted/40 p-1 text-[12px] font-medium">
+ <div className="inline-flex min-h-8 items-center gap-1 rounded-full bg-muted/40 p-1 text-ui-label">
{[t("filePreview.preview"), t("filePreview.source")].map((label) => <span key={label} className="invisible px-3 py-1 [@media(pointer:coarse)]:min-h-9">{label}</span>)}
</div>
</div> : null}
- {previewKind === "markdown" && mode === "preview" ? <div className="px-5 pb-6 pt-1 text-sm sm:px-6">
- <div className="flex h-7 items-center"><div className="h-5 w-2/3 rounded bg-muted/40" /></div>
- {["w-full", "w-5/6", "w-3/4"].map((width) => <div key={width} className="mt-4 flex h-[1.625em] items-center">
+ {previewKind === "markdown" && mode === "preview" ? <div className="markdown-content px-5 pb-6 pt-1 sm:px-6">
+ <h1 data-file-preview-heading-skeleton className="flex h-[1lh] items-center"><div className="h-[0.75em] w-2/3 rounded bg-muted/40" /></h1>
+ {["w-full", "w-5/6", "w-3/4"].map((width) => <div key={width} className="mt-4 flex h-[1lh] items-center">
<div className={`h-3 rounded bg-muted/40 ${width}`} />
</div>)}
- </div> : <div className="px-4 py-3 font-mono text-[13px] leading-[1.55]">
- {["w-2/3", "w-full", "w-5/6", "w-3/4", "w-1/2", "w-3/5"].map((width) => <div key={width} className="flex h-[1.55em] items-center">
+ </div> : <div className="px-4 py-3 font-mono text-code">
+ {["w-2/3", "w-full", "w-5/6", "w-3/4", "w-1/2", "w-3/5"].map((width) => <div key={width} className="flex h-[1lh] items-center">
<div className="w-[4.25em] shrink-0 pr-[1.15rem]"><div className="ml-auto h-3 w-2 rounded bg-muted/40" /></div>
<div className={`h-3 max-w-[calc(100%-4.25em)] rounded bg-muted/40 ${width}`} />
</div>)}
@@ -111,7 +111,7 @@ export function FilePreviewPanelView({ path, state, imageOpen, onImageOpenChange
) : null}
{markdown && mode === "preview" ? (
<MarkdownText documentPath={state.payload.path} onOpenFilePreview={onOpenFilePreview}
- className="px-5 pb-6 pt-1 text-sm [overflow-wrap:anywhere] sm:px-6 [&>:first-child]:mt-0">
+ className="px-5 pb-6 pt-1 [overflow-wrap:anywhere] sm:px-6 [&>:first-child]:mt-0">
{state.payload.content}
</MarkdownText>
) : <CodeBlock
diff --git a/webui/src/components/MarkdownText.tsx b/webui/src/components/MarkdownText.tsx
index 42fb4c601..8b9792293 100644
--- a/webui/src/components/MarkdownText.tsx
+++ b/webui/src/components/MarkdownText.tsx
@@ -97,7 +97,7 @@ export function MarkdownText({
const plainFallback = (
<div
className={cn(
- "whitespace-pre-wrap break-words leading-relaxed text-foreground/92",
+ "whitespace-pre-wrap break-words text-reading text-foreground/92",
streaming && "streaming-text-fallback",
className,
)}
diff --git a/webui/src/components/MarkdownTextRenderer.tsx b/webui/src/components/MarkdownTextRenderer.tsx
index 2d56c40d7..9be380c4c 100644
--- a/webui/src/components/MarkdownTextRenderer.tsx
+++ b/webui/src/components/MarkdownTextRenderer.tsx
@@ -619,8 +619,8 @@ export default function MarkdownTextRenderer({
return (
<code
className={cn(
- "block min-w-0 max-w-full overflow-x-auto whitespace-pre bg-transparent p-0 font-mono text-[0.8125rem]",
- "leading-snug text-inherit",
+ "block min-w-0 max-w-full overflow-x-auto whitespace-pre bg-transparent p-0 font-mono text-code",
+ "text-inherit",
cls,
)}
{...props}
@@ -632,7 +632,7 @@ export default function MarkdownTextRenderer({
return (
<code
className={cn(
- "rounded bg-muted px-1 py-0.5 font-mono text-[0.85em]",
+ "markdown-inline-code rounded bg-muted px-1 py-0.5 font-mono",
cls,
)}
{...props}
@@ -654,7 +654,7 @@ export default function MarkdownTextRenderer({
<pre
className={cn(
"my-3 overflow-x-auto rounded-lg border border-border/60 bg-muted/35",
- "p-3 font-mono text-[0.8125rem] leading-snug text-foreground/90",
+ "p-3 font-mono text-code text-foreground/90",
"whitespace-pre [overflow-wrap:normal]",
)}
>
@@ -755,7 +755,7 @@ export default function MarkdownTextRenderer({
>
<table
className={cn(
- "w-full table-fixed border-collapse text-[13px] leading-5",
+ "w-full table-fixed border-collapse text-reading-small",
"[&_thead]:bg-muted/45 [&_thead]:text-muted-foreground",
"[&_th]:border-b [&_th]:border-border/65 [&_th]:px-3 [&_th]:py-2",
"[&_th]:text-left [&_th]:font-medium [&_th]:whitespace-normal",
@@ -793,7 +793,7 @@ export default function MarkdownTextRenderer({
className={cn(
itemClassName,
taskItem
- ? "flex min-w-0 items-start gap-2 text-[13px] leading-5 [&>p]:m-0"
+ ? "flex min-w-0 items-start gap-2 [&>p]:m-0"
: "[&>p]:inline",
)}
>
@@ -809,12 +809,12 @@ export default function MarkdownTextRenderer({
data-testid="markdown-task-checkbox"
data-task-checked={checked ? "true" : "false"}
className={cn(
- "mt-0.5 inline-grid h-4 w-4 shrink-0 place-items-center rounded-full",
+ "mt-[0.35em] inline-grid h-[1em] w-[1em] shrink-0 place-items-center rounded-full",
"border border-dashed border-muted-foreground/55 bg-background text-background",
checked && "border-solid border-emerald-500 bg-emerald-500 text-white",
)}
>
- {checked ? <Check className="h-3 w-3 stroke-[3]" /> : null}
+ {checked ? <Check className="h-[0.75em] w-[0.75em] stroke-[3]" /> : null}
</span>
);
},
@@ -840,7 +840,7 @@ export default function MarkdownTextRenderer({
},
summary({ children: markdownChildren }) {
return (
- <summary className="cursor-pointer select-none text-sm font-medium text-foreground/88 marker:text-muted-foreground">
+ <summary className="cursor-pointer select-none text-foreground/88 marker:text-muted-foreground">
{markdownChildren}
</summary>
);
@@ -887,8 +887,7 @@ export default function MarkdownTextRenderer({
components={components}
className={cn(
"markdown-content prose max-w-none dark:prose-invert",
- "prose-headings:mt-4 prose-headings:mb-2 prose-headings:font-semibold prose-headings:tracking-tight",
- "prose-h1:text-lg prose-h2:text-base prose-h3:text-sm prose-h4:text-[13px]",
+ "prose-headings:mt-4 prose-headings:mb-2 prose-headings:tracking-tight",
"prose-p:my-2",
"prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5",
"prose-blockquote:my-3 prose-blockquote:border-l-2 prose-blockquote:font-normal",
diff --git a/webui/src/components/MessageBubble.tsx b/webui/src/components/MessageBubble.tsx
index ed898496a..899224625 100644
--- a/webui/src/components/MessageBubble.tsx
+++ b/webui/src/components/MessageBubble.tsx
@@ -390,8 +390,7 @@ function IncomingSessionMessage({
return (
<div
data-session-message
- className="group relative w-full text-[15px]"
- style={{ lineHeight: "var(--cjk-line-height)" }}
+ className="group relative w-full text-reading"
>
{contextMenu}
<div
@@ -503,7 +502,7 @@ export function MessageBubble({
data-temporary-message={temporary ? "true" : undefined}
className={cn(
"ml-auto w-fit max-w-full min-w-0 rounded-floating px-4 py-2",
- "text-left text-[16px]/[1.75] whitespace-pre-wrap [overflow-wrap:anywhere]",
+ "text-left text-reading whitespace-pre-wrap [overflow-wrap:anywhere]",
temporary
? "border border-dashed border-muted-foreground/40 bg-transparent"
: "bg-secondary/70",
@@ -537,8 +536,7 @@ export function MessageBubble({
return (
<div
data-assistant-message
- className="group/assistant relative w-full text-[15px]"
- style={{ lineHeight: "var(--cjk-line-height)" }}
+ className="group/assistant relative w-full text-reading"
>
{contextMenu}
{hasReasoning ? (
@@ -579,7 +577,7 @@ function UserQuotedContext({ text, label }: { text: string; label: string }) {
aria-label={label}
>
<Quote className="mt-0.5 h-3.5 w-3.5 shrink-0" aria-hidden />
- <p className="min-w-0 line-clamp-3 whitespace-pre-wrap text-[13px]/[1.45] [overflow-wrap:anywhere]">
+ <p className="min-w-0 line-clamp-3 whitespace-pre-wrap text-reading-small [overflow-wrap:anywhere]">
{text}
</p>
</blockquote>
diff --git a/webui/src/components/settings/SettingsSidebar.tsx b/webui/src/components/settings/SettingsSidebar.tsx
index 5845875f7..918757ab7 100644
--- a/webui/src/components/settings/SettingsSidebar.tsx
+++ b/webui/src/components/settings/SettingsSidebar.tsx
@@ -103,7 +103,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
onClick={onBackToChat}
aria-label={t("settings.backToChat")}
className={cn(
- "touch-target mb-2 inline-flex h-9 w-9 items-center justify-center rounded-xl text-[13px] leading-5 font-normal text-sidebar-content transition-colors duration-150 motion-reduce:transition-none focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-ring hover:text-foreground lg:mb-3",
+ "touch-target mb-2 inline-flex h-9 w-9 items-center justify-center rounded-xl text-ui text-sidebar-content transition-colors duration-150 motion-reduce:transition-none focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-ring hover:text-foreground lg:mb-3",
hostChromeInset && "-ml-1",
)}
>
@@ -130,7 +130,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
aria-current={active ? "page" : undefined}
onClick={() => onSelectSection(key)}
className={cn(
- "touch-target flex h-9 w-full items-center gap-2 rounded-xl px-2.5 text-left text-[13px] leading-5 font-normal",
+ "touch-target flex h-9 w-full items-center gap-2 rounded-xl px-2.5 text-left text-ui",
SIDEBAR_SELECTION_ITEM_CLASS,
active
? "text-sidebar-accent-foreground"
@@ -161,7 +161,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
onClick={onRestart}
disabled={isRestarting}
aria-describedby={restartPending ? "settings-restart-status" : undefined}
- className={cn("h-9 w-full justify-start gap-2 rounded-control px-2.5 text-[13px] leading-5 font-normal settings-hover",
+ className={cn("h-9 w-full justify-start gap-2 rounded-control px-2.5 text-ui settings-hover",
restartPending && !isRestarting
? "settings-restart-pending text-orange-600 hover:text-orange-700 dark:text-orange-400 dark:hover:text-orange-300"
: "text-sidebar-content hover:text-foreground")}
@@ -177,7 +177,7 @@ export function SettingsSidebar(props: SettingsSidebarProps) {
type="button"
variant="ghost"
onClick={onLogout}
- className="hidden h-9 w-full justify-start gap-2 rounded-control px-2.5 text-[13px] leading-5 font-normal text-sidebar-content hover:bg-destructive/8 hover:text-destructive lg:flex"
+ className="hidden h-9 w-full justify-start gap-2 rounded-control px-2.5 text-ui text-sidebar-content hover:bg-destructive/8 hover:text-destructive lg:flex"
>
<LogOut className="h-4 w-4" aria-hidden />
<span>{t("app.account.logout")}</span>
diff --git a/webui/src/components/settings/overview/AppearanceSettingsView.tsx b/webui/src/components/settings/overview/AppearanceSettingsView.tsx
index 576543cee..de7fbb246 100644
--- a/webui/src/components/settings/overview/AppearanceSettingsView.tsx
+++ b/webui/src/components/settings/overview/AppearanceSettingsView.tsx
@@ -50,6 +50,28 @@ export function AppearanceSettingsView({
<section>
<SettingsSectionTitle>{tx("settings.sections.localPreferences", "Local preferences")}</SettingsSectionTitle>
<SettingsGroup>
+ <SettingsRow title={t("settings.rows.readingTextSize")}>
+ <SegmentedControl
+ value={localPrefs.readingTextSize}
+ mode="radio"
+ ariaLabel={t("settings.rows.readingTextSize")}
+ className="w-36 [@media(pointer:coarse)]:w-40"
+ itemClassName="flex flex-1 basis-0 items-center justify-center !overflow-visible px-0 after:absolute after:inset-x-0 after:top-1/2 after:h-11 after:-translate-y-1/2 after:content-['']"
+ options={([
+ ["small", "text-[12px]"],
+ ["standard", "text-[16px]"],
+ ["large", "text-[20px]"],
+ ] as const).map(([value, size]) => ({
+ value,
+ label: <span aria-hidden className={size}>A</span>,
+ ariaLabel: t(`settings.readingTextSize.${value}`),
+ tooltip: t(`settings.readingTextSize.${value}`),
+ }))}
+ onChange={(readingTextSize) =>
+ onChangeLocalPrefs((prev) => ({ ...prev, readingTextSize }))
+ }
+ />
+ </SettingsRow>
<SettingsRow title={tx("settings.rows.activityMode", "Activity detail")}>
<SegmentedControl
value={localPrefs.activityMode}
diff --git a/webui/src/components/settings/shared/SettingsControls.tsx b/webui/src/components/settings/shared/SettingsControls.tsx
index 641d58dee..64e4c1834 100644
--- a/webui/src/components/settings/shared/SettingsControls.tsx
+++ b/webui/src/components/settings/shared/SettingsControls.tsx
@@ -68,7 +68,7 @@ export function NanobotFeatureInstallDialog({
className="w-[min(calc(100vw-2rem),24rem)] gap-0 p-5 text-center"
>
<DialogHeader className="items-center space-y-0 text-center">
- <DialogTitle className="text-center text-[20px] font-semibold leading-tight tracking-[-0.02em] text-foreground">
+ <DialogTitle className="text-center text-title tracking-[-0.02em] text-foreground">
{tx("settings.nanobotFeatures.installConfirmTitle", "Install support for {{name}}?", { name })}
</DialogTitle>
<DialogDescription className="mt-3 max-w-[20rem] text-center text-[14px] leading-6 text-muted-foreground">
@@ -189,7 +189,7 @@ export function RestartRequiredNotice({
export function SettingsSectionTitle({ children }: { children: ReactNode }) {
return (
- <h2 className="settings-section-title select-none text-[13px] font-semibold tracking-[-0.01em] text-foreground/85">
+ <h2 className="settings-section-title select-none text-ui-heading tracking-[-0.01em] text-foreground/85">
{children}
</h2>
);
@@ -215,7 +215,7 @@ export function SettingsRow({
return (
<div className="settings-row rounded-xl transition-colors settings-hover focus-within:bg-sidebar-accent/60">
<div className="min-w-0">
- <div className="select-none text-[14px] font-medium leading-5 text-foreground">
+ <div className="select-none text-control-label text-foreground">
{description ? <SettingsHint description={description}>{title}</SettingsHint> : title}
</div>
</div>
@@ -235,7 +235,7 @@ export function ReadOnlyRow({
}) {
return (
<SettingsRow title={title} description={description}>
- <span className="block max-w-full truncate text-left text-[13px] text-muted-foreground sm:max-w-[320px] sm:text-right">
+ <span className="block max-w-full truncate text-left text-ui text-muted-foreground sm:max-w-[320px] sm:text-right">
{value}
</span>
</SettingsRow>
diff --git a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
index 5c9cac626..cd0e21897 100644
--- a/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
+++ b/webui/src/components/settings/shared/SettingsSectionSkeleton.tsx
@@ -7,7 +7,7 @@ import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { RUNTIME_CONFIG_FIELDS, RUNTIME_CONFIG_GROUPS, type RuntimeConfigPage } from "@/components/settings/system/runtime-config-fields";
import { cn } from "@/lib/utils";
-type Control = "switch" | "input" | "duration" | "segments" | "theme" | "edit" | "text" | "feature";
+type Control = "switch" | "input" | "duration" | "segments" | "reading" | "theme" | "edit" | "text" | "feature";
const block = "rounded bg-muted-foreground/20";
function Title({ heading = false }: { heading?: boolean }) {
@@ -22,10 +22,11 @@ function Row({ control }: { control: Control }) {
<div className="flex h-5 items-center"><div className={cn(block, "h-3.5 w-32 max-w-full")} /></div>
<div className="settings-control">
{control === "feature" ? <div className={cn(block, "mr-3 h-3 w-14")} /> : null}
- {control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} className={cn(block,
+ {control === "duration" ? <div className="w-full"><div className={cn(block, "h-9 w-full rounded-full")} /><div className="mt-1.5 flex h-4 items-center"><div className={cn(block, "h-2.5 w-4/5 opacity-60")} /></div></div> : <div data-skeleton-switch={toggle ? "" : undefined} data-skeleton-reading-size={control === "reading" ? "" : undefined} className={cn(block,
toggle ? "h-5 w-9 shrink-0 rounded-full" : control === "input" ? "h-9 w-full rounded-full"
- : control === "segments" || control === "theme" ? "segmented-control w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[19.5px] w-24",
- control === "segments" && "h-[34px]", control === "theme" && "h-8",
+ : control === "segments" || control === "reading" || control === "theme" ? "segmented-control w-44 rounded-full" : control === "edit" ? "ml-auto h-9 w-9 rounded-full" : "h-[1lh] w-24 text-ui",
+ (control === "segments" || control === "reading") && "h-[34px]", control === "theme" && "h-8",
+ control === "reading" && "w-36 [@media(pointer:coarse)]:w-40",
)} />}
</div>
</div>;
@@ -52,7 +53,7 @@ export function SettingsSectionSkeleton({ section, showRestart = false }: { sect
</>;
else switch (section) {
case "appearance":
- content = <><Group controls={["theme", "input"]} /><Group controls={["segments", "segments", "switch", "switch"]} /></>;
+ content = <><Group controls={["theme", "input"]} /><Group controls={["reading", "segments", "segments", "switch", "switch"]} /></>;
break;
case "notifications":
content = <section><Title /><SettingsGroup>
diff --git a/webui/src/components/settings/system/AutomationRunDialogView.tsx b/webui/src/components/settings/system/AutomationRunDialogView.tsx
index 3f2d44f29..0045a4f31 100644
--- a/webui/src/components/settings/system/AutomationRunDialogView.tsx
+++ b/webui/src/components/settings/system/AutomationRunDialogView.tsx
@@ -82,7 +82,7 @@ export function AutomationRunDialogView({ job, run, locale, open, result, onRetr
</Button>
</div>
) : result.response?.trim() ? (
- <MarkdownText className="min-w-0 text-sm [overflow-wrap:anywhere]">{result.response}</MarkdownText>
+ <MarkdownText className="min-w-0 [overflow-wrap:anywhere]">{result.response}</MarkdownText>
) : (
<p className="text-muted-foreground">{t(result.response === null
? "settings.automations.runDetails.noOutput"
diff --git a/webui/src/components/thread/AgentActivityCluster.tsx b/webui/src/components/thread/AgentActivityCluster.tsx
index d9d337885..429022a8b 100644
--- a/webui/src/components/thread/AgentActivityCluster.tsx
+++ b/webui/src/components/thread/AgentActivityCluster.tsx
@@ -593,8 +593,7 @@ function ActivityModelMessage({
<div
data-testid="activity-model-message"
data-assistant-selectable={active && message.isStreaming ? undefined : "true"}
- className="w-full min-w-0 py-1 text-[15px]"
- style={{ lineHeight: "var(--cjk-line-height)" }}
+ className="w-full min-w-0 py-1 text-reading"
>
<MarkdownText
streaming={active && !!message.isStreaming}
diff --git a/webui/src/components/thread/PromptRail.tsx b/webui/src/components/thread/PromptRail.tsx
index dc1333719..349bcfa72 100644
--- a/webui/src/components/thread/PromptRail.tsx
+++ b/webui/src/components/thread/PromptRail.tsx
@@ -178,7 +178,7 @@ export const PromptRail = memo(function PromptRail({ messages, prompts, onJumpTo
style={{ top: Math.max(60, Math.min(height - 60, padding + focused * GAP - scrollTop)) }}>
<div className="line-clamp-2 whitespace-pre-wrap break-words text-[15px] font-semibold leading-6">{preview.preview || preview.label}</div>
{preview.answerPreview ? <div className="mt-1.5 max-h-[4.5rem] overflow-hidden break-words text-sm leading-6 text-muted-foreground">
- <MarkdownText className="max-w-none text-sm leading-6 prose-headings:my-0 prose-headings:text-sm prose-p:my-0">{preview.answerPreview}</MarkdownText>
+ <MarkdownText className="max-w-none prose-headings:my-0 prose-p:my-0">{preview.answerPreview}</MarkdownText>
</div> : null}
</div> : null}
</div>;
diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsx
index 81e4d2d2c..33923215a 100644
--- a/webui/src/components/thread/ThreadComposer.tsx
+++ b/webui/src/components/thread/ThreadComposer.tsx
@@ -143,6 +143,7 @@ import {
import { formatQuotedUserMessage } from "@/lib/user-message-quote";
import { cn } from "@/lib/utils";
import type { ComposerDraftStore } from "@/lib/composer-draft";
+import { useLocalPreferences } from "@/hooks/useLocalPreferences";
const VOICE_SHORTCUT_CODE = "KeyD";
const VOICE_SHORTCUT_ARIA = "Control+Shift+D";
@@ -973,7 +974,7 @@ function GoalStateStrip({
id="nanobot-goal-panel-scroll"
className="min-h-0 flex-1 overflow-y-auto scrollbar-thin px-3 pb-3 pt-2"
>
- <MarkdownText className="max-w-none text-[13.5px] leading-relaxed text-foreground/90">
+ <MarkdownText className="max-w-none text-foreground/90">
{markdownBody}
</MarkdownText>
</div>
@@ -1113,6 +1114,7 @@ export function ThreadComposer({
// Coarser than hasTouchPrimaryPointer on purpose: tablets with a physical
// keyboard still get the newline-on-Enter behavior.
const hasCoarsePointer = useMediaQuery("(pointer: coarse)");
+ const { readingTextSize } = useLocalPreferences();
const textareaRef = useRef<HTMLTextAreaElement>(null);
const mentionOverlayRef = useRef<HTMLDivElement>(null);
const formRef = useRef<HTMLFormElement>(null);
@@ -1751,6 +1753,10 @@ export function ThreadComposer({
if (mentionOverlayRef.current) mentionOverlayRef.current.scrollTop = el.scrollTop;
}, [compactControls, mentionInput.isComposing, mentionInput.value]);
+ useEffect(() => {
+ resizeTextarea(false);
+ }, [readingTextSize, resizeTextarea]);
+
// Runs before paint so switching sessions never flashes stale draft text.
useLayoutEffect(() => {
if (previousPendingQueueKeyRef.current === pendingQueueKey) return;
@@ -2470,15 +2476,15 @@ export function ThreadComposer({
) : null;
const inputTextClasses = cn(
// Keep the overlay's CJK/Latin spacing aligned with the native textarea caret.
- "w-full resize-none bg-transparent [text-autospace:no-autospace]",
+ "w-full resize-none bg-transparent text-composer [text-autospace:no-autospace]",
compactControls
- ? "min-h-[52px] px-4 pb-2 pt-3 text-[16px] leading-6"
+ ? "min-h-[52px] px-4 pb-2 pt-3"
: isHero
? cn(
- "min-h-[78px] px-4 text-[16px] leading-6 sm:px-5",
+ "min-h-[78px] px-4 sm:px-5",
relaxedHeroInput ? "pb-2 pt-[27px]" : "pb-1.5 pt-4",
)
- : "min-h-[50px] px-3.5 pb-1.5 pt-3 text-[16px] leading-5 sm:px-4",
+ : "min-h-[50px] px-3.5 pb-1.5 pt-3 sm:px-4",
);
const paletteBeside = showAnyPalette && slashPaletteLayout.placement === "beside";
@@ -2617,7 +2623,7 @@ export function ThreadComposer({
aria-label={t("thread.composer.quotedContext")}
>
<Quote className="mt-0.5 h-3.5 w-3.5 shrink-0" aria-hidden />
- <p className="line-clamp-2 min-w-0 flex-1 text-[13px]/[1.45]">
+ <p className="line-clamp-2 min-w-0 flex-1 text-reading-small">
{normalizedQuotedContext}
</p>
<button
diff --git a/webui/src/components/thread/activity/DiffSyntaxHighlight.tsx b/webui/src/components/thread/activity/DiffSyntaxHighlight.tsx
index 5cd63e3dd..78bea4fa7 100644
--- a/webui/src/components/thread/activity/DiffSyntaxHighlight.tsx
+++ b/webui/src/components/thread/activity/DiffSyntaxHighlight.tsx
@@ -12,18 +12,6 @@ interface DiffSyntaxHighlightProps {
type RendererArgs = Parameters<NonNullable<SyntaxHighlighterProps["renderer"]>>[0];
type SyntaxNode = RendererArgs["rows"][number];
-const CODE_FONT_STACK = [
- '"JetBrains Mono"',
- '"SFMono-Regular"',
- '"SF Mono"',
- '"Fira Code"',
- '"Cascadia Code"',
- '"Source Code Pro"',
- "Menlo",
- "Consolas",
- "monospace",
-].join(", ");
-
const LazyDiffSyntaxHighlight = lazy(async () => {
const [
{ default: SyntaxHighlighter },
@@ -50,18 +38,18 @@ const LazyDiffSyntaxHighlight = lazy(async () => {
margin: 0,
padding: 0,
overflow: "visible",
- fontFamily: CODE_FONT_STACK,
- fontSize: "11px",
- lineHeight: "1.25rem",
+ fontFamily: "inherit",
+ fontSize: "inherit",
+ lineHeight: "inherit",
}}
codeTagProps={{
style: {
background: "transparent",
- fontFamily: CODE_FONT_STACK,
+ fontFamily: "inherit",
},
}}
data-language={language}
- className="code-content"
+ className="code-content font-mono text-code-dense"
data-testid="syntax-highlighted-diff-hunk"
renderer={({ rows, stylesheet, useInlineStyles }) => (
<DiffLineTable
@@ -110,7 +98,7 @@ function DiffLineTable({
renderCode: (line: RenderableFileDiffLine, index: number) => ReactNode;
}) {
return (
- <table className="w-full border-collapse font-mono text-[11px] leading-5">
+ <table className="w-full border-collapse font-mono text-code-dense">
<tbody>
{lines.map((line, index) => (
<DiffLineRow
diff --git a/webui/src/components/ui/button.tsx b/webui/src/components/ui/button.tsx
index e7d96edc6..5c34add37 100644
--- a/webui/src/components/ui/button.tsx
+++ b/webui/src/components/ui/button.tsx
@@ -5,7 +5,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const buttonVariants = cva(
- "inline-flex items-center justify-center whitespace-nowrap rounded-control text-sm font-medium ring-offset-background transition-colors duration-150 motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
+ "inline-flex items-center justify-center whitespace-nowrap rounded-control text-control-label font-medium ring-offset-background transition-colors duration-150 motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
{
variants: {
variant: {
diff --git a/webui/src/components/ui/input.tsx b/webui/src/components/ui/input.tsx
index 7406557e4..93b230c02 100644
--- a/webui/src/components/ui/input.tsx
+++ b/webui/src/components/ui/input.tsx
@@ -13,7 +13,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
- "touch-text-input flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
+ "touch-text-input flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-ui-body file:border-0 file:bg-transparent file:text-control-label placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
variant === "search" || type === "search"
? "focus:outline-none" : formControlFocusClassName,
className,
diff --git a/webui/src/components/ui/segmented-control.tsx b/webui/src/components/ui/segmented-control.tsx
index 841cff6a6..b54eb532f 100644
--- a/webui/src/components/ui/segmented-control.tsx
+++ b/webui/src/components/ui/segmented-control.tsx
@@ -6,11 +6,14 @@ import {
type ReactNode,
} from "react";
+import { HoverHint } from "@/components/ui/hover-hint";
import { cn } from "@/lib/utils";
interface SegmentedControlOption<T extends string> {
value: T;
label: ReactNode;
+ ariaLabel?: string;
+ tooltip?: string;
}
interface SegmentedControlProps<T extends string> {
@@ -18,7 +21,7 @@ interface SegmentedControlProps<T extends string> {
options: Array<SegmentedControlOption<T>>;
onChange: (value: T) => void;
ariaLabel?: string;
- mode?: "buttons" | "tabs";
+ mode?: "buttons" | "tabs" | "radio";
className?: string;
itemClassName?: string;
indicatorClassName?: string;
@@ -55,6 +58,8 @@ export function SegmentedControl<T extends string>({
animateIndicator = true,
}: SegmentedControlProps<T>) {
const tabs = mode === "tabs";
+ const radio = mode === "radio";
+ const rovingFocus = tabs || radio;
const rootRef = useRef<HTMLDivElement>(null);
const itemRefs = useRef<Array<HTMLButtonElement | null>>([]);
const previousValueRef = useRef<T | undefined>(undefined);
@@ -106,12 +111,14 @@ export function SegmentedControl<T extends string>({
};
}, [optionValuesKey, selectedIndex, value]);
- const handleTabKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {
- if (!tabs) return;
+ const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {
+ if (!rovingFocus) return;
let nextIndex: number | null = null;
if (event.key === "ArrowRight") nextIndex = (index + 1) % options.length;
if (event.key === "ArrowLeft") nextIndex = (index - 1 + options.length) % options.length;
+ if (radio && event.key === "ArrowDown") nextIndex = (index + 1) % options.length;
+ if (radio && event.key === "ArrowUp") nextIndex = (index - 1 + options.length) % options.length;
if (event.key === "Home") nextIndex = 0;
if (event.key === "End") nextIndex = options.length - 1;
if (nextIndex === null) return;
@@ -126,10 +133,10 @@ export function SegmentedControl<T extends string>({
return (
<div
ref={rootRef}
- role={tabs ? "tablist" : ariaLabel ? "group" : undefined}
+ role={tabs ? "tablist" : radio ? "radiogroup" : ariaLabel ? "group" : undefined}
aria-label={ariaLabel}
className={cn(
- "segmented-control relative isolate inline-flex min-h-8 max-w-full flex-nowrap items-center gap-1 rounded-full bg-muted/65 p-1 text-[12px] font-medium text-muted-foreground",
+ "segmented-control relative isolate inline-flex min-h-8 max-w-full flex-nowrap items-center gap-1 rounded-full bg-muted/65 p-1 text-ui-label text-muted-foreground",
className,
)}
>
@@ -152,19 +159,21 @@ export function SegmentedControl<T extends string>({
) : null}
{options.map((option, index) => {
const selected = value === option.value;
- return (
+ const button = (
<button
ref={(item) => {
itemRefs.current[index] = item;
}}
key={option.value}
type="button"
- role={tabs ? "tab" : undefined}
+ role={tabs ? "tab" : radio ? "radio" : undefined}
+ aria-label={option.ariaLabel}
aria-selected={tabs ? selected : undefined}
- aria-pressed={tabs ? undefined : selected}
- tabIndex={tabs ? (selected || (selectedIndex < 0 && index === 0) ? 0 : -1) : undefined}
+ aria-checked={radio ? selected : undefined}
+ aria-pressed={rovingFocus ? undefined : selected}
+ tabIndex={rovingFocus ? (selected || (selectedIndex < 0 && index === 0) ? 0 : -1) : undefined}
onClick={() => onChange(option.value)}
- onKeyDown={(event) => handleTabKeyDown(event, index)}
+ onKeyDown={(event) => handleKeyDown(event, index)}
className={cn(
"relative z-[1] min-w-0 truncate whitespace-nowrap rounded-full px-2 py-1 text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
selected ? "text-foreground" : "hover:text-foreground",
@@ -174,6 +183,9 @@ export function SegmentedControl<T extends string>({
{option.label}
</button>
);
+ return option.tooltip
+ ? <HoverHint key={option.value} content={option.tooltip} sideOffset={12}>{button}</HoverHint>
+ : button;
})}
</div>
);
diff --git a/webui/src/components/ui/tooltip-primitives.tsx b/webui/src/components/ui/tooltip-primitives.tsx
index 322fd5c8a..3b5f3cca6 100644
--- a/webui/src/components/ui/tooltip-primitives.tsx
+++ b/webui/src/components/ui/tooltip-primitives.tsx
@@ -20,7 +20,7 @@ const TooltipContent = React.forwardRef<
sideOffset={sideOffset}
className={cn(
floatingSurfaceElevationClassName,
- "z-50 overflow-hidden rounded-control px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95",
+ "z-50 overflow-hidden rounded-control px-3 py-1.5 text-caption animate-in fade-in-0 zoom-in-95",
className,
)}
{...props}
diff --git a/webui/src/globals.css b/webui/src/globals.css
index a532f2217..5e7295333 100644
--- a/webui/src/globals.css
+++ b/webui/src/globals.css
@@ -59,6 +59,11 @@
--radius-pill: 9999px;
--corner-shape: superellipse(1.5);
--content-column-width: 49.5rem;
+ --reading-size-wide: 18px;
+ --reading-size-narrow: 16px;
+ --text-reading-size: var(--reading-size-wide);
+ --text-code-size: calc(var(--text-reading-size) * 0.875);
+ --text-code-dense-size: calc(var(--text-reading-size) * 0.75);
--sidebar: 40 8% 96.8%;
--sidebar-foreground: 0 0% 3.9%;
--sidebar-content: 240 3% 30%;
@@ -74,6 +79,22 @@
--scrollbar-thumb-hover: hsl(var(--muted-foreground) / 0.42);
}
+ :root[data-reading-text-size="small"] {
+ --reading-size-wide: 16px;
+ --reading-size-narrow: 15px;
+ }
+
+ :root[data-reading-text-size="large"] {
+ --reading-size-wide: 20px;
+ --reading-size-narrow: 18px;
+ }
+
+ @media (max-width: 639px) {
+ :root {
+ --text-reading-size: var(--reading-size-narrow);
+ }
+ }
+
.dark {
color-scheme: dark;
--background: 0 0% 19%;
@@ -392,7 +413,35 @@
--tw-prose-headings: hsl(var(--foreground));
--tw-prose-bold: hsl(var(--foreground));
--tw-prose-lead: hsl(var(--foreground));
- line-height: var(--cjk-line-height);
+ @apply text-reading;
+ }
+
+ .markdown-content :is(h1, h2, h3, h4, h5, h6) {
+ font-weight: 600;
+ line-height: 1.4;
+ }
+ .markdown-content h1 { font-size: 1.5em; }
+ .markdown-content h2 { font-size: 1.25em; }
+ .markdown-content h3 { font-size: 1.125em; }
+ .markdown-content :is(h4, h5, h6) { font-size: 1em; }
+ .markdown-content strong { font-weight: 600; }
+ .markdown-content :is(th, td) {
+ font-size: inherit;
+ line-height: inherit;
+ }
+ .markdown-content blockquote {
+ font-size: 1em;
+ line-height: inherit;
+ }
+ .markdown-content summary {
+ font-size: 1em;
+ font-weight: 600;
+ line-height: inherit;
+ }
+
+ .markdown-inline-code {
+ font-size: 0.875em;
+ font-weight: 400;
}
.markdown-content .contains-task-list {
@@ -948,12 +997,11 @@
}
[data-user-text-bubble] > .message-block-menu-trigger {
- /* The first text line is 28px tall, with py-2 around the bubble. */
- top: calc((1rem + 28px - var(--message-block-control-size)) / 2);
+ top: calc((1rem + var(--text-reading-size) * var(--cjk-line-height) - var(--message-block-control-size)) / 2);
}
[data-user-text-bubble] > .message-block-hover-time {
- top: calc((1rem + 28px + var(--message-block-control-size)) / 2);
+ top: calc((1rem + var(--text-reading-size) * var(--cjk-line-height) + var(--message-block-control-size)) / 2);
}
[data-context-block-active] .message-block-menu-trigger,
diff --git a/webui/src/hooks/useReadingTypography.ts b/webui/src/hooks/useReadingTypography.ts
new file mode 100644
index 000000000..65cc88d52
--- /dev/null
+++ b/webui/src/hooks/useReadingTypography.ts
@@ -0,0 +1,11 @@
+import { useLayoutEffect } from "react";
+
+import { useLocalPreferences } from "@/hooks/useLocalPreferences";
+
+/** Project browser preferences onto text tokens, without scaling the UI or rem. */
+export function useReadingTypography(): void {
+ const { readingTextSize } = useLocalPreferences();
+ useLayoutEffect(() => {
+ document.documentElement.dataset.readingTextSize = readingTextSize;
+ }, [readingTextSize]);
+}
diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json
index 2fec354f5..1fc7f8288 100644
--- a/webui/src/i18n/locales/en/common.json
+++ b/webui/src/i18n/locales/en/common.json
@@ -802,6 +802,11 @@
"failed": "Task failed. Click for details.",
"interrupted": "Task needs attention. Click to continue."
},
+ "readingTextSize": {
+ "small": "Small reading text",
+ "standard": "Standard reading text",
+ "large": "Large reading text"
+ },
"rows": {
"theme": "Theme",
"language": "Language",
@@ -816,6 +821,7 @@
"currentModel": "Current configuration",
"selectedPreset": "Selected preset",
"presetModel": "Preset model",
+ "readingTextSize": "Reading text size",
"activityMode": "Activity details",
"fileEditDisplay": "Edit preview",
"codeWrap": "Code wrapping",
diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json
index 4102887a0..fba161809 100644
--- a/webui/src/i18n/locales/es/common.json
+++ b/webui/src/i18n/locales/es/common.json
@@ -547,6 +547,11 @@
"failed": "La tarea falló. Haz clic para ver los detalles.",
"interrupted": "La tarea necesita atención. Haz clic para continuar."
},
+ "readingTextSize": {
+ "small": "Texto de lectura pequeño",
+ "standard": "Texto de lectura estándar",
+ "large": "Texto de lectura grande"
+ },
"rows": {
"theme": "Tema",
"language": "Idioma",
@@ -560,6 +565,7 @@
"pendingChanges": "Cambios pendientes",
"selectedPreset": "Preajuste seleccionado",
"presetModel": "Modelo del preajuste",
+ "readingTextSize": "Tamaño del texto de lectura",
"activityMode": "Detalles de actividad",
"fileEditDisplay": "Vista previa de cambios",
"codeWrap": "Ajuste de línea del código",
diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json
index e30bd1a03..62004b85f 100644
--- a/webui/src/i18n/locales/fr/common.json
+++ b/webui/src/i18n/locales/fr/common.json
@@ -547,6 +547,11 @@
"failed": "La tâche a échoué. Cliquez pour les détails.",
"interrupted": "La tâche demande votre attention. Cliquez pour continuer."
},
+ "readingTextSize": {
+ "small": "Texte de lecture : petit",
+ "standard": "Texte de lecture : standard",
+ "large": "Texte de lecture : grand"
+ },
"rows": {
"theme": "Thème",
"language": "Langue",
@@ -560,6 +565,7 @@
"pendingChanges": "Modifications en attente",
"selectedPreset": "Préréglage sélectionné",
"presetModel": "Modèle du préréglage",
+ "readingTextSize": "Taille du texte de lecture",
"activityMode": "Détails de l’activité",
"fileEditDisplay": "Aperçu des modifications",
"codeWrap": "Retour à la ligne du code",
diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json
index 1a4347c79..191d6846e 100644
--- a/webui/src/i18n/locales/id/common.json
+++ b/webui/src/i18n/locales/id/common.json
@@ -547,6 +547,11 @@
"failed": "Tugas gagal. Klik untuk melihat detailnya.",
"interrupted": "Tugas perlu perhatian. Klik untuk melanjutkan."
},
+ "readingTextSize": {
+ "small": "Teks bacaan kecil",
+ "standard": "Teks bacaan standar",
+ "large": "Teks bacaan besar"
+ },
"rows": {
"theme": "Tema",
"language": "Bahasa",
@@ -560,6 +565,7 @@
"pendingChanges": "Perubahan tertunda",
"selectedPreset": "Preset dipilih",
"presetModel": "Model prasetel",
+ "readingTextSize": "Ukuran teks bacaan",
"activityMode": "Detail aktivitas",
"fileEditDisplay": "Pratinjau perubahan",
"codeWrap": "Bungkus baris kode",
diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json
index 5659c7d01..690719e14 100644
--- a/webui/src/i18n/locales/ja/common.json
+++ b/webui/src/i18n/locales/ja/common.json
@@ -547,6 +547,11 @@
"failed": "タスクが失敗しました。クリックして詳細を確認。",
"interrupted": "対応が必要です。クリックして続行。"
},
+ "readingTextSize": {
+ "small": "本文の文字サイズ:小",
+ "standard": "本文の文字サイズ:標準",
+ "large": "本文の文字サイズ:大"
+ },
"rows": {
"theme": "テーマ",
"language": "言語",
@@ -560,6 +565,7 @@
"pendingChanges": "適用待ちの変更",
"selectedPreset": "選択中のプリセット",
"presetModel": "プリセットモデル",
+ "readingTextSize": "本文の文字サイズ",
"activityMode": "処理の詳細",
"fileEditDisplay": "変更のプレビュー",
"codeWrap": "コードの折り返し",
diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json
index 272eb07f8..9b5527bf6 100644
--- a/webui/src/i18n/locales/ko/common.json
+++ b/webui/src/i18n/locales/ko/common.json
@@ -547,6 +547,11 @@
"failed": "작업이 실패했습니다. 눌러서 자세히 확인하세요.",
"interrupted": "확인이 필요합니다. 눌러서 계속하세요."
},
+ "readingTextSize": {
+ "small": "읽기 글자 크기: 작게",
+ "standard": "읽기 글자 크기: 표준",
+ "large": "읽기 글자 크기: 크게"
+ },
"rows": {
"theme": "테마",
"language": "언어",
@@ -560,6 +565,7 @@
"pendingChanges": "적용 대기 변경",
"selectedPreset": "선택한 프리셋",
"presetModel": "프리셋 모델",
+ "readingTextSize": "읽기 글자 크기",
"activityMode": "처리 과정",
"fileEditDisplay": "수정 미리 보기",
"codeWrap": "코드 줄바꿈",
diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json
index 05ddc4532..041d2eaa5 100644
--- a/webui/src/i18n/locales/pt-BR/common.json
+++ b/webui/src/i18n/locales/pt-BR/common.json
@@ -616,6 +616,11 @@
"failed": "A tarefa falhou. Clique para ver os detalhes.",
"interrupted": "A tarefa precisa de atenção. Clique para continuar."
},
+ "readingTextSize": {
+ "small": "Texto de leitura pequeno",
+ "standard": "Texto de leitura padrão",
+ "large": "Texto de leitura grande"
+ },
"rows": {
"theme": "Tema",
"language": "Idioma",
@@ -630,6 +635,7 @@
"currentModel": "Configuração atual",
"selectedPreset": "Preset selecionado",
"presetModel": "Modelo da predefinição",
+ "readingTextSize": "Tamanho do texto de leitura",
"activityMode": "Detalhes da atividade",
"fileEditDisplay": "Prévia de alterações",
"codeWrap": "Quebra de linha no código",
diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json
index b03f25a51..bd2d9b32c 100644
--- a/webui/src/i18n/locales/vi/common.json
+++ b/webui/src/i18n/locales/vi/common.json
@@ -547,6 +547,11 @@
"failed": "Tác vụ thất bại. Nhấp để xem chi tiết.",
"interrupted": "Tác vụ cần chú ý. Nhấp để tiếp tục."
},
+ "readingTextSize": {
+ "small": "Cỡ chữ đọc nhỏ",
+ "standard": "Cỡ chữ đọc tiêu chuẩn",
+ "large": "Cỡ chữ đọc lớn"
+ },
"rows": {
"theme": "Chủ đề",
"language": "Ngôn ngữ",
@@ -560,6 +565,7 @@
"pendingChanges": "Thay đổi chờ áp dụng",
"selectedPreset": "Bộ thiết lập đã chọn",
"presetModel": "Mô hình của cấu hình đặt trước",
+ "readingTextSize": "Cỡ chữ đọc",
"activityMode": "Chi tiết xử lý",
"fileEditDisplay": "Xem trước thay đổi",
"codeWrap": "Xuống dòng mã",
diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json
index ffb20557e..e4db02237 100644
--- a/webui/src/i18n/locales/zh-CN/common.json
+++ b/webui/src/i18n/locales/zh-CN/common.json
@@ -802,6 +802,11 @@
"failed": "任务失败,点击查看详情。",
"interrupted": "任务需要处理,点击继续。"
},
+ "readingTextSize": {
+ "small": "阅读字号:小",
+ "standard": "阅读字号:标准",
+ "large": "阅读字号:大"
+ },
"rows": {
"theme": "主题",
"language": "语言",
@@ -816,6 +821,7 @@
"currentModel": "当前配置",
"selectedPreset": "所选预设",
"presetModel": "预设模型",
+ "readingTextSize": "阅读字号",
"activityMode": "处理过程",
"fileEditDisplay": "修改预览",
"codeWrap": "代码换行",
diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json
index 01d8ad029..864009f1f 100644
--- a/webui/src/i18n/locales/zh-TW/common.json
+++ b/webui/src/i18n/locales/zh-TW/common.json
@@ -547,6 +547,11 @@
"failed": "任務失敗,點選查看詳情。",
"interrupted": "任務需要處理,點選繼續。"
},
+ "readingTextSize": {
+ "small": "閱讀字級:小",
+ "standard": "閱讀字級:標準",
+ "large": "閱讀字級:大"
+ },
"rows": {
"theme": "主題",
"language": "語言",
@@ -560,6 +565,7 @@
"pendingChanges": "待生效項",
"selectedPreset": "所選預設",
"presetModel": "預設模型",
+ "readingTextSize": "閱讀字級",
"activityMode": "處理過程",
"fileEditDisplay": "修改預覽",
"codeWrap": "程式碼換行",
diff --git a/webui/src/lib/local-preferences.ts b/webui/src/lib/local-preferences.ts
index ebfb7dd03..60c09ec1a 100644
--- a/webui/src/lib/local-preferences.ts
+++ b/webui/src/lib/local-preferences.ts
@@ -1,8 +1,10 @@
export type LocalActivityMode = "auto" | "expanded";
+export type ReadingTextSize = "small" | "standard" | "large";
export type FileEditDisplayMode = "summary" | "diff" | "collapsed_diff";
export interface LocalPreferences {
activityMode: LocalActivityMode;
+ readingTextSize: ReadingTextSize;
codeWrap: boolean;
brandLogos: boolean;
browserNotifications: boolean;
@@ -20,6 +22,7 @@ type PersistedLocalPreferences = Partial<LocalPreferences> & {
export const DEFAULT_LOCAL_PREFS: LocalPreferences = {
activityMode: "auto",
+ readingTextSize: "standard",
codeWrap: true,
brandLogos: true,
browserNotifications: false,
@@ -38,6 +41,8 @@ export function readLocalPreferences(): LocalPreferences {
const parsed = JSON.parse(raw) as PersistedLocalPreferences;
return {
activityMode: parsed.activityMode === "expanded" ? "expanded" : "auto",
+ readingTextSize: parsed.readingTextSize === "small" || parsed.readingTextSize === "large"
+ ? parsed.readingTextSize : "standard",
codeWrap: parsed.codeWrap !== false,
brandLogos: parsed.schemaVersion === LOCAL_PREFS_SCHEMA_VERSION
? parsed.brandLogos !== false
diff --git a/webui/src/lib/utils.ts b/webui/src/lib/utils.ts
index b8ac6fa7f..b13a7e9fb 100644
--- a/webui/src/lib/utils.ts
+++ b/webui/src/lib/utils.ts
@@ -6,6 +6,9 @@ const twMerge = extendTailwindMerge({
theme: {
borderRadius: ["mark", "compact", "control", "floating", "panel", "modal", "prominent"],
},
+ classGroups: {
+ "font-size": [{ text: ["ui", "ui-label", "ui-heading", "ui-body", "control-label", "caption", "title", "reading", "reading-small", "code", "code-dense", "composer"] }],
+ },
},
});
diff --git a/webui/src/tests/local-preferences.test.ts b/webui/src/tests/local-preferences.test.ts
index cafea7d45..e59b7a22b 100644
--- a/webui/src/tests/local-preferences.test.ts
+++ b/webui/src/tests/local-preferences.test.ts
@@ -26,6 +26,27 @@ describe("local preferences", () => {
expect(readLocalPreferences().brandLogos).toBe(false);
});
+ it.each([undefined, "obsolete", 24])("defaults missing or invalid reading sizes without resetting other preferences: %s", (readingTextSize) => {
+ localStorage.setItem(LOCAL_PREFS_STORAGE_KEY, JSON.stringify({
+ schemaVersion: 1,
+ readingTextSize,
+ activityMode: "expanded",
+ codeWrap: false,
+ brandLogos: false,
+ notificationSound: true,
+ fileEditDisplayMode: "diff",
+ }));
+ expect(readLocalPreferences()).toEqual({
+ ...DEFAULT_LOCAL_PREFS,
+ readingTextSize: "standard",
+ activityMode: "expanded",
+ codeWrap: false,
+ brandLogos: false,
+ notificationSound: true,
+ fileEditDisplayMode: "diff",
+ });
+ });
+
it("keeps browser notifications opt-in", () => {
expect(DEFAULT_LOCAL_PREFS.browserNotifications).toBe(false);
expect(readLocalPreferences().browserNotifications).toBe(false);
diff --git a/webui/src/tests/segmented-control.test.tsx b/webui/src/tests/segmented-control.test.tsx
index df318de03..da55e204b 100644
--- a/webui/src/tests/segmented-control.test.tsx
+++ b/webui/src/tests/segmented-control.test.tsx
@@ -20,7 +20,7 @@ function Example({
mode = "buttons",
animateIndicator = true,
}: {
- mode?: "buttons" | "tabs";
+ mode?: "buttons" | "tabs" | "radio";
animateIndicator?: boolean;
}) {
const [value, setValue] = useState("summary");
@@ -101,6 +101,24 @@ describe("SegmentedControl", () => {
expect(diff).toHaveFocus();
});
+ it("exposes one checked radio and moves selection and focus with the keyboard", () => {
+ render(<Example mode="radio" />);
+ const summary = screen.getByRole("radio", { name: "Summary" });
+ const diff = screen.getByRole("radio", { name: "Diff" });
+ expect(summary).toBeChecked();
+ expect(summary).toHaveAttribute("tabindex", "0");
+ expect(diff).toHaveAttribute("tabindex", "-1");
+
+ summary.focus();
+ fireEvent.keyDown(summary, { key: "ArrowRight" });
+ expect(diff).toBeChecked();
+ expect(diff).toHaveFocus();
+ expect(summary).not.toBeChecked();
+ fireEvent.keyDown(diff, { key: "Home" });
+ expect(summary).toBeChecked();
+ expect(summary).toHaveFocus();
+ });
+
it("can disable motion when the set of segments is dynamic", () => {
const { container } = render(<Example animateIndicator={false} />);
const summary = screen.getByRole("button", { name: "Summary" });
diff --git a/webui/src/tests/settings-overview.test.tsx b/webui/src/tests/settings-overview.test.tsx
index 96a9d55cc..c2692d0b4 100644
--- a/webui/src/tests/settings-overview.test.tsx
+++ b/webui/src/tests/settings-overview.test.tsx
@@ -112,6 +112,18 @@ describe("Settings overview and appearance", () => {
expect(url.href).not.toContain("private-host");
});
+ it("saves the reading size immediately while preserving the other local preferences", async () => {
+ const previous = { ...DEFAULT_LOCAL_PREFS, codeWrap: false, brandLogos: false, notificationSound: true };
+ writeLocalPreferences(previous);
+ renderSettingsView({ initialSection: "appearance", initialSettings: settingsPayload() });
+
+ expect(screen.getByRole("radio", { name: "Standard reading text" })).toBeChecked();
+ fireEvent.click(screen.getByRole("radio", { name: "Large reading text" }));
+
+ await waitFor(() => expect(readLocalPreferences()).toEqual({ ...previous, readingTextSize: "large" }));
+ expect(screen.getByRole("radio", { name: "Large reading text" })).toBeChecked();
+ });
+
it("persists the file edit display local preference", async () => {
renderSettingsView({
initialSection: "appearance",
diff --git a/webui/src/tests/thread-composer.test.tsx b/webui/src/tests/thread-composer.test.tsx
index 8d74cf5e5..db810fbcc 100644
--- a/webui/src/tests/thread-composer.test.tsx
+++ b/webui/src/tests/thread-composer.test.tsx
@@ -585,7 +585,7 @@ describe("ThreadComposer", () => {
const input = screen.getByPlaceholderText("Ask anything...");
expect(input).toBeInTheDocument();
expect(input.className).toContain("min-h-[78px]");
- expect(input.className).toContain("text-[16px]");
+ expect(input.className).toContain("text-composer");
expect(input.className).toContain("pt-[27px]");
fireEvent.change(input, { target: { value: "1" } });
expect(input.className).toContain("pt-[27px]");
@@ -820,7 +820,7 @@ describe("ThreadComposer", () => {
}
const input = screen.getByPlaceholderText("Type your message...");
expect(input.className).toContain("min-h-[50px]");
- expect(input.className).toContain("text-[16px]");
+ expect(input.className).toContain("text-composer");
expect(input.parentElement?.parentElement?.className).toContain("max-w-[49.5rem]");
expect(input.parentElement?.parentElement?.className).toContain("rounded-panel");
expect(input.parentElement?.parentElement?.className).not.toContain("shadow-");
diff --git a/webui/src/tests/touch-input.test.tsx b/webui/src/tests/touch-input.test.tsx
index 0a411f945..a7e268731 100644
--- a/webui/src/tests/touch-input.test.tsx
+++ b/webui/src/tests/touch-input.test.tsx
@@ -10,7 +10,7 @@ import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
describe("touch form typography", () => {
- it("keeps the touch baseline on compact shared fields without changing desktop classes", () => {
+ it("keeps the touch baseline and desktop text roles on compact shared fields", () => {
render(<>
<Input aria-label="Name" />
<Input aria-label="Address" className="text-[13px]" />
@@ -19,7 +19,7 @@ describe("touch form typography", () => {
for (const field of screen.getAllByRole("textbox")) {
expect(field).toHaveClass("touch-text-input");
}
- expect(screen.getByLabelText("Name")).toHaveClass("text-sm");
+ expect(screen.getByLabelText("Name")).toHaveClass("text-ui-body");
expect(screen.getByLabelText("Address")).toHaveClass("text-[13px]");
expect(screen.getByLabelText("Pairing code")).toHaveClass("text-xs", "font-mono");
});
@@ -28,20 +28,20 @@ describe("touch form typography", () => {
const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));
const source = readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8");
const result = await postcss([tailwindcss({ ...config, content: [{
- raw: 'class="touch-text-input text-xs text-sm text-[13px] text-[19px]"',
+ raw: 'class="touch-text-input text-xs text-sm text-ui-body text-[13px] text-[19px]"',
}] })]).process(source, { from: undefined });
let baseline = -1;
let index = 0;
const compact: number[] = [];
result.root.walkRules((rule) => {
index++;
- if ([".text-xs", ".text-sm", ".text-\\[13px\\]"].includes(rule.selector)) compact.push(index);
+ if ([".text-xs", ".text-sm", ".text-ui-body", ".text-\\[13px\\]"].includes(rule.selector)) compact.push(index);
if (rule.selector !== ".touch-text-input") return;
baseline = index;
expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });
expect(rule.nodes).toContainEqual(expect.objectContaining({ prop: "font-size", value: "max(16px, 1rem)" }));
});
- expect(compact).toHaveLength(3);
+ expect(compact).toHaveLength(4);
expect(baseline).toBeGreaterThan(Math.max(...compact));
});
});
diff --git a/webui/tailwind.config.js b/webui/tailwind.config.js
index e66b43dba..04d4916fb 100644
--- a/webui/tailwind.config.js
+++ b/webui/tailwind.config.js
@@ -21,6 +21,21 @@ export default {
},
},
extend: {
+ // Text roles own their metrics; reading preferences never change the rem grid.
+ fontSize: {
+ ui: ["0.8125rem", { lineHeight: "1.25rem", fontWeight: "400" }],
+ "ui-label": ["0.75rem", { lineHeight: "1.125rem", fontWeight: "500" }],
+ "ui-heading": ["0.8125rem", { lineHeight: "1.25rem", fontWeight: "600" }],
+ "ui-body": ["0.875rem", { lineHeight: "1.25rem", fontWeight: "400" }],
+ "control-label": ["0.875rem", { lineHeight: "1.25rem", fontWeight: "500" }],
+ caption: ["0.75rem", { lineHeight: "1.125rem", fontWeight: "400" }],
+ title: ["1.25rem", { lineHeight: "1.75rem", fontWeight: "600" }],
+ reading: ["var(--text-reading-size)", { lineHeight: "var(--cjk-line-height)", fontWeight: "400" }],
+ "reading-small": ["calc(var(--text-reading-size) * 0.875)", { lineHeight: "var(--cjk-line-height)", fontWeight: "400" }],
+ code: ["var(--text-code-size)", { lineHeight: "1.6", fontWeight: "400" }],
+ "code-dense": ["var(--text-code-dense-size)", { lineHeight: "1.6", fontWeight: "400" }],
+ composer: ["max(16px, var(--text-reading-size))", { lineHeight: "1.5", fontWeight: "400" }],
+ },
fontFamily: {
sans: [
"system-ui",
@@ -41,6 +56,8 @@ export default {
],
mono: [
'"JetBrains Mono"',
+ '"SFMono-Regular"',
+ '"SF Mono"',
'"Fira Code"',
'"Cascadia Code"',
'"Source Code Pro"',