Skip to content

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

feat(ui): readable warm and neutral palettes, font and text size choices (#6765)

wangshunfc9b3ae490cf
diff --git a/src/ui/i18n/mywork-fr.ts b/src/ui/i18n/mywork-fr.ts
index 514e94f72..c8d59353e 100644
--- a/src/ui/i18n/mywork-fr.ts
+++ b/src/ui/i18n/mywork-fr.ts
@@ -1269,4 +1269,19 @@ export const myworkFr: Record<string, string> = {
"Once, or a few times long ago.": "Une fois, ou quelques fois il y a longtemps.",
"More about your rules": "Plus sur vos règles",
"Preview rules file": "Aperçu du fichier de règles",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "Palette de lecture",
+ "Font": "Police",
+ "Text size": "Taille du texte",
+ "Current default": "Défaut actuel",
+ "Warm cream": "Crème chaud",
+ "Neutral light": "Neutre clair",
+ "Warm tint": "Teinte chaude",
+ "Neutral dark": "Neutre sombre",
+ "Geist": "Geist",
+ "System sans": "Sans-serif du système",
+ "Serif": "Serif",
+ "Monospace": "Chasse fixe",
+ "Default": "Par défaut",
+ "Comfortable": "Confortable",
};
diff --git a/src/ui/i18n/mywork-ko.ts b/src/ui/i18n/mywork-ko.ts
index 14e8c6a8c..3667c3e2c 100644
--- a/src/ui/i18n/mywork-ko.ts
+++ b/src/ui/i18n/mywork-ko.ts
@@ -1246,4 +1246,19 @@ export const myworkKo: Record<string, string> = {
"Once, or a few times long ago.": "한 번, 또는 오래전에 몇 번 말했습니다.",
"More about your rules": "내 규칙 더 알아보기",
"Preview rules file": "규칙 파일 미리 보기",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "읽기 팔레트",
+ "Font": "글꼴",
+ "Text size": "글자 크기",
+ "Current default": "현재 기본값",
+ "Warm cream": "따뜻한 크림",
+ "Neutral light": "중립 밝은색",
+ "Warm tint": "따뜻한 색조",
+ "Neutral dark": "중립 어두운색",
+ "Geist": "Geist",
+ "System sans": "시스템 산세리프",
+ "Serif": "세리프",
+ "Monospace": "고정폭",
+ "Default": "기본값",
+ "Comfortable": "넉넉하게",
};
diff --git a/src/ui/i18n/mywork-pt-BR.ts b/src/ui/i18n/mywork-pt-BR.ts
index d1f5609fa..1dc9fe560 100644
--- a/src/ui/i18n/mywork-pt-BR.ts
+++ b/src/ui/i18n/mywork-pt-BR.ts
@@ -1236,4 +1236,19 @@ export const myworkPtBr: Record<string, string> = {
"Once, or a few times long ago.": "Uma vez, ou algumas vezes há muito tempo.",
"More about your rules": "Mais sobre suas regras",
"Preview rules file": "Visualizar o arquivo de regras",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "Paleta de leitura",
+ "Font": "Fonte",
+ "Text size": "Tamanho do texto",
+ "Current default": "Padrão atual",
+ "Warm cream": "Creme quente",
+ "Neutral light": "Neutro claro",
+ "Warm tint": "Tom quente",
+ "Neutral dark": "Neutro escuro",
+ "Geist": "Geist",
+ "System sans": "Sem serifa do sistema",
+ "Serif": "Serifada",
+ "Monospace": "Monoespaçada",
+ "Default": "Padrão",
+ "Comfortable": "Confortável",
};
diff --git a/src/ui/i18n/mywork-ru.ts b/src/ui/i18n/mywork-ru.ts
index 1e8de1eec..89d7630cb 100644
--- a/src/ui/i18n/mywork-ru.ts
+++ b/src/ui/i18n/mywork-ru.ts
@@ -1266,4 +1266,19 @@ export const myworkRu: Record<string, string> = {
"Once, or a few times long ago.": "Один раз или несколько раз, но давно.",
"More about your rules": "Подробнее о ваших правилах",
"Preview rules file": "Просмотреть файл правил",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "Палитра для чтения",
+ "Font": "Шрифт",
+ "Text size": "Размер текста",
+ "Current default": "Текущая по умолчанию",
+ "Warm cream": "Тёплый кремовый",
+ "Neutral light": "Нейтральный светлый",
+ "Warm tint": "Тёплый оттенок",
+ "Neutral dark": "Нейтральный тёмный",
+ "Geist": "Geist",
+ "System sans": "Системный без засечек",
+ "Serif": "С засечками",
+ "Monospace": "Моноширинный",
+ "Default": "По умолчанию",
+ "Comfortable": "Просторный",
};
diff --git a/src/ui/i18n/mywork-tr.ts b/src/ui/i18n/mywork-tr.ts
index 6db0f391c..36d7517c9 100644
--- a/src/ui/i18n/mywork-tr.ts
+++ b/src/ui/i18n/mywork-tr.ts
@@ -1247,4 +1247,19 @@ export const myworkTr: Record<string, string> = {
"Once, or a few times long ago.": "Bir kez ya da uzun zaman önce birkaç kez.",
"More about your rules": "Kurallarınız hakkında daha fazlası",
"Preview rules file": "Kural dosyasını önizle",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "Okuma paleti",
+ "Font": "Yazı tipi",
+ "Text size": "Metin boyutu",
+ "Current default": "Geçerli varsayılan",
+ "Warm cream": "Sıcak krem",
+ "Neutral light": "Nötr açık",
+ "Warm tint": "Sıcak ton",
+ "Neutral dark": "Nötr koyu",
+ "Geist": "Geist",
+ "System sans": "Sistem sans-serif",
+ "Serif": "Serif",
+ "Monospace": "Eş aralıklı",
+ "Default": "Varsayılan",
+ "Comfortable": "Rahat",
};
diff --git a/src/ui/i18n/mywork-zh.ts b/src/ui/i18n/mywork-zh.ts
index 9f482c1d2..a45c96db5 100644
--- a/src/ui/i18n/mywork-zh.ts
+++ b/src/ui/i18n/mywork-zh.ts
@@ -1267,4 +1267,19 @@ export const myworkZh: Record<string, string> = {
"Once, or a few times long ago.": "说过一次,或很久以前说过几次。",
"More about your rules": "关于您的规则的更多信息",
"Preview rules file": "预览规则文件",
+ // Reading appearance (src/ui/theme-appearance.ts): palettes, faces and text sizes both apps offer.
+ "Reading palette": "阅读配色",
+ "Font": "字体",
+ "Text size": "文字大小",
+ "Current default": "当前默认",
+ "Warm cream": "暖奶油色",
+ "Neutral light": "中性浅色",
+ "Warm tint": "暖色调",
+ "Neutral dark": "中性深色",
+ "Geist": "Geist",
+ "System sans": "系统无衬线",
+ "Serif": "衬线",
+ "Monospace": "等宽",
+ "Default": "默认",
+ "Comfortable": "舒适",
};
diff --git a/src/ui/my-work/src/App.tsx b/src/ui/my-work/src/App.tsx
index 8745e2191..cd1dd2843 100644
--- a/src/ui/my-work/src/App.tsx
+++ b/src/ui/my-work/src/App.tsx
@@ -3,6 +3,7 @@ import { MotionConfig } from 'motion/react'
import { FlaskConicalIcon } from 'lucide-react'
import { useI18n } from '@/lib/i18n'
import { useAppliedTheme } from '@/lib/use-applied-theme'
+import { useAppearance } from '@/lib/use-appearance'
import { crumbOf, PAGE_FRAME, type PageColumn } from '@/lib/page-frame'
import { areaShown } from '@/live/area-page'
import { requestsHeading } from '@/lib/requests-heading'
@@ -117,6 +118,8 @@ export default function App() {
const finishSetup = useStore.use.finishSetup()
// G8: one theme for every screen, the loading and failed ones and setup included.
useAppliedTheme(theme)
+ // The shared reading palette, face and size, on every screen as the theme is.
+ useAppearance()
// Once per mount, read from the store at effect time. Depending on the action
// identity re-posted an open whenever that function was replaced.
useEffect(() => { useStore.getState().reportOpen() }, [])
diff --git a/src/ui/my-work/src/index.css b/src/ui/my-work/src/index.css
index 35ae8a0a9..3f9aca5bd 100644
--- a/src/ui/my-work/src/index.css
+++ b/src/ui/my-work/src/index.css
@@ -790,3 +790,358 @@
:root[data-work-session-checking] body > :not([data-work-session-status]) {
display: none !important;
}
+
+/*
+ * Readable palettes (the theme presets Memory and My Work share): each sets the app's colour tokens, so the green cast
+ * does not survive under a warm or neutral choice. Each belongs to one theme (PALETTE_THEMES in
+ * src/ui/theme-appearance.ts) and applies only under it, so Tailwind's dark: variants and the palette never mix: picking
+ * a palette also picks its theme, and switching the theme afterwards shows that theme's own palette. Faces and reading
+ * sizes follow the same shared appearance.
+ */
+
+html:not(.dark)[data-palette="warm-cream"] {
+ --background: #f5f2eb;
+ --foreground: #202020;
+ --card: #fffdf8;
+ --card-foreground: #202020;
+ --popover: #fffdf8;
+ --popover-foreground: #202020;
+ --primary: #4a3828;
+ --primary-bright: #4a3828;
+ --primary-deep: #3d2e21;
+ --primary-foreground: #fbf8f1;
+ --secondary: #ece7dc;
+ --secondary-foreground: #202020;
+ --muted: #ece7dc;
+ --muted-foreground: #5c554b;
+ --accent: #ece7dc;
+ --accent-foreground: #8a4b2f;
+ --accent-border: #d6cec0;
+ --destructive: #a33733;
+ --border: #e3dccf;
+ --input: #fffdf8;
+ --control-edge: #8a8174;
+ --ring: #8a4b2f;
+ --chart-1: #1b664e;
+ --chart-2: #285d72;
+ --chart-3: #654a73;
+ --chart-4: #784b09;
+ --chart-5: #b44627;
+ --radius: 0.625rem;
+ --sidebar: #fffdf8;
+ --sidebar-foreground: #202020;
+ --sidebar-primary: #4a3828;
+ --sidebar-primary-foreground: #fbf8f1;
+ --sidebar-accent: #ece7dc;
+ --sidebar-accent-foreground: #8a4b2f;
+ --sidebar-border: #d6cec0;
+ --sidebar-ring: #8a4b2f;
+ --place-active: #e2ebdf;
+ --place-active-foreground: #3f6b44;
+ --surface: #ece7dc;
+ --surface-warm: #fffdf8;
+ --surface-cool: #ece7dc;
+ --working: #e2ebdf;
+ --working-foreground: #8a4b2f;
+ --working-border: #d6cec0;
+ --review: #eee4e9;
+ --review-foreground: #76516b;
+ --review-border: #d8c9de;
+ --attention: #f5e8d2;
+ --attention-foreground: #7b511a;
+ --attention-border: #e6d2a8;
+ --idle: #ece7dc;
+ --idle-foreground: #5c554b;
+ --idle-border: #d6cec0;
+ --shipped: #e0e9ed;
+ --shipped-foreground: #3d6477;
+ --shipped-border: #b9d0db;
+ --goal: #e5eee3;
+ --goal-foreground: #385d46;
+ --goal-border: #b7cbb9;
+ --goal-heading: #173e2c;
+ --agent-claude: #f5e4d9;
+ --agent-claude-foreground: #a6472b;
+ --agent-claude-border: #ecc9b8;
+ --agent-codex: #eeeee7;
+ --agent-codex-foreground: #5c554b;
+ --agent-codex-border: #cfd2c8;
+ --agent-gemini: #deeaf0;
+ --agent-gemini-foreground: #285d72;
+ --agent-gemini-border: #b9d0db;
+ --terminal: #f2f2ec;
+ --terminal-foreground: #536057;
+ --terminal-border: #dfe2d8;
+ --panel-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --popover-shadow: 0 2px 6px rgb(30 41 31 / 0.06), 0 18px 44px -16px rgb(30 41 31 / 0.22);
+ --control-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --primary-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --tile-shadow: 0 1px 1.5px rgb(30 41 31 / 0.08);
+ --image-viewer-shadow: 0 4px 12px rgb(30 41 31 / 0.12), 0 32px 80px -24px rgb(17 22 18 / 0.55);
+ --image-viewer-backdrop: rgb(17 22 18 / 0.7);
+ --overlay-dim: rgb(17 22 18 / 0.4);
+ --brand-mark: #d86441;
+}
+
+html:not(.dark)[data-palette="neutral-light"] {
+ --background: #fafafa;
+ --foreground: #242424;
+ --card: #ffffff;
+ --card-foreground: #242424;
+ --popover: #ffffff;
+ --popover-foreground: #242424;
+ --primary: #242424;
+ --primary-bright: #242424;
+ --primary-deep: #333333;
+ --primary-foreground: #fafafa;
+ --secondary: #f0f0f0;
+ --secondary-foreground: #242424;
+ --muted: #f0f0f0;
+ --muted-foreground: #525252;
+ --accent: #f0f0f0;
+ --accent-foreground: #1f5d8a;
+ --accent-border: #d4d4d4;
+ --destructive: #a33733;
+ --border: #e5e5e5;
+ --input: #ffffff;
+ --control-edge: #7a7a7a;
+ --ring: #1f5d8a;
+ --chart-1: #1b664e;
+ --chart-2: #285d72;
+ --chart-3: #654a73;
+ --chart-4: #784b09;
+ --chart-5: #b44627;
+ --radius: 0.625rem;
+ --sidebar: #ffffff;
+ --sidebar-foreground: #242424;
+ --sidebar-primary: #242424;
+ --sidebar-primary-foreground: #fafafa;
+ --sidebar-accent: #f0f0f0;
+ --sidebar-accent-foreground: #1f5d8a;
+ --sidebar-border: #d4d4d4;
+ --sidebar-ring: #1f5d8a;
+ --place-active: #e3eee5;
+ --place-active-foreground: #2f6b3a;
+ --surface: #f0f0f0;
+ --surface-warm: #ffffff;
+ --surface-cool: #f0f0f0;
+ --working: #e3eee5;
+ --working-foreground: #1f5d8a;
+ --working-border: #d4d4d4;
+ --review: #eee6f0;
+ --review-foreground: #654a73;
+ --review-border: #d8c9de;
+ --attention: #f7ecd6;
+ --attention-foreground: #784b09;
+ --attention-border: #e6d2a8;
+ --idle: #f0f0f0;
+ --idle-foreground: #525252;
+ --idle-border: #d4d4d4;
+ --shipped: #e1ebf0;
+ --shipped-foreground: #285d72;
+ --shipped-border: #b9d0db;
+ --goal: #e5eee3;
+ --goal-foreground: #385d46;
+ --goal-border: #b7cbb9;
+ --goal-heading: #173e2c;
+ --agent-claude: #f7e8e1;
+ --agent-claude-foreground: #a94b2d;
+ --agent-claude-border: #ecc9b8;
+ --agent-codex: #eeeee7;
+ --agent-codex-foreground: #525252;
+ --agent-codex-border: #cfd2c8;
+ --agent-gemini: #deeaf0;
+ --agent-gemini-foreground: #285d72;
+ --agent-gemini-border: #b9d0db;
+ --terminal: #f2f2ec;
+ --terminal-foreground: #536057;
+ --terminal-border: #dfe2d8;
+ --panel-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --popover-shadow: 0 2px 6px rgb(30 41 31 / 0.06), 0 18px 44px -16px rgb(30 41 31 / 0.22);
+ --control-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --primary-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --tile-shadow: 0 1px 1.5px rgb(30 41 31 / 0.08);
+ --image-viewer-shadow: 0 4px 12px rgb(30 41 31 / 0.12), 0 32px 80px -24px rgb(17 22 18 / 0.55);
+ --image-viewer-backdrop: rgb(17 22 18 / 0.7);
+ --overlay-dim: rgb(17 22 18 / 0.4);
+ --brand-mark: #d86441;
+}
+
+html:not(.dark)[data-palette="warm-tint"] {
+ --background: #edd1b0;
+ --foreground: #202020;
+ --card: #f8e4cc;
+ --card-foreground: #202020;
+ --popover: #f8e4cc;
+ --popover-foreground: #202020;
+ --primary: #4a2f1c;
+ --primary-bright: #4a2f1c;
+ --primary-deep: #3b2516;
+ --primary-foreground: #fff8ee;
+ --secondary: #e4c39c;
+ --secondary-foreground: #202020;
+ --muted: #e4c39c;
+ --muted-foreground: #4a3a2b;
+ --accent: #e4c39c;
+ --accent-foreground: #6f3b16;
+ --accent-border: #c9a77d;
+ --destructive: #8f2f2b;
+ --border: #d8bb95;
+ --input: #f8e4cc;
+ --control-edge: #8a6b46;
+ --ring: #6f4324;
+ --chart-1: #1b664e;
+ --chart-2: #285d72;
+ --chart-3: #654a73;
+ --chart-4: #784b09;
+ --chart-5: #b44627;
+ --radius: 0.625rem;
+ --sidebar: #f8e4cc;
+ --sidebar-foreground: #202020;
+ --sidebar-primary: #4a2f1c;
+ --sidebar-primary-foreground: #fff8ee;
+ --sidebar-accent: #e4c39c;
+ --sidebar-accent-foreground: #6f3b16;
+ --sidebar-border: #c9a77d;
+ --sidebar-ring: #6f4324;
+ --place-active: #e2e7d4;
+ --place-active-foreground: #2f5b34;
+ --surface: #e4c39c;
+ --surface-warm: #f8e4cc;
+ --surface-cool: #e4c39c;
+ --working: #e2e7d4;
+ --working-foreground: #6f3b16;
+ --working-border: #c9a77d;
+ --review: #eadde0;
+ --review-foreground: #6b455f;
+ --review-border: #d8c9de;
+ --attention: #f1dfbf;
+ --attention-foreground: #714511;
+ --attention-border: #e6d2a8;
+ --idle: #e4c39c;
+ --idle-foreground: #4a3a2b;
+ --idle-border: #c9a77d;
+ --shipped: #dfe6e5;
+ --shipped-foreground: #355a6b;
+ --shipped-border: #b9d0db;
+ --goal: #e5eee3;
+ --goal-foreground: #385d46;
+ --goal-border: #b7cbb9;
+ --goal-heading: #173e2c;
+ --agent-claude: #f0d9c8;
+ --agent-claude-foreground: #8f3c21;
+ --agent-claude-border: #ecc9b8;
+ --agent-codex: #eeeee7;
+ --agent-codex-foreground: #4a3a2b;
+ --agent-codex-border: #cfd2c8;
+ --agent-gemini: #deeaf0;
+ --agent-gemini-foreground: #285d72;
+ --agent-gemini-border: #b9d0db;
+ --terminal: #f2f2ec;
+ --terminal-foreground: #536057;
+ --terminal-border: #dfe2d8;
+ --panel-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --popover-shadow: 0 2px 6px rgb(30 41 31 / 0.06), 0 18px 44px -16px rgb(30 41 31 / 0.22);
+ --control-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --primary-shadow: 0 2px 4px rgb(30 41 31 / 0.035);
+ --tile-shadow: 0 1px 1.5px rgb(30 41 31 / 0.08);
+ --image-viewer-shadow: 0 4px 12px rgb(30 41 31 / 0.12), 0 32px 80px -24px rgb(17 22 18 / 0.55);
+ --image-viewer-backdrop: rgb(17 22 18 / 0.7);
+ --overlay-dim: rgb(17 22 18 / 0.4);
+ --brand-mark: #b9502f;
+}
+
+html.dark[data-palette="neutral-dark"] {
+ --background: #22252a;
+ --foreground: #e0e0e0;
+ --card: #282c32;
+ --card-foreground: #e0e0e0;
+ --popover: #282c32;
+ --popover-foreground: #e0e0e0;
+ --primary: #e0e0e0;
+ --primary-bright: #e0e0e0;
+ --primary-deep: #d0d0d0;
+ --primary-foreground: #22252a;
+ --secondary: #2d3138;
+ --secondary-foreground: #e0e0e0;
+ --muted: #2d3138;
+ --muted-foreground: #b8c0c9;
+ --accent: #2d3138;
+ --accent-foreground: #9cc7f0;
+ --accent-border: #444a52;
+ --destructive: #f39a96;
+ --border: #343a41;
+ --input: #282c32;
+ --control-edge: #818a94;
+ --ring: #a9c7e8;
+ --chart-1: #a1d6b5;
+ --chart-2: #afd3dd;
+ --chart-3: #d9bedf;
+ --chart-4: #efd096;
+ --chart-5: #f1a183;
+ --sidebar: #282c32;
+ --sidebar-foreground: #e0e0e0;
+ --sidebar-primary: #e0e0e0;
+ --sidebar-primary-foreground: #22252a;
+ --sidebar-accent: #2d3138;
+ --sidebar-accent-foreground: #9cc7f0;
+ --sidebar-border: #444a52;
+ --sidebar-ring: #a9c7e8;
+ --place-active: #2b3a31;
+ --place-active-foreground: #98d6a6;
+ --surface: #2d3138;
+ --surface-warm: #282c32;
+ --surface-cool: #2d3138;
+ --working: #2b3a31;
+ --working-foreground: #9cc7f0;
+ --working-border: #444a52;
+ --review: #36303d;
+ --review-foreground: #d3bfe0;
+ --review-border: #5a4a61;
+ --attention: #373328;
+ --attention-foreground: #e5cf9f;
+ --attention-border: #5c4b31;
+ --idle: #2d3138;
+ --idle-foreground: #b8c0c9;
+ --idle-border: #444a52;
+ --shipped: #293740;
+ --shipped-foreground: #a9cbe3;
+ --shipped-border: #41575f;
+ --goal: #263c30;
+ --goal-foreground: #c1d6c4;
+ --goal-border: #415e49;
+ --goal-heading: #f1f5e9;
+ --agent-claude: #372d28;
+ --agent-claude-foreground: #eaa88d;
+ --agent-claude-border: #5c4234;
+ --agent-codex: #262d26;
+ --agent-codex-foreground: #b8c0c9;
+ --agent-codex-border: #434b42;
+ --agent-gemini: #29383e;
+ --agent-gemini-foreground: #afd3dd;
+ --agent-gemini-border: #41575f;
+ --terminal: #1b1f1c;
+ --terminal-foreground: #b4bcb1;
+ --terminal-border: #343d35;
+ --panel-shadow: 0 0 #0000;
+ --popover-shadow: 0 18px 44px -14px rgb(0 0 0 / 0.75);
+ --control-shadow: 0 0 #0000;
+ --primary-shadow: 0 0 #0000;
+ --tile-shadow: 0 0 #0000;
+ --image-viewer-shadow: 0 4px 12px rgb(0 0 0 / 0.5), 0 32px 80px -24px rgb(0 0 0 / 0.9);
+ --image-viewer-backdrop: rgb(17 22 18 / 0.75);
+ --overlay-dim: rgb(17 22 18 / 0.6);
+ --brand-mark: #d86441;
+}
+
+html[data-font="sans"] { --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; --font-heading: var(--font-sans); }
+html[data-font="serif"] { --font-sans: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif; --font-heading: var(--font-sans); }
+html[data-font="mono"] { --font-sans: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; --font-heading: var(--font-sans); }
+
+/* Reading sizes scale the root font size, so every rem-based Tailwind size follows; not zoom, which moves the
+ coordinates Radix's popovers and menus are placed by. */
+html[data-reading="compact"] { --theme-scale: 0.94; --theme-line-height: 1.45; }
+html[data-reading="default"] { --theme-scale: 1; --theme-line-height: 1.54; }
+html[data-reading="comfortable"] { --theme-scale: 1.08; --theme-line-height: 1.65; }
+html[data-reading] { font-size: calc(100% * var(--theme-scale, 1)); }
+html[data-reading] body { line-height: var(--theme-line-height, 1.54); }
diff --git a/src/ui/my-work/src/lib/theme-pre-paint.ts b/src/ui/my-work/src/lib/theme-pre-paint.ts
index 33dc9582b..026e27d79 100644
--- a/src/ui/my-work/src/lib/theme-pre-paint.ts
+++ b/src/ui/my-work/src/lib/theme-pre-paint.ts
@@ -8,6 +8,9 @@
// this file outside the app.
import { THEME_CHOICE_STORAGE_KEY, THEME_CHOICES, type ResolvedTheme, type ThemeChoice } from './theme.ts'
import { OLDEST_MIGRATED_PREFERENCES_VERSION, PREFERENCES_STORAGE_KEY, PREFERENCES_VERSION } from '../store/preferences.ts'
+import {
+ DEFAULT_THEME_APPEARANCE, FONT_CHOICES, READING_CHOICES, THEME_APPEARANCE_STORAGE_KEY, THEME_PRESETS,
+} from '../../../theme-appearance.ts'
/** The choice that follows the operating system, and the one resolved theme that puts `.dark` on <html>. */
const FOLLOWS_SYSTEM: ThemeChoice = 'system'
@@ -25,7 +28,7 @@ export const THEME_PRE_PAINT_MARK = '<!-- theme-pre-paint -->'
* be read (blocked storage, broken JSON) leave the system's theme and say why in the console; the store then starts
* from the same defaults.
*/
-export const THEME_PRE_PAINT_SCRIPT = `(function (choices, followsSystem, dark, themeKey, preferencesKey, oldest, version) {
+export const THEME_PRE_PAINT_SCRIPT = `(function (choices, followsSystem, dark, themeKey, preferencesKey, oldest, version, appearanceKey, presets, fonts, readings, defaultAppearance) {
var params = new URLSearchParams(location.search)
var choice = params.get('theme')
if (choices.indexOf(choice) < 0) {
@@ -43,7 +46,24 @@ export const THEME_PRE_PAINT_SCRIPT = `(function (choices, followsSystem, dark,
}
var resolved = choice === followsSystem ? (matchMedia('(prefers-color-scheme: dark)').matches ? dark : null) : choice
if (resolved === dark) document.documentElement.classList.add('dark')
-})(${JSON.stringify(THEME_CHOICES)}, ${JSON.stringify(FOLLOWS_SYSTEM)}, ${JSON.stringify(DARK)}, ${JSON.stringify(THEME_CHOICE_STORAGE_KEY)}, ${JSON.stringify(PREFERENCES_STORAGE_KEY)}, ${JSON.stringify(OLDEST_MIGRATED_PREFERENCES_VERSION)}, ${JSON.stringify(PREFERENCES_VERSION)})`
+ var root = document.documentElement
+ var look = defaultAppearance
+ try {
+ var stored = JSON.parse(localStorage.getItem(appearanceKey) || 'null')
+ if (stored) look = {
+ preset: presets.indexOf(stored.preset) >= 0 ? stored.preset : defaultAppearance.preset,
+ font: fonts.indexOf(stored.font) >= 0 ? stored.font : defaultAppearance.font,
+ reading: readings.indexOf(stored.reading) >= 0 ? stored.reading : defaultAppearance.reading
+ }
+ } catch (error) {
+ console.warn('[my-work] The saved reading appearance could not be read, so the default is used:', error)
+ }
+ root.setAttribute('data-palette', look.preset)
+ root.setAttribute('data-font', look.font)
+ root.setAttribute('data-reading', look.reading)
+})(${[THEME_CHOICES, FOLLOWS_SYSTEM, DARK, THEME_CHOICE_STORAGE_KEY, PREFERENCES_STORAGE_KEY, OLDEST_MIGRATED_PREFERENCES_VERSION, PREFERENCES_VERSION,
+ THEME_APPEARANCE_STORAGE_KEY, THEME_PRESETS, FONT_CHOICES, READING_CHOICES, DEFAULT_THEME_APPEARANCE]
+ .map(value => JSON.stringify(value)).join(', ')})`
/** index.html with the script where its mark is. Fails loudly when the mark is missing, so a build never ships without it. */
export function withThemePrePaintScript(html: string): string {
diff --git a/src/ui/my-work/src/lib/use-appearance.ts b/src/ui/my-work/src/lib/use-appearance.ts
new file mode 100644
index 000000000..fa2d47780
--- /dev/null
+++ b/src/ui/my-work/src/lib/use-appearance.ts
@@ -0,0 +1,11 @@
+import { useLayoutEffect, useSyncExternalStore } from 'react'
+import {
+ applyThemeAppearance, DEFAULT_THEME_APPEARANCE, subscribeThemeAppearance, themeAppearanceSnapshot, updateThemeAppearance,
+} from '../../../theme-appearance.ts'
+
+/** The shared reading appearance (src/ui/theme-appearance.ts): keeps it on <html> and returns its change function. */
+export function useAppearance() {
+ const appearance = useSyncExternalStore(subscribeThemeAppearance, themeAppearanceSnapshot, () => DEFAULT_THEME_APPEARANCE)
+ useLayoutEffect(() => { applyThemeAppearance(document.documentElement, appearance) }, [appearance])
+ return { appearance, update: updateThemeAppearance }
+}
diff --git a/src/ui/my-work/src/pages/workspace.tsx b/src/ui/my-work/src/pages/workspace.tsx
index e53ea30ed..ea431591b 100644
--- a/src/ui/my-work/src/pages/workspace.tsx
+++ b/src/ui/my-work/src/pages/workspace.tsx
@@ -21,6 +21,11 @@ import { RowMark, RowWords } from '@/components/page-controls'
import { interpolate, LOCALE_NAMES, LOCALES, useI18n } from '@/lib/i18n'
import { placeLinkPress, usePageHref } from '@/lib/place-link'
import { isThemeChoice, THEME_CHOICES, type ThemeChoice } from '@/lib/theme'
+import { useAppearance } from '@/lib/use-appearance'
+import {
+ APPEARANCE_WORDS, FONT_CHOICES, FONT_CHOICE_LABELS, PALETTE_THEMES, READING_CHOICES, READING_CHOICE_LABELS,
+ THEME_PRESETS, THEME_PRESET_LABELS, type FontChoice, type ReadingChoice, type ThemePreset,
+} from '../../../theme-appearance'
import { cn } from '@/lib/utils'
import { Req } from '@/spec/req'
import { isServedFromCloud } from '@/live/served-from'
@@ -106,6 +111,7 @@ export function Workspace() {
const feedLabel = useStore((state) => state.work.connection?.label ?? null)
const sample = useStore((state) => state.work.sourceKind === 'sample')
const theme = useStore((state) => themeChoiceInUse(state.view))
+ const { appearance, update: updateAppearance } = useAppearance()
const showSpec = useStore((state) => state.view.showSpec)
const artwork = useStore((state) => state.view.focusArtwork)
const { setTheme, setShowSpec, setWorkspace, setFocusArtwork, goToPage } = useStore.getState()
@@ -118,6 +124,12 @@ export function Workspace() {
if (!isThemeChoice(value)) throw new Error(`Unknown theme choice ${value}`)
setTheme(value)
}
+ /** A palette belongs to one theme (PALETTE_THEMES), so choosing it also chooses that theme. */
+ const choosePalette = (preset: ThemePreset) => {
+ updateAppearance({ preset })
+ const paletteTheme = PALETTE_THEMES[preset]
+ if (paletteTheme) setTheme(paletteTheme)
+ }
const chooseLocale = (value: string) => {
if (!value) return
const chosen = LOCALES.find((code) => code === value)
@@ -139,12 +151,34 @@ export function Workspace() {
<PanelPair>
<Panel title={t('Appearance')}>
<ChoiceRow icon={SunMoonIcon} title={t('Theme')} value={THEME_CHOICE_LOOK[theme].words(t)} open={open === 'theme'} onToggle={toggle('theme')}>
- <ToggleGroup type="single" variant="outline" size="sm" spacing={1} value={theme} onValueChange={chooseTheme} aria-label={t('Theme')}>
- {THEME_CHOICES.map((choice) => {
- const { words, icon: Icon } = THEME_CHOICE_LOOK[choice]
- return <ToggleGroupItem key={choice} value={choice} data-theme-choice={choice} className="gap-1.5 px-3"><Icon aria-hidden="true" />{words(t)}</ToggleGroupItem>
- })}
- </ToggleGroup>
+ <div className="space-y-4">
+ <ToggleGroup type="single" variant="outline" size="sm" spacing={1} value={theme} onValueChange={chooseTheme} aria-label={t('Theme')}>
+ {THEME_CHOICES.map((choice) => {
+ const { words, icon: Icon } = THEME_CHOICE_LOOK[choice]
+ return <ToggleGroupItem key={choice} value={choice} data-theme-choice={choice} className="gap-1.5 px-3"><Icon aria-hidden="true" />{words(t)}</ToggleGroupItem>
+ })}
+ </ToggleGroup>
+ <div className="grid gap-3 sm:grid-cols-2">
+ <label className="grid gap-1 text-sm font-medium">{t(APPEARANCE_WORDS.palette)}
+ <select className="min-h-10 rounded-md border border-control-edge bg-card px-2 text-sm font-normal" value={appearance.preset}
+ onChange={(event) => choosePalette(event.target.value as ThemePreset)}>
+ {THEME_PRESETS.map((preset) => <option key={preset} value={preset}>{t(THEME_PRESET_LABELS[preset])}</option>)}
+ </select>
+ </label>
+ <label className="grid gap-1 text-sm font-medium">{t(APPEARANCE_WORDS.font)}
+ <select className="min-h-10 rounded-md border border-control-edge bg-card px-2 text-sm font-normal" value={appearance.font}
+ onChange={(event) => updateAppearance({ font: event.target.value as FontChoice })}>
+ {FONT_CHOICES.map((font) => <option key={font} value={font}>{t(FONT_CHOICE_LABELS[font])}</option>)}
+ </select>
+ </label>
+ <label className="grid gap-1 text-sm font-medium">{t(APPEARANCE_WORDS.reading)}
+ <select className="min-h-10 rounded-md border border-control-edge bg-card px-2 text-sm font-normal" value={appearance.reading}
+ onChange={(event) => updateAppearance({ reading: event.target.value as ReadingChoice })}>
+ {READING_CHOICES.map((reading) => <option key={reading} value={reading}>{t(READING_CHOICE_LABELS[reading])}</option>)}
+ </select>
+ </label>
+ </div>
+ </div>
</ChoiceRow>
<ChoiceRow icon={LanguagesIcon} title={t('Language')} value={LOCALE_NAMES[locale]} open={open === 'language'} onToggle={toggle('language')}>
<ToggleGroup type="single" variant="outline" size="sm" spacing={1} value={locale} onValueChange={chooseLocale} aria-label={t('Language')}>
diff --git a/src/ui/theme-appearance.ts b/src/ui/theme-appearance.ts
new file mode 100644
index 000000000..5eb22a05c
--- /dev/null
+++ b/src/ui/theme-appearance.ts
@@ -0,0 +1,164 @@
+// The readable palettes and type choices both apps save, beside the theme (src/ui/theme-choice.ts): a curated warm
+// palette for long reading, a font and a reading size. No imports and no React, so the pre-paint scripts, both apps'
+// useAppearance hooks and the viewer bundle can all take the one definition.
+
+/** The curated palettes, in the order both apps offer them. "Default" keeps the palette each theme already has. */
+export const THEME_PRESETS = ['default', 'warm-cream', 'neutral-light', 'warm-tint', 'neutral-dark'] as const
+export type ThemePreset = (typeof THEME_PRESETS)[number]
+
+export const THEME_PRESET_LABELS: Record<ThemePreset, string> = {
+ default: 'Current default',
+ 'warm-cream': 'Warm cream',
+ 'neutral-light': 'Neutral light',
+ 'warm-tint': 'Warm tint',
+ 'neutral-dark': 'Neutral dark',
+}
+
+/**
+ * The theme each palette belongs to. A palette's tokens apply only under its theme (both stylesheets scope them), and
+ * choosing a palette also chooses its theme, so a light palette never paints under dark components or the reverse.
+ * "Default" belongs to neither: it keeps whichever theme is chosen.
+ */
+export const PALETTE_THEMES: Record<ThemePreset, 'light' | 'dark' | null> = {
+ default: null,
+ 'warm-cream': 'light',
+ 'neutral-light': 'light',
+ 'warm-tint': 'light',
+ 'neutral-dark': 'dark',
+}
+
+/** The faces words can use. "Default" is the app's own (Geist); the others are faces people already have. */
+export const FONT_CHOICES = ['default', 'sans', 'serif', 'mono'] as const
+export type FontChoice = (typeof FONT_CHOICES)[number]
+
+export const FONT_CHOICE_LABELS: Record<FontChoice, string> = {
+ default: 'Geist',
+ sans: 'System sans',
+ serif: 'Serif',
+ mono: 'Monospace',
+}
+
+/** How large reading text runs. Each also sets its line height (compact 1.45, default 1.54, comfortable 1.65). */
+export const READING_CHOICES = ['compact', 'default', 'comfortable'] as const
+export type ReadingChoice = (typeof READING_CHOICES)[number]
+
+export const READING_CHOICE_LABELS: Record<ReadingChoice, string> = {
+ compact: 'Compact',
+ default: 'Default',
+ comfortable: 'Comfortable',
+}
+
+/** The words the appearance controls show. Passed through t(); tests/viewer/theme-appearance.test.ts checks every
+ * catalog has them, since the literal t('…') scan cannot see words picked from a table. */
+export const APPEARANCE_WORDS = {
+ appearance: 'Appearance',
+ palette: 'Reading palette',
+ font: 'Font',
+ reading: 'Text size',
+} as const
+
+/** The localStorage key the appearance is saved under, beside the theme's `claude-mem-theme`. */
+export const THEME_APPEARANCE_STORAGE_KEY = 'claude-mem-theme-appearance'
+
+export interface ThemeAppearance {
+ preset: ThemePreset
+ font: FontChoice
+ reading: ReadingChoice
+}
+
+/** What both apps use when nothing (or nothing readable) is saved. */
+export const DEFAULT_THEME_APPEARANCE: ThemeAppearance = Object.freeze({
+ preset: 'default',
+ font: 'default',
+ reading: 'default',
+})
+
+/** The part of localStorage the appearance uses; left out, the browser's localStorage. */
+export type AppearanceStorage = Pick<Storage, 'getItem' | 'setItem'>
+
+export function isThemePreset(value: unknown): value is ThemePreset {
+ return (THEME_PRESETS as readonly unknown[]).includes(value)
+}
+
+export function isFontChoice(value: unknown): value is FontChoice {
+ return (FONT_CHOICES as readonly unknown[]).includes(value)
+}
+
+export function isReadingChoice(value: unknown): value is ReadingChoice {
+ return (READING_CHOICES as readonly unknown[]).includes(value)
+}
+
+/** A saved or hand-edited value in this version's meaning: each field a choice it knows, else its default. */
+export function normalizeThemeAppearance(value: unknown): ThemeAppearance {
+ const saved = (value ?? {}) as Partial<Record<keyof ThemeAppearance, unknown>>
+ return {
+ preset: isThemePreset(saved.preset) ? saved.preset : DEFAULT_THEME_APPEARANCE.preset,
+ font: isFontChoice(saved.font) ? saved.font : DEFAULT_THEME_APPEARANCE.font,
+ reading: isReadingChoice(saved.reading) ? saved.reading : DEFAULT_THEME_APPEARANCE.reading,
+ }
+}
+
+/**
+ * The saved appearance, or the default when none is saved or the saved value is not readable. Storage that cannot be
+ * read (blocked site data) is said in the console and reads as the default, as the theme's saved value does.
+ */
+export function readSavedThemeAppearance(storage?: AppearanceStorage): ThemeAppearance {
+ try {
+ const saved = (storage ?? localStorage).getItem(THEME_APPEARANCE_STORAGE_KEY)
+ return saved === null ? DEFAULT_THEME_APPEARANCE : normalizeThemeAppearance(JSON.parse(saved))
+ } catch (error: unknown) {
+ console.warn('The saved reading appearance could not be read, so the default is used:', error instanceof Error ? error.message : String(error))
+ return DEFAULT_THEME_APPEARANCE
+ }
+}
+
+/** Saves the appearance for both apps. Storage that cannot be written is said in the console; the choice then lasts only while the page is open. */
+export function saveThemeAppearance(appearance: ThemeAppearance, storage?: AppearanceStorage): ThemeAppearance {
+ const normalized = normalizeThemeAppearance(appearance)
+ try {
+ (storage ?? localStorage).setItem(THEME_APPEARANCE_STORAGE_KEY, JSON.stringify(normalized))
+ } catch (error: unknown) {
+ console.warn('The reading appearance could not be saved, so it lasts only while this page is open:', error instanceof Error ? error.message : String(error))
+ }
+ return normalized
+}
+
+/** Said on window when this page changes the appearance; another tab's change arrives as a storage event. */
+const APPEARANCE_CHANGE_EVENT = 'claude-mem-theme-appearance-change'
+let current: ThemeAppearance | null = null
+/** The page's window as an event target. Typed structurally, since this file is also compiled without the DOM library. */
+const pageEvents = (): EventTarget => globalThis as unknown as EventTarget
+
+/** The appearance in use on this page (useSyncExternalStore's snapshot): read once, then kept in step by changes. */
+export function themeAppearanceSnapshot(): ThemeAppearance {
+ if (current === null) current = readSavedThemeAppearance()
+ return current
+}
+
+/** Calls `onChange` when this page or another tab changes the appearance (useSyncExternalStore's subscribe). */
+export function subscribeThemeAppearance(onChange: () => void): () => void {
+ const onStorage = (event: Event) => {
+ const { key } = event as Event & { key: string | null }
+ if (key === null || key === THEME_APPEARANCE_STORAGE_KEY) { current = null; onChange() }
+ }
+ // A change made here already set `current`; it holds even when storage is blocked, as the theme keeps its choice.
+ pageEvents().addEventListener(APPEARANCE_CHANGE_EVENT, onChange)
+ pageEvents().addEventListener('storage', onStorage)
+ return () => {
+ pageEvents().removeEventListener(APPEARANCE_CHANGE_EVENT, onChange)
+ pageEvents().removeEventListener('storage', onStorage)
+ }
+}
+
+/** Saves a change for both apps and tells this page's subscribers. */
+export function updateThemeAppearance(change: Partial<ThemeAppearance>): void {
+ current = saveThemeAppearance({ ...themeAppearanceSnapshot(), ...change })
+ pageEvents().dispatchEvent(new Event(APPEARANCE_CHANGE_EVENT))
+}
+
+/** Puts the appearance on <html> as the attributes both stylesheets read: its palette, face and reading size. */
+export function applyThemeAppearance(root: { setAttribute(name: string, value: string): void }, appearance: ThemeAppearance): void {
+ root.setAttribute('data-palette', appearance.preset)
+ root.setAttribute('data-font', appearance.font)
+ root.setAttribute('data-reading', appearance.reading)
+}
diff --git a/src/ui/viewer-template.html b/src/ui/viewer-template.html
index a05c0466e..df44edb46 100644
--- a/src/ui/viewer-template.html
+++ b/src/ui/viewer-template.html
@@ -281,6 +281,239 @@
}
}
+ /* Readable palettes (the theme presets both apps offer): a warm page for long reading, two neutral ones and the
+ designer's warm tint. Each sets every token the stylesheet reads, so no green cast survives from the theme under
+ it. Each belongs to one theme (PALETTE_THEMES in src/ui/theme-appearance.ts) and applies only under it: picking a
+ palette also picks its theme, and switching the theme afterwards shows that theme's own palette, never a mix. */
+
+ [data-theme="light"][data-palette="warm-cream"] {
+ --color-bg-primary: #f5f2eb;
+ --color-bg-secondary: #ece7dc;
+ --color-bg-tertiary: #ece7dc;
+ --color-bg-header: #fffdf8;
+ --color-bg-card: #fffdf8;
+ --color-bg-card-hover: #ece7dc;
+ --color-bg-input: #fffdf8;
+ --color-bg-button: #4a3828;
+ --color-bg-button-hover: #3d2e21;
+ --color-bg-control-hover: #ece7dc;
+ --color-bg-scrollbar-track: #f5f2eb;
+ --color-bg-scrollbar-thumb: #cfc7b8;
+ --color-bg-scrollbar-thumb-hover: #8a8174;
+ --color-border-primary: #d6cec0;
+ --color-border-secondary: #e3dccf;
+ --color-border-control: #8a8174;
+ --color-border-hover: #6b6256;
+ --color-border-focus: #8a4b2f;
+ --color-border-observation: #c9b6a0;
+ --color-text-primary: #202020;
+ --color-text-secondary: #5c554b;
+ --color-text-tertiary: #6d655a;
+ --color-text-header: #202020;
+ --color-text-title: #202020;
+ --color-text-button: #fbf8f1;
+ --color-accent-primary: #8a4b2f;
+ --color-accent-focus: #8a4b2f;
+ --color-accent-success: #3f6b44;
+ --color-accent-error: #a33733;
+ --color-tone-green: #3f6b44;
+ --color-tone-green-bg: #e2ebdf;
+ --color-tone-blue: #3d6477;
+ --color-tone-blue-bg: #e0e9ed;
+ --color-tone-purple: #76516b;
+ --color-tone-purple-bg: #eee4e9;
+ --color-tone-amber: #7b511a;
+ --color-tone-amber-bg: #f5e8d2;
+ --color-tone-brand: #a6472b;
+ --color-tone-brand-bg: #f5e4d9;
+ --color-brand-mark: #d86441;
+ --color-skeleton-base: #e3dccf;
+ --shadow-focus: 0 0 0 2px rgba(138, 75, 47, 0.3);
+ --shadow-panel: 0 2px 4px rgba(61, 46, 33, 0.04);
+ --color-log-debug: #5c554b;
+ --color-log-info: #3d6477;
+ --color-log-warn: #7b511a;
+ --color-log-error: #a33733;
+ --color-log-success: #3f6b44;
+ --color-log-component: #76516b;
+ --font-sans: 'Geist Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-terminal: 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
+ }
+
+ [data-theme="light"][data-palette="neutral-light"] {
+ --color-bg-primary: #fafafa;
+ --color-bg-secondary: #f0f0f0;
+ --color-bg-tertiary: #f0f0f0;
+ --color-bg-header: #ffffff;
+ --color-bg-card: #ffffff;
+ --color-bg-card-hover: #f0f0f0;
+ --color-bg-input: #ffffff;
+ --color-bg-button: #242424;
+ --color-bg-button-hover: #333333;
+ --color-bg-control-hover: #f0f0f0;
+ --color-bg-scrollbar-track: #fafafa;
+ --color-bg-scrollbar-thumb: #d4d4d4;
+ --color-bg-scrollbar-thumb-hover: #7a7a7a;
+ --color-border-primary: #d4d4d4;
+ --color-border-secondary: #e5e5e5;
+ --color-border-control: #7a7a7a;
+ --color-border-hover: #525252;
+ --color-border-focus: #1f5d8a;
+ --color-border-observation: #c4c4c4;
+ --color-text-primary: #242424;
+ --color-text-secondary: #525252;
+ --color-text-tertiary: #616161;
+ --color-text-header: #242424;
+ --color-text-title: #242424;
+ --color-text-button: #fafafa;
+ --color-accent-primary: #1f5d8a;
+ --color-accent-focus: #1f5d8a;
+ --color-accent-success: #2f6b3a;
+ --color-accent-error: #a33733;
+ --color-tone-green: #2f6b3a;
+ --color-tone-green-bg: #e3eee5;
+ --color-tone-blue: #285d72;
+ --color-tone-blue-bg: #e1ebf0;
+ --color-tone-purple: #654a73;
+ --color-tone-purple-bg: #eee6f0;
+ --color-tone-amber: #784b09;
+ --color-tone-amber-bg: #f7ecd6;
+ --color-tone-brand: #a94b2d;
+ --color-tone-brand-bg: #f7e8e1;
+ --color-brand-mark: #d86441;
+ --color-skeleton-base: #e5e5e5;
+ --shadow-focus: 0 0 0 2px rgba(31, 93, 138, 0.3);
+ --shadow-panel: 0 2px 4px rgba(31, 41, 31, 0.035);
+ --color-log-debug: #525252;
+ --color-log-info: #285d72;
+ --color-log-warn: #784b09;
+ --color-log-error: #a33733;
+ --color-log-success: #2f6b3a;
+ --color-log-component: #654a73;
+ --font-sans: 'Geist Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-terminal: 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
+ }
+
+ [data-theme="light"][data-palette="warm-tint"] {
+ --color-bg-primary: #edd1b0;
+ --color-bg-secondary: #e4c39c;
+ --color-bg-tertiary: #e4c39c;
+ --color-bg-header: #f8e4cc;
+ --color-bg-card: #f8e4cc;
+ --color-bg-card-hover: #e4c39c;
+ --color-bg-input: #f8e4cc;
+ --color-bg-button: #4a2f1c;
+ --color-bg-button-hover: #3b2516;
+ --color-bg-control-hover: #e4c39c;
+ --color-bg-scrollbar-track: #edd1b0;
+ --color-bg-scrollbar-thumb: #c3a47f;
+ --color-bg-scrollbar-thumb-hover: #8a6b46;
+ --color-border-primary: #c9a77d;
+ --color-border-secondary: #d8bb95;
+ --color-border-control: #8a6b46;
+ --color-border-hover: #6f5330;
+ --color-border-focus: #6f4324;
+ --color-border-observation: #c9a77d;
+ --color-text-primary: #202020;
+ --color-text-secondary: #4a3a2b;
+ --color-text-tertiary: #5b4938;
+ --color-text-header: #202020;
+ --color-text-title: #202020;
+ --color-text-button: #fff8ee;
+ --color-accent-primary: #6f3b16;
+ --color-accent-focus: #6f4324;
+ --color-accent-success: #2f5b34;
+ --color-accent-error: #8f2f2b;
+ --color-tone-green: #2f5b34;
+ --color-tone-green-bg: #e2e7d4;
+ --color-tone-blue: #355a6b;
+ --color-tone-blue-bg: #dfe6e5;
+ --color-tone-purple: #6b455f;
+ --color-tone-purple-bg: #eadde0;
+ --color-tone-amber: #714511;
+ --color-tone-amber-bg: #f1dfbf;
+ --color-tone-brand: #8f3c21;
+ --color-tone-brand-bg: #f0d9c8;
+ --color-brand-mark: #b9502f;
+ --color-skeleton-base: #d8bb95;
+ --shadow-focus: 0 0 0 2px rgba(111, 67, 36, 0.3);
+ --shadow-panel: 0 2px 4px rgba(74, 47, 28, 0.05);
+ --color-log-debug: #4a3a2b;
+ --color-log-info: #355a6b;
+ --color-log-warn: #714511;
+ --color-log-error: #8f2f2b;
+ --color-log-success: #2f5b34;
+ --color-log-component: #6b455f;
+ --font-sans: 'Geist Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-terminal: 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
+ }
+
+ [data-theme="dark"][data-palette="neutral-dark"] {
+ --color-bg-primary: #22252a;
+ --color-bg-secondary: #2d3138;
+ --color-bg-tertiary: #2d3138;
+ --color-bg-header: #282c32;
+ --color-bg-card: #282c32;
+ --color-bg-card-hover: #2d3138;
+ --color-bg-input: #282c32;
+ --color-bg-button: #e0e0e0;
+ --color-bg-button-hover: #d0d0d0;
+ --color-bg-control-hover: #2d3138;
+ --color-bg-scrollbar-track: #22252a;
+ --color-bg-scrollbar-thumb: #444a52;
+ --color-bg-scrollbar-thumb-hover: #818a94;
+ --color-border-primary: #444a52;
+ --color-border-secondary: #343a41;
+ --color-border-control: #818a94;
+ --color-border-hover: #b8c0c9;
+ --color-border-focus: #a9c7e8;
+ --color-border-observation: #46535f;
+ --color-text-primary: #e0e0e0;
+ --color-text-secondary: #b8c0c9;
+ --color-text-tertiary: #aab3bc;
+ --color-text-header: #e0e0e0;
+ --color-text-title: #e0e0e0;
+ --color-text-button: #22252a;
+ --color-accent-primary: #9cc7f0;
+ --color-accent-focus: #a9c7e8;
+ --color-accent-success: #98d6a6;
+ --color-accent-error: #f39a96;
+ --color-tone-green: #98d6a6;
+ --color-tone-green-bg: #2b3a31;
+ --color-tone-blue: #a9cbe3;
+ --color-tone-blue-bg: #293740;
+ --color-tone-purple: #d3bfe0;
+ --color-tone-purple-bg: #36303d;
+ --color-tone-amber: #e5cf9f;
+ --color-tone-amber-bg: #373328;
+ --color-tone-brand: #eaa88d;
+ --color-tone-brand-bg: #372d28;
+ --color-brand-mark: #d86441;
+ --color-skeleton-base: #343a41;
+ --shadow-focus: 0 0 0 2px rgba(169, 199, 232, 0.25);
+ --shadow-panel: 0 0 #0000;
+ --color-log-debug: #b8c0c9;
+ --color-log-info: #a9cbe3;
+ --color-log-warn: #e5cf9f;
+ --color-log-error: #f39a96;
+ --color-log-success: #98d6a6;
+ --color-log-component: #d3bfe0;
+ --font-sans: 'Geist Variable', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-terminal: 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace;
+ }
+
+ /* Font choices replace only the words' face; Geist Mono keeps ids, times and logs. */
+ [data-font="sans"] { --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
+ [data-font="serif"] { --font-sans: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Times New Roman', serif; }
+ [data-font="mono"] { --font-sans: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
+
+ /* Reading sizes: Memory's type sizes are the fixed sheet above (tests/viewer/viewer-type-scale.test.ts), so here a
+ size choice made in My Work sets only the line height that goes with it, never a page zoom (the windowed feed and
+ the menus measure the page, and zooming would change what they measure). */
+ [data-reading="compact"] { --theme-line-height: 1.45; }
+ [data-reading="default"] { --theme-line-height: 1.54; }
+ [data-reading="comfortable"] { --theme-line-height: 1.65; }
+
* {
margin: 0;
padding: 0;
@@ -1174,7 +1407,7 @@
.textbtn, .icbtn, .listrow, .rowtitle, .rowmeta, .sketch-icon, .sectionline, .panel, .formrow; My Work's bar sizes.
Every class here starts with mem-. A page's own rules go in its block below.
========================================================================== */
- body { font-family: var(--font-sans); font-size: 16px; line-height: 1.54; -webkit-font-smoothing: antialiased; }
+ body { font-family: var(--font-sans); font-size: 16px; line-height: var(--theme-line-height, 1.54); -webkit-font-smoothing: antialiased; }
.mem-bar a:focus-visible, .mem-bar button:focus-visible, .mem-bottom-bar a:focus-visible, .mem-page a:focus-visible,
.mem-page button:focus-visible, .mem-page select:focus-visible, .mem-page input:focus-visible, .mem-page summary:focus-visible {
outline: 3px solid var(--color-accent-focus); outline-offset: 4px;
diff --git a/src/ui/viewer/App.tsx b/src/ui/viewer/App.tsx
index 2c6ad263b..fa209306f 100644
--- a/src/ui/viewer/App.tsx
+++ b/src/ui/viewer/App.tsx
@@ -20,6 +20,7 @@ import { useSettingsDraft } from './hooks/useSettingsDraft';
import { PageRejectedError, usePagination } from './hooks/usePagination';
import { useSessionCatalog } from './hooks/useSessionCatalog';
import { useTheme } from './hooks/useTheme';
+import { useAppearance } from './hooks/useAppearance';
import { useFeedDeletes } from './hooks/useFeedItemDelete';
import { Observation, Summary, UserPrompt, FeedItemType, type FeedItem } from './types';
import { buildFeedItems, mergeAndDeduplicateByProject } from './utils/data';
@@ -149,6 +150,8 @@ export function App() {
// Declared before the hashchange listener below: its own (capturing) listener asks before the settings pages are left.
const settingsDraft = useSettingsDraft({ settings, isSaving, saveStatus }, route);
const { preference, setThemePreference } = useTheme();
+ // The reading palette, face and size (src/ui/theme-appearance.ts): applied here so every page and the error card share it.
+ useAppearance();
const pagination = usePagination(feedScope.project, feedScope.session);
// Held here, above the views, so a delete's refusal is still on its card after the reader leaves and comes back.
const feedDeletes = useFeedDeletes(removeDeletedItem);
@@ -669,6 +672,7 @@ export function App() {
isSaving={isSaving}
saveStatus={saveStatus}
draft={settingsDraft}
+ onThemeChange={setThemePreference}
/>
);
} else if (route.view === 'context-preview') {
diff --git a/src/ui/viewer/components/AppearanceSettings.tsx b/src/ui/viewer/components/AppearanceSettings.tsx
new file mode 100644
index 000000000..ecf2e64e0
--- /dev/null
+++ b/src/ui/viewer/components/AppearanceSettings.tsx
@@ -0,0 +1,43 @@
+import React, { useId } from 'react';
+import { useI18n } from '../../i18n';
+import type { ResolvedTheme } from '../../theme-choice';
+import {
+ APPEARANCE_WORDS, FONT_CHOICES, FONT_CHOICE_LABELS, PALETTE_THEMES, THEME_PRESETS, THEME_PRESET_LABELS,
+ type FontChoice, type ThemePreset,
+} from '../../theme-appearance';
+import { useAppearance } from '../hooks/useAppearance';
+
+/**
+ * Reading appearance on Memory's Display settings: the curated palette and the face. The text size is My Work's alone
+ * (Memory's type sizes are a fixed sheet; viewer-template.html says why), so it is not offered here. The pre-paint
+ * script (utils/theme-pre-paint.ts) already put the saved choice on <html>, and useAppearance (App.tsx) keeps it there;
+ * this only changes the shared saved value. A palette also picks its own theme (PALETTE_THEMES).
+ */
+export function AppearanceSettings({ onThemeChange }: { onThemeChange: (theme: ResolvedTheme) => void }) {
+ const { t } = useI18n();
+ const id = useId();
+ const { appearance, update } = useAppearance();
+ const choosePalette = (preset: ThemePreset) => {
+ update({ preset });
+ const theme = PALETTE_THEMES[preset];
+ if (theme) onThemeChange(theme);
+ };
+ return (
+ <div className="appearance-settings" role="group" aria-label={t(APPEARANCE_WORDS.appearance)}>
+ <div className="mem-formrow">
+ <label htmlFor={`${id}-palette`}>{t(APPEARANCE_WORDS.palette)}</label>
+ <select id={`${id}-palette`} className="mem-select" value={appearance.preset}
+ onChange={event => choosePalette(event.target.value as ThemePreset)}>
+ {THEME_PRESETS.map(preset => <option key={preset} value={preset}>{t(THEME_PRESET_LABELS[preset])}</option>)}
+ </select>
+ </div>
+ <div className="mem-formrow">
+ <label htmlFor={`${id}-font`}>{t(APPEARANCE_WORDS.font)}</label>
+ <select id={`${id}-font`} className="mem-select" value={appearance.font}
+ onChange={event => update({ font: event.target.value as FontChoice })}>
+ {FONT_CHOICES.map(font => <option key={font} value={font}>{t(FONT_CHOICE_LABELS[font])}</option>)}
+ </select>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/viewer/components/ContextSettingsModal.tsx b/src/ui/viewer/components/ContextSettingsModal.tsx
index 4b9958c0a..03f01b0f9 100644
--- a/src/ui/viewer/components/ContextSettingsModal.tsx
+++ b/src/ui/viewer/components/ContextSettingsModal.tsx
@@ -6,6 +6,9 @@ import type { SaveOutcome, SaveStatus } from '../hooks/useSettings';
import { replaceAddress, type SettingsDraft } from '../hooks/useSettingsDraft';
import type { Settings } from '../types';
import { InlineConfirm } from './InlineConfirm';
+import { AppearanceSettings } from './AppearanceSettings';
+import { APPEARANCE_WORDS as APPEARANCE_WORDS_SETTINGS } from '../../theme-appearance';
+import type { ResolvedTheme } from '../../theme-choice';
import { ArrowRightIcon, CheckCircleIcon, ChevronLeftIcon, EyeIcon, EyeOffIcon, LockIcon, WarningIcon } from './icons';
import { useBackupStatus } from '../hooks/useBackupStatus';
import { DEFAULT_SETTINGS } from '../constants/settings';
@@ -35,6 +38,8 @@ interface SettingsPageProps {
/** How the last save ended (useSettings is its one writer). */
saveStatus: SaveStatus;
draft: SettingsDraft;
+ /** Saves a theme choice (App's useTheme): choosing a reading palette also chooses the theme it belongs to. */
+ onThemeChange: (theme: ResolvedTheme) => void;
}
type Translate = (english: string) => string;
@@ -307,6 +312,7 @@ export function SettingsPage({
isSaving,
saveStatus,
draft,
+ onThemeChange,
}: SettingsPageProps) {
const { t } = useI18n();
const idPrefix = useId();
@@ -449,6 +455,9 @@ export function SettingsPage({
</>)}
{panel('display', <>
+ <Subsection label={t(APPEARANCE_WORDS_SETTINGS.appearance)}>
+ <AppearanceSettings onThemeChange={onThemeChange} />
+ </Subsection>
<Subsection label={t('Full Observations')}>
<NumberField
label={t('Count')}
diff --git a/src/ui/viewer/components/Header.tsx b/src/ui/viewer/components/Header.tsx
index 1f5e61343..6c6636feb 100644
--- a/src/ui/viewer/components/Header.tsx
+++ b/src/ui/viewer/components/Header.tsx
@@ -3,6 +3,8 @@ import { LOCALES, LOCALE_NAMES, useI18n, interpolate } from '../../i18n';
import { FIND_WORK_PLACE, MEMORY_PLACE, MY_WORK_PLACES, type MyWorkPlaceId } from '../../app-places';
import { THEME_LABELS } from './ThemeToggle';
import { THEME_PREFERENCES, type ThemePreference } from '../hooks/useTheme';
+import { useAppearance } from '../hooks/useAppearance';
+import { APPEARANCE_WORDS, PALETTE_THEMES, THEME_PRESETS, THEME_PRESET_LABELS } from '../../theme-appearance';
import { useSpinningFavicon } from '../hooks/useSpinningFavicon';
import { formatStarCount, useGitHubStars } from '../hooks/useGitHubStars';
import { PRO_TRIAL_PITCH, PRO_TRIAL_SHORT, PRO_TRIAL_URL, TEAMBRAIN_PITCH, TEAMBRAIN_START_URL } from '../constants/promo';
@@ -158,6 +160,7 @@ export function Header({
showProTrialLink = true,
}: HeaderProps) {
const { t, locale, setLocale } = useI18n();
+ const { appearance, update: updateAppearance } = useAppearance();
useSpinningFavicon(isProcessing);
// The star count is only seen inside the "…" menu, so GitHub is asked once, when the menu first opens.
const [starsWanted, setStarsWanted] = React.useState(false);
@@ -201,6 +204,19 @@ export function Header({
</MenuRadioItem>
))}
</MenuGroup>
+ <MenuGroup label={t(APPEARANCE_WORDS.palette)}>
+ {THEME_PRESETS.map(preset => (
+ <MenuRadioItem key={preset} checked={appearance.preset === preset}
+ onSelect={() => {
+ // A palette belongs to one theme (PALETTE_THEMES), so choosing it also chooses that theme.
+ updateAppearance({ preset });
+ const theme = PALETTE_THEMES[preset];
+ if (theme) onThemeChange(theme);
+ }}>
+ {t(THEME_PRESET_LABELS[preset])}
+ </MenuRadioItem>
+ ))}
+ </MenuGroup>
<MenuGroup label={t('Language')} icon={<GlobeIcon size={14} />}>
{LOCALES.map(code => (
<MenuRadioItem key={code} checked={locale === code} lang={code} onSelect={() => setLocale(code)}>
diff --git a/src/ui/viewer/hooks/useAppearance.ts b/src/ui/viewer/hooks/useAppearance.ts
new file mode 100644
index 000000000..be2b22673
--- /dev/null
+++ b/src/ui/viewer/hooks/useAppearance.ts
@@ -0,0 +1,11 @@
+import { useLayoutEffect, useSyncExternalStore } from 'react';
+import {
+ applyThemeAppearance, DEFAULT_THEME_APPEARANCE, subscribeThemeAppearance, themeAppearanceSnapshot, updateThemeAppearance,
+} from '../../theme-appearance';
+
+/** The shared reading appearance (src/ui/theme-appearance.ts): keeps it on <html> and returns its change function. */
+export function useAppearance() {
+ const appearance = useSyncExternalStore(subscribeThemeAppearance, themeAppearanceSnapshot, () => DEFAULT_THEME_APPEARANCE);
+ useLayoutEffect(() => { applyThemeAppearance(document.documentElement, appearance); }, [appearance]);
+ return { appearance, update: updateThemeAppearance };
+}
diff --git a/src/ui/viewer/utils/theme-pre-paint.ts b/src/ui/viewer/utils/theme-pre-paint.ts
index 85d0cfbf9..08c9f566e 100644
--- a/src/ui/viewer/utils/theme-pre-paint.ts
+++ b/src/ui/viewer/utils/theme-pre-paint.ts
@@ -2,9 +2,14 @@
// puts this script inline in viewer.html's <head>, where the template has its mark; it runs before the page draws, and
// the bundle loads later, so the script cannot import anything. Its key and choices come from their one definition,
// src/ui/theme-choice.ts (My Work saves its choice under the same key), as My Work's own pre-paint script takes them
-// (src/ui/my-work/src/lib/theme-pre-paint.ts). The app's useTheme keeps the attribute after. No imports beyond that
-// module, so the build script and the browser tests can load this file outside the bundle.
+// (src/ui/my-work/src/lib/theme-pre-paint.ts). The reading appearance comes from its own definition,
+// src/ui/theme-appearance.ts, and is put on <html> here too, so a warm palette or a larger reading size never flashes
+// the default first. The app's useTheme and useAppearance keep both after. No imports beyond those modules, so the build
+// script and the browser tests can load this file outside the bundle.
import { THEME_CHOICE_STORAGE_KEY, THEME_CHOICES, type ResolvedTheme, type ThemeChoice } from '../../theme-choice';
+import {
+ DEFAULT_THEME_APPEARANCE, FONT_CHOICES, READING_CHOICES, THEME_APPEARANCE_STORAGE_KEY, THEME_PRESETS,
+} from '../../theme-appearance';
/** The choice that follows the operating system, and the two themes it resolves to. */
const FOLLOWS_SYSTEM: ThemeChoice = 'system';
@@ -15,7 +20,7 @@ const LIGHT: ResolvedTheme = 'light';
export const VIEWER_THEME_PRE_PAINT_MARK = '<!-- theme-pre-paint -->';
/** The saved choice, else the system's theme; storage that cannot be read follows the system and says why. */
-export const VIEWER_THEME_PRE_PAINT_SCRIPT = `(function (key, choices, followsSystem, dark, light) {
+export const VIEWER_THEME_PRE_PAINT_SCRIPT = `(function (key, choices, followsSystem, dark, light, appearanceKey, presets, fonts, readings, defaultAppearance) {
var choice = followsSystem
try {
var saved = localStorage.getItem(key)
@@ -24,8 +29,25 @@ export const VIEWER_THEME_PRE_PAINT_SCRIPT = `(function (key, choices, followsSy
console.warn('The saved theme could not be read, so the page follows the system theme:', error)
}
if (choice === followsSystem) choice = matchMedia('(prefers-color-scheme: dark)').matches ? dark : light
- document.documentElement.setAttribute('data-theme', choice)
-})(${[THEME_CHOICE_STORAGE_KEY, THEME_CHOICES, FOLLOWS_SYSTEM, DARK, LIGHT].map(value => JSON.stringify(value)).join(', ')})`;
+ var root = document.documentElement
+ root.setAttribute('data-theme', choice)
+ var look = defaultAppearance
+ try {
+ var stored = JSON.parse(localStorage.getItem(appearanceKey) || 'null')
+ if (stored) look = {
+ preset: presets.indexOf(stored.preset) >= 0 ? stored.preset : defaultAppearance.preset,
+ font: fonts.indexOf(stored.font) >= 0 ? stored.font : defaultAppearance.font,
+ reading: readings.indexOf(stored.reading) >= 0 ? stored.reading : defaultAppearance.reading
+ }
+ } catch (error) {
+ console.warn('The saved reading appearance could not be read, so the default is used:', error)
+ }
+ root.setAttribute('data-palette', look.preset)
+ root.setAttribute('data-font', look.font)
+ root.setAttribute('data-reading', look.reading)
+})(${[THEME_CHOICE_STORAGE_KEY, THEME_CHOICES, FOLLOWS_SYSTEM, DARK, LIGHT,
+ THEME_APPEARANCE_STORAGE_KEY, THEME_PRESETS, FONT_CHOICES, READING_CHOICES, DEFAULT_THEME_APPEARANCE]
+ .map(value => JSON.stringify(value)).join(', ')})`;
/** The template with the script where its mark is. Fails loudly when the mark is missing, so no build ships without it. */
export function withViewerThemePrePaintScript(html: string): string {
diff --git a/tests/ui/viewer/settings-fixture.ts b/tests/ui/viewer/settings-fixture.ts
index 7bab94e10..ba217586f 100644
--- a/tests/ui/viewer/settings-fixture.ts
+++ b/tests/ui/viewer/settings-fixture.ts
@@ -32,7 +32,7 @@ export function compileSettingsFixture(script = "fetch('/ready');"): string {
function Page({ route, state, draft }) {
if (route.view === 'settings') {
return <SettingsPage section={route.section} settings={state.settings} isLoaded={state.isLoaded} loadError={state.loadError}
- onRetryLoad={state.reload} onSave={state.saveSettings} isSaving={state.isSaving} saveStatus={state.saveStatus} draft={draft} />;
+ onRetryLoad={state.reload} onSave={state.saveSettings} isSaving={state.isSaving} saveStatus={state.saveStatus} draft={draft} onThemeChange={() => {}} />;
}
if (route.view === 'context-preview') {
return <ContextPreviewPage draft={draft} onShowInTimeline={project => window.timelineProjects.push(project)} />;
diff --git a/tests/viewer/theme-appearance.test.ts b/tests/viewer/theme-appearance.test.ts
new file mode 100644
index 000000000..3b20adc2a
--- /dev/null
+++ b/tests/viewer/theme-appearance.test.ts
@@ -0,0 +1,161 @@
+import { describe, expect, it } from 'bun:test';
+import { readdirSync, readFileSync } from 'fs';
+import { join } from 'path';
+import { VIEWER_THEME_PRE_PAINT_SCRIPT } from '../../src/ui/viewer/utils/theme-pre-paint';
+import { THEME_PRE_PAINT_SCRIPT } from '../../src/ui/my-work/src/lib/theme-pre-paint';
+import {
+ APPEARANCE_WORDS, FONT_CHOICE_LABELS, PALETTE_THEMES, READING_CHOICE_LABELS, THEME_PRESET_LABELS, THEME_PRESETS,
+} from '../../src/ui/theme-appearance';
+import { LOCALES } from '../../src/ui/i18n/locale';
+
+const template = readFileSync(join(import.meta.dir, '../../src/ui/viewer-template.html'), 'utf-8');
+const myWorkCss = readFileSync(join(import.meta.dir, '../../src/ui/my-work/src/index.css'), 'utf-8');
+const I18N_DIR = join(import.meta.dir, '../../src/ui/i18n');
+const APPEARANCE_KEY = 'claude-mem-theme-appearance';
+
+/** Custom properties declared in the first rule that opens with `ruleOpener` (same parser as theme-tokens.test.ts). */
+function tokens(ruleOpener: string): Record<string, string> {
+ const start = template.indexOf(ruleOpener);
+ expect(start).toBeGreaterThan(-1);
+ const body = template.slice(start + ruleOpener.length, template.indexOf('}', start));
+ return Object.fromEntries([...body.matchAll(/(--[\w-]+):\s*([^;]+);/g)].map(match => [match[1], match[2].trim()]));
+}
+
+function luminance(hex: string): number {
+ const channels = [0, 2, 4].map(offset => parseInt(hex.slice(1 + offset, 3 + offset), 16) / 255)
+ .map(channel => (channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4));
+ return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2];
+}
+
+function contrast(foreground: string, background: string): number {
+ const [lighter, darker] = [luminance(foreground), luminance(background)].sort((a, b) => b - a);
+ return (lighter + 0.05) / (darker + 0.05);
+}
+
+function runScript(source: string, saved: Record<string, string>, options: { systemDark?: boolean; search?: string } = {}) {
+ const items = new Map(Object.entries(saved));
+ const attributes = new Map<string, string>();
+ const properties = new Map<string, string>();
+ const classes = new Set<string>();
+ const root = {
+ setAttribute: (name: string, value: string) => { attributes.set(name, value); },
+ getAttribute: (name: string) => attributes.get(name) ?? null,
+ classList: { add: (name: string) => { classes.add(name); } },
+ style: {
+ setProperty: (name: string, value: string) => { properties.set(name, value); },
+ removeProperty: (name: string) => { properties.delete(name); },
+ },
+ };
+ const localStorage = { getItem: (key: string) => items.get(key) ?? null, setItem: (key: string, value: string) => { items.set(key, value); } };
+ const document = { documentElement: root };
+ const matchMedia = () => ({ matches: options.systemDark ?? false });
+ const location = { search: options.search ?? '' };
+ new Function('localStorage', 'document', 'matchMedia', 'location', 'console', source)(localStorage, document, matchMedia, location, console);
+ return { attributes, properties, classes };
+}
+
+const readerLook = JSON.stringify({ preset: 'warm-cream', font: 'serif', reading: 'comfortable' });
+
+describe('readable theme appearance', () => {
+ it('offers warm cream, neutral light, warm tint and neutral dark palettes, with faces and reading sizes', () => {
+ const warmCream = tokens('[data-theme="light"][data-palette="warm-cream"] {');
+ expect(warmCream['--color-bg-primary']).toBe('#f5f2eb');
+ expect(warmCream['--color-text-primary']).toBe('#202020');
+ const neutralLight = tokens('[data-theme="light"][data-palette="neutral-light"] {');
+ expect(neutralLight['--color-bg-primary']).toBe('#fafafa');
+ expect(neutralLight['--color-text-primary']).toBe('#242424');
+ const warmTint = tokens('[data-theme="light"][data-palette="warm-tint"] {');
+ expect(warmTint['--color-bg-primary']).toBe('#edd1b0');
+ const neutralDark = tokens('[data-theme="dark"][data-palette="neutral-dark"] {');
+ expect(neutralDark['--color-bg-primary']).toBe('#22252a');
+ expect(neutralDark['--color-text-primary']).toBe('#e0e0e0');
+ // A palette is a complete token set, never a half-tinted page with the theme's old green behind it.
+ const read = new Set([...template.matchAll(/var\(\s*(--(?:color|shadow|font)-[\w-]+)/g)].map(match => match[1]));
+ expect(read.size).toBeGreaterThan(20);
+ for (const [name, palette] of Object.entries({ warmCream, neutralLight, warmTint, neutralDark })) {
+ expect({ name, missing: [...read].filter(token => !(token in palette)) }).toEqual({ name, missing: [] });
+ }
+ expect(tokens('[data-font="serif"] {')['--font-sans']).toContain('Georgia');
+ expect(tokens('[data-reading="comfortable"] {')['--theme-line-height']).toBe('1.65');
+ expect(myWorkCss).toContain('html[data-reading="comfortable"] { --theme-scale: 1.08;');
+ expect(myWorkCss).toContain('html[data-reading] { font-size: calc(100% * var(--theme-scale, 1)); }');
+ // A font-size scale, not zoom: zoom moves the coordinates popovers and menus are placed by.
+ expect(template).not.toMatch(/\bzoom:/);
+ expect(myWorkCss).not.toMatch(/\bzoom:/);
+ });
+
+ it('keeps body text readable in every curated palette', () => {
+ for (const name of ['warm-cream', 'neutral-light', 'warm-tint', 'neutral-dark']) {
+ const palette = tokens(`[data-theme="${PALETTE_THEMES[name as keyof typeof PALETTE_THEMES]}"][data-palette="${name}"] {`);
+ expect({ name, ratio: contrast(palette['--color-text-primary'], palette['--color-bg-primary']) >= 4.5 })
+ .toEqual({ name, ratio: true });
+ }
+ });
+
+ it('puts a saved warm palette, face and reading size on <html> before the first paint', () => {
+ const drawn = runScript(VIEWER_THEME_PRE_PAINT_SCRIPT, {
+ 'claude-mem-theme': 'light', [APPEARANCE_KEY]: readerLook,
+ });
+ expect({ theme: drawn.attributes.get('data-theme'), palette: drawn.attributes.get('data-palette'),
+ font: drawn.attributes.get('data-font'), reading: drawn.attributes.get('data-reading') })
+ .toEqual({ theme: 'light', palette: 'warm-cream', font: 'serif', reading: 'comfortable' });
+ expect(drawn.properties.size).toBe(0);
+ });
+
+ it('follows the system and the default palette when the saved appearance is broken or unknown', () => {
+ const broken = runScript(VIEWER_THEME_PRE_PAINT_SCRIPT, {
+ 'claude-mem-theme': 'system', [APPEARANCE_KEY]: '{not json',
+ }, { systemDark: true });
+ expect({ theme: broken.attributes.get('data-theme'), palette: broken.attributes.get('data-palette'),
+ font: broken.attributes.get('data-font'), reading: broken.attributes.get('data-reading') })
+ .toEqual({ theme: 'dark', palette: 'default', font: 'default', reading: 'default' });
+ expect(broken.properties.size).toBe(0);
+
+ const unknown = runScript(VIEWER_THEME_PRE_PAINT_SCRIPT, {
+ [APPEARANCE_KEY]: JSON.stringify({ preset: 'sepia', background: '#123456', font: 'comic', reading: 'huge' }),
+ });
+ expect({ palette: unknown.attributes.get('data-palette'), font: unknown.attributes.get('data-font'),
+ reading: unknown.attributes.get('data-reading') })
+ .toEqual({ palette: 'default', font: 'default', reading: 'default' });
+ // A background colour saved by an earlier build is ignored, not painted.
+ expect(unknown.properties.size).toBe(0);
+ });
+
+ it('My Work puts the same saved appearance on <html> before its first paint', () => {
+ const drawn = runScript(THEME_PRE_PAINT_SCRIPT, {
+ 'claude-mem-theme': 'dark', [APPEARANCE_KEY]: readerLook,
+ });
+ expect({ dark: drawn.classes.has('dark'), palette: drawn.attributes.get('data-palette'),
+ font: drawn.attributes.get('data-font'), reading: drawn.attributes.get('data-reading') })
+ .toEqual({ dark: true, palette: 'warm-cream', font: 'serif', reading: 'comfortable' });
+ });
+
+ it('applies a palette only under its own theme, so a light palette under the dark theme sets no palette tokens', () => {
+ // Every rule that names a palette, in both stylesheets, with the theme condition it carries.
+ const rules = (css: string) => [...css.matchAll(/^\s*([^{}\n]*data-palette[^{}\n]*)\{/gm)].map(match => match[1].trim());
+ const viewerRules = rules(template), myWorkRules = rules(myWorkCss);
+ const curated = THEME_PRESETS.filter(preset => PALETTE_THEMES[preset] !== null);
+ expect(viewerRules).toHaveLength(curated.length);
+ expect(myWorkRules).toHaveLength(curated.length);
+ for (const preset of curated) {
+ const theme = PALETTE_THEMES[preset]!;
+ expect(viewerRules).toContain(`[data-theme="${theme}"][data-palette="${preset}"]`);
+ expect(myWorkRules).toContain(`${theme === 'dark' ? 'html.dark' : 'html:not(.dark)'}[data-palette="${preset}"]`);
+ }
+ // So under data-theme="dark" (viewer) or .dark (My Work), the light palettes' rules match nothing.
+ for (const rule of viewerRules) expect(rule).toMatch(/^\[data-theme="(light|dark)"\]\[data-palette="[\w-]+"\]$/);
+ });
+
+ it('every appearance word is in every language catalog', () => {
+ // The words reach t() from tables, which tests/ui-i18n.test.ts's literal t('…') scan cannot see.
+ const words = [...Object.values(APPEARANCE_WORDS), ...Object.values(THEME_PRESET_LABELS),
+ ...Object.values(FONT_CHOICE_LABELS), ...Object.values(READING_CHOICE_LABELS)];
+ for (const locale of LOCALES.filter(code => code !== 'en')) {
+ const suffix = locale === 'zh-CN' ? 'zh' : locale;
+ const catalog: Record<string, string> = Object.assign({}, ...readdirSync(I18N_DIR)
+ .filter(file => file.endsWith(`-${suffix}.ts`))
+ .map(file => Object.values(require(join(I18N_DIR, file)))[0] as Record<string, string>));
+ expect({ locale, missing: words.filter(word => !(word in catalog)) }).toEqual({ locale, missing: [] });
+ }
+ });
+});