Skip to content

The agent that grows with you

fix(desktop): one Classic Hermes card after the reverted build, and a light Classic

teknium19b6e759751ba
diff --git a/apps/desktop/src/themes/backend-sync.ts b/apps/desktop/src/themes/backend-sync.ts
index dc855b06aca..e6fac9b2c3b 100644
--- a/apps/desktop/src/themes/backend-sync.ts
+++ b/apps/desktop/src/themes/backend-sync.ts
@@ -21,7 +21,7 @@ import { atom } from 'nanostores'
import { readJson, writeJson } from '@/lib/storage'
-import { BUILTIN_THEMES, DEFAULT_SKIN_NAME } from './presets'
+import { BUILTIN_THEMES, DEFAULT_SKIN_NAME, RETIRED_SKINS } from './presets'
import { skinToDesktopTheme } from './skin'
import { type DesktopTheme, isValidTheme } from './types'
@@ -41,13 +41,27 @@ export const localDisplaySkinProfile = localDisplaySkinName
? (localSkinPayload?.profile ?? '').trim() || 'default'
: null
-const readCached = (): Record<string, DesktopTheme> =>
- Object.fromEntries(
- Object.entries(readJson<Record<string, unknown>>(BACKEND_THEMES_KEY) ?? {}).filter(
- (entry): entry is [string, DesktopTheme] => !BUILTIN_THEMES[entry[0]] && isValidTheme(entry[1])
- )
+// Built-in names keep their desktop palette and retired names resolve to the
+// default skin, so a cached theme under either is a shadow nothing should list.
+const cacheable = (name: string) => !BUILTIN_THEMES[name] && !RETIRED_SKINS.has(name)
+
+// Dropped entries are written back out, so a stale shadow (the reverted #130015
+// build cached the CLI `default` skin as a second "Classic Hermes") is gone from
+// disk on the first launch, not only hidden until the next registry change.
+const readCached = (): Record<string, DesktopTheme> => {
+ const stored = Object.entries(readJson<Record<string, unknown>>(BACKEND_THEMES_KEY) ?? {})
+
+ const kept = Object.fromEntries(
+ stored.filter((entry): entry is [string, DesktopTheme] => cacheable(entry[0]) && isValidTheme(entry[1]))
)
+ if (Object.keys(kept).length !== stored.length) {
+ writeJson(BACKEND_THEMES_KEY, kept)
+ }
+
+ return kept
+}
+
/** Skins pushed by the backend, keyed by name. Merged by `listAllThemes`. */
export const $backendThemes = atom<Record<string, DesktopTheme>>(typeof window === 'undefined' ? {} : readCached())
@@ -91,14 +105,15 @@ export function ingestBackendSkin(skin: HermesSkin | undefined | null, { apply }
return
}
- // `default` is "no opinion" on the PALETTE — the desktop keeps its own default
- // (nous), so we never register a converted theme under `default`. It is still a
+ // `default` (like every retired name) is "no opinion" on the PALETTE — the
+ // desktop keeps its own default (nous), so we never register a converted theme
+ // under `default`. It is still a
// valid apply TARGET though: a runtime switch back to `default` must repaint the
// desktop to its own default (setTheme normalizes `default` → nous). So we only
// skip the registry step here and let it flow through the apply logic below.
// Built-in names (mono/slate/…) already have a hand-tuned desktop palette — we
// never shadow it, but the name is still a valid apply target.
- if (name !== 'default' && !BUILTIN_THEMES[name]) {
+ if (cacheable(name)) {
const theme = skinToDesktopTheme(skin as HermesSkin)
if (!theme) {
diff --git a/apps/desktop/src/themes/classic-skin.test.tsx b/apps/desktop/src/themes/classic-skin.test.tsx
index bf025c9401a..4b1aa553b63 100644
--- a/apps/desktop/src/themes/classic-skin.test.tsx
+++ b/apps/desktop/src/themes/classic-skin.test.tsx
@@ -1,7 +1,9 @@
+import { contrastRatio } from '@hermes/shared/color'
import { act, cleanup, render } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { useTheme } from './context'
+import { skinToDesktopTheme } from './skin'
// What the gateway and the Electron bridge report for a STOCK config
// (`display.skin: default`): the CLI's classic gold skin, by name `default`.
@@ -11,6 +13,8 @@ const stockDefaultSkin = {
colors: { banner_text: '#FFF8DC', status_bar_bg: '#1a1a2e', ui_accent: '#FFBF00', banner_border: '#CD7F32' }
}
+const BACKEND_THEMES_KEY = 'hermes-desktop-backend-themes-v1'
+
const cssVar = (name: string) => window.document.documentElement.style.getPropertyValue(name)
const paintedSkin = () => window.document.documentElement.dataset.hermesTheme
@@ -81,10 +85,11 @@ describe('Classic Hermes is an explicit Desktop pick, never inferred from stock
expect(paintedSkin()).toBe('nous')
})
- it('a Classic pick paints gold/navy and survives connect, reconnect and relaunch; a later Nous pick sticks', async () => {
+ it('a Classic pick paints gold/navy (dark mode) and survives connect, reconnect and relaunch; a later Nous pick sticks', async () => {
let run = await launch(stockDefaultSkin)
expect(run.api.theme?.availableThemes.find(t => t.name === 'classic')?.label).toBe('Classic Hermes')
+ act(() => run.api.theme?.setMode('dark'))
act(() => run.api.theme?.setTheme('classic'))
expect(paintedSkin()).toBe('classic')
expect(cssVar('--theme-background-seed')).toBe('#1a1a2e')
@@ -120,4 +125,43 @@ describe('Classic Hermes is an explicit Desktop pick, never inferred from stock
act(() => void run.api.skin?.('default'))
expect(run.api.theme?.themeName).toBe('nous')
})
+
+ it('a cache left by the reverted #130015 build (CLI `default` as "Classic Hermes") shows ONE Classic and is purged', async () => {
+ // Exactly what that build wrote: the converted CLI `default` skin, relabelled.
+ window.localStorage.setItem(
+ BACKEND_THEMES_KEY,
+ JSON.stringify({
+ default: {
+ ...skinToDesktopTheme(stockDefaultSkin),
+ description: stockDefaultSkin.description,
+ label: 'Classic Hermes'
+ }
+ })
+ )
+
+ const run = await launch(stockDefaultSkin)
+ run.connect()
+
+ const themes = run.api.theme?.availableThemes ?? []
+ expect(themes.filter(t => t.label === 'Classic Hermes').map(t => t.name)).toEqual(['classic'])
+ expect(themes.some(t => t.name === 'default')).toBe(false)
+ expect(run.api.skin?.('list').match(/Classic Hermes/g)).toHaveLength(1)
+ expect(JSON.parse(window.localStorage.getItem(BACKEND_THEMES_KEY) ?? '{}')).not.toHaveProperty('default')
+ })
+
+ it('Classic follows the light/dark toggle: a light surface in light mode, gold on navy in dark, both readable', async () => {
+ const run = await launch(stockDefaultSkin)
+ act(() => run.api.theme?.setTheme('classic'))
+
+ act(() => run.api.theme?.setMode('light'))
+ expect(window.document.documentElement.dataset.hermesMode).toBe('light')
+ expect(cssVar('--theme-background-seed').toLowerCase()).toBe('#f5f5f5')
+ expect(contrastRatio(cssVar('--theme-foreground'), cssVar('--theme-background-seed'))).toBeGreaterThanOrEqual(4.5)
+ expect(contrastRatio(cssVar('--theme-primary'), cssVar('--theme-sidebar-seed'))).toBeGreaterThanOrEqual(4.5)
+
+ act(() => run.api.theme?.setMode('dark'))
+ expect(window.document.documentElement.dataset.hermesMode).toBe('dark')
+ expect(cssVar('--theme-background-seed')).toBe('#1a1a2e')
+ expect(contrastRatio(cssVar('--theme-foreground'), cssVar('--theme-background-seed'))).toBeGreaterThanOrEqual(4.5)
+ })
})
diff --git a/apps/desktop/src/themes/context.tsx b/apps/desktop/src/themes/context.tsx
index 892802c8045..32ea4444427 100644
--- a/apps/desktop/src/themes/context.tsx
+++ b/apps/desktop/src/themes/context.tsx
@@ -31,7 +31,7 @@ import {
} from './backend-sync'
import { $chatFontFamily, resolveChatFontFamily } from './chat-font'
import { harmonize, readableInk } from './color'
-import { BUILTIN_THEME_LIST, DEFAULT_SKIN_NAME, DEFAULT_TYPOGRAPHY, nousTheme } from './presets'
+import { BUILTIN_THEME_LIST, DEFAULT_SKIN_NAME, DEFAULT_TYPOGRAPHY, nousTheme, RETIRED_SKINS } from './presets'
import { retintTheme } from './retint'
import type { DesktopTheme, DesktopThemeColors } from './types'
import { $userThemes, listAllThemes, resolveTheme } from './user-themes'
@@ -48,9 +48,6 @@ const PROFILE_MODES_KEY = 'hermes-desktop-profile-modes-v1'
// Last active profile, recorded so the boot-time paint can pick that profile's
// theme before the gateway reports which profile actually launched.
const LAST_PROFILE_KEY = 'hermes-desktop-active-profile-v1'
-// Skins that no longer exist. A profile still pointing at one falls back to
-// DEFAULT_SKIN_NAME rather than painting a name nothing resolves.
-const RETIRED_SKINS = new Set(['nous-light', 'default', 'gold'])
export type ThemeMode = 'light' | 'dark' | 'system'
diff --git a/apps/desktop/src/themes/presets.ts b/apps/desktop/src/themes/presets.ts
index 70cdb3313cd..32796c58f5d 100644
--- a/apps/desktop/src/themes/presets.ts
+++ b/apps/desktop/src/themes/presets.ts
@@ -339,29 +339,49 @@ export const nousAltTheme: DesktopTheme = {
}
}
+// The converter's input: the keys it reads from `hermes_cli/skin_engine.py`'s
+// `default` skin. Light is that skin's `light_colors` overlay (its goldenrod
+// ladder for white backgrounds; `banner_border` is not overridden there) with
+// one change: the ink. The CLI's `#5C4718` is a single-weight terminal color,
+// but Desktop sets secondary and tertiary text at 74% / 54% of it, which left
+// them at 4.2:1 / 2.7:1. A deeper ink of the same brown gives 6.5:1 / 3.5:1,
+// the levels Nous Light has.
+const CLASSIC_DARK_SKIN_COLORS = {
+ status_bar_bg: '#1a1a2e',
+ banner_text: '#FFF8DC',
+ ui_accent: '#FFBF00',
+ banner_border: '#CD7F32',
+ banner_dim: '#B8860B',
+ ui_error: '#ef5350',
+ completion_menu_bg: '#1a1a2e'
+}
+
+const CLASSIC_LIGHT_SKIN_COLORS = {
+ status_bar_bg: '#F5F5F5',
+ banner_text: '#2B2109',
+ ui_accent: '#D89B04',
+ banner_border: '#CD7F32',
+ banner_dim: '#B8860B',
+ ui_error: '#C62828',
+ completion_menu_bg: '#F5F5F5'
+}
+
+const classicPalette = (colors: Record<string, string>) => skinToDesktopTheme({ name: 'classic', colors })!.colors
+
/**
* Classic Hermes — the CLI's stock `default` skin (gold on navy), offered as a
* Desktop pick under its OWN id. Never `default`: stock config ships
* `display.skin: default`, and Desktop reads that as "no pick" (→ nous), so a
- * user only ever gets Classic by choosing it (#76579). The palette goes through
- * the same converter a backend skin takes, fed the colors it reads from
- * `hermes_cli/skin_engine.py`'s `default`, so it paints what the CLI paints.
+ * user only ever gets Classic by choosing it (#76579). Both palettes go through
+ * the converter a backend skin takes, so each mode paints what the CLI paints
+ * in a dark or light terminal.
*/
export const classicTheme: DesktopTheme = {
- ...(skinToDesktopTheme({
- name: 'classic',
- colors: {
- status_bar_bg: '#1a1a2e',
- banner_text: '#FFF8DC',
- ui_accent: '#FFBF00',
- banner_border: '#CD7F32',
- banner_dim: '#B8860B',
- ui_error: '#ef5350',
- completion_menu_bg: '#1a1a2e'
- }
- }) as DesktopTheme),
+ name: 'classic',
label: 'Classic Hermes',
- description: 'Classic Hermes — gold and kawaii'
+ description: "Gold on navy, the CLI's original look",
+ colors: classicPalette(CLASSIC_LIGHT_SKIN_COLORS),
+ darkColors: classicPalette(CLASSIC_DARK_SKIN_COLORS)
}
/**
@@ -440,3 +460,9 @@ export const BUILTIN_THEME_LIST = Object.values(BUILTIN_THEMES)
/** Skin used when nothing is persisted or the persisted name is retired. */
export const DEFAULT_SKIN_NAME = 'nous'
+
+/** Names that no longer resolve to a skin of their own. A stored pick of one
+ * falls back to DEFAULT_SKIN_NAME, and a cached backend theme under one is
+ * dropped (the reverted #130015 build cached the CLI `default` skin as a
+ * second "Classic Hermes"). */
+export const RETIRED_SKINS = new Set(['nous-light', 'default', 'gold'])