Skip to content

The agent that grows with you

feat(desktop-sdk): expose chatTextScale through host.settings

Teknium93c3abe35e63
diff --git a/apps/desktop/src/sdk/settings.test.ts b/apps/desktop/src/sdk/settings.test.ts
index bf094f2fb7e..8cd499e4a4e 100644
--- a/apps/desktop/src/sdk/settings.test.ts
+++ b/apps/desktop/src/sdk/settings.test.ts
@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { onPersistenceEvent } from '@/lib/storage'
import { host } from '@/sdk'
import { $backdrop, setBackdrop } from '@/store/backdrop'
+import { $chatTextScale, setChatTextScale } from '@/store/chat-text-scale'
import { $composerPopoutGesturesEnabled, setComposerPopoutGesturesEnabled } from '@/store/composer-popout'
import { $introSplash, setIntroSplash } from '@/store/intro-splash'
import { $reasoningCollapsedByDefault, setReasoningCollapsedByDefault } from '@/store/reasoning-disclosure'
@@ -16,6 +17,7 @@ const resetSettings = () => {
setIntroSplash(true)
setReasoningCollapsedByDefault(false)
setComposerPopoutGesturesEnabled(true)
+ setChatTextScale(110)
}
describe('host.settings', () => {
@@ -32,6 +34,7 @@ describe('host.settings', () => {
host.settings.set('intro-splash.v1', false)
host.settings.set('reasoning.collapsedByDefault', true)
host.settings.set('composerPopout.gesturesEnabled', false)
+ host.settings.set('chatTextScale', 125)
expect(host.settings.get('sessionListDensity')).toBe('detailed')
expect(host.settings.get('tabStripDefault')).toBe('always')
@@ -39,6 +42,7 @@ describe('host.settings', () => {
expect(host.settings.get('intro-splash.v1')).toBe(false)
expect(host.settings.get('reasoning.collapsedByDefault')).toBe(true)
expect(host.settings.get('composerPopout.gesturesEnabled')).toBe(false)
+ expect(host.settings.get('chatTextScale')).toBe(125)
expect($sessionListDensity.get()).toBe('detailed')
expect($tabStripDefault.get()).toBe('always')
@@ -46,6 +50,7 @@ describe('host.settings', () => {
expect($introSplash.get()).toBe(false)
expect($reasoningCollapsedByDefault.get()).toBe(true)
expect($composerPopoutGesturesEnabled.get()).toBe(false)
+ expect($chatTextScale.get()).toBe(125)
})
it('preserves the stores existing persistence schema', () => {
@@ -63,6 +68,7 @@ describe('host.settings', () => {
host.settings.set('intro-splash.v1', false)
host.settings.set('reasoning.collapsedByDefault', true)
host.settings.set('composerPopout.gesturesEnabled', false)
+ host.settings.set('chatTextScale', 150)
unsubscribe()
@@ -73,7 +79,8 @@ describe('host.settings', () => {
['hermes.desktop.backdrop.v1', 'true'],
['hermes.desktop.intro-splash.v1', 'false'],
['hermes.desktop.reasoning.collapsedByDefault', 'true'],
- ['hermes.desktop.composerPopout.gesturesEnabled', 'false']
+ ['hermes.desktop.composerPopout.gesturesEnabled', 'false'],
+ ['hermes.desktop.chat-text-scale.v1', '150']
])
)
})
@@ -95,6 +102,36 @@ describe('host.settings', () => {
expect(listener).toHaveBeenCalledTimes(2)
})
+ it('drives the chat text size the native Appearance control drives', () => {
+ const listener = vi.fn()
+ const unsubscribe = host.settings.subscribe('chatTextScale', listener)
+
+ expect(listener).toHaveBeenLastCalledWith(110)
+
+ // A native Appearance change reaches plugin subscribers...
+ setChatTextScale(90)
+ expect(listener).toHaveBeenLastCalledWith(90)
+
+ // ...and a plugin write applies the same CSS variable the chat reads.
+ host.settings.set('chatTextScale', 175)
+ expect(listener).toHaveBeenLastCalledWith(175)
+ expect(document.documentElement.style.getPropertyValue('--chat-text-scale')).toBe('1.75')
+
+ unsubscribe()
+ })
+
+ it('accepts only the native chat text size presets', () => {
+ const setUnchecked = host.settings.set as (key: string, value: unknown) => void
+
+ // Off-preset numbers are refused, not silently snapped: the store would
+ // normalize 112 to the 110 default and the plugin would never learn why.
+ for (const bad of [112, 0, 1000, Number.NaN, '125', null]) {
+ expect(() => setUnchecked('chatTextScale', bad)).toThrow('Invalid value for desktop setting: chatTextScale')
+ }
+
+ expect($chatTextScale.get()).toBe(110)
+ })
+
it('rejects keys and values outside the public allowlist', () => {
expect(() => (host.settings.get as (key: string) => unknown)('pluginDecisions.v2')).toThrow(
'Unsupported desktop setting: pluginDecisions.v2'
diff --git a/apps/desktop/src/sdk/settings.ts b/apps/desktop/src/sdk/settings.ts
index 11061bd7039..f21b8a34199 100644
--- a/apps/desktop/src/sdk/settings.ts
+++ b/apps/desktop/src/sdk/settings.ts
@@ -1,6 +1,7 @@
import type { ReadableAtom } from 'nanostores'
import { $backdrop, setBackdrop } from '@/store/backdrop'
+import { $chatTextScale, CHAT_TEXT_SCALE_PRESETS, type ChatTextScale, setChatTextScale } from '@/store/chat-text-scale'
import { $composerPopoutGesturesEnabled, setComposerPopoutGesturesEnabled } from '@/store/composer-popout'
import { $introSplash, setIntroSplash } from '@/store/intro-splash'
import { $reasoningCollapsedByDefault, setReasoningCollapsedByDefault } from '@/store/reasoning-disclosure'
@@ -9,6 +10,7 @@ import { $tabStripDefault, setTabStripDefault, type TabStripDefault } from '@/st
export interface DesktopSettingValues {
'backdrop.v1': boolean
+ chatTextScale: ChatTextScale
'composerPopout.gesturesEnabled': boolean
'intro-splash.v1': boolean
'reasoning.collapsedByDefault': boolean
@@ -38,6 +40,11 @@ const bindSetting = <T>(
const isBoolean = (value: unknown): value is boolean => typeof value === 'boolean'
+// Exact presets only: the store snaps an off-preset number to the default,
+// which would turn a plugin's typo into a silent reset of the user's size.
+const isChatTextScale = (value: unknown): value is ChatTextScale =>
+ CHAT_TEXT_SCALE_PRESETS.some(preset => preset === value)
+
const isSessionListDensity = (value: unknown): value is SessionListDensity =>
value === 'compact' || value === 'comfortable' || value === 'detailed'
@@ -46,6 +53,7 @@ const isTabStripDefault = (value: unknown): value is TabStripDefault =>
const settingBindings = {
'backdrop.v1': bindSetting($backdrop, setBackdrop, isBoolean),
+ chatTextScale: bindSetting($chatTextScale, setChatTextScale, isChatTextScale),
'composerPopout.gesturesEnabled': bindSetting(
$composerPopoutGesturesEnabled,
setComposerPopoutGesturesEnabled,
diff --git a/website/docs/developer-guide/desktop-plugin-sdk.md b/website/docs/developer-guide/desktop-plugin-sdk.md
index 051c3767f0e..3bd8c430f69 100644
--- a/website/docs/developer-guide/desktop-plugin-sdk.md
+++ b/website/docs/developer-guide/desktop-plugin-sdk.md
@@ -1203,6 +1203,7 @@ wins (no plugin "owns" the value afterwards, nothing to tear down for `set`).
```ts
type DesktopSettingValues = {
'backdrop.v1': boolean
+ chatTextScale: 90 | 100 | 110 | 125 | 150 | 175 // percent; Appearance → Chat Text Size
'composerPopout.gesturesEnabled': boolean
'intro-splash.v1': boolean
'reasoning.collapsedByDefault': boolean
@@ -1226,6 +1227,22 @@ register(ctx) {
}
```
+`chatTextScale` is the user's chat text size (default `110`). It scales the
+transcript and composer text (and its line height) through the host's
+`--chat-text-scale` CSS variable, so a plugin or theme that wants larger/smaller
+reading text sets the same preset the user would pick; pane geometry, row
+spacing and chrome stay core-owned. Only the
+six presets are accepted: an off-preset number (`112`, `'125'`) throws instead of
+being snapped, so a typo can't silently reset the user's size. Like every key
+here it is the user's preference, not a plugin override: write it from an
+explicit user action in your UI (never at `register`), and read/subscribe to
+adapt your own rendering.
+
+```ts
+const dispose = host.settings.subscribe('chatTextScale', pct => setMyFontScale(pct / 100))
+ctx.onDispose(dispose)
+```
+
Arbitration: the allowlist above is closed. An unknown key or a value outside
the key's type throws **synchronously** (`Unsupported desktop setting: …` /
`Invalid value for desktop setting: …`) and nothing is written — `host.settings`
@@ -1239,6 +1256,7 @@ Deliberately **not** keys, and why:
| keybind map (`hermes.desktop.keybinds`) | `KEYBINDS_AREA` contribution | a raw map write rebinds every other plugin's shortcuts; the area merges per plugin and is torn down with it |
| active theme / mode record | `THEMES_AREA` (register a theme; the user selects it) | theme selection is per window/profile and arbitrated by the app, not a flat preference |
| `pluginDecisions` (desktop plugin on/off) | the app's Plugins tab (a read-only view is a separate SDK hook) | a plugin toggling another plugin's enable state is plugins interfering with each other |
+| chat / composer width, turn spacing, session-row geometry | nothing yet — these become keys only once they exist as core Appearance preferences (chat width: #55287) | layout is host-owned; a plugin-owned geometry contract would make every theme a layout contract |
| `toolView.technical`, `embed-mode`, `titlebarAppActions`, `translucency.v2`, `user-bubble-transparency.v1`, `hermesDesktop.zoom.*` | follow-up keys after each store is audited | some drive the main process or window chrome; each needs its own guard and ownership review before it becomes plugin-writable |
Migration — `hermes-appearance-hub`, which today does