Skip to content

The agent that grows with you

fix(desktop): wire archive pagination through sessions API

Shawn Wangb7a5f04327a3
diff --git a/apps/desktop/src/api/sessions.ts b/apps/desktop/src/api/sessions.ts
index 4fd866c6d1a..8b759e957b3 100644
--- a/apps/desktop/src/api/sessions.ts
+++ b/apps/desktop/src/api/sessions.ts
@@ -139,7 +139,8 @@ export async function listAllProfileSessions(
archived: 'exclude' | 'include' | 'only' = 'exclude',
order: 'created' | 'recent' = 'recent',
profile: 'all' | (string & {}) = 'all',
- filter: SessionSourceFilter = {}
+ filter: SessionSourceFilter = {},
+ offset = 0
): Promise<PaginatedSessions> {
const sourceParam = filter.source ? `&source=${encodeURIComponent(filter.source)}` : ''
@@ -150,7 +151,7 @@ export async function listAllProfileSessions(
const result = await hermesApi<PaginatedSessions>({
...profileScoped(),
path:
- `/api/profiles/sessions?limit=${limit}&offset=0&min_messages=${Math.max(0, minMessages)}` +
+ `/api/profiles/sessions?limit=${limit}&offset=${Math.max(0, offset)}&min_messages=${Math.max(0, minMessages)}` +
`&archived=${archived}&order=${order}&profile=${encodeURIComponent(profile)}${sourceParam}${excludeParam}`,
timeoutMs: SESSION_LIST_REQUEST_TIMEOUT_MS
})
@@ -158,7 +159,7 @@ export async function listAllProfileSessions(
return {
...result,
sessions: pageWindow(stampActiveConnectionOwner(result.sessions), limit),
- offset: 0
+ offset: Math.max(0, offset)
}
}
diff --git a/apps/desktop/src/store/sidebar-archive.test.ts b/apps/desktop/src/store/sidebar-archive.test.ts
index 5f139262e7b..97dbc42439b 100644
--- a/apps/desktop/src/store/sidebar-archive.test.ts
+++ b/apps/desktop/src/store/sidebar-archive.test.ts
@@ -7,6 +7,7 @@ import { $archivedSessions, listEveryArchivedSession, loadArchivedSessions } fro
vi.mock('@/hermes', () => ({
listAllProfileSessions: vi.fn()
}))
+}))
const row = (id: string): SessionInfo =>
({
diff --git a/apps/desktop/src/store/sidebar-archive.ts b/apps/desktop/src/store/sidebar-archive.ts
index de84a441833..9d6e24ddbec 100644
--- a/apps/desktop/src/store/sidebar-archive.ts
+++ b/apps/desktop/src/store/sidebar-archive.ts
@@ -1,6 +1,7 @@
import { atom, computed } from 'nanostores'
-import { listAllProfileSessions, type SessionInfo } from '@/hermes'
+import { listAllProfileSessions } from '@/api/sessions'
+import type { SessionInfo } from '@/types/hermes'
import { $sessions } from './session'