Repository navigation
fix(project): 批量查询按需项目树的 Git 跟踪目录 - #73
Merged
Merged
Conversation
20 tasks done
…y-tree-git-batching
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.
关联问题
问题与根因
创建真实 Git 仓库,在
.gitignore中写入generated*/,建立 500 个同层忽略目录和一个可见源码文件,开启默认 Git 索引排除后打开项目。目录真实存在且可读,当前主干仍能复现上述错误。workspace.listDirectories除了读取文件系统,还会通过IndexingContext::prepare_parent查询索引排除标记。该路径已经批量执行git check-ignore,但缺少全树预取答案时,仍为每个 ignored 普通目录各启动一次git ls-files。累积耗时会超过桌面端现有的两秒预算。这段逐目录查询由 主仓库 #1597 引入,当时位于
rust/lithe-core/src/project/indexing.rs;该 PR 新增文件的精确 head 为1a82ddfa480169c670991132781b05c2552e6b87。迁入独立 Core 后逻辑保留。Core #60 优化了全树预取,本 PR 处理未预热的按需目录读取。改动
rust/crates/project/src/indexing.rs。prepare_parent收集同层 ignored 目录,复用已有lithe_git::tracked_directories,按 16 KiB 路径参数预算分批。继续使用 literal pathspec 和 NUL 分隔结果。None时保留原逐目录回退与git_failed处理。取消直接向上传播,最终缓存写入仍检查 generation。不修改 C ABI、命令名称、JSON 字段、插件协议、SDK 或桌面超时。正常目录浏览与索引排除语义保持不变。
回归与验证
先写进程计数回归,再改生产实现。最初 64 个 ignored sibling 的真实 Git 夹具在旧代码中记录到 64 次
ls-files(预期 1 次),断言失败;新代码两次列目录合计只有 1 次check-ignore+ 1 次ls-files。最终夹具还覆盖空格/特殊字符路径、force-added 内容和嵌套仓库。回退夹具用明确标记确认确实进入了批量失败分支,取消夹具在真实 Git 启动事件触发取消。最终提交
bad169425069788b0b81c6823f87c393b3731376的远端indexing.rsblob 与验证源码完全一致:5ac2a10def8e66c818b6d592671b654954c7c789。cargo test --offline --locked --manifest-path rust/Cargo.toml -p lithe-project -p lithe-lsp-engine -p lithe-core -- --test-threads=4cargo clippy --offline --locked --manifest-path rust/Cargo.toml -p lithe-project -p lithe-lsp-engine -p lithe-core --all-targets --all-features -- -D warnings--all-targets --target x86_64-pc-windows-msvc -- -D warningscargo fmt --all -- --check、git diff --checknode --test scripts/rust-core/*.test.mjs所有 Cargo 验证使用本工作树独立 target。受影响 crate 为
lithe-project、lithe-lsp-engine、lithe-core。Windows Clippy 不等于 Windows 原生运行或桌面验收;macOS 原生验收未执行。桌面接入
桌面配套分支为 lithe-support/fix-large-directory-project-tree,固定到本 Core commit,并加入 500 个真实目录的 Viva 无头回归、功能矩阵证据和中文 Agent Note。对应 PR 会引用本 PR;建议先合入 Core,再合入桌面接入。若 squash 改变 Core SHA,桌面 pin 应在合入前更新为最终 main SHA。
本地检查完成后通过 Lithe-Support MCP 创建待评审 PR;该工具不提供 Draft→ready 转换,因此在验证完成后直接创建 ready。没有自动合并或发布。