fix(issues): persist enrichment to disk before notifying frontend

sendComplete() was firing before the enrichment file write finished,
so the renderer's loadEnrichment() read stale data — resulting in 0%
completeness and empty fields after triage.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
Sondre Engebråten
2026-02-13 16:06:58 +01:00
co-authored by Claude Opus 4.6
parent a060271760
commit b897369ef3
@@ -176,9 +176,9 @@ export function registerAITriageHandlers(
}
const enrichmentResult = result.data as AIEnrichmentResult;
sendComplete(enrichmentResult);
// Persist enrichment data to local file
// Persist enrichment data to local file BEFORE notifying the frontend,
// so that loadEnrichment() in the renderer reads the updated file.
try {
await withEnrichmentFileLock(project.path, async () => {
const enrichmentFile = await readEnrichmentFile(project.path);
@@ -206,6 +206,8 @@ export function registerAITriageHandlers(
error: persistErr instanceof Error ? persistErr.message : persistErr,
});
}
sendComplete(enrichmentResult);
});
} catch (error) {
sendError(error instanceof Error ? error.message : 'Failed to run enrichment');