Skip to content

The agent that grows with you

fix(desktop): profiles with no chats keep their sections when nothing else is listed

Tekniumeaf03cb4dca1
diff --git a/apps/desktop/src/app/chat/sidebar/chat-sidebar.integration.test.tsx b/apps/desktop/src/app/chat/sidebar/chat-sidebar.integration.test.tsx
index 0a94d88820a..a9d4df3afc1 100644
--- a/apps/desktop/src/app/chat/sidebar/chat-sidebar.integration.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/chat-sidebar.integration.test.tsx
@@ -398,6 +398,32 @@ describe('ChatSidebar empty-profile sections', () => {
expect(container.textContent).toContain('No sessions yet')
expect(screen.queryByPlaceholderText('Search sessions…')).toBeNull()
})
+
+ it('shows a section per profile when several profiles have no chats anywhere', () => {
+ $messagingSessions.set([])
+ $sidebarMessagingOpenIds.set([])
+ $profiles.set([
+ { name: 'default', is_default: true },
+ { name: 'work', is_default: false }
+ ] as typeof $profiles.value)
+ setShowAllProfiles(true)
+ setSidebarGrouping('profile')
+
+ try {
+ const { container } = renderSidebar('/', 'chat')
+
+ const groups = [...container.querySelectorAll<HTMLElement>('[data-gateway-group]')].map(
+ node => node.dataset.gatewayGroup
+ )
+
+ expect(screen.getByPlaceholderText('Search sessions…')).toBeTruthy()
+ expect(groups.some(id => id?.includes('"default"'))).toBe(true)
+ expect(groups.some(id => id?.includes('"work"'))).toBe(true)
+ } finally {
+ setSidebarGrouping('date')
+ setShowAllProfiles(false)
+ }
+ })
})
describe('ChatSidebar messaging owners', () => {
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index 238d8b752ca..270356ebbe4 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -181,6 +181,7 @@ import {
} from './projects'
import { WorktreeDialog } from './projects/worktree-dialog'
import {
+ hasSessionArea,
SidebarBlankState,
SidebarLoadErrorState,
SidebarPinnedEmptyState,
@@ -1509,19 +1510,14 @@ export function ChatSidebar({
// every background refresh instead of the empty state.
const showSessionSkeletons = sessionsLoading && scopedSessions.length === 0
- // Filtered down to nothing still renders the section: the empty state is what
- // tells you the filter — not an empty account — is why the list is bare.
- // Messaging threads and cron jobs live inside this area too: a profile whose
- // only sessions are messaging threads (or that only has scheduled jobs) must
- // not collapse the whole sidebar to the blank state (#63593).
- const showSessionSections =
- showSessionSkeletons ||
- sessionsLoadError ||
- filtersActive ||
- sortedSessions.length > 0 ||
- projectModel.length > 0 ||
- messagingGroups.length > 0 ||
- (showsAdvancedChrome && cronJobs.length > 0)
+ const showSessionSections = hasSessionArea({
+ cronJobs: showsAdvancedChrome ? cronJobs.length : 0,
+ loading: showSessionSkeletons || Boolean(sessionsLoadError) || filtersActive,
+ messaging: messagingGroups.length,
+ profileGroups: profileGroups?.length ?? 0,
+ projects: projectModel.length,
+ sessions: sortedSessions.length
+ })
// The sidebar's session-area mode — exposed as data-attributes so custom
// skins can target project mode (overview vs. entered), archived, or search
diff --git a/apps/desktop/src/app/chat/sidebar/section-states.tsx b/apps/desktop/src/app/chat/sidebar/section-states.tsx
index 362a541b07b..3d1058034be 100644
--- a/apps/desktop/src/app/chat/sidebar/section-states.tsx
+++ b/apps/desktop/src/app/chat/sidebar/section-states.tsx
@@ -29,6 +29,26 @@ export function SidebarSessionSkeletons() {
)
}
+interface SessionAreaCounts {
+ cronJobs: number
+ loading: boolean
+ messaging: number
+ profileGroups: number
+ projects: number
+ sessions: number
+}
+
+/** Whether the sidebar renders its session area instead of the blank state. Filtered down to
+ * nothing still renders it: the empty state is what tells you the filter, not an empty account,
+ * is why the list is bare. Messaging threads and cron jobs live inside this area too, so a profile
+ * whose only sessions are threads or scheduled jobs never collapses to the blank state (#63593).
+ * Every profile keeps a section, chats or not; a lone empty profile keeps the blank state. */
+export function hasSessionArea(counts: SessionAreaCounts): boolean {
+ const { cronJobs, loading, messaging, profileGroups, projects, sessions } = counts
+
+ return loading || sessions > 0 || projects > 0 || messaging > 0 || cronJobs > 0 || profileGroups > 1
+}
+
export function SidebarBlankState({ onNewProject }: { onNewProject: () => void }) {
const { t } = useI18n()
const s = t.sidebar