fix: 磁盘管理异步化 + 文件监听过滤高频目录,修复超大工作区 UI 冻结#453
Merged
ErlichLiu merged 1 commit intoMay 14, 2026
Merged
Conversation
关闭 #431 **storage-service.ts** - `getDirSize()` 从同步 readdirSync/statSync 改为 async fsPromises, 彻底释放主进程事件循环控制权,避免 38 万文件场景下 UI 冻结数分钟 - 新增 SKIP_DIRS 跳过 node_modules/.next/.git 等已知大型目录 - 新增 MAX_FILE_SCAN=100,000 全局扫描上限,防止失控递归 - calculateStorageStats() 改用 Promise.all() 并行计算六个分类,提速明显 - 所有 calcXxx / cleanupOrphan 函数一并改为 async **workspace-watcher.ts** - 新增 HIGH_NOISE_SEGMENTS + isHighNoisePath(),跳过 node_modules/.next 等 目录产生的文件变更事件,防止大规模工作区下 IPC 事件风暴导致渲染进程连续刷新 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 #431
根因
磁盘管理页面一打开就调用
calculateStorageStats(),内部getDirSize()用同步readdirSync+statSync递归遍历整个工作区。当工作区包含.next(~358k 文件)、node_modules(~18k 文件)等目录时,Node.js 主进程事件循环被完全阻塞,Electron 无法响应任何 IPC 或渲染进程消息,UI 冻结数分钟。改动说明
storage-service.tsgetDirSize()改为 async,使用fs.promises.readdir/statawait都将控制权交还事件循环,UI 保持响应SKIP_DIRS:跳过node_modules/.next/.git/dist等MAX_FILE_SCAN = 100_000全局上限calculateStorageStats()改用Promise.all()calcXxx/cleanupOrphan函数一并改为 asyncworkspace-watcher.tsHIGH_NOISE_SEGMENTS+isHighNoisePath()node_modules/.next等目录的变更事件if (isHighNoisePath(...)) return测试建议
node_modules或.next的工作区打开设置 → 磁盘管理,应在 < 1s 内可交互🤖 Generated with Claude Code