The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): keep a later page's scan errors in a deep primary prefix
Teknium85b5c4147f12
diff --git a/apps/desktop/electron/profile-session-routing.test.ts b/apps/desktop/electron/profile-session-routing.test.tsindex b2fe55241e5..874b569903f 100644--- a/apps/desktop/electron/profile-session-routing.test.ts+++ b/apps/desktop/electron/profile-session-routing.test.ts@@ -418,6 +418,32 @@ test('merged profile windows retain pinned rows outside the recency window', ()assert.deepEqual(mergeProfileSessionWindow(rows, 0, 3), [rows[0], rows[1], rows[2], rows[3], rows[4]])})+test('a deep primary prefix keeps a later page scan error instead of reporting a complete read', async () => {+ const rows = Array.from({ length: 650 }, (_, index) => ({ id: `s${index}`, profile: 'default', started_at: 650 - index }))++ const base = await fetchPrimaryProfileSessions(+ new URLSearchParams({ limit: '200', offset: '400', profile: 'all' }),+ async (_profile, path) => {+ const params = new URL(path, 'http://x').searchParams+ const offset = Number(params.get('offset'))+ const limit = Number(params.get('limit'))++ return {+ sessions: rows.slice(offset, offset + limit),+ total: 650,+ profile_totals: { default: 650, work: 10 },+ errors: offset === 0 ? [] : [{ profile: 'work', error: 'database is locked' }],+ storage: offset === 0 ? {} : { work: { corrupt: true } }+ }+ },+ { prefixForMerge: true }+ )++ assert.deepEqual(base.errors, [{ profile: 'work', error: 'database is locked' }])+ assert.deepEqual((base as any).storage, { work: { corrupt: true } })+ assert.equal(base.sessions.length, 600)+})+test('registry paging uses the backend total instead of its fetched prefix or pinned backfill', async () => {const rows = Array.from({ length: 650 }, (_, index) => ({id: `s${index}`,diff --git a/apps/desktop/electron/profile-session-routing.ts b/apps/desktop/electron/profile-session-routing.tsindex bc14dcb3a6b..93a556fca23 100644--- a/apps/desktop/electron/profile-session-routing.ts+++ b/apps/desktop/electron/profile-session-routing.ts@@ -1126,11 +1126,15 @@ async function readEachProfile(/** One scope's rows from offset 0 through `want`, in backend-sized pages.* Pinned backfill repeats across pages; keep one row per profile/session before- * the merged list is sorted and windowed. The first page carries totals. */+ * the merged list is sorted and windowed. The first page carries totals; scan+ * `errors` and `storage` accumulate across pages, so a profile that fails on a+ * later page is not reported as a complete read. */async function readProfileSessionRows(url: URL, profile: string, want: number, fetchPage: FetchProfilePage) {let first: anyconst rows: unknown[] = []const seen = new Set<string>()+ const errors: SessionScanError[] = []+ const storage: Record<string, unknown> = {}for (let offset = 0; ; ) {const params = new URLSearchParams(url.searchParams)@@ -1143,6 +1147,16 @@ async function readProfileSessionRows(url: URL, profile: string, want: number, fconst pageRows = rowsOf(page)first ??= page+ for (const error of errorsOf(page) ?? []) {+ if (!errors.some(seenError => seenError.profile === error.profile && seenError.error === error.error)) {+ errors.push(error)+ }+ }++ if (page?.storage && typeof page.storage === 'object') {+ Object.assign(storage, page.storage)+ }+for (const row of pageRows) {const id = profileSessionId(row)@@ -1160,7 +1174,7 @@ async function readProfileSessionRows(url: URL, profile: string, want: number, foffset += limitif (offset >= want || pageRows.length < limit) {- return { ...first, sessions: rows }+ return { ...first, sessions: rows, errors, ...(first?.storage || Object.keys(storage).length ? { storage } : {}) }}}}