Skip to content

The agent that grows with you

fix(desktop): keep Sessions workspace when opening a Bot Chat

EndeavorYen2367b90b9f16
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.js b/apps/desktop/src/plugins/hermes-bots/plugin.js
index 1641da4e069..9585d291a5f 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.js
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.js
@@ -3287,7 +3287,7 @@ async function openStoredBotChat(name, storedId, summary) {
intent: 'main',
awaitHydration: true,
expectHistory,
- keepAllProfilesScope: false,
+ keepAllProfilesScope: true,
retryHydrationTimeoutOnce: true
})
@@ -3328,7 +3328,7 @@ function createCanonicalChat(name) {
if (sid && typeof host.openSession === 'function') {
try {
- await host.openSession(sid, { profile: name, intent: 'main', keepAllProfilesScope: false })
+ await host.openSession(sid, { profile: name, intent: 'main', keepAllProfilesScope: true })
opened = true
} catch {
// The stored row may not exist until the kickoff persists it. Retry
@@ -3343,7 +3343,7 @@ function createCanonicalChat(name) {
await host.request('prompt.submit', { session_id: runtime, text: 'Hey, tell me about yourself!' })
if (!opened && sid && typeof host.openSession === 'function') {
- await host.openSession(sid, { profile: name, intent: 'main', keepAllProfilesScope: false })
+ await host.openSession(sid, { profile: name, intent: 'main', keepAllProfilesScope: true })
}
} catch {
// The chat already exists. Keep the pin so the next click
@@ -7852,7 +7852,7 @@ async function openProfileSession(botName, session, gatewayGeneration) {
typeof session?.message_count === 'number' && Number.isFinite(session.message_count)
const expectHistory = hasAuthoritativeCount ? session.message_count > 0 : Boolean(session?.preview)
- await host.openSession(id, { profile, awaitHydration: true, expectHistory, keepAllProfilesScope: false })
+ await host.openSession(id, { profile, awaitHydration: true, expectHistory, keepAllProfilesScope: true })
if (gatewayGeneration !== $sessionsGatewayGeneration.get()) return
$botSelectedSessions.set({ ...$botSelectedSessions.get(), [profile]: id })
}
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-identity.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-identity.test.mjs
index b59e11f20be..2c060568fd6 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-identity.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/canonical-chat-identity.test.mjs
@@ -112,7 +112,7 @@ test('pin: preferred_session present opens the resolved session and keeps the pi
intent: 'main',
awaitHydration: true,
expectHistory: true,
- keepAllProfilesScope: false,
+ keepAllProfilesScope: true,
retryHydrationTimeoutOnce: true
}
}])
diff --git a/apps/desktop/src/plugins/hermes-bots/tests/session-workspace.test.mjs b/apps/desktop/src/plugins/hermes-bots/tests/session-workspace.test.mjs
index e209eebc159..238d863ed1e 100644
--- a/apps/desktop/src/plugins/hermes-bots/tests/session-workspace.test.mjs
+++ b/apps/desktop/src/plugins/hermes-bots/tests/session-workspace.test.mjs
@@ -90,7 +90,7 @@ test('sessions workspace: opening a stored row uses profile-aware navigation and
const runtime = load({ profile: 'default' })
await runtime.__sessions.openProfileSession('ops', { id: 'stored-123', message_count: 4 }, 0)
assert.deepEqual(plain(runtime.calls), [
- ['openSession', 'stored-123', { profile: 'ops', awaitHydration: true, expectHistory: true, keepAllProfilesScope: false }]
+ ['openSession', 'stored-123', { profile: 'ops', awaitHydration: true, expectHistory: true, keepAllProfilesScope: true }]
])
assert.equal(runtime.__sessions.$botSelectedSessions.get().ops, 'stored-123')
})
@@ -117,7 +117,7 @@ test('sessions workspace: an empty session with no preview does not demand histo
const runtime = load()
await runtime.__sessions.openProfileSession('ops', { id: 'stored-empty', message_count: 0 }, 0)
assert.deepEqual(plain(runtime.calls), [
- ['openSession', 'stored-empty', { profile: 'ops', awaitHydration: true, expectHistory: false, keepAllProfilesScope: false }]
+ ['openSession', 'stored-empty', { profile: 'ops', awaitHydration: true, expectHistory: false, keepAllProfilesScope: true }]
])
})
diff --git a/apps/desktop/src/sdk/index.ts b/apps/desktop/src/sdk/index.ts
index e514259764d..2aee7a86dca 100644
--- a/apps/desktop/src/sdk/index.ts
+++ b/apps/desktop/src/sdk/index.ts
@@ -431,14 +431,6 @@ export const host = {
window.location.hash = path.startsWith('#') ? path : `#${path}`
},
- /** Open a stored session the way core surfaces do (focus an existing
- * tile/main, else load into main). When `profile` names a non-active
- * profile, its backend is activated first so the resume routes to the
- * right state.db — the same soft profile swap the unified sidebar does.
- * `keepAllProfilesScope` (default true) keeps the Sessions sidebar in the
- * unified all-profiles view instead of narrowing it to the target
- * profile's sessions — a cross-profile open from a plugin surface is a
- * navigation, not a scope choice; pass false to also scope the sidebar. */
/** Pre-dial a profile's gateway socket in the background — pool-only, no
* activation, no navigation, no scope change (openGatewayForProfile; it
* already no-ops for shared-remote routes and the primary). Roster UIs
@@ -555,7 +547,10 @@ export const host = {
ensureAgent: async (connectionId: null | string, profile: string): Promise<void> =>
ensureGatewayAgent(connectionId, (profile ?? '').trim() || 'default'),
- /** Open a stored session — optionally pre-activating its profile first. */
+ /** Open a stored session the way core surfaces do. A plugin/Bot Mode open
+ * is navigation, not a workspace switch — keepAllProfilesScope defaults
+ * true so Sessions stays on the unified list (the bot forever-chat is
+ * hidden and would otherwise look like every session disappeared). */
openSession: async (storedSessionId: string, options: PluginOpenSessionOptions = {}): Promise<void> => {
const generation = ++openSessionGeneration
const profile = (options.profile ?? '').trim()
@@ -588,10 +583,14 @@ export const host = {
? awaitProfileActivation(profile, targetProfile, hydrationTimeoutMs)
: ensureGatewayProfile(profile))
profileActiveAt = Date.now()
+ }
- if (options.keepAllProfilesScope !== false) {
- setShowAllProfiles(true)
- }
+ // Outside the dial branch on purpose: re-opening a bot whose profile is
+ // ALREADY active still has to restore the unified list. Scoped inside,
+ // the second open of the same bot left Sessions collapsed onto a profile
+ // whose forever-chat is hidden — an empty sidebar and no roster.
+ if (profile && options.keepAllProfilesScope !== false) {
+ setShowAllProfiles(true)
}
wakePhase = 'hydration'
diff --git a/apps/desktop/src/sdk/profile-routing.test.ts b/apps/desktop/src/sdk/profile-routing.test.ts
index 770cc7f8cc0..0a1e24c9d43 100644
--- a/apps/desktop/src/sdk/profile-routing.test.ts
+++ b/apps/desktop/src/sdk/profile-routing.test.ts
@@ -104,7 +104,7 @@ const { openSession: openSessionCore } = await import('@/app/open-session')
const { deleteProfile } = await import('@/hermes')
const { requestGatewayForAgent, requestGatewayForProfile, retireLocalProfileGateways } = await import('@/store/gateway')
-const { $activeGatewayProfile, $gatewaySwapTarget, $profiles, ensureGatewayProfile, refreshProfiles } =
+const { $activeGatewayProfile, $gatewaySwapTarget, $profiles, ensureGatewayProfile, refreshProfiles, setShowAllProfiles } =
await import('@/store/profile')
const { $focusedRuntimeId, $focusedSessionState, $focusedStoredSessionId } = await import('@/store/session-states')
@@ -559,6 +559,21 @@ describe('profile-aware plugin session opens', () => {
expect($gatewaySwapTarget.get()).toBeNull()
})
+ it('keeps the Sessions sidebar in all-profiles even when the bot is already live', async () => {
+ $activeGatewayProfile.set('hyoseob')
+ setMockAtom($selectedStoredSessionId, 'bot-chat')
+ setMockAtom($activeSessionId, 'runtime-live')
+ setMockAtom($messages, [{ id: 'history', parts: [], role: 'assistant' }] as never)
+
+ await host.openSession('bot-chat', {
+ profile: 'hyoseob',
+ awaitHydration: true,
+ expectHistory: true,
+ hydrationTimeoutMs: 1_000
+ })
+
+ expect(setShowAllProfiles).toHaveBeenCalledWith(true)
+ })
it('surfaces a wedged profile activation instead of waiting on it forever (#89556)', async () => {
// The dial the store is waiting on never settles - a backend that accepts