feat: Fix progress bar hanging and improve UI responsiveness during indexing

Adds strategic yield points and direct stdout writes to prevent progress animation from freezing when the main thread is blocked by synchronous operations. Introduces 'finalizing' phase to smooth transition between parsing and resolving steps, ensuring progress reaches 100% completion.
This commit is contained in:
Colby McHenry
2026-04-06 09:50:30 -05:00
parent b768a9aa18
commit 9a2d3d9a13
5 changed files with 55 additions and 9 deletions
+5 -2
View File
@@ -326,10 +326,10 @@ export class ReferenceResolver {
* Processes unresolved references in chunks, persisting edges and cleaning
* up resolved refs after each batch to avoid accumulating large arrays.
*/
resolveAndPersistBatched(
async resolveAndPersistBatched(
onProgress?: (current: number, total: number) => void,
batchSize: number = 5000
): ResolutionResult {
): Promise<ResolutionResult> {
this.warmCaches();
const total = this.queries.getUnresolvedReferencesCount();
@@ -388,6 +388,9 @@ export class ReferenceResolver {
processed += batch.length;
onProgress?.(processed, total);
// Yield so progress UI can render between batches
await new Promise(resolve => setImmediate(resolve));
// If nothing was resolved or removed in this batch, we'd loop forever
// on the same rows. Break to avoid infinite loop.
if (result.resolved.length === 0 && result.unresolved.length === batch.length) {