The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): share a profile as a portable bundle - theme, layout, skills
Brooklyn Nicholson6e7eafc7e844
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 200ecb5fed2..76fd414d660 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -10510,6 +10510,22 @@ ipcMain.handle('hermes:writeClipboard', (_event, text) => {return true})+// Native save-location picker (profile export etc.) — the write itself happens+// elsewhere (the backend, for profile archives); this only picks the path.+ipcMain.handle('hermes:selectSavePath', async (_event, options: any = {}) => {+ const result = await dialog.showSaveDialog(mainWindow, {+ title: options?.title || 'Save',+ defaultPath: options?.defaultPath ? String(options.defaultPath) : undefined,+ filters: Array.isArray(options?.filters) ? options.filters : undefined+ })++ if (result.canceled || !result.filePath) {+ return null+ }++ return result.filePath+})+// Paired reader for the GUI terminal's paste chord: the renderer's// navigator.clipboard.readText() throws "Document is not focused" whenever a// portaled overlay has focus, and there's no way to route a read through thediff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.tsindex 11483d9ce82..dd9537b26fd 100644--- a/apps/desktop/electron/preload.ts+++ b/apps/desktop/electron/preload.ts@@ -115,6 +115,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {},readFileText: filePath => ipcRenderer.invoke('hermes:readFileText', filePath),selectPaths: options => ipcRenderer.invoke('hermes:selectPaths', options),+ selectSavePath: options => ipcRenderer.invoke('hermes:selectSavePath', options),writeClipboard: text => ipcRenderer.invoke('hermes:writeClipboard', text),readClipboard: () => ipcRenderer.invoke('hermes:readClipboard'),saveImageFromUrl: url => ipcRenderer.invoke('hermes:saveImageFromUrl', url),diff --git a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsxindex 1bd5ad3c1d1..4a178f15c5f 100644--- a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx@@ -59,6 +59,7 @@ import {setShowAllProfiles,sortByProfileOrder} from '@/store/profile'+import { runExportProfileFlow, runImportProfileFlow } from '@/store/profile-share'import type { ProfileInfo } from '@/types/hermes'import { CreateProfileDialog } from '../../profiles/create-profile-dialog'@@ -264,6 +265,7 @@ export function ProfileRail() {profiles={named}/><AddProfileButton label={p.newProfile} onClick={() => setCreateOpen(true)} />+ <ImportProfileButton label={p.importProfile} /></div>) : (<div@@ -302,6 +304,7 @@ export function ProfileRail() {)}<AddProfileButton label={p.newProfile} onClick={() => setCreateOpen(true)} />+ <ImportProfileButton label={p.importProfile} /></div>)}@@ -435,6 +438,24 @@ function AddProfileButton({ label, onClick }: { label: string; onClick: () => vo)}+// Import-archive door beside the "+": adopt a shared profile bundle (theme,+// skills, layout) as a new profile. Same chrome as AddProfileButton; the whole+// flow (picker → import → apply overlay → switch) lives in the store.+function ImportProfileButton({ label }: { label: string }) {+ return (+ <Tip label={label}>+ <button+ aria-label={label}+ className="grid size-5 shrink-0 place-items-center rounded-[3px] text-(--ui-text-tertiary) opacity-55 transition hover:bg-(--ui-control-hover-background) hover:text-foreground hover:opacity-100"+ onClick={() => void runImportProfileFlow()}+ type="button"+ >+ <Codicon name="cloud-download" size="0.75rem" />+ </button>+ </Tip>+ )+}+// The condensed rail: every named profile in one compact select. The trigger// shows the active profile (tinted initial + name); on default/all scope it// falls back to the placeholder since the left toggle pill carries that state.@@ -692,6 +713,10 @@ function ProfileSquare({<Codicon name="edit" size="0.875rem" /><span>{p.editSoul}</span></ContextMenuItem>+ <ContextMenuItem onSelect={() => void runExportProfileFlow(label)}>+ <Codicon name="package" size="0.875rem" />+ <span>{p.exportProfile}</span>+ </ContextMenuItem><ContextMenuItemclassName="text-destructive focus:text-destructive"onSelect={onDelete}diff --git a/apps/desktop/src/app/contrib/controller.tsx b/apps/desktop/src/app/contrib/controller.tsxindex da4ff828cb8..b643a31c1b4 100644--- a/apps/desktop/src/app/contrib/controller.tsx+++ b/apps/desktop/src/app/contrib/controller.tsx@@ -39,7 +39,7 @@ import { useContributions } from '@/contrib/react/use-contributions'import { registry } from '@/contrib/registry'import { discoverRuntimePlugins } from '@/contrib/runtime-loader'import { sessionTitle as storedSessionTitle } from '@/lib/chat-runtime'-import { FileText, LayoutDashboard, PanelBottom, Terminal, Zap } from '@/lib/icons'+import { Download, FileText, LayoutDashboard, PanelBottom, Terminal, Upload, Zap } from '@/lib/icons'import { type KeybindContribution, KEYBINDS_AREA } from '@/lib/keybinds/actions'import { setYoloEnabled } from '@/lib/yolo-session'import { pruneComposerPopoutZones } from '@/store/composer-popout'@@ -56,6 +56,7 @@ import {SIDEBAR_MAX_WIDTH} from '@/store/layout'import { $previewOpenRequest, $previewTabs, closeRightRail } from '@/store/preview'+import { runExportProfileFlow, runImportProfileFlow } from '@/store/profile-share'import { $reviewOpen, closeReview, openReview, REVIEW_PANE_ID } from '@/store/review'import { $currentCwd, $selectedStoredSessionId, $sessions, $yoloActive, sessionMatchesStoredId } from '@/store/session'import { watchSessionPins } from '@/store/session-pin-sync'@@ -314,6 +315,31 @@ registry.registerMany([keywords: ['keybinds', 'shortcuts', 'hotkeys', 'keyboard'],run: () => window.dispatchEvent(new CustomEvent('hermes:open-keybinds'))} satisfies PaletteContribution+ },+ // Profile sharing: bundle the active profile (config, skills, theme, layout)+ // into a portable archive, or adopt someone else's. Both open native dialogs,+ // so the palette closing on select is correct.+ {+ id: 'profile.export',+ area: PALETTE_AREA,+ data: {+ id: 'profile.export',+ label: 'Export profile…',+ icon: Upload,+ keywords: ['profile', 'export', 'share', 'bundle', 'theme', 'settings', 'backup'],+ run: () => void runExportProfileFlow()+ } satisfies PaletteContribution+ },+ {+ id: 'profile.import',+ area: PALETTE_AREA,+ data: {+ id: 'profile.import',+ label: 'Import profile…',+ icon: Download,+ keywords: ['profile', 'import', 'share', 'bundle', 'archive', 'restore'],+ run: () => void runImportProfileFlow()+ } satisfies PaletteContribution}])diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.tsindex c2b677619ec..efd7811876e 100644--- a/apps/desktop/src/global.d.ts+++ b/apps/desktop/src/global.d.ts@@ -129,6 +129,12 @@ declare global {}readFileText: (filePath: string) => Promise<HermesReadFileTextResult>selectPaths: (options?: HermesSelectPathsOptions) => Promise<string[]>+ /** Native save dialog; returns the chosen path or null on cancel. */+ selectSavePath?: (options?: {+ defaultPath?: string+ filters?: Array<{ extensions: string[]; name: string }>+ title?: string+ }) => Promise<null | string>writeClipboard: (text: string) => Promise<boolean>readClipboard: () => Promise<string>saveImageFromUrl: (url: string) => Promise<boolean>diff --git a/apps/desktop/src/hermes.ts b/apps/desktop/src/hermes.tsindex b3d5a45555a..f33d05226c1 100644--- a/apps/desktop/src/hermes.ts+++ b/apps/desktop/src/hermes.ts@@ -47,6 +47,7 @@ import type {PairingResponse,PairingUser,ProfileCreatePayload,+ ProfileDesktopOverlay,ProfileSetupCommand,ProfileSoul,ProfilesResponse,@@ -186,6 +187,7 @@ export type {PairingResponse,PairingUser,ProfileCreatePayload,+ ProfileDesktopOverlay,ProfileInfo,ProfileSetupCommand,ProfileSoul,@@ -1431,6 +1433,36 @@ export function getProfileSetupCommand(name: string): Promise<ProfileSetupComman})}+/** Export a profile to a shareable .tar.gz on the backend's filesystem.+ * `extraFiles` stages extra root-level files (desktop.json — the appearance/+ * interface overlay) into the archive alongside the profile's own artifacts. */+export function exportProfileArchive(+ name: string,+ opts: { extraFiles?: Record<string, string>; output?: string } = {}+): Promise<{ archive: string; ok: boolean }> {+ return window.hermesDesktop.api<{ archive: string; ok: boolean }>({+ path: `/api/profiles/${encodeURIComponent(name)}/export`,+ method: 'POST',+ body: { extra_files: opts.extraFiles ?? {}, output: opts.output ?? '' },+ timeoutMs: STARTUP_REQUEST_TIMEOUT_MS+ })+}++/** Import a profile .tar.gz as a new profile. Returns the bundled desktop+ * appearance overlay too (when the archive carried one) so the caller can+ * apply theme/layout without another round-trip. */+export function importProfileArchive(+ archive: string,+ name?: string+): Promise<{ desktop: null | ProfileDesktopOverlay; name: string; ok: boolean; path: string }> {+ return window.hermesDesktop.api<{ desktop: null | ProfileDesktopOverlay; name: string; ok: boolean; path: string }>({+ path: '/api/profiles/import',+ method: 'POST',+ body: { archive, name: name || null },+ timeoutMs: STARTUP_REQUEST_TIMEOUT_MS+ })+}+export function getUsageAnalytics(days = 30): Promise<AnalyticsResponse> {return window.hermesDesktop.api<AnalyticsResponse>({...profileScoped(),diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 6091c916c33..a5a63e258e1 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -1293,6 +1293,12 @@ export const ar = defineLocale({count: count => `${count} ملف شخصي`,loading: 'جار التحميل...',newProfile: 'ملف شخصي جديد',+ importProfile: 'استيراد ملف شخصي…',+ exportProfile: 'تصدير ملف شخصي…',+ imported: 'تم استيراد الملف الشخصي',+ exported: 'تم تصدير الملف الشخصي',+ failedImport: 'فشل استيراد الملف الشخصي',+ failedExport: 'فشل تصدير الملف الشخصي',allProfiles: 'كل الملفات الشخصية',showAllProfiles: 'إظهار كل الملفات الشخصية',switchToProfile: name => `التبديل إلى ${name}`,diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex fe764eb310a..93ef3daa403 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1559,6 +1559,12 @@ export const en: Translations = {search: 'Search profiles...',loading: 'Loading profiles...',newProfile: 'New profile',+ importProfile: 'Import profile…',+ exportProfile: 'Export profile…',+ imported: 'Profile imported',+ exported: 'Profile exported',+ failedImport: 'Failed to import profile',+ failedExport: 'Failed to export profile',allProfiles: 'All profiles',showAllProfiles: 'Show all profiles',switchToProfile: name => `Switch to ${name}`,diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 16d58834c62..f269e7d0d6b 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -1396,6 +1396,12 @@ export const ja = defineLocale({search: 'プロファイルを検索...',loading: 'プロファイルを読み込み中...',newProfile: '新しいプロファイル',+ importProfile: 'プロファイルをインポート…',+ exportProfile: 'プロファイルをエクスポート…',+ imported: 'プロファイルをインポートしました',+ exported: 'プロファイルをエクスポートしました',+ failedImport: 'プロファイルのインポートに失敗しました',+ failedExport: 'プロファイルのエクスポートに失敗しました',allProfiles: 'すべてのプロファイル',showAllProfiles: 'すべてのプロファイルを表示',switchToProfile: name => `${name} に切り替え`,diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex b82feb40011..59834d21366 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -1305,6 +1305,12 @@ export interface Translations {search: stringloading: stringnewProfile: string+ importProfile: string+ exportProfile: string+ imported: string+ exported: string+ failedImport: string+ failedExport: stringallProfiles: stringshowAllProfiles: stringswitchToProfile: (name: string) => stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 31a0b62a53e..f205fe20488 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -1345,6 +1345,12 @@ export const zhHant = defineLocale({search: '搜尋設定檔…',loading: '正在載入設定檔…',newProfile: '新增設定檔',+ importProfile: '匯入設定檔…',+ exportProfile: '匯出設定檔…',+ imported: '設定檔已匯入',+ exported: '設定檔已匯出',+ failedImport: '匯入設定檔失敗',+ failedExport: '匯出設定檔失敗',allProfiles: '全部設定檔',showAllProfiles: '顯示全部設定檔',switchToProfile: name => `切換至 ${name}`,diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 10b47272459..3904e7c06ca 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1753,6 +1753,12 @@ export const zh: Translations = {search: '搜索配置档案…',loading: '正在加载配置档案…',newProfile: '新建配置档案',+ importProfile: '导入配置档案…',+ exportProfile: '导出配置档案…',+ imported: '配置档案已导入',+ exported: '配置档案已导出',+ failedImport: '导入配置档案失败',+ failedExport: '导出配置档案失败',allProfiles: '全部配置档案',showAllProfiles: '显示全部配置档案',switchToProfile: name => `切换到 ${name}`,diff --git a/apps/desktop/src/store/profile-share.test.ts b/apps/desktop/src/store/profile-share.test.tsnew file mode 100644index 00000000000..985564e9342--- /dev/null+++ b/apps/desktop/src/store/profile-share.test.ts@@ -0,0 +1,126 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'++import type { DesktopTheme } from '@/themes/types'+import type { ProfileDesktopOverlay } from '@/types/hermes'++// Keep side-effecting transitive imports inert (gateway sockets, REST).+vi.mock('@/store/gateway', async () => {+ const { atom } = await import('nanostores')++ return {+ $gateway: atom<unknown>(null),+ ensureGatewayForProfile: vi.fn(async () => undefined),+ openGatewayForProfile: vi.fn(async () => undefined)+ }+})+vi.mock('@/hermes', () => ({+ exportProfileArchive: vi.fn(async () => ({ archive: '/tmp/out.tar.gz', ok: true })),+ getProfiles: vi.fn(async () => ({ profiles: [] })),+ importProfileArchive: vi.fn(async () => ({ desktop: null, name: 'imported', ok: true, path: '/tmp/p' })),+ setApiRequestProfile: vi.fn()+}))+vi.mock('@/lib/query-client', () => ({ invalidateProfileScopedQueries: vi.fn() }))+vi.mock('@/store/starmap', () => ({ resetStarmapGraph: vi.fn() }))++const { applyDesktopOverlay, buildDesktopOverlay, exportProfileBundle } = await import('./profile-share')+const { $profileColors, setProfileColor } = await import('./profile')+const { modePref, skinPref } = await import('@/themes/context')+const { $userThemes } = await import('@/themes/user-themes')+const { $layoutTree } = await import('@/components/pane-shell/tree/store')+const { exportProfileArchive } = await import('@/hermes')++// isValidTheme only requires background/foreground/primary at runtime; the+// static type wants the full palette, hence the cast.+const roseTheme = {+ name: 'rose-quartz',+ label: 'Rose Quartz',+ description: 'test theme',+ colors: { background: '#fff0f5', foreground: '#221122', primary: '#e91e63' }+} as unknown as DesktopTheme++beforeEach(() => {+ window.localStorage.clear()+ $userThemes.set({})+ $profileColors.set({})+})++afterEach(() => {+ vi.clearAllMocks()+})++describe('buildDesktopOverlay', () => {+ it('snapshots skin, mode, rail color, and the layout tree for the profile', () => {+ skinPref.assign('glam', 'mono')+ modePref.assign('glam', 'dark')+ setProfileColor('glam', '#e91e63')++ const overlay = buildDesktopOverlay('glam')++ expect(overlay.version).toBe(1)+ expect(overlay.skin).toBe('mono')+ expect(overlay.mode).toBe('dark')+ expect(overlay.profileColor).toBe('#e91e63')+ // Built-in skin → no bundled theme definitions.+ expect(overlay.themes).toBeUndefined()+ })++ it('bundles the full definition of a non-built-in skin', () => {+ $userThemes.set({ 'rose-quartz': roseTheme })+ skinPref.assign('glam', 'rose-quartz')++ const overlay = buildDesktopOverlay('glam')++ expect(overlay.skin).toBe('rose-quartz')+ expect(overlay.themes).toEqual({ 'rose-quartz': roseTheme })+ })+})++describe('applyDesktopOverlay', () => {+ it('installs bundled themes and assigns skin/mode/color to the new profile', () => {+ applyDesktopOverlay('glam-copy', {+ version: 1,+ skin: 'rose-quartz',+ mode: 'dark',+ themes: { 'rose-quartz': roseTheme },+ profileColor: '#e91e63'+ })++ expect($userThemes.get()['rose-quartz']).toEqual(roseTheme)+ expect(skinPref.resolve('glam-copy')).toBe('rose-quartz')+ expect(modePref.resolve('glam-copy')).toBe('dark')+ expect($profileColors.get()['glam-copy']).toBe('#e91e63')+ })++ it('ignores a skin that resolves to nothing and junk layout trees', () => {+ const before = $layoutTree.get()++ applyDesktopOverlay('glam-copy', {+ skin: 'no-such-skin',+ layoutTree: { bogus: true }+ } as ProfileDesktopOverlay)++ // Unresolvable skin → pref falls back to the default resolution.+ expect(skinPref.resolve('glam-copy')).toBe(skinPref.resolve('some-unassigned'))+ expect($layoutTree.get()).toBe(before)+ })++ it('is a no-op for a plain CLI archive (no overlay)', () => {+ expect(() => applyDesktopOverlay('glam-copy', null)).not.toThrow()+ expect(() => applyDesktopOverlay('glam-copy', undefined)).not.toThrow()+ })+})++describe('exportProfileBundle', () => {+ it('stages desktop.json into the archive through extra_files', async () => {+ skinPref.assign('glam', 'mono')++ const archive = await exportProfileBundle('glam', '/tmp/glam.tar.gz')++ expect(archive).toBe('/tmp/out.tar.gz')+ const call = vi.mocked(exportProfileArchive).mock.calls[0]+ expect(call[0]).toBe('glam')+ const overlay = JSON.parse(call[1]?.extraFiles?.['desktop.json'] ?? '{}') as ProfileDesktopOverlay+ expect(overlay.skin).toBe('mono')+ expect(call[1]?.output).toBe('/tmp/glam.tar.gz')+ })+})diff --git a/apps/desktop/src/store/profile-share.ts b/apps/desktop/src/store/profile-share.tsnew file mode 100644index 00000000000..ee5d0528712--- /dev/null+++ b/apps/desktop/src/store/profile-share.ts@@ -0,0 +1,219 @@+/**+ * Profile share: export/import a profile as a portable bundle.+ *+ * The archive is the CLI's own `hermes profile export` tar.gz (config, skills,+ * SOUL.md, cron — credentials always excluded), plus one desktop-only file at+ * the root: `desktop.json`, the appearance/interface overlay (skin + mode,+ * any user-theme definitions the skin needs, the profile rail color, and the+ * layout tree). A CLI import of the same archive simply carries the file+ * along; the desktop import applies it so the receiving user gets the whole+ * look — theme, layout, skills — as a ready-to-use profile.+ *+ * Paths, not bytes, cross the renderer↔backend boundary: the native save/open+ * dialogs and the backend share the filesystem for local and pooled backends.+ */++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 { modePref, skinPref, type ThemeMode } from '@/themes/context'+import { BUILTIN_THEMES } from '@/themes/presets'+import type { DesktopTheme } from '@/themes/types'+import { $userThemes, installUserTheme, resolveTheme } from '@/themes/user-themes'+import type { ProfileDesktopOverlay } from '@/types/hermes'++import { notify, notifyError } from './notifications'+import {+ $activeGatewayProfile,+ $profileColors,+ normalizeProfileKey,+ refreshActiveProfile,+ selectProfile,+ setProfileColor+} from './profile'++/** Filename of the overlay inside the archive (profile root). */+export const DESKTOP_OVERLAY_FILENAME = 'desktop.json'++const OVERLAY_VERSION = 1++/**+ * Snapshot the desktop appearance/interface for `profile` into the overlay.+ * The layout tree is global (one window layout, not per-profile) — it rides+ * along so the receiver can opt into the sender's whole interface.+ */+export function buildDesktopOverlay(profile: string): ProfileDesktopOverlay {+ const key = normalizeProfileKey(profile)+ const skin = skinPref.resolve(key)+ const mode = modePref.resolve(key)++ // Bundle the full definition of any non-built-in theme the skin points at,+ // so the receiver's picker can resolve it. Built-ins resolve by name.+ const themes: Record<string, unknown> = {}+ const userTheme = BUILTIN_THEMES[skin] ? undefined : $userThemes.get()[skin]++ if (userTheme) {+ themes[userTheme.name] = userTheme+ }++ return {+ version: OVERLAY_VERSION,+ skin,+ mode,+ ...(Object.keys(themes).length ? { themes } : {}),+ profileColor: $profileColors.get()[key] ?? null,+ layoutTree: $layoutTree.get()+ }+}++/** Export `profile` (backend archive + desktop overlay) to `output` (or the+ * backend's staging dir when omitted). Returns the archive path. */+export async function exportProfileBundle(profile: string, output?: string): Promise<string> {+ const overlay = buildDesktopOverlay(profile)++ const { archive } = await exportProfileArchive(profile, {+ extraFiles: { [DESKTOP_OVERLAY_FILENAME]: JSON.stringify(overlay, null, 2) },+ output+ })++ return archive+}++const isThemeMode = (value: unknown): value is ThemeMode =>+ value === 'light' || value === 'dark' || value === 'system'++/**+ * Apply an imported overlay: install bundled themes, assign the new profile's+ * skin + mode + rail color, and (when present) adopt the sender's layout tree.+ * Every step is independent and best-effort — a malformed half never blocks+ * the rest, and a missing overlay is a plain CLI-exported archive (no-op).+ */+export function applyDesktopOverlay(profile: string, overlay: null | ProfileDesktopOverlay | undefined): void {+ if (!overlay || typeof overlay !== 'object') {+ return+ }++ const key = normalizeProfileKey(profile)++ // 1. Bundled theme definitions. installUserTheme validates shape and refuses+ // built-in collisions; a bad entry just doesn't install.+ for (const theme of Object.values(overlay.themes ?? {})) {+ try {+ installUserTheme(theme as DesktopTheme)+ } catch {+ // Invalid/colliding theme — the skin assignment below falls back.+ }+ }++ // 2. Appearance assignment for the new profile. Only assign a skin that+ // actually resolves so the pref never points at nothing.+ if (typeof overlay.skin === 'string' && resolveTheme(overlay.skin)) {+ skinPref.assign(key, overlay.skin)+ }++ if (isThemeMode(overlay.mode)) {+ modePref.assign(key, overlay.mode)+ }++ // 3. Rail color.+ if (typeof overlay.profileColor === 'string' && overlay.profileColor) {+ setProfileColor(key, overlay.profileColor)+ }++ // 4. Layout tree — global by design (one window layout). Normalize through+ // the same canonicalizer the boot load uses; a null result means the+ // tree was junk, so the current layout stays.+ if (overlay.layoutTree != null && isLayoutNode(overlay.layoutTree)) {+ const tree = normalize(overlay.layoutTree)++ if (tree) {+ $layoutTree.set(tree)+ persistTree()+ markActivePreset('custom')+ }+ }+}++/** 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)+ applyDesktopOverlay(result.name, result.desktop)++ return result.name+}++/** The profile the export pickers should default to — the active one. */+export function activeProfileKey(): string {+ return normalizeProfileKey($activeGatewayProfile.get())+}++// ── Dialog-driven flows ──────────────────────────────────────────────────────+// One store function per user verb (⌘K row, rail button, and any future menu+// item all funnel here). Toasts via the shared notification store; strings via+// translateNow so the flows stay callable from non-React surfaces.++const ARCHIVE_FILTERS = [{ extensions: ['tar.gz', 'tgz'], name: 'Hermes profile' }]++/** Pick a save location and export `profile` (default: the active one).+ * Returns the archive path, or null when the user cancelled. */+export async function runExportProfileFlow(profile?: string): Promise<null | string> {+ const target = normalizeProfileKey(profile ?? activeProfileKey())+ const pick = window.hermesDesktop?.selectSavePath++ if (!pick) {+ return null+ }++ const output = await pick({+ title: translateNow('profiles.exportProfile'),+ defaultPath: `${target}.tar.gz`,+ filters: ARCHIVE_FILTERS+ })++ if (!output) {+ return null+ }++ try {+ const archive = await exportProfileBundle(target, output)+ notify({ kind: 'success', title: translateNow('profiles.exported'), message: archive })++ return archive+ } catch (error) {+ notifyError(error, translateNow('profiles.failedExport'))++ return null+ }+}++/** Pick an archive and import it as a new profile; lands the user in it on a+ * fresh chat. Returns the new profile name, or null when cancelled/failed. */+export async function runImportProfileFlow(): Promise<null | string> {+ const paths = await window.hermesDesktop?.selectPaths?.({+ title: translateNow('profiles.importProfile'),+ multiple: false,+ filters: ARCHIVE_FILTERS+ })++ const archive = paths?.[0]++ if (!archive) {+ return null+ }++ try {+ const name = await importProfileBundle(archive)+ notify({ kind: 'success', title: translateNow('profiles.imported'), message: name })+ // Same landing as CreateProfileDialog's onCreated: refresh the list, then+ // switch into the new profile on a fresh chat.+ await refreshActiveProfile()+ selectProfile(name)++ return name+ } catch (error) {+ notifyError(error, translateNow('profiles.failedImport'))++ return null+ }+}diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.tsindex bc1fb5c581b..e468d21d12a 100644--- a/apps/desktop/src/types/hermes.ts+++ b/apps/desktop/src/types/hermes.ts@@ -871,6 +871,26 @@ export interface ProfileSetupCommand {command: string}+// The desktop appearance/interface overlay bundled into a profile export as+// `desktop.json`. Everything optional — an archive exported by an older (or+// non-desktop) Hermes simply carries none of it. See store/profile-share.ts.+export interface ProfileDesktopOverlay {+ /** Overlay schema version (1). */+ version?: number+ /** Skin name (built-in or bundled user theme). */+ skin?: string+ /** Light/dark/system preference. */+ mode?: string+ /** Full user-theme definitions the skin may reference (DesktopTheme JSON). */+ themes?: Record<string, unknown>+ /** Rail color override for this profile. */+ profileColor?: null | string+ /** Layout tree (hermes.desktop.layoutTree.v2 shape). */+ layoutTree?: unknown+ /** Active layout preset id. */+ layoutPreset?: string+}+// ── Projects ───────────────────────────────────────────────────────────────// A first-class, per-profile, human-named workspace spanning one or more// folders. Mirrors hermes_cli/projects_db.Project.to_dict().