Skip to content

Commit ceadeca

Browse files
committed
feat: add text size setting (S / M / L / XL)
Add adjustable text size for chat messages: - Four sizes: S (text-sm), M (text-base), L (text-lg), XL (text-xl) - Picker in Settings → Chat section - Applied to all message content (user and assistant) - Persisted via Zustand store (localStorage) - Default: M (text-base, matches current behavior) Changes: - src/hooks/use-chat-settings.ts: add TextSize type + textSizeClasses map - src/screens/chat/components/settings-dialog.tsx: add size picker buttons - src/screens/chat/components/message-item.tsx: apply text size class No new dependencies.
1 parent 574b943 commit ceadeca

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

apps/webclaw/src/hooks/use-chat-settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ import { create } from 'zustand'
33
import { persist } from 'zustand/middleware'
44

55
export type ThemeMode = 'system' | 'light' | 'dark'
6+
export type TextSize = 'sm' | 'md' | 'lg' | 'xl'
7+
8+
export const textSizeClasses: Record<TextSize, string> = {
9+
sm: 'text-sm',
10+
md: 'text-base',
11+
lg: 'text-lg',
12+
xl: 'text-xl',
13+
}
614

715
export type ChatSettings = {
816
showToolMessages: boolean
917
showReasoningBlocks: boolean
1018
theme: ThemeMode
19+
textSize: TextSize
1120
}
1221

1322
type ChatSettingsState = {
@@ -22,6 +31,7 @@ export const useChatSettingsStore = create<ChatSettingsState>()(
2231
showToolMessages: true,
2332
showReasoningBlocks: true,
2433
theme: 'system',
34+
textSize: 'md',
2535
},
2636
updateSettings: (updates) =>
2737
set((state) => ({

apps/webclaw/src/screens/chat/components/message-item.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { ToolPart } from '@/components/prompt-kit/tool'
1010
import { Message, MessageContent } from '@/components/prompt-kit/message'
1111
import { Thinking } from '@/components/prompt-kit/thinking'
1212
import { Tool } from '@/components/prompt-kit/tool'
13-
import { useChatSettings } from '@/hooks/use-chat-settings'
13+
import { useChatSettings, textSizeClasses } from '@/hooks/use-chat-settings'
1414
import { cn } from '@/lib/utils'
1515

1616
type MessageItemProps = {
@@ -172,6 +172,7 @@ function MessageItemComponent({
172172
markdown={!isUser}
173173
className={cn(
174174
'text-primary-900',
175+
textSizeClasses[settings.textSize],
175176
!isUser
176177
? 'bg-transparent w-full'
177178
: 'bg-primary-100 px-4 py-2.5 max-w-[85%]',

apps/webclaw/src/screens/chat/components/settings-dialog.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ import {
1515
} from '@/components/ui/dialog'
1616
import { Switch } from '@/components/ui/switch'
1717
import { Tabs, TabsList, TabsTab } from '@/components/ui/tabs'
18-
import { useChatSettings } from '@/hooks/use-chat-settings'
19-
import type { ThemeMode } from '@/hooks/use-chat-settings'
18+
import { useChatSettings, textSizeClasses } from '@/hooks/use-chat-settings'
19+
import type { ThemeMode, TextSize } from '@/hooks/use-chat-settings'
2020
import { Button } from '@/components/ui/button'
21+
import { cn } from '@/lib/utils'
2122

2223
type SettingsSectionProps = {
2324
title: string
@@ -154,6 +155,34 @@ export function SettingsDialog({
154155
</SettingsSection>
155156

156157
<SettingsSection title="Chat">
158+
<SettingsRow label="Text size">
159+
<div className="flex gap-1">
160+
{(['sm', 'md', 'lg', 'xl'] as const).map(function renderSize(size) {
161+
const labels: Record<TextSize, string> = {
162+
sm: 'S',
163+
md: 'M',
164+
lg: 'L',
165+
xl: 'XL',
166+
}
167+
return (
168+
<button
169+
key={size}
170+
onClick={function handleClick() {
171+
updateSettings({ textSize: size })
172+
}}
173+
className={cn(
174+
'px-2.5 py-1 rounded-md text-xs font-medium transition-colors',
175+
settings.textSize === size
176+
? 'bg-primary-900 text-white'
177+
: 'bg-primary-100 text-primary-600 hover:bg-primary-200',
178+
)}
179+
>
180+
{labels[size]}
181+
</button>
182+
)
183+
})}
184+
</div>
185+
</SettingsRow>
157186
<SettingsRow label="Show tool messages">
158187
<Switch
159188
checked={settings.showToolMessages}

0 commit comments

Comments
 (0)