fix(tool,tui): codeindex build progress on a live status line - #2539
Merged
Merged
Conversation
Screenshot-reported: the 'Building code index...' line sits silent for the whole build and the UI reads as hung until 'Code index ready' lands. Forensics (this round, per review): the build itself was never blocking - StartBackgroundIndex runs on its own goroutine, doBuild constructs the index entirely OUTSIDE m.mu (the lock is only taken for the final publish at :458), and the status messages were async Sends from their introduction in bfb37db. Sampled profiles and the 17s input-drain log pinned the real freezes elsewhere (session JSON parse, section-collector first refresh - fixed in #2537/#2538). What was missing is FEEDBACK: a long walk over a large or slow tree (external volume, tens of projects) shows a frozen-looking line for the whole build. Change: CodeIndexManager.SetOnProgress(done, total) - doBuild fires it throttled to at most once per 400ms, snapshotting the callback once before the loop (registration during a build is not a scenario worth locking for). The REPL wires it to a systemNotifyMsg with a fixed ItemID and Replace=true, so the 'Building code index...' line updates in place ('Building code index... 1200/5803 files') instead of spamming one message per tick. Unready degradation path verified unchanged: FilePathFuzzy returns nil before ready and CompleteMention falls back to a depth-4 capped walk. Tests: registration contract pinned; internal/tool and internal/tui suites green. Co-Authored-By: ggcode <noreply@ggcode.dev>
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.
背景与取证(review 要求的完整链路)
截图观察:"Building code index..." 整个构建期静置,UI 观感挂死直到 ready 落地。
取证结论:构建从未阻塞 UI(非回归)
真正缺口是反馈:大树(外置卷/几十个项目)长 walk 期间状态行纹丝不动=挂死观感。
修复
SetOnProgress(done,total)——doBuild 节流 400ms 触发;REPL 用固定 ItemID+Replace 原位更新("Building code index... 1200/5803 files"),不刷屏。未就绪降级路径验证不变(FilePathFuzzy 返 nil→CompleteMention 深 4 封顶 walk)。
验证
注册契约测试+internal/tool、internal/tui 双包全绿。
Co-Authored-By: ggcode noreply@ggcode.dev