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

* feat(webui): add reading text size preferences

* fix(webui): align loading skeletons with reading typography
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-20 16:33:05 +08:00
1 parent 816c9221a0
commit 282839cc65
48 files changed
+662 -120

No files matched your search

+3 -3
View File
@@ -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"
+10 -22
View File
@@ -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,
@@ -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
+1 -1
View File
@@ -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,
)}
+10 -11
View File
@@ -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",
+4 -6
View File
@@ -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>
@@ -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>
@@ -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}
@@ -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>
@@ -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>
@@ -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"
@@ -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}
+1 -1
View File
@@ -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>;
+12 -6
View File
@@ -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
@@ -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
+1 -1
View File
@@ -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: {
+1 -1
View File
@@ -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,
+22 -10
View File
@@ -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>
);
@@ -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}