Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: persist sidebar task list cache to skip repeat skeleton (#17706)

YuTengjing61d8fd4687fd
diff --git a/src/features/AgentSidebar/Task/index.tsx b/src/features/AgentSidebar/Task/index.tsx
index 23456f4fc4a..652d9f5b38a 100644
--- a/src/features/AgentSidebar/Task/index.tsx
+++ b/src/features/AgentSidebar/Task/index.tsx
@@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next';
import SkeletonList from '@/features/NavPanel/components/SkeletonList';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useClientDataSWR } from '@/libs/swr';
-import { sidebarKeys } from '@/libs/swr/keys';
+import { taskKeys } from '@/libs/swr/keys';
import { taskService } from '@/services/task';
import { useAgentStore } from '@/store/agent';
import type { TaskGroupItem } from '@/store/task/slices/list/initialState';
@@ -33,7 +33,7 @@ const TaskList = memo<TaskListProps>(({ itemKey }) => {
const enabled = !!agentId;
const { data, isLoading } = useClientDataSWR<{ data: TaskGroupItem[]; success: boolean }>(
- enabled ? sidebarKeys.taskGroups(agentId) : null,
+ enabled ? taskKeys.sidebarGroups(agentId) : null,
async ([, id]: [string, string]) =>
taskService.groupList({ assigneeAgentId: id, groups: SIDEBAR_GROUPS }),
{
diff --git a/src/libs/swr/keys.test.ts b/src/libs/swr/keys.test.ts
index 01ea15b3156..8f795619341 100644
--- a/src/libs/swr/keys.test.ts
+++ b/src/libs/swr/keys.test.ts
@@ -1,6 +1,8 @@
+import { unstable_serialize } from 'swr';
import { describe, expect, it } from 'vitest';
-import { recentKeys } from './keys';
+import { recentKeys, taskKeys } from './keys';
+import { CACHE_TIERS } from './localStorageProvider';
describe('recentKeys', () => {
it('keys the Home recent list by identity cache scope', () => {
@@ -24,3 +26,17 @@ describe('recentKeys', () => {
);
});
});
+
+describe('taskKeys', () => {
+ // Regression for LOBE-12552: the sidebar task list used a `sidebar:` domain
+ // key that no CACHE_TIERS pattern matched, so it was memory-only and every
+ // fresh page load showed a skeleton. The key must route to a persisted tier
+ // (the provider matches patterns against the serialized SWR key).
+ it('routes the sidebar task-groups key to a persisted cache tier', () => {
+ const serialized = unstable_serialize(taskKeys.sidebarGroups('agent-1'));
+ const persisted = [...CACHE_TIERS.idb, ...CACHE_TIERS.local].some((pattern) =>
+ serialized.includes(pattern),
+ );
+ expect(persisted).toBe(true);
+ });
+});
diff --git a/src/libs/swr/keys.ts b/src/libs/swr/keys.ts
index 3467bd2365b..490a6a0db86 100644
--- a/src/libs/swr/keys.ts
+++ b/src/libs/swr/keys.ts
@@ -253,6 +253,12 @@ export const taskKeys = {
visibility,
],
),
+ /**
+ * AgentSidebar task panel. Lives in the `task:` domain (not a `sidebar:`
+ * one) so the tiered cache provider persists it to IndexedDB and the second
+ * open renders from cache instead of a skeleton.
+ */
+ sidebarGroups: def('task:sidebarGroups', (agentId: string) => ['task:sidebarGroups', agentId]),
};
// ---- work ---------------------------------------------------------------
@@ -1060,9 +1066,6 @@ export const builtinAgentKeys = {
export const imessageKeys = {
bridgeStatus: def('imessage:bridgeStatus', () => ['imessage:bridgeStatus']),
};
-export const sidebarKeys = {
- taskGroups: def('sidebar:taskGroups', (agentId: string) => ['sidebar:taskGroups', agentId]),
-};
// Desktop/electron IPC fetches — roots keep their existing `electron:getXxx` value.
export const electronKeys = {
appTrayVisible: def('electron:getAppTrayVisible', () => ['electron:getAppTrayVisible']),
@@ -1135,7 +1138,6 @@ export const swrKeys = {
serverConfig: serverConfigKeys,
session: sessionKeys,
share: shareKeys,
- sidebar: sidebarKeys,
stats: statsKeys,
task: taskKeys,
taskTemplate: taskTemplateKeys,