Skip to content

fix(tool,tui): codeindex build progress on a live status line - #2539

Merged
topcheer merged 1 commit into
mainfrom
fix/codeindex-progress-report
Sep 18, 2026
Merged

topcheer merged 1 commit into
mainfrom
fix/codeindex-progress-report

Conversation

@topcheer

Copy link
Copy Markdown
Owner

背景与取证(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

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>
@topcheer
topcheer merged commit 5e20862 into main Sep 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant