Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(studio): preserve session list failures and retry state (#6709)

Xinmin Zeng96ae3cef929f
diff --git a/web-studio/src/i18n/locales/en/activity.ts b/web-studio/src/i18n/locales/en/activity.ts
index cc327f75f..4be550faf 100644
--- a/web-studio/src/i18n/locales/en/activity.ts
+++ b/web-studio/src/i18n/locales/en/activity.ts
@@ -10,6 +10,8 @@ const activity = {
count: '{{count}} session',
count_other: '{{count}} sessions',
loading: 'Loading sessions...',
+ loadFailed: 'Could not load sessions',
+ retry: 'Retry',
emptyTitle: 'No sessions yet',
emptyDescription: 'Select the plus button to start a new conversation.',
deleteSession: 'Delete “{{title}}”',
diff --git a/web-studio/src/i18n/locales/zh-CN/activity.ts b/web-studio/src/i18n/locales/zh-CN/activity.ts
index 1b6d35bef..145ed515d 100644
--- a/web-studio/src/i18n/locales/zh-CN/activity.ts
+++ b/web-studio/src/i18n/locales/zh-CN/activity.ts
@@ -10,6 +10,8 @@ const activity = {
count: '{{count}} 个会话',
count_other: '{{count}} 个会话',
loading: '正在加载会话...',
+ loadFailed: '会话加载失败',
+ retry: '重试',
emptyTitle: '还没有会话',
emptyDescription: '点击右上角的加号开始一段新对话。',
deleteSession: '删除“{{title}}”',
diff --git a/web-studio/src/lib/sessions/use-sessions.ts b/web-studio/src/lib/sessions/use-sessions.ts
index c48abdf3a..7f9c801f5 100644
--- a/web-studio/src/lib/sessions/use-sessions.ts
+++ b/web-studio/src/lib/sessions/use-sessions.ts
@@ -13,7 +13,7 @@ import type { Message } from './types/message'
import { resolveSessionHistorySource } from './history-source'
import { useAppConnection } from '#/hooks/use-app-connection'
import type { SessionMemoryDiff } from './memory-diff'
-import type { SessionListItem, SessionMeta } from '@ov-server/api/v1/sessions'
+import type { SessionMeta } from '@ov-server/api/v1/sessions'
const SESSIONS_KEY = ['sessions'] as const
const BOT_HEALTH_KEY = ['bot', 'health'] as const
@@ -43,11 +43,9 @@ export function useSessionList() {
* without a timestamp at the bottom.
*/
export function useSessionListByRecency() {
- const { data: sessions, isLoading } = useSessionList()
+ const query = useSessionList()
- if (!sessions) return { data: [] as SessionListItem[], isLoading }
-
- const data = [...sessions].sort((a, b) => {
+ const data = [...(query.data ?? [])].sort((a, b) => {
const aTime = a.mod_time || ''
const bTime = b.mod_time || ''
// Missing timestamps sort to bottom.
@@ -58,7 +56,7 @@ export function useSessionListByRecency() {
return bTime.localeCompare(aTime)
})
- return { data, isLoading }
+ return { ...query, data }
}
export function useSession(sessionId: string | undefined) {
diff --git a/web-studio/src/routes/sessions/-components/thread-list.tsx b/web-studio/src/routes/sessions/-components/thread-list.tsx
index bbe666265..eecbec323 100644
--- a/web-studio/src/routes/sessions/-components/thread-list.tsx
+++ b/web-studio/src/routes/sessions/-components/thread-list.tsx
@@ -28,6 +28,7 @@ import {
useSessionListByRecency,
} from '#/lib/sessions/use-sessions'
import { useSessionTitles } from '#/lib/sessions/use-session-titles'
+import { normalizeOvClientError } from '#/lib/ov-client'
import { cn } from '#/lib/utils'
interface ThreadListProps {
@@ -40,7 +41,14 @@ export function ThreadList({ activeSessionId, className }: ThreadListProps) {
const { provider } = useStudioService()
const { identityScopeKey } = useAppConnection()
const navigate = useNavigate()
- const { data: sessions, isLoading } = useSessionListByRecency()
+ const {
+ data: sessions,
+ error: listError,
+ isError,
+ isFetching,
+ isPending,
+ refetch,
+ } = useSessionListByRecency()
const { getTitle, removeTitle, setTitle } = useSessionTitles(identityScopeKey)
const createSession = useCreateSession()
const deleteSession = useDeleteSession()
@@ -104,7 +112,7 @@ export function ThreadList({ activeSessionId, className }: ThreadListProps) {
? t('studio:sessionRecords')
: t('threadList.title')}
</h1>
- {!isLoading ? (
+ {!isPending && (!isError || sessions.length > 0) ? (
<p className="mt-0.5 text-xs text-muted-foreground">
{t('threadList.count', { count: sessions.length })}
</p>
@@ -130,25 +138,50 @@ export function ThreadList({ activeSessionId, className }: ThreadListProps) {
</div>
<div className="min-h-0 flex-1 overflow-y-auto p-2">
- {isLoading ? (
+ {isError ? (
+ <div
+ role="alert"
+ className="mb-2 grid gap-2 rounded-lg border border-destructive/30 p-3 text-sm"
+ >
+ <p className="font-medium text-destructive">
+ {t('threadList.loadFailed')}
+ </p>
+ <p className="wrap-anywhere text-xs text-muted-foreground">
+ {normalizeOvClientError(listError).message}
+ </p>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="justify-self-start"
+ disabled={isFetching}
+ onClick={() => void refetch()}
+ >
+ {t('threadList.retry')}
+ </Button>
+ </div>
+ ) : null}
+ {isPending ? (
<div className="flex h-28 items-center justify-center gap-2 text-sm text-muted-foreground">
<LoaderCircleIcon className="size-4 animate-spin" />
<span>{t('threadList.loading')}</span>
</div>
) : sessions.length === 0 ? (
- <div className="flex h-40 flex-col items-center justify-center px-6 text-center">
- <div className="flex size-9 items-center justify-center rounded-xl bg-muted">
- <MessageSquareIcon className="size-4 text-muted-foreground" />
+ isError ? null : (
+ <div className="flex h-40 flex-col items-center justify-center px-6 text-center">
+ <div className="flex size-9 items-center justify-center rounded-xl bg-muted">
+ <MessageSquareIcon className="size-4 text-muted-foreground" />
+ </div>
+ <p className="mt-3 text-sm font-medium text-foreground">
+ {t('threadList.emptyTitle')}
+ </p>
+ <p className="mt-1 text-xs leading-5 text-muted-foreground">
+ {provider === 'opensource'
+ ? t('threadList.emptyDescription')
+ : t('studio:noSessionRecords')}
+ </p>
</div>
- <p className="mt-3 text-sm font-medium text-foreground">
- {t('threadList.emptyTitle')}
- </p>
- <p className="mt-1 text-xs leading-5 text-muted-foreground">
- {provider === 'opensource'
- ? t('threadList.emptyDescription')
- : t('studio:noSessionRecords')}
- </p>
- </div>
+ )
) : (
<div className="space-y-1">
{sessions.map((session) => {