The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a saved accent is one copy per base and colour, so profiles never overwrite each other
alt-glitch1c3bf9fcadc2
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 73d1490e788..d83da6a3656 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')+ expect($pendingSkinApply.get()).toBe('nous-accent-e0218a')expect($themePicks.get()['session-a']).toBeUndefined()})diff --git a/apps/desktop/src/store/appearance-apply.test.ts b/apps/desktop/src/store/appearance-apply.test.tsindex 46d6d555682..b378f221cad 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')+ expect($pendingSkinApply.get()).toBe('nous-accent-8a2be2')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 e10e0842e49..c3422a9b01b 100644--- a/apps/desktop/src/themes/context.tsx+++ b/apps/desktop/src/themes/context.tsx@@ -223,8 +223,9 @@ export const accentBase = (theme: DesktopTheme): DesktopTheme =>/*** `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.+ * paints them. Every other colour and the CSS stay the base's. One `<base>-accent-<hex>` copy per base and+ * colour: user themes are shared by every profile, so a copy per base alone let one profile's accent+ * overwrite another's. The base's own accent returns the base itself.*/export function accentedTheme(theme: DesktopTheme, accent: string): DesktopTheme {const base = accentBase(theme)@@ -238,7 +239,7 @@ export function accentedTheme(theme: DesktopTheme, accent: string): DesktopThemereturn {...base,- name: `${base.name}-accent`,+ name: `${base.name}-accent-${hex.slice(1)}`,label: `${base.label} · ${hex}`,accentOf: base.name,colors: tint('light'),diff --git a/apps/desktop/src/themes/persist-accent.test.tsx b/apps/desktop/src/themes/persist-accent.test.tsxindex 70ca9508fd4..c3b38877b8d 100644--- a/apps/desktop/src/themes/persist-accent.test.tsx+++ b/apps/desktop/src/themes/persist-accent.test.tsx@@ -91,13 +91,39 @@ describe('persistAccent', () => {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.+ // A different colour makes its own copy; the same base and colour reuses it.+ const pink = theme.themeNameact(() => persistAccent('#2ea043'))- expect(Object.keys($userThemes.get()).sort()).toEqual([ember.name, theme.themeName].sort())- expect(resolveTheme(theme.themeName)!.colors.background).toBe(ember.colors.background)+ const green = theme.themeName+ expect(green).not.toBe(pink)+ expect(resolveTheme(green)!.colors.background).toBe(ember.colors.background)+ act(() => persistAccent('#e0218a'))+ expect(theme.themeName).toBe(pink)+ expect(Object.keys($userThemes.get()).sort()).toEqual([ember.name, pink, green].sort())// The theme's own accent puts the theme itself back.act(() => persistAccent(null))expect(theme.themeName).toBe(ember.name)})++ it("never overwrites another profile's saved accent", () => {+ $activeGatewayProfile.set('home')+ render(+ <ThemeProvider>+ <ThemeProbe />+ </ThemeProvider>+ )++ act(() => persistAccent('#8a2be2'))+ const violet = skinPref.resolve('home')++ act(() => $activeGatewayProfile.set('work'))+ act(() => persistAccent('#e0218a'))++ expect(skinPref.resolve('work')).not.toBe(violet)+ expect(skinPref.resolve('home')).toBe(violet)+ expect(resolveTheme(violet)!.accentOf).toBe(nousTheme.name)+ expect(resolveTheme(skinPref.resolve('work'))!.label).toContain('#e0218a')+ expect(resolveTheme(violet)!.label).toContain('#8a2be2')+ })})diff --git a/apps/desktop/src/themes/persist-accent.ts b/apps/desktop/src/themes/persist-accent.tsindex 429270d5339..92becdd30dd 100644--- a/apps/desktop/src/themes/persist-accent.ts+++ b/apps/desktop/src/themes/persist-accent.ts@@ -5,7 +5,7 @@ import { requestTheme } from './request'import { installUserTheme } from './user-themes'/**- * Save an accent on the live profile's theme: only its accent moves, saved as the `<base>-accent` user theme+ * Save an accent on the live profile's theme: only its accent moves, saved as the `<base>-accent-<hex>` 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.*/diff --git a/apps/desktop/src/themes/types.ts b/apps/desktop/src/themes/types.tsindex 906b6f0885f..b212f594207 100644--- a/apps/desktop/src/themes/types.ts+++ b/apps/desktop/src/themes/types.ts@@ -110,7 +110,7 @@ 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. */+ /** On a saved accent retint (`<base>-accent-<hex>`): the theme it was retinted from. */accentOf?: string}