fix: eliminate Trae parse blocking that stalled serve/first paint (#40) - #41
Merged
Conversation
Trae session metadata was extracted by spawning one `git log` per tag (plus a second pass for the no-chain-start fallback). With large snapshot repos (~72 repos, ~696 tags) this meant hundreds of git subprocesses per repo — ~40s on Windows — which blocked `/api/refresh` and left the dashboard stuck on the loading state. - parse-trae: replace the per-tag `git log` scan with a single `git for-each-ref --format='%(refname:short)\t%(creatordate:unix)'` call per repo (~768 spawns -> 72). Output records are unchanged. - web: render existing DB data before triggering a refresh, then update silently in the background, so the home and overview pages never block the first paint on log parsing. - add parse-trae regression tests covering tag parsing, the earliest-tag fallback, the lastImportedAt watermark, and missing ModularData.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40.
Problem
On Windows with a large Trae snapshot store (~72 git repos, ~696 tags),
aiusage serveopened to a dashboard stuck on the loading state. The cause was two-fold:git logper tag (plus a second full pass for the no-chain-startfallback) — ~768 git subprocesses per parse. On Windows process spawn is ~40–60ms each, so a single Trae parse took ~40s (REFRESH ms=40815in the report), blocking/api/refresh.triggerRefresh()(the full parse) before rendering, so the page never showed existing DB data during that ~40s.Changes
parse-trae.ts: replace the per-taggit logscan with a singlegit for-each-ref --format='%(refname:short)\t%(creatordate:unix)'call per repo. Git subprocesses drop from ~768 to 72 (one per repo).%(creatordate:unix)is semantically equivalent to the previousgit log %atfor these snapshot tags, so parsed records are unchanged.web/routes/+page.svelte&overview/+page.svelte: render whatever is already in the database first, then trigger the refresh in the background and update silently. First paint is no longer blocked on log parsing, regardless of how slow any single source is.tests/commands/parse-trae.test.ts(new): builds real git snapshot repos and covers tag parsing, the earliest-tag fallback, thelastImportedAtwatermark, and missingModularData.Expected impact
Test plan
npx vitest runinpackages/cli— 402/402 pass (incl. 4 new parse-trae tests)svelte-check— no new errors in changed filesservefirst paint is instant and refresh completes in seconds