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:
1 parent
816c9221a0
commit
282839cc65
48 files changed
+662
-120
No files matched your search
@@ -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("");
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}
|
||||
|
||||
+52
-4
@@ -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,
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -547,6 +547,11 @@
|
||||
"failed": "タスクが失敗しました。クリックして詳細を確認。",
|
||||
"interrupted": "対応が必要です。クリックして続行。"
|
||||
},
|
||||
"readingTextSize": {
|
||||
"small": "本文の文字サイズ:小",
|
||||
"standard": "本文の文字サイズ:標準",
|
||||
"large": "本文の文字サイズ:大"
|
||||
},
|
||||
"rows": {
|
||||
"theme": "テーマ",
|
||||
"language": "言語",
|
||||
@@ -560,6 +565,7 @@
|
||||
"pendingChanges": "適用待ちの変更",
|
||||
"selectedPreset": "選択中のプリセット",
|
||||
"presetModel": "プリセットモデル",
|
||||
"readingTextSize": "本文の文字サイズ",
|
||||
"activityMode": "処理の詳細",
|
||||
"fileEditDisplay": "変更のプレビュー",
|
||||
"codeWrap": "コードの折り返し",
|
||||
|
||||
@@ -547,6 +547,11 @@
|
||||
"failed": "작업이 실패했습니다. 눌러서 자세히 확인하세요.",
|
||||
"interrupted": "확인이 필요합니다. 눌러서 계속하세요."
|
||||
},
|
||||
"readingTextSize": {
|
||||
"small": "읽기 글자 크기: 작게",
|
||||
"standard": "읽기 글자 크기: 표준",
|
||||
"large": "읽기 글자 크기: 크게"
|
||||
},
|
||||
"rows": {
|
||||
"theme": "테마",
|
||||
"language": "언어",
|
||||
@@ -560,6 +565,7 @@
|
||||
"pendingChanges": "적용 대기 변경",
|
||||
"selectedPreset": "선택한 프리셋",
|
||||
"presetModel": "프리셋 모델",
|
||||
"readingTextSize": "읽기 글자 크기",
|
||||
"activityMode": "처리 과정",
|
||||
"fileEditDisplay": "수정 미리 보기",
|
||||
"codeWrap": "코드 줄바꿈",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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ã",
|
||||
|
||||
@@ -802,6 +802,11 @@
|
||||
"failed": "任务失败,点击查看详情。",
|
||||
"interrupted": "任务需要处理,点击继续。"
|
||||
},
|
||||
"readingTextSize": {
|
||||
"small": "阅读字号:小",
|
||||
"standard": "阅读字号:标准",
|
||||
"large": "阅读字号:大"
|
||||
},
|
||||
"rows": {
|
||||
"theme": "主题",
|
||||
"language": "语言",
|
||||
@@ -816,6 +821,7 @@
|
||||
"currentModel": "当前配置",
|
||||
"selectedPreset": "所选预设",
|
||||
"presetModel": "预设模型",
|
||||
"readingTextSize": "阅读字号",
|
||||
"activityMode": "处理过程",
|
||||
"fileEditDisplay": "修改预览",
|
||||
"codeWrap": "代码换行",
|
||||
|
||||
@@ -547,6 +547,11 @@
|
||||
"failed": "任務失敗,點選查看詳情。",
|
||||
"interrupted": "任務需要處理,點選繼續。"
|
||||
},
|
||||
"readingTextSize": {
|
||||
"small": "閱讀字級:小",
|
||||
"standard": "閱讀字級:標準",
|
||||
"large": "閱讀字級:大"
|
||||
},
|
||||
"rows": {
|
||||
"theme": "主題",
|
||||
"language": "語言",
|
||||
@@ -560,6 +565,7 @@
|
||||
"pendingChanges": "待生效項",
|
||||
"selectedPreset": "所選預設",
|
||||
"presetModel": "預設模型",
|
||||
"readingTextSize": "閱讀字級",
|
||||
"activityMode": "處理過程",
|
||||
"fileEditDisplay": "修改預覽",
|
||||
"codeWrap": "程式碼換行",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"] }],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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-");
|
||||
|
||||
@@ -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));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user