diff --git a/src/commands/import.ts b/src/commands/import.ts index 3f6b4c4ca..c20e14828 100644 --- a/src/commands/import.ts +++ b/src/commands/import.ts @@ -86,6 +86,11 @@ export async function runImport( : strategy === 'auto' ? 'syncable' : 'markdown'; console.log(`Found ${allFiles.length} ${fileTypeLabel} files`); + // v0.33.1: sort newest-first so recent pages get processed before older ones. + // Brain paths are typically date-prefixed (meetings/2026-05-13-*, daily/2026-05-13.md) + // so a descending lexicographic sort naturally prioritizes recent content. + allFiles.sort((a, b) => b.localeCompare(a)); + // Resume from checkpoint if available const checkpointPath = gbrainPath('import-checkpoint.json'); let files = allFiles; diff --git a/src/commands/sync.ts b/src/commands/sync.ts index 0cc80e646..9147bb05e 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -700,6 +700,13 @@ async function performSyncInner(engine: BrainEngine, opts: SyncOpts): Promise = []; const addsAndMods = [...filtered.added, ...filtered.modified]; + // v0.33.1: sort newest-first so recent pages get embedded before older ones. + // Brain paths are typically date-prefixed (meetings/2026-05-13-*, daily/2026-05-13.md) + // so a descending lexicographic sort naturally prioritizes recent content. + // This ensures that after a burst of writes, the most relevant pages become + // searchable first instead of waiting behind alphabetically-earlier backlog. + addsAndMods.sort((a, b) => b.localeCompare(a)); + // v0.22.13 (PR #490 Q5): one source of truth for the concurrency decision. // engine.kind === 'pglite' → forced 1; explicit opts.concurrency wins; // auto path returns DEFAULT_PARALLEL_WORKERS only when fileCount > 100.