Skip to content

The agent that grows with you

fix(desktop): keep hidden Bot Mode chats out of the Sessions sidebar (#113273)

Jervaisee46b5650fd61
diff --git a/apps/desktop/src/app/chat/session-tile-actions.test.ts b/apps/desktop/src/app/chat/session-tile-actions.test.ts
index 4f8f862b9b5..306977d0a99 100644
--- a/apps/desktop/src/app/chat/session-tile-actions.test.ts
+++ b/apps/desktop/src/app/chat/session-tile-actions.test.ts
@@ -37,6 +37,20 @@ describe('session tile optimistic owner metadata', () => {
$sessionTiles.set([])
})
+ it('never lists a bots-workspace tile — hidden relationship chats stay off the Sessions list (#113273)', () => {
+ expect(
+ listTileSessionRow({
+ preview: 'hello from the bot chat',
+ runtimeId: 'rt-bot-chat',
+ sessions: [],
+ storedSessionId: 'stored-bot-chat',
+ workspaceMode: 'bots'
+ })
+ ).toBe(false)
+
+ expect($sessions.get()).toEqual([])
+ })
+
it('keeps the tile source on its first optimistic sidebar row', () => {
const storedSessionId = 'stored-tile-owner-metadata'
const ownerRoute = { connectionId: 'source-a', profile: 'default' }
diff --git a/apps/desktop/src/app/chat/session-tile-actions.ts b/apps/desktop/src/app/chat/session-tile-actions.ts
index c2dc8c7a2d9..070b27eae22 100644
--- a/apps/desktop/src/app/chat/session-tile-actions.ts
+++ b/apps/desktop/src/app/chat/session-tile-actions.ts
@@ -30,6 +30,7 @@ import {
} from '@/store/session-request-router'
import {
$sessionStates,
+ $sessionTiles,
isSessionRemote,
patchSessionTile,
sessionTileDelegate,
@@ -41,6 +42,8 @@ import { clearSessionTodos } from '@/store/todos'
import { setSessionDraftingTool } from '@/store/tool-drafting'
import type { SessionInfo } from '@/types/hermes'
+import type { WorkspaceMode } from '@/contrib/types'
+
import type { GatewayRequester } from '../contrib/types'
import { uploadComposerAttachment } from '../session/hooks/use-prompt-actions'
import {
@@ -89,7 +92,16 @@ export function listTileSessionRow(deps: {
runtimeId: string
sessions: readonly SessionInfo[]
storedSessionId: string
+ workspaceMode?: WorkspaceMode
}): boolean {
+ // Bot Mode tabs mirror hidden relationship chats (canonical Bot Chats stay
+ // off the Sessions list by design — the bot row is the only door), so a
+ // first send must not seed a flagless row the refresh keep-list would then
+ // hold forever (#113273).
+ if (deps.workspaceMode === 'bots') {
+ return false
+ }
+
const preview = deps.preview.trim()
if (!preview || deps.sessions.some(session => sessionMatchesStoredId(session, deps.storedSessionId))) {
@@ -203,7 +215,8 @@ export function useSessionTileActions({ requestGateway, runtimeId, scope, stored
preview,
runtimeId,
sessions: $sessions.get(),
- storedSessionId: storedIdRef.current
+ storedSessionId: storedIdRef.current,
+ workspaceMode: $sessionTiles.get().find(tile => tile.storedSessionId === storedIdRef.current)?.workspaceMode
})
}, [])
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/resolve-stored-session.test.ts b/apps/desktop/src/app/session/hooks/use-session-actions/resolve-stored-session.test.ts
index cea4b01c32f..95f6c7927ec 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions/resolve-stored-session.test.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/resolve-stored-session.test.ts
@@ -4,7 +4,7 @@ import type * as HermesModule from '@/hermes'
import { getSession } from '@/hermes'
import { $activeGatewayProfile, $profiles } from '@/store/profile'
import { $projectTree } from '@/store/projects'
-import { $cronSessions, $messagingSessions, $sessions } from '@/store/session'
+import { $cronSessions, $messagingSessions, $sessions, $unlistedSessionOwnerRows } from '@/store/session'
import type { SessionInfo } from '@/types/hermes'
import { cachedSessionRow, resolveSessionProfile, resolveStoredSession } from './utils'
@@ -28,6 +28,7 @@ describe('resolveStoredSession profile ownership', () => {
$projectTree.set([])
$profiles.set(profiles('default', 'meta'))
$activeGatewayProfile.set('meta')
+ $unlistedSessionOwnerRows.set([])
mockGetSession.mockReset()
})
@@ -38,6 +39,7 @@ describe('resolveStoredSession profile ownership', () => {
$projectTree.set([])
$profiles.set([])
$activeGatewayProfile.set('default')
+ $unlistedSessionOwnerRows.set([])
})
it('returns a cached row that carries an owning profile', async () => {
@@ -128,6 +130,20 @@ describe('resolveStoredSession profile ownership', () => {
expect($sessions.get().find(s => s.id === 's1')?.profile).toBe('meta')
})
+ it('parks a hidden by-id hit off-list — canonical Bot Chats never get a sidebar row (#113273)', async () => {
+ // Opening a bot's chat resolves it by id; the backend row carries
+ // hidden=true. Listed, it would paint a Sessions row the refresh
+ // keep-list then holds open indefinitely.
+ mockGetSession.mockResolvedValueOnce(session({ hidden: true, id: 's1' }))
+
+ const resolved = await resolveStoredSession('s1')
+
+ expect(resolved?.hidden).toBe(true)
+ expect($sessions.get()).toEqual([])
+ // owner resolution still finds the row on the off-list stub atom
+ expect($unlistedSessionOwnerRows.get().find(s => s.id === 's1')?.hidden).toBe(true)
+ })
+
it('probed desktop profile overrides a remote backend answering as its own "default"', async () => {
// Per-profile remote override: Electron strips the desktop alias before
// forwarding, so the standalone backend stamps its backend-local root.
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
index 0a1917b4753..91c0b9f1d8d 100644
--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts
@@ -1478,6 +1478,20 @@ export function restoreListedSession(session: SessionInfo, slice?: ListedSession
function upsertResolvedSession(session: SessionInfo, storedSessionId: string) {
const lineage = session._lineage_root_id ?? session.id
+ // A hidden row (canonical Bot Chat, room plumbing) is unlisted by design:
+ // inserting it into $sessions paints a sidebar row until the next refresh,
+ // and the keep-list then holds it there (#113273). Park it on the off-list
+ // owner atom the draft stubs ride — owner resolution still finds it via
+ // ownerLookupSessionRows, the sidebar never does.
+ if (session.hidden) {
+ setUnlistedSessionOwnerRows(prev => [
+ session,
+ ...prev.filter(existing => (existing._lineage_root_id ?? existing.id) !== lineage)
+ ])
+
+ return
+ }
+
const prepend = (prev: SessionInfo[]) => [
session,
...prev.filter(existing => {
diff --git a/apps/desktop/src/store/session.test.ts b/apps/desktop/src/store/session.test.ts
index ee875f084bc..81b9134d8c1 100644
--- a/apps/desktop/src/store/session.test.ts
+++ b/apps/desktop/src/store/session.test.ts
@@ -535,6 +535,19 @@ describe('mergeSessionPage', () => {
expect(mergeSessionPage(previous, incoming, ['b']).map(s => s.id)).toEqual(['b'])
})
+ it('never resurrects a HIDDEN session even when the keep set names it (#113273)', () => {
+ // Bot Mode canonical chats are born hidden and are live almost constantly
+ // (routines, bot-to-bot turns), so $workingSessionIds nearly always holds
+ // them — and an open Bot Chat tab pins the id via the tile keep too. The
+ // server page never lists hidden rows; the merge must not let the
+ // keep-list re-insert what the backend excludes by design, or "Bot Chat"
+ // rows become permanent residents of the Sessions sidebar.
+ const previous = [session({ hidden: true, id: 'bot-chat', title: 'Bot Chat' }), session({ id: 'mine' })]
+ const incoming = [session({ id: 'mine', message_count: 3 })]
+
+ expect(mergeSessionPage(previous, incoming, ['bot-chat']).map(s => s.id)).toEqual(['mine'])
+ })
+
it('keeps a pinned session that has aged off the recent page', () => {
// Repro of "loses pins until you refresh": a pinned chat falls off the
// most-recent page, so the server stops returning it. A hard replace would
diff --git a/apps/desktop/src/store/session.ts b/apps/desktop/src/store/session.ts
index af544e8e832..ec74421ac0e 100644
--- a/apps/desktop/src/store/session.ts
+++ b/apps/desktop/src/store/session.ts
@@ -655,6 +655,10 @@ export function mergeSessionPage(
const survivors = previous.filter(
session =>
+ // The keep-list answers "live, not listed yet" — a hidden row (canonical
+ // Bot Chat, room plumbing) is LISTED-NEVER by design, so a live turn or
+ // open tab must not resurrect it into the sidebar (#113273).
+ !session.hidden &&
!incomingIds.has(identity(session)) &&
!incomingLineageKeys.has(lineageIdentity(session)) &&
(keep.has(session.id) || (session._lineage_root_id != null && keep.has(session._lineage_root_id)))
diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.ts
index 2330d0405cd..5630eafc8ce 100644
--- a/apps/desktop/src/types/hermes.ts
+++ b/apps/desktop/src/types/hermes.ts
@@ -548,6 +548,13 @@ export interface SessionInfo {
* elsewhere. Undefined against a backend predating the flag; treat that as
* "no opinion" and leave the local pin set alone. */
pinned?: boolean
+ /** Server-side hide flag (`sessions.hidden`). Hidden rows (canonical Bot
+ * Chats, group-chat plumbing) never reach a sidebar page, so a row
+ * carrying `hidden: true` only exists in the local list through an
+ * optimistic insert or a keep-list carry — the merge must not let it
+ * survive a refresh (#113273). Undefined against older backends; treat
+ * as visible. */
+ hidden?: boolean
/** Derived read state (backend watermark: `last_read_at` vs `last_active`,
* see `SessionDB.session_unread`). True when the conversation was
* explicitly marked unread or a response arrived after it was last read.