Skip to content

The agent that grows with you

fix(desktop): a Webapp tab opened on the saved default names that profile in its address

emozillaaf30b299c98c
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot-webapp-profile.test.tsx b/apps/desktop/src/app/gateway/hooks/use-gateway-boot-webapp-profile.test.tsx
index 600d2c9a1c8..06114bfd2a2 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot-webapp-profile.test.tsx
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot-webapp-profile.test.tsx
@@ -168,11 +168,14 @@ it('a bare tab on a gateway launched as a named profile names default when it as
expect(await sentFor('default', 'session.active_list')).toEqual({ profile: 'default' })
})
-it('a bare tab opens on the saved default the same way', async () => {
+it('a bare tab opens on the saved default the same way, and records it in its address as a switch does', async () => {
window.localStorage.setItem('hermes:webapp:default-profile:/', JSON.stringify({ connectionId: 'local', profile: 'research' }))
await bootWebappTab('/#/')
expect($activeGatewayProfile.get()).toBe('research')
expect(await sentFor('research', 'session.active_list')).toEqual({ profile: 'research' })
expect(mints.map(url => url.searchParams.get('profile'))).toEqual([null])
+ // Files, uploads and the terminal fall back to the address's profile whenever the connection
+ // descriptor names none (a reconnect publishes the tab's own socket), so it must name this one.
+ expect(new URLSearchParams(window.location.search).get('profile')).toBe('research')
})
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
index f1d83ff6cd8..c9733a9db88 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts
@@ -186,6 +186,9 @@ async function openWebappTabProfile(desktop: Window['hermesDesktop'], primary: s
try {
await ensureGatewayProfile(profile)
+ // As a live switch does: the address names the profile the tab is on, so a reload lands here and
+ // files and the terminal, which fall back to the address's profile, follow it.
+ await desktop.profile?.remember?.(normalizeProfileKey(profile))
} catch (error) {
console.warn(`[gateway] could not open this tab on profile "${profile}"; it stays on "${primary}"`, error)
}