perf(review): 避免 Agent 工作时重复重建 Diff - #3591
Merged
Merged
Conversation
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/useReviewGitState.ts | 将 Review 的 store 驱动刷新限制为 Agent turn 结束边沿,并增加可取消 debounce 与卸载清理。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/useLastTurnFilter.ts | 将 external-store snapshot 改为排序后的路径集合序列化值,使路径未变化的 stream 通知不再触发消费者重渲染。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/diffRows.ts | 新增与 unified/split 行构建逻辑一致的轻量行数统计,并扩展文件列表虚拟化判定。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/ReviewTabBody.tsx | 根据展开且未自行虚拟化的 Diff 行数动态启用外层虚拟化,并在该场景下降低 overscan。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/tests/useReviewGitState.test.ts | 覆盖 running→stopped 刷新、继续运行时取消待刷新及非运行通知不误刷新的行为。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/tests/useLastTurnFilter.test.ts | 验证路径集合不变时不重渲染、路径集合变化时正确更新。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/tests/ReviewTabBody.helpers.test.ts | 验证展开 Diff 行预算仅累计未自行虚拟化的文件,并在文件数已超阈值时跳过扫描。 |
| apps/desktop/src/renderer/features/right-sidebar/plugins/review/DiffViewer/tests/PlainUnifiedDiff.test.ts | 验证 unified/split 轻量计数与新增文件列表虚拟化阈值。 |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Agent turn running] --> B[忽略普通 stream 更新]
B --> C{running 变为 stopped?}
C -- 否 --> B
C -- 是 --> D[Debounce Review 刷新]
D --> E[重新加载 Git Diff]
E --> F[统计已展开的 eager Diff 行]
F --> G{累计行数超过阈值?}
G -- 是 --> H[启用外层文件列表虚拟化]
G -- 否 --> I[保持普通文件列表渲染]
Reviews (1): Last reviewed commit: "perf(review): 避免 Agent 工作时重复重建 Diff" | Re-trigger Greptile
DavidShenXD
force-pushed
the
cindy/epic-goodall
branch
from
August 29, 2026 05:41
95278eb to
3d4cbc5
Compare
Collaborator
Author
反馈已处理已处理:
变更:
验证:
备注:
|
Signed-off-by: david <david@xd.com>
DavidShenXD
force-pushed
the
cindy/epic-goodall
branch
from
August 29, 2026 06:41
3d4cbc5 to
68a867b
Compare
Collaborator
Author
|
已再次同步最新
本地 trace/fixture 工具仍保留为未暂存文件,未进入 PR。新的 CI 已由本次推送触发,当前等待 GitHub 检查结果。 |
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.
这次改了什么
摘要
修复审查界面展开多个 Diff 后,Agent 持续修改文件时整个 Desktop 严重掉帧、审查区域外操作也出现高延迟的问题。
本次包含三项针对性优化:
变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
UI 变化
无视觉、布局或文案变化;仅调整既有 Review 的后台刷新时机和大列表渲染策略。
怎么验证的
自动验证
定向 Review 测试共 107 项,107/107 通过。独立 review 覆盖
running → stopped → running延迟刷新竞态、重新 running 时取消待执行刷新、卸载清理及虚拟化阈值;未发现新的刷新或 callback 问题。手工验证
在同一台 Windows 机器、同一 Dev Desktop/profile、同一任务下做双版本 trace。窗口为 1934×1229、165Hz,展开 21 个 Diff;每版采样 9 秒,执行 8 次 text stream,并对 6 个夹具文件各修改和恢复一次(共 12 次
apply_patch)。2310a133)95278ebf7)结论:主要瓶颈是 stream 更新反复触发完整 Review 重建,Script 是最大成本,Paint/Layout 是完整重建带来的放大结果。优化后 Agent 运行阶段不再重复刷新整个 Review,结束时统一刷新;多个展开 Diff 的累计行数过大时由外层虚拟化限制常驻 DOM。该同机同场景 A/B 中,rAF p95 从 36.3ms 降至 6.2ms,Trace 长任务从 42 个降至 0。
未执行的验证
风险
风险分类
影响与回滚
提交前检查
git commit -s,见 DCO)