The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): an accent retints the active theme, not a Nous copy
alt-glitch9922d626dc27
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/theme-requests.test.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/theme-requests.test.tsindex d83da6a3656..73d1490e788 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/theme-requests.test.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/theme-requests.test.ts@@ -50,7 +50,7 @@ describe('set_theme requests', () => {expect(pickTheme('session-a', { accent: 'pink' })).toBe(true)expect(respond).toHaveBeenCalledWith({ picked: { accent: 'pink' } })- expect($pendingSkinApply.get()).toBe('nous-accent-e0218a')+ expect($pendingSkinApply.get()).toBe('nous-accent')expect($themePicks.get()['session-a']).toBeUndefined()})diff --git a/apps/desktop/src/components/assistant-ui/theme-picker/look-preview.ts b/apps/desktop/src/components/assistant-ui/theme-picker/look-preview.tsindex b4ade706865..0dd4e414c69 100644--- a/apps/desktop/src/components/assistant-ui/theme-picker/look-preview.ts+++ b/apps/desktop/src/components/assistant-ui/theme-picker/look-preview.ts@@ -1,9 +1,12 @@import { useEffect, useState } from 'react'+import { $terminalTakeover, setTerminalTakeover } from '@/app/right-sidebar/store'import { type PreviewUndo, snapshotChatLayout } from '@/components/onboarding/first-run/assembly'-import { applyDesktopLayoutPreset } from '@/store/pane-focus'+import { $fileBrowserOpen, setFileBrowserOpen } from '@/store/layout'+import { applyDesktopLayoutPreset, openLayoutPickPanes } from '@/store/pane-focus'import { $accentOverride, setAccentOverride } from '@/themes/accent-override'-import { NOUS_ACCENT, resolveAccentPick } from '@/themes/accents'+import { resolveAccentPick } from '@/themes/accents'+import { ownAccent } from '@/themes/persist-accent'/** A staged pick; `value` null is the theme's own accent. */export interface StagedLook {@@ -16,9 +19,9 @@ interface LiveLook {}// The accent previews through the unsaved override so nothing is persisted before Continue; the theme's own-// accent previews as Nous blue because an empty override would keep the current colour.+// accent previews as the base theme's colour because an empty override would keep the current (maybe saved) one.const ACCENT: LiveLook = {- apply: (value, dark) => setAccentOverride(resolveAccentPick(value ?? 'theme', dark)?.hex ?? NOUS_ACCENT),+ apply: (value, dark) => setAccentOverride(resolveAccentPick(value ?? 'theme', dark)?.hex ?? ownAccent()),snapshot: () => {const override = $accentOverride.get()@@ -30,11 +33,25 @@ const ACCENT: LiveLook = {// Simple/Advanced when the preset needs it), so a cancelled preview never touches either mode's saved layout.const LAYOUT: LiveLook = {apply: value => {- if (value) {- applyDesktopLayoutPreset(value)+ if (value && applyDesktopLayoutPreset(value)) {+ openLayoutPickPanes(value)}},- snapshot: snapshotChatLayout+ // The terminal and file tree keep their open state outside the layout tree.+ snapshot: () => {+ const chat = snapshotChatLayout()+ const terminal = $terminalTakeover.get()+ const files = $fileBrowserOpen.get()++ return {+ keep: chat.keep,+ revert: () => {+ chat.revert()+ setTerminalTakeover(terminal)+ setFileBrowserOpen(files)+ }+ }+ }}export interface LookPreview {diff --git a/apps/desktop/src/store/appearance-apply.test.ts b/apps/desktop/src/store/appearance-apply.test.tsindex b378f221cad..46d6d555682 100644--- a/apps/desktop/src/store/appearance-apply.test.ts+++ b/apps/desktop/src/store/appearance-apply.test.ts@@ -25,7 +25,7 @@ describe('applyAppearance', () => {applied: { accent: 'violet', layout: 'terminal-deck', mode: 'dark' },success: true})- expect($pendingSkinApply.get()).toBe('nous-accent-8a2be2')+ expect($pendingSkinApply.get()).toBe('nous-accent')expect($pendingModeApply.get()).toBe('dark')expect($activePresetId.get()).toBe('terminal-deck')expect($interfaceMode.get()).toBe('advanced')diff --git a/apps/desktop/src/themes/context.tsx b/apps/desktop/src/themes/context.tsxindex e581fa801a1..e10e0842e49 100644--- a/apps/desktop/src/themes/context.tsx+++ b/apps/desktop/src/themes/context.tsx@@ -30,7 +30,7 @@ import {localDisplaySkinProfile} from './backend-sync'import { $chatFontFamily, resolveChatFontFamily } from './chat-font'-import { harmonize, readableInk } from './color'+import { harmonize, normalizeHex, readableInk } from './color'import { BUILTIN_THEME_LIST, DEFAULT_SKIN_NAME, DEFAULT_TYPOGRAPHY, nousTheme, RETIRED_SKINS } from './presets'import { $pendingModeApply } from './request'import { retintTheme } from './retint'@@ -135,6 +135,10 @@ const storedSkin = (profile: string): string =>skinPref.stored(profile) ??(profile === BOOT_PROFILE_KEY ? (localDisplaySkinName ?? DEFAULT_SKIN_NAME) : DEFAULT_SKIN_NAME)+/** The live profile's committed theme: what the ThemeProvider paints without a preview. */+export const committedTheme = (): DesktopTheme =>+ resolveTheme(normalizeSkin(storedSkin(normalizeProfileKey($activeGatewayProfile.get())))) ?? nousTheme+/** Everything a peer window could change that this one has to repaint for. */const APPEARANCE_KEYS = new Set([SKIN_KEY, PROFILE_SKINS_KEY, MODE_KEY, PROFILE_MODES_KEY])@@ -182,8 +186,10 @@ function synthLightColors(seed: DesktopTheme): DesktopThemeColors {/** Returns the seed palette for a given skin + mode (no overrides applied). */export function getBaseColors(skinName: string, mode: 'light' | 'dark'): DesktopThemeColors {- const seed = resolveTheme(skinName) ?? nousTheme+ return paletteFor(resolveTheme(skinName) ?? nousTheme, mode)+}+function paletteFor(seed: DesktopTheme, mode: 'light' | 'dark'): DesktopThemeColors {if (mode === 'dark') {return seed.darkColors ?? seed.colors}@@ -191,20 +197,53 @@ export function getBaseColors(skinName: string, mode: 'light' | 'dark'): Desktopreturn seed.darkColors ? seed.colors : synthLightColors(seed)}-function deriveTheme(skinName: string, mode: 'light' | 'dark'): DesktopTheme {- const seed = resolveTheme(skinName) ?? nousTheme+// A backend skin named `default`/`mono`/… keeps the desktop's own palette+// (never shadowed — see ingestBackendSkin), but its customCSS is carried+// separately in $backendCustomCSS. The seed's own customCSS (non-built-in+// backend skins) wins when both exist.+const customCSSOf = (seed: DesktopTheme): string | undefined => seed.customCSS ?? $backendCustomCSS.get()[seed.name]+function deriveFrom(seed: DesktopTheme, mode: 'light' | 'dark'): DesktopTheme {return {...seed,- name: `${skinName}-${mode}`,+ name: `${seed.name}-${mode}`,label: `${seed.label} ${mode === 'light' ? 'Light' : 'Dark'}`,description: `${seed.label} ${mode} palette`,- colors: getBaseColors(skinName, mode),- // A backend skin named `default`/`mono`/… keeps the desktop's own palette- // (never shadowed — see ingestBackendSkin), but its customCSS is carried- // separately in $backendCustomCSS. The seed's own customCSS (non-built-in- // backend skins) wins when both exist.- customCSS: seed.customCSS ?? $backendCustomCSS.get()[skinName]+ colors: paletteFor(seed, mode),+ customCSS: customCSSOf(seed)+ }+}++const deriveTheme = (skinName: string, mode: 'light' | 'dark'): DesktopTheme =>+ deriveFrom({ ...(resolveTheme(skinName) ?? nousTheme), name: skinName }, mode)++/** The theme a saved accent was retinted from; any other theme is its own base. */+export const accentBase = (theme: DesktopTheme): DesktopTheme =>+ (theme.accentOf && resolveTheme(theme.accentOf)) || theme++/**+ * `theme` with only its accent moved to `accent`, both modes painted exactly as the live accent preview+ * paints them. Every other colour and the CSS stay the base's. One `<base>-accent` copy per base, so+ * re-tinting replaces it; the base's own accent returns the base itself.+ */+export function accentedTheme(theme: DesktopTheme, accent: string): DesktopTheme {+ const base = accentBase(theme)+ const hex = normalizeHex(accent)++ if (!hex || hex === normalizeHex(base.colors.primary)) {+ return base+ }++ const tint = (mode: 'light' | 'dark') => retintTheme({ ...base, colors: paletteFor(base, mode) }, hex).colors++ return {+ ...base,+ name: `${base.name}-accent`,+ label: `${base.label} · ${hex}`,+ accentOf: base.name,+ colors: tint('light'),+ darkColors: tint('dark'),+ customCSS: customCSSOf(base)}}@@ -559,14 +598,17 @@ export function ThemeProvider({ children }: { children: ReactNode }) {[paintedName, paintedMode, userThemes, backendThemes, backendCustomCSS, registryVersion])- // Dev-only accent retint. `null` (always, in production) returns the theme- // untouched, and retintTheme is an identity when the seed already matches —- // so the picker costs nothing until it's actually moved off the default.+ // Unsaved accent preview (dev picker, onboarding accent card). `null` returns+ // the theme untouched.const accentOverride = useStore($accentOverride)+ // Painted from the same theme persistAccent saves, so committing the accent changes nothing on screen.const paintedTheme = useMemo(- () => (accentOverride === null ? activeTheme : retintTheme(activeTheme, accentOverride)),- [activeTheme, accentOverride]+ () =>+ accentOverride === null+ ? activeTheme+ : deriveFrom(accentedTheme(resolveTheme(paintedName) ?? nousTheme, accentOverride), paintedMode),+ [activeTheme, accentOverride, paintedName, paintedMode])// What actually gets painted (matches the `.dark` class applyTheme toggles).diff --git a/apps/desktop/src/themes/persist-accent.test.tsx b/apps/desktop/src/themes/persist-accent.test.tsxindex 2bd30e82909..70ca9508fd4 100644--- a/apps/desktop/src/themes/persist-accent.test.tsx+++ b/apps/desktop/src/themes/persist-accent.test.tsx@@ -7,7 +7,8 @@ import { $accentOverride, setAccentOverride } from './accent-override'import { skinPref, ThemeProvider, useTheme } from './context'import { persistAccent } from './persist-accent'import { nousTheme } from './presets'-import { $userThemes } from './user-themes'+import type { DesktopTheme } from './types'+import { $userThemes, installUserTheme, resolveTheme } from './user-themes'let theme: ReturnType<typeof useTheme>@@ -53,4 +54,50 @@ describe('persistAccent', () => {expect(theme.themeName).toBe(nousTheme.name)expect(skinPref.resolve('default')).toBe(nousTheme.name)})++ it('retints the active theme, keeping its own colours and CSS, exactly as the preview painted it', () => {+ const ember: DesktopTheme = {+ ...nousTheme,+ name: 'my-campfire',+ label: 'My campfire',+ description: 'A custom skin',+ colors: { ...nousTheme.colors, background: '#fff4e8', foreground: '#2b1a0e', card: '#fffaf3', border: '#e8cfb5' },+ darkColors: { ...nousTheme.darkColors!, background: '#1c120b', foreground: '#f5e6d6', card: '#24170e' },+ customCSS: '.campfire-only { letter-spacing: 0.02em; }'+ }++ installUserTheme(ember)+ skinPref.assign('default', ember.name)++ render(+ <ThemeProvider>+ <ThemeProbe />+ </ThemeProvider>+ )++ expect(theme.themeName).toBe(ember.name)++ act(() => setAccentOverride('#e0218a'))+ const previewed = theme.theme++ act(() => persistAccent('#e0218a'))+ const saved = resolveTheme(theme.themeName)!++ expect(saved.name).not.toBe(ember.name)+ expect(saved.customCSS).toBe(ember.customCSS)+ expect(saved.colors.background).toBe(ember.colors.background)+ expect(saved.colors.foreground).toBe(ember.colors.foreground)+ expect(saved.darkColors?.background).toBe(ember.darkColors!.background)+ expect(theme.theme.colors).toEqual(previewed.colors)+ expect(theme.theme.customCSS).toBe(previewed.customCSS)++ // A second accent on the same base replaces the copy instead of adding one.+ act(() => persistAccent('#2ea043'))+ expect(Object.keys($userThemes.get()).sort()).toEqual([ember.name, theme.themeName].sort())+ expect(resolveTheme(theme.themeName)!.colors.background).toBe(ember.colors.background)++ // The theme's own accent puts the theme itself back.+ act(() => persistAccent(null))+ expect(theme.themeName).toBe(ember.name)+ })})diff --git a/apps/desktop/src/themes/persist-accent.ts b/apps/desktop/src/themes/persist-accent.tsindex f58eacd8568..429270d5339 100644--- a/apps/desktop/src/themes/persist-accent.ts+++ b/apps/desktop/src/themes/persist-accent.ts@@ -1,14 +1,13 @@import { setAccentOverride } from './accent-override'import { normalizeHex } from './color'-import { nousTheme } from './presets'+import { accentBase, accentedTheme, committedTheme } from './context'import { requestTheme } from './request'-import { retintTheme } from './retint'import { installUserTheme } from './user-themes'/**- * Save an accent as the live profile's theme: a Nous copy retinted to `accent`, installed as a user theme.- * `null` or Nous blue returns to the built-in Nous theme. Clears the unsaved `$accentOverride` preview.- * An unparseable colour changes nothing.+ * Save an accent on the live profile's theme: only its accent moves, saved as the `<base>-accent` user theme+ * the `$accentOverride` preview painted. `null` (or the base's own accent) returns to the base theme itself.+ * Clears the unsaved preview. An unparseable colour changes nothing.*/export function persistAccent(accent: null | string): void {const hex = accent === null ? null : normalizeHex(accent)@@ -17,15 +16,12 @@ export function persistAccent(accent: null | string): void {return}- const theme =- hex === null || hex === normalizeHex(nousTheme.colors.primary)- ? nousTheme- : installUserTheme({- ...retintTheme(nousTheme, hex),- name: `nous-accent-${hex.slice(1)}`,- label: `${nousTheme.label} · ${hex}`- })+ const active = committedTheme()+ const next = hex === null ? accentBase(active) : accentedTheme(active, hex)- requestTheme(theme.name)+ requestTheme(next.accentOf ? installUserTheme(next).name : next.name)setAccentOverride(null)}++/** The accent the live theme's own palette carries, for previewing a return to it. */+export const ownAccent = (): string => accentBase(committedTheme()).colors.primarydiff --git a/apps/desktop/src/themes/types.ts b/apps/desktop/src/themes/types.tsindex c78e3ca87bc..906b6f0885f 100644--- a/apps/desktop/src/themes/types.ts+++ b/apps/desktop/src/themes/types.ts@@ -110,6 +110,8 @@ export interface DesktopTheme {* Persists across updates because it lives in ~/.hermes/skins/,* not inside app.asar. */customCSS?: string+ /** On a saved accent retint (`<base>-accent`): the theme it was retinted from. */+ accentOf?: string}// The minimal set of color keys a stored theme must carry to be usable. We keep