Skip to content

The agent that grows with you

fix(profiles): make browser Export profile explain itself instead of doing nothing

David Dudok de Wit554695ed4bcb
diff --git a/apps/desktop/src/store/profile-share.test.ts b/apps/desktop/src/store/profile-share.test.ts
index f8c54d309a8..5e014d03a5e 100644
--- a/apps/desktop/src/store/profile-share.test.ts
+++ b/apps/desktop/src/store/profile-share.test.ts
@@ -110,6 +110,32 @@ describe('applyDesktopOverlay', () => {
})
})
+describe('runExportProfileFlow', () => {
+ // The browser Webapp bridge has no save dialog: Export must say so, not do nothing.
+ it('explains itself in the browser Webapp instead of silently returning', async () => {
+ const { installBrowserDesktopBridge } = await import('@/lib/browser-desktop-bridge')
+ const { clearWebappSession, seedWebappSession } = await import('@/test/webapp-session')
+ const { runExportProfileFlow } = await import('./profile-share')
+ const { $notifications } = await import('./notifications')
+ seedWebappSession('served-token')
+ vi.stubGlobal('fetch', vi.fn(async () => new Response('{}')))
+
+ try {
+ expect(installBrowserDesktopBridge()).toBe(true)
+ expect(window.hermesDesktop.selectSavePath).toBeUndefined()
+ await expect(runExportProfileFlow('glam')).resolves.toBeNull()
+ expect(exportProfileArchive).not.toHaveBeenCalled()
+ expect($notifications.get().at(-1)).toMatchObject({ kind: 'error', title: 'Failed to export profile' })
+ expect($notifications.get().at(-1)?.message).toContain('hermes profile export glam')
+ } finally {
+ clearWebappSession()
+ Reflect.deleteProperty(window, 'hermesDesktop')
+ document.documentElement.removeAttribute('data-hermes-desktop-host')
+ vi.unstubAllGlobals()
+ }
+ })
+})
+
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.ts
index d1aa8f229a9..97155150325 100644
--- a/apps/desktop/src/store/profile-share.ts
+++ b/apps/desktop/src/store/profile-share.ts
@@ -160,7 +160,12 @@ export async function runExportProfileFlow(profile?: string): Promise<null | str
const target = normalizeProfileKey(profile ?? activeProfileKey())
const pick = window.hermesDesktop?.selectSavePath
+ // The browser Webapp has no save dialog for a host-side archive. Say how to
+ // export there instead of doing nothing.
if (!pick) {
+ const reason = `The browser can't save a profile archive. On the Hermes host, run: hermes profile export ${target}`
+ notifyError(new Error(reason), translateNow('profiles.failedExport'))
+
return null
}