Skip to content

fix(desktop): remove composer ghost sync IPC - #1235

Merged
MagicLizi merged 3 commits into
makecindy:mainfrom
hushaowu-rh:fix/desktop-composer-ghost-cache
Aug 1, 2026
Merged

fix(desktop): remove composer ghost sync IPC#1235
MagicLizi merged 3 commits into
makecindy:mainfrom
hushaowu-rh:fix/desktop-composer-ghost-cache

Conversation

@hushaowu-rh

@hushaowu-rh hushaowu-rh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

移除 Desktop ChatInput$ 命令发现和发送期展开中的同步 ghosts.listSync() IPC,改为复用窗口级 useInstalledGhosts() 快照,避免输入热路径阻塞 renderer。另加入隐私安全、限流的 composer 更新到下一帧延迟探针;根据 review,探针在没有日志 sink 或日志预算无效时会成为真正的 no-op,不读取时钟也不调度 RAF。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:Mac Desktop composer 偶发输入卡顿定位与修复
  • 本 PR 包含:Ghost 快照复用;移除 ChatInput 的直接同步 Ghost IPC;隐私安全的慢帧探针;探针禁用态 no-op;相关回归测试
  • 明确不包含:普通 Tiptap transaction 的 React 渲染、草稿序列化与 caret-scroll 优化(由独立 PR perf(desktop): reduce composer typing work #1236 处理)
  • 用户可见变化:输入 $ 或发送 $command 时不再因同步 Ghost 枚举阻塞;无界面、交互或文案变化
  • 是否存在 breaking change:无

UI 变化

不涉及:仅调整 composer 内部数据来源和性能观测逻辑,无视觉、交互或文案变化,因此无截图/录屏可提供。

  • 引用的设计规范:不涉及:未改变 UI 布局、样式、交互或文案,仅移除同步 IPC 并增加内部性能探针

怎么验证的

自动验证

pnpm --dir apps/desktop exec vitest run
  src/renderer/__tests__/chatInputGhostSnapshot.test.ts
  src/renderer/__tests__/chatInputListContinuation.test.ts
  src/renderer/__tests__/chatInputSessionFocus.test.ts
  src/renderer/__tests__/chatInputSteerShortcut.test.ts
  src/renderer/__tests__/composerDraftAttachmentsRoundTrip.test.ts
  src/renderer/__tests__/composerDraftMountRace.test.ts
  src/renderer/__tests__/composerExternalDraftEmptyDoc.test.ts
  src/renderer/lib/__tests__/composerDraftStore.test.ts
  src/renderer/lib/__tests__/composerInputLatencyProbe.test.ts
结果:9 个文件、63 个测试通过

pnpm --dir apps/desktop typecheck
结果:通过

pnpm --dir apps/desktop exec eslint
  src/renderer/components/new-chat/ChatInput.tsx
  src/renderer/__tests__/chatInputGhostSnapshot.test.ts
  src/renderer/lib/composerInputLatencyProbe.ts
  src/renderer/lib/__tests__/composerInputLatencyProbe.test.ts
结果:通过

git merge-tree --write-tree origin/main HEAD
结果:三方合并 clean,无冲突

pnpm check:dco
结果:3 个 commit 均通过 DCO

git diff origin/main...HEAD --check
结果:通过

此前还验证过 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)。未删除、跳过或弱化测试来制造通过。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:renderer 性能与低频诊断日志

影响与回滚

  • 影响范围:Desktop composer 的 Ghost 命令发现、发送期 Ghost 命令展开和慢帧诊断;日志只包含更新类型、耗时与文档大小,不包含文本、路径或 session 标识
  • 回滚 / 降级方式:回退本 PR 的 commits 即恢复原行为;探针也可通过不提供 logger 或将日志预算设为非正数来完全禁用

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI 则跳过)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

🤖 Generated with Claude Code

Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
@hushaowu-rh
hushaowu-rh requested a review from a team as a code owner July 31, 2026 14:39
Copilot AI review requested due to automatic review settings July 31, 2026 14:39
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 移除 Desktop composer 热路径中的同步 Ghost 清单 IPC,并增加受限的输入延迟诊断。

  • $ 命令面板和发送期命令展开改为复用窗口级 useInstalledGhosts() 快照。
  • 新增基于下一动画帧的 composer 更新延迟探针,仅记录更新类型、耗时和文档大小。
  • 为 Ghost 快照使用方式、探针限流、禁用态 no-op、IME 跳过及清理行为补充回归测试。

Confidence Score: 5/5

当前变更看起来可以安全合并。

未发现仍需阻止合并的故障。

Important Files Changed

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread apps/desktop/src/renderer/lib/composerInputLatencyProbe.ts
@MagicLizi

Copy link
Copy Markdown
Contributor

@hushaowu-rh 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/composerInputLatencyProbe.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

格式门未通过

PR description 缺少以下必要段落(参照 .github/PULL_REQUEST_TEMPLATE.md):

  • 这次改了什么(What)
  • 怎么验证的(Test Plan)
  • 风险(Risks)

请补齐上述段落后更新 PR description。

@MagicLizi

Copy link
Copy Markdown
Contributor

本 PR 命中 UI 路径(apps/desktop/src/renderer/components/new-chat/ChatInput.tsx 等)但 description 未附界面效果证据。建议补充改动后效果:截图/录屏,或说明纯逻辑改动无视觉变化。

此提醒不阻断合并,仅供参考。

@MagicLizi

Copy link
Copy Markdown
Contributor

⏸️ 本 PR 触发白名单确认门(product:命中 UI 路径)。

放行名单成员在本 PR 上 Approve 即放行;需修改请 Request Changes。

讨论 issue 见上方链接。

讨论 issue:#1255

Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 1, 2026 05:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在「待确认 PR」面板完成维护者确认。

@MagicLizi

Copy link
Copy Markdown
Contributor

白名单确认门已放行(product,由 MagicLizi 确认),PR 恢复正常推进。

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查通过,零 P0/P1。clean IPC removal,复用现有 window-level snapshot,测试充分。

@MagicLizi

Copy link
Copy Markdown
Contributor

@hushaowu-rh 👋 审查已通过 (approve),但刚合并的 #1236 导致本 PR 与 main 产生了冲突。请 merge 最新的 origin/main 解决冲突后推送,下一轮 auto-review 会自动继续合并流程。

@MagicLizi

Copy link
Copy Markdown
Contributor

@hushaowu-rh 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

Signed-off-by: Shao-Wu Hu <271197399+hushaowu-rh@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 1, 2026 06:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@MagicLizi MagicLizi added awaiting-discussion 等待维护者讨论(review-pr) and removed needs-maintainer-approval labels Aug 1, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在「待确认 PR」面板完成维护者确认。

@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 1, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查通过,零 P0/P1。干净且范围恰当的修复:移除 ChatInput 热路径上两处 ghosts.listSync() 同步 IPC 调用,改用已有的窗口级 useInstalledGhosts() 缓存;新增带速率控制的延迟探针,测试覆盖完善。先前 Copilot 评论(无 sink 时冗余 RAF)已修复并验证。CI 全绿。

@MagicLizi
MagicLizi merged commit 90b7bdb into makecindy:main Aug 1, 2026
6 checks passed
@MagicLizi

Copy link
Copy Markdown
Contributor

把 ChatInput 里阻塞主线程的同步 IPC 换成已有的广播缓存,干净利落——输入延迟的 RAF 探针设计也很妥帖,侵入性极低。感谢贡献!

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.

3 participants