fix(desktop): remove composer ghost sync IPC - #1235
Conversation
Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/components/new-chat/ChatInput.tsx | Ghost 命令发现与发送期展开改用共享安装快照,并注册和清理 composer 延迟探针。 |
| apps/desktop/src/renderer/lib/composerInputLatencyProbe.ts | 新增按帧合并、阈值过滤、限流且可完整禁用的输入延迟诊断实现。 |
| apps/desktop/src/renderer/lib/tests/composerInputLatencyProbe.test.ts | 覆盖慢帧记录、隐私字段、合并、IME、限流、清理和禁用态行为。 |
| apps/desktop/src/renderer/tests/chatInputGhostSnapshot.test.ts | 通过源码契约测试防止 ChatInput 重新引入同步 Ghost 清单 IPC。 |
Reviews (3): Last reviewed commit: "fix(desktop): isolate composer latency p..." | Re-trigger Greptile
There was a problem hiding this comment.
Pull request overview
该 PR 针对 Desktop renderer 的 ChatInput 里 $ 触发的同步 Ghost 枚举(同步 Electron IPC)导致的输入卡顿问题做了优化:复用窗口级的已安装 Ghost 快照,避免在用户输入时触发同步扫描;同时新增一个隐私安全、低频率的“composer 更新到下一帧”的延迟探针,用于捕捉慢帧。
Changes:
- 将
$命令面板与发送期$command展开从ghosts.listSync()改为复用useInstalledGhosts()的窗口级快照,并在发送时通过 ref 读取最新快照。 - 新增
composerInputLatencyProbe:按阈值与窗口限流记录慢帧日志(仅 kind / 耗时 / docSize,不记录文本等用户内容)。 - 增加相应的单测与“无同步 listSync”契约测试,防止回归。
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/desktop/src/renderer/lib/composerInputLatencyProbe.ts | 新增输入更新到下一帧的延迟探针(阈值 + 限流 + 隐私约束)。 |
| apps/desktop/src/renderer/lib/tests/composerInputLatencyProbe.test.ts | 覆盖慢帧记录、同帧合并、IME 忽略、限流、dispose 行为与默认值。 |
| apps/desktop/src/renderer/components/new-chat/ChatInput.tsx | 移除 ghosts.listSync() 同步 IPC;复用快照用于 $ 菜单与发送期展开;接入延迟探针。 |
| apps/desktop/src/renderer/tests/chatInputGhostSnapshot.test.ts | 契约测试:确保 ChatInput 不再包含 ghosts.listSync() 且快照链路符合约定。 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@hushaowu-rh 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/composerInputLatencyProbe.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。 如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。 |
MagicLizi
left a comment
There was a problem hiding this comment.
格式门未通过
PR description 缺少以下必要段落(参照 .github/PULL_REQUEST_TEMPLATE.md):
- 这次改了什么(What)
- 怎么验证的(Test Plan)
- 风险(Risks)
请补齐上述段落后更新 PR description。
|
本 PR 命中 UI 路径( 此提醒不阻断合并,仅供参考。 |
|
⏸️ 本 PR 触发白名单确认门(product:命中 UI 路径)。 放行名单成员在本 PR 上 Approve 即放行;需修改请 Request Changes。 讨论 issue 见上方链接。 讨论 issue:#1255 |
Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
|
白名单确认门已放行(product,由 MagicLizi 确认),PR 恢复正常推进。 |
MagicLizi
left a comment
There was a problem hiding this comment.
审查通过,零 P0/P1。clean IPC removal,复用现有 window-level snapshot,测试充分。
|
@hushaowu-rh 👋 审查已通过 (approve),但刚合并的 #1236 导致本 PR 与 main 产生了冲突。请 merge 最新的 origin/main 解决冲突后推送,下一轮 auto-review 会自动继续合并流程。 |
|
@hushaowu-rh 👋 这个 PR 目前与 请在本地 merge 最新的 |
Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
MagicLizi
left a comment
There was a problem hiding this comment.
审查通过,零 P0/P1。干净且范围恰当的修复:移除 ChatInput 热路径上两处 ghosts.listSync() 同步 IPC 调用,改用已有的窗口级 useInstalledGhosts() 缓存;新增带速率控制的延迟探针,测试覆盖完善。先前 Copilot 评论(无 sink 时冗余 RAF)已修复并验证。CI 全绿。
|
把 ChatInput 里阻塞主线程的同步 IPC 换成已有的广播缓存,干净利落——输入延迟的 RAF 探针设计也很妥帖,侵入性极低。感谢贡献! |
这次改了什么
摘要
移除 Desktop
ChatInput在$命令发现和发送期展开中的同步ghosts.listSync()IPC,改为复用窗口级useInstalledGhosts()快照,避免输入热路径阻塞 renderer。另加入隐私安全、限流的 composer 更新到下一帧延迟探针;根据 review,探针在没有日志 sink 或日志预算无效时会成为真正的 no-op,不读取时钟也不调度 RAF。变更类型
feat新功能fix缺陷修复refactor/perf重构或性能优化docs/test/chore文档、测试或工程维护范围
ChatInput的直接同步 Ghost IPC;隐私安全的慢帧探针;探针禁用态 no-op;相关回归测试$或发送$command时不再因同步 Ghost 枚举阻塞;无界面、交互或文案变化UI 变化
不涉及:仅调整 composer 内部数据来源和性能观测逻辑,无视觉、交互或文案变化,因此无截图/录屏可提供。
怎么验证的
自动验证
此前还验证过
useInstalledGhosts、Ghost command 和 ChatInput snapshot 契约;合并 #1236 后的 composer focused suite 也通过。手工验证
不涉及界面变化;本轮未进行独立视觉验收。
未执行的验证
pnpm test:unit已尝试:runner 自测 323 pass / 1 skip,除 Desktop 外其余 workspace 通过;Desktop Vitest 的 threads pool 在当前 macOS/Node 环境发生原生SIGSEGV。改用 forks 单 worker 完整诊断后未再崩溃,结果为 1490 个文件通过,BillingPage.test.tsx仅有 2 个与本 PR 无关的固定 UTC 日期/本地时区断言失败(17889 tests pass / 2 fail / 2 skip)。未删除、跳过或弱化测试来制造通过。风险
风险分类
影响与回滚
提交前检查
git commit -s,见 DCO)🤖 Generated with Claude Code