Skip to content

The agent that grows with you

fix(desktop): show retry in place of "No sessions yet" when the first read fails

brooklyn!620d38838dce
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 8abd38f7ae4..978c36f51a8 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
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react'
import { MemoryRouter } from 'react-router'
-import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { group, split } from '@/components/pane-shell/tree/model'
import { $layoutTree, noteActiveTreeGroup } from '@/components/pane-shell/tree/store'
@@ -17,6 +17,8 @@ import {
$messagingTruncated,
$selectedStoredSessionId,
$sessions,
+ $sessionsLoadError,
+ $sessionsLoading,
$workspaceCwdOwner
} from '@/store/session'
import { $removedSessionIds } from '@/store/session-removal'
@@ -38,7 +40,7 @@ const sessionRows = [
makeSessionInfo({ id: 'tile-two', last_active: 2, profile: 'default', started_at: 1, title: 'Tile two' })
]
-const renderSidebar = (pathname: string, currentView: AppView) =>
+const renderSidebar = (pathname: string, currentView: AppView, onRetrySessions: () => Promise<void> = noopAsync) =>
render(
<MemoryRouter initialEntries={[pathname]}>
<SidebarProvider>
@@ -53,6 +55,7 @@ const renderSidebar = (pathname: string, currentView: AppView) =>
onNewSessionInWorkspace={noop}
onNewSessionSplit={noop}
onResumeSession={noop}
+ onRetrySessions={onRetrySessions}
onTriggerCronJob={noopAsync}
/>
</SidebarProvider>
@@ -196,6 +199,31 @@ describe('ChatSidebar navigation activity', () => {
})
})
+// #67600: a cold-start read that failed used to render as an empty account.
+describe('ChatSidebar cold-start load failure', () => {
+ afterEach(() => {
+ cleanup()
+ $sessions.set([])
+ $sessionsLoading.set(true)
+ $sessionsLoadError.set(false)
+ })
+
+ it('offers retry in place of the empty state', () => {
+ const retry = vi.fn(noopAsync)
+ $sessions.set([])
+ $sessionsLoading.set(false)
+ $sessionsLoadError.set(true)
+
+ renderSidebar('/', 'chat', retry)
+
+ expect(screen.getByText('Could not load sessions')).toBeTruthy()
+ expect(screen.queryByText('No sessions yet')).toBeNull()
+
+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }))
+ expect(retry).toHaveBeenCalledTimes(1)
+ })
+})
+
// Entering a project is a scope switch: the conversation main is showing keeps
// its workspace, so Files/Review and the composer's Git context can't drift to
// the project while the transcript stays on the old chat (#72772).
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
index a652c699913..73276d0319e 100644
--- a/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups-drag.test.tsx
@@ -22,6 +22,8 @@ import { ChatSidebar } from './index'
const noop = () => {}
+const noopAsync = async () => {}
+
const mount = () =>
render(
<MemoryRouter>
@@ -37,6 +39,7 @@ const mount = () =>
onNewSessionInWorkspace={noop}
onNewSessionSplit={noop}
onResumeSession={vi.fn()}
+ onRetrySessions={noopAsync}
onTriggerCronJob={async () => {}}
/>
</SidebarProvider>
diff --git a/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx b/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx
index 4176503eabc..5cc0a65f35f 100644
--- a/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx
+++ b/apps/desktop/src/app/chat/sidebar/gateway-groups.test.tsx
@@ -13,6 +13,8 @@ import { makeSessionInfo } from '@/test/session-info'
import { ChatSidebar } from './index'
const noop = () => {}
+
+const noopAsync = async () => {}
const resume = vi.fn()
const mount = () =>
@@ -30,6 +32,7 @@ const mount = () =>
onNewSessionInWorkspace={noop}
onNewSessionSplit={noop}
onResumeSession={resume}
+ onRetrySessions={noopAsync}
onTriggerCronJob={async () => {}}
/>
</SidebarProvider>
diff --git a/apps/desktop/src/app/chat/sidebar/index.tsx b/apps/desktop/src/app/chat/sidebar/index.tsx
index d48fe2bb3e1..1a696bf6b25 100644
--- a/apps/desktop/src/app/chat/sidebar/index.tsx
+++ b/apps/desktop/src/app/chat/sidebar/index.tsx
@@ -122,6 +122,7 @@ import {
$messagingTruncated,
$sessionProfilesTruncated,
$sessions,
+ $sessionsLoadError,
$sessionsLoading,
$unreadFinishedSessionIds,
markAllSessionsRead,
@@ -367,6 +368,7 @@ interface ChatSidebarProps extends React.ComponentProps<typeof Sidebar> {
currentView: AppView
onNavigate: (item: SidebarNavItem) => void
onLoadMoreSessions: () => Promise<void> | void
+ onRetrySessions: () => Promise<void> | void
onLoadMoreMessaging?: (platform: string) => Promise<void> | void
onResumeSession: (sessionId: string, session?: SessionInfo) => void
onDeleteSession: (sessionId: string) => void
@@ -388,6 +390,7 @@ export function ChatSidebar({
currentView: routeView,
onNavigate,
onLoadMoreSessions,
+ onRetrySessions,
onLoadMoreMessaging,
onResumeSession,
onDeleteSession,
@@ -480,6 +483,7 @@ export function ChatSidebar({
const messagingPlatformTotals = useStore($messagingPlatformTotals)
const messagingTruncated = useStore($messagingTruncated)
const sessionsLoading = useStore($sessionsLoading)
+ const sessionsLoadError = useStore($sessionsLoadError)
const sessionProfilesTruncated = useStore($sessionProfilesTruncated)
const unreadCount = useStore($unreadFinishedSessionIds).length
const profiles = useStore($profiles)
@@ -1513,7 +1517,7 @@ export function ChatSidebar({
// 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.
const showSessionSections =
- showSessionSkeletons || filtersActive || sortedSessions.length > 0 || projectModel.length > 0
+ showSessionSkeletons || sessionsLoadError || filtersActive || sortedSessions.length > 0 || projectModel.length > 0
// The sidebar's session-area mode — exposed as data-attributes so custom
// skins can target project mode (overview vs. entered), archived, or search
@@ -1803,6 +1807,8 @@ export function ChatSidebar({
emptyState={
inProject && projectLoadFailed ? null : showSessionSkeletons || (inProject && projectLoading) ? (
<SidebarSessionSkeletons />
+ ) : !inProject && sessionsLoadError ? (
+ <SidebarLoadErrorState onRetry={() => void onRetrySessions()} />
) : (
<div className="grid min-h-16 place-items-center rounded-lg px-2 text-center text-xs text-(--ui-text-tertiary)">
{inProject
diff --git a/apps/desktop/src/app/contrib/latest-actions.test.ts b/apps/desktop/src/app/contrib/latest-actions.test.ts
index d3f020c2689..f14fa9256fb 100644
--- a/apps/desktop/src/app/contrib/latest-actions.test.ts
+++ b/apps/desktop/src/app/contrib/latest-actions.test.ts
@@ -41,6 +41,7 @@ function makeSidebarActions(): SidebarActions {
onDeleteSession: vi.fn(),
onLoadMoreMessaging: vi.fn(),
onLoadMoreSessions: vi.fn(),
+ onRetrySessions: vi.fn(),
onManageCronJob: vi.fn(),
onNavigate: vi.fn(),
onNewSessionInWorkspace: vi.fn(),
diff --git a/apps/desktop/src/app/contrib/latest-actions.ts b/apps/desktop/src/app/contrib/latest-actions.ts
index 4648ea28afb..32e1e25dd84 100644
--- a/apps/desktop/src/app/contrib/latest-actions.ts
+++ b/apps/desktop/src/app/contrib/latest-actions.ts
@@ -64,6 +64,7 @@ export function latestSidebarActions(actions: SidebarActions): SidebarActions {
onDeleteSession: (...args) => actions.onDeleteSession(...args),
onLoadMoreMessaging: latestOptional(() => actions.onLoadMoreMessaging),
onLoadMoreSessions: (...args) => actions.onLoadMoreSessions(...args),
+ onRetrySessions: (...args) => actions.onRetrySessions(...args),
onManageCronJob: (...args) => actions.onManageCronJob(...args),
onNavigate: (...args) => actions.onNavigate(...args),
onNewSessionInWorkspace: (...args) => actions.onNewSessionInWorkspace(...args),
diff --git a/apps/desktop/src/app/contrib/types.ts b/apps/desktop/src/app/contrib/types.ts
index 46fab0c7c1b..21625c852a8 100644
--- a/apps/desktop/src/app/contrib/types.ts
+++ b/apps/desktop/src/app/contrib/types.ts
@@ -16,6 +16,7 @@ export type SidebarActions = Pick<
| 'onDeleteSession'
| 'onLoadMoreMessaging'
| 'onLoadMoreSessions'
+ | 'onRetrySessions'
| 'onManageCronJob'
| 'onNavigate'
| 'onNewSessionInWorkspace'
diff --git a/apps/desktop/src/app/contrib/wiring.tsx b/apps/desktop/src/app/contrib/wiring.tsx
index fc80385a6d0..94c6c744b1c 100644
--- a/apps/desktop/src/app/contrib/wiring.tsx
+++ b/apps/desktop/src/app/contrib/wiring.tsx
@@ -1110,6 +1110,7 @@ export function ContribWiring({ children }: { children: ReactNode }) {
onEdit: editMessage,
onLoadMoreMessaging: loadMoreMessagingForPlatform,
onLoadMoreSessions: loadMoreSessions,
+ onRetrySessions: () => refreshSessions().catch(() => undefined),
onManageCronJob: jobId => {
setCronFocusJobId(jobId)
navigate(CRON_ROUTE)
diff --git a/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx b/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx
index 4138d2949d1..6aa374a6b00 100644
--- a/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-session-list-actions.test.tsx
@@ -26,8 +26,8 @@ import {
setMessagingTruncated,
setSessionProfilesTruncated,
setSessionProfilesUsage,
- setSessionsLoadError,
setSessions,
+ setSessionsLoadError,
setSessionsLoading
} from '@/store/session'
diff --git a/apps/desktop/src/app/session/hooks/use-session-list-actions.ts b/apps/desktop/src/app/session/hooks/use-session-list-actions.ts
index f1a73a84009..0ba7cc82da7 100644
--- a/apps/desktop/src/app/session/hooks/use-session-list-actions.ts
+++ b/apps/desktop/src/app/session/hooks/use-session-list-actions.ts
@@ -35,8 +35,8 @@ import {
setMessagingTruncated,
setSessionProfilesTruncated,
setSessionProfilesUsage,
- setSessionsLoadError,
setSessions,
+ setSessionsLoadError,
setSessionsLoading
} from '@/store/session'
import { $removedSessionIds } from '@/store/session-removal'
diff --git a/apps/desktop/src/store/gateway-switch.ts b/apps/desktop/src/store/gateway-switch.ts
index 5c8bef55253..db332a29fdc 100644
--- a/apps/desktop/src/store/gateway-switch.ts
+++ b/apps/desktop/src/store/gateway-switch.ts
@@ -22,8 +22,8 @@ import {
setSelectedStoredSessionId,
setSessionProfilesTruncated,
setSessionProfilesUsage,
- setSessionsLoadError,
setSessions,
+ setSessionsLoadError,
setSessionsLoading
} from '@/store/session'
import { clearAllSessionControl } from '@/store/session-control'