The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): an imported profile drops a reused name's leftover prefs
unsupportedpastels5d9ce70cd6e2
diff --git a/apps/desktop/src/store/profile-share.test.ts b/apps/desktop/src/store/profile-share.test.tsindex 5e014d03a5e..cff157a3dd6 100644--- a/apps/desktop/src/store/profile-share.test.ts+++ b/apps/desktop/src/store/profile-share.test.ts@@ -136,6 +136,51 @@ describe('runExportProfileFlow', () => {})})+describe('importProfileBundle', () => {+ const folderKey = (profile: string) => `hermes:browser:default-project-dir:${JSON.stringify(['/hermes', profile])}`+ const startupKey = 'hermes:webapp:default-profile:/hermes'++ function seedLeftovers() {+ window.localStorage.setItem(folderKey('imported'), '/srv/deleted-imported')+ window.localStorage.setItem(folderKey('other'), '/srv/other')+ window.localStorage.setItem(startupKey, JSON.stringify({ connectionId: null, profile: 'imported' }))+ }++ afterEach(() => {+ document.documentElement.removeAttribute('data-hermes-desktop-host')+ Reflect.deleteProperty(window, '__HERMES_BASE_PATH__')+ })++ // An import never lands on a live profile's name, so prefs stored under it were left by a deleted one.+ it('drops what a deleted profile of the same name left, only once the import succeeded', async () => {+ const { importProfileBundle } = await import('./profile-share')+ const { importProfileArchive } = await import('@/hermes')+ document.documentElement.dataset.hermesDesktopHost = 'browser'+ Object.assign(window, { __HERMES_BASE_PATH__: '/hermes' })+ seedLeftovers()+ vi.mocked(importProfileArchive).mockRejectedValueOnce(new Error('bad archive'))++ await expect(importProfileBundle('/tmp/in.tar.gz')).rejects.toThrow('bad archive')+ expect(window.localStorage.getItem(folderKey('imported'))).toBe('/srv/deleted-imported')+ expect(window.localStorage.getItem(startupKey)).not.toBeNull()++ await expect(importProfileBundle('/tmp/in.tar.gz')).resolves.toBe('imported')+ expect(window.localStorage.getItem(folderKey('imported'))).toBeNull()+ expect(window.localStorage.getItem(startupKey)).toBeNull()+ expect(window.localStorage.getItem(folderKey('other'))).toBe('/srv/other')+ })++ it('keeps browser prefs in native Desktop', async () => {+ const { importProfileBundle } = await import('./profile-share')+ Object.assign(window, { __HERMES_BASE_PATH__: '/hermes' })+ seedLeftovers()++ await expect(importProfileBundle('/tmp/in.tar.gz')).resolves.toBe('imported')+ expect(window.localStorage.getItem(folderKey('imported'))).toBe('/srv/deleted-imported')+ expect(window.localStorage.getItem(startupKey)).not.toBeNull()+ })+})+describe('exportProfileBundle', () => {it('stages desktop.json into the archive through extra_files', async () => {skinPref.assign('glam', 'mono')diff --git a/apps/desktop/src/store/profile-share.ts b/apps/desktop/src/store/profile-share.tsindex 3d2ba3f0d32..12a4cf49caf 100644--- a/apps/desktop/src/store/profile-share.ts+++ b/apps/desktop/src/store/profile-share.ts@@ -17,6 +17,7 @@ import { isLayoutNode, normalize } from '@/components/pane-shell/tree/model'import { $layoutTree, markActivePreset, persistTree } from '@/components/pane-shell/tree/store'import { exportProfileArchive, importProfileArchive } from '@/hermes'import { translateNow } from '@/i18n'+import { dropBrowserProfilePrefs } from '@/lib/browser-profile-prefs'import { modePref, skinPref, type ThemeMode } from '@/themes/context'import { BUILTIN_THEMES } from '@/themes/presets'import type { DesktopTheme } from '@/themes/types'@@ -137,6 +138,9 @@ export function applyDesktopOverlay(profile: string, overlay: null | ProfileDesk/** Import an archive, apply its desktop overlay, return the new profile name. */export async function importProfileBundle(archive: string, name?: string): Promise<string> {const result = await importProfileArchive(archive, name)+ // An import never lands on a live profile's name, so a folder or startup profile stored under+ // it was left by a profile deleted before delete dropped them.+ dropBrowserProfilePrefs(result.name)applyDesktopOverlay(result.name, result.desktop)return result.name