Skip to content

Commit d8ab8c9

Browse files
jom-sqampcode-com
andcommitted
fix(threads): always scan local files, not just when API returns 500
The conditional scan missed older threads when API returned <500 (e.g., after archiving/deleting). Local file scan is fast and ensures threads beyond the API's 500 limit are always visible. Co-authored-by: Amp <amp@ampcode.com>
1 parent 2e80a18 commit d8ab8c9

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

server/lib/threadProvider.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
type ThreadFile,
1717
type ThreadMessage,
1818
} from './threadTypes.js';
19-
import { listThreads, AMP_API_MAX, type AmpThreadSummary } from './amp-api.js';
19+
import { listThreads, type AmpThreadSummary } from './amp-api.js';
2020
import { formatRelativeTime, parseFileUri, runAmp } from './utils.js';
2121

2222
// ── Visibility normalization ────────────────────────────────────────────
@@ -62,12 +62,11 @@ export async function listAllThreads(): Promise<Thread[]> {
6262
const threads = summaries.map(toThread);
6363
const apiIds = new Set(threads.map((t) => t.id));
6464

65-
// Supplement with local thread files not in the API response
66-
if (apiIds.size >= AMP_API_MAX) {
67-
// API returned its max — there are likely more threads on disk
68-
const localExtras = await getLocalOnlyThreads(apiIds);
69-
threads.push(...localExtras);
70-
}
65+
// Always supplement with local thread files not in the API response.
66+
// The API returns at most 500 most-recent threads, so older threads
67+
// only appear via their local files on disk.
68+
const localExtras = await getLocalOnlyThreads(apiIds);
69+
threads.push(...localExtras);
7170

7271
// Enrich handoff relationships from local files + batch heuristic
7372
await enrichRelationships(threads);

0 commit comments

Comments
 (0)