Skip to content

fix(desktop): 清除伙伴消息的灵动岛未读状态 - #4054

Merged
MagicLizi merged 9 commits into
mainfrom
dash/bot-island-unread-fix
Sep 8, 2026
Merged

MagicLizi merged 9 commits into
mainfrom
dash/bot-island-unread-fix

Conversation

@dashhuang

@dashhuang dashhuang commented Sep 7, 2026

Copy link
Copy Markdown
Member

这次改了什么

摘要

修复阅读伙伴消息后灵动岛仍保留未读的问题,同时防止伙伴设置入口误清主任务未读、伙伴页面误清此前分栏任务的未读。

变更类型

  • fix 缺陷修复

范围

  • 关联需求:伙伴消息的灵动岛未读状态同步。
  • 本 PR 包含:伙伴聊天/历史视图通过归属校验后上报可见任务;移除通知跳转的提前上报;仅普通任务聊天路由合并分栏;回归测试。
  • 明确不包含:Main、preload、原生灵动岛实现及持久化协议变更。
  • 用户可见变化:阅读伙伴聊天清除对应未读;打开伙伴设置短链不会清除未展示聊天的未读。
  • breaking change:无。

UI 变化

  • 引用的设计规范:不涉及新的视觉、布局、控件或文案;本次修复已有灵动岛未读行为。遵循 docs/product-rules/cindy-bots-runtime.md §6.2 的对应任务可见性约束;docs/design-rules/DESIGN.md 的 Light/Dark 样式实现保持不变,实机效果未验证。

怎么验证的

自动验证

corepack pnpm --filter desktop exec vitest run src/renderer/__tests__/agentIslandVisibleSessionRoute.test.ts src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx src/renderer/features/bots/__tests__/botSessionRead.test.tsx src/renderer/features/bots/__tests__/botNavigation.test.ts
通过:4 files, 48 tests
env -u NODE_ENV -u CINDY_AUTH_REGION -u VITE_CINDY_AUTH_REGION corepack pnpm --filter desktop exec vitest run src/renderer/features/bots/__tests__/botIslandVisibility.test.tsx src/renderer/__tests__/agentIslandVisibleSessionRoute.test.ts src/main/agent-island/__tests__/service.test.ts src/main/agent-island/__tests__/state.test.ts --pool=threads --maxWorkers=1
通过:4 files, 279 tests;覆盖 main 拒绝普通后台上报、接受匹配的 pending focus ack
corepack pnpm test:unit:related
通过:Desktop 相关单测
corepack pnpm --filter desktop run --if-present typecheck
通过
git diff --check
通过

手工验证

已核对 BotsHomeView 的短链跳转、设置入口及 BotSettingsDrawer 保留聊天的源码路径。未启动客户端目检。

未执行的验证

真实 macOS 灵动岛行为与 Light/Dark 实机效果未验证。

风险

风险分类

  • 其他:Desktop 可见任务上报影响灵动岛未读清除。

影响与回滚

  • 不变量:伙伴被动已读只包含已通过既有归属校验的聊天。普通任务聊天页可合并分栏;伙伴短链、设置、邀请、loading/error/unavailable 均不上报聊天 ID。
  • MainLayout 将伙伴路由上报交给对应视图;聊天 ready 与历史 allowed 复用一个 focus/cleanup hook,不复制归属判据。视图按 botId/sessionId 重建,避免旧授权或迟到查询结果沿用到新页面。通知点击只导航,等待实际校验结果。
  • 生命周期:校验中为 null,通过后上报 ID;由 main 既有门禁决定是否接受(来源窗口聚焦,或命中用户点击后的限时 pending focus 目标)。Renderer 不重复检查 DOM 焦点,避免吞掉通知首次确认。重新聚焦重报;切换/卸载清除并移除监听;异步查询由既有 cancelled guard 丢弃迟到结果。
  • 新测试同时覆盖聊天和历史的延迟校验、无归属、查询失败、切换、迟到结果、后台/重新聚焦、卸载和不支持灵动岛的平台。
  • 回归覆盖普通分栏 → 伙伴短链 → 设置 → 聊天 → 历史 → 返回分栏的切换。聊天路由上的设置抽屉仍保留聊天,区别于独立设置入口。
  • 远程/Mobile:仅 Desktop 本地灵动岛可见状态计算,无新增 IPC 或跨端行为。
  • 回滚:回滚本 PR 提交。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 带 DCO 签名
  • 已说明 UI 变化和验证限制
  • 未提交凭证、令牌或授权文件
  • 已补充必要说明
  • 已确认测试结果

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang
dashhuang requested a review from a team as a code owner September 7, 2026 10:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T07:47:26.955972Z 3cf792d New commits
🔒 Security Review Completed 2026-09-08T07:46:41.643619Z 3cf792d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为 Desktop renderer 增加伙伴路由的 Agent Island 可见任务解析,并在伙伴通知跳转时直接上报目标会话。

  • 从伙伴主路由的 profile 中推导 canonical session
  • 从伙伴子任务路由中直接提取 session ID
  • 在伙伴通知跳转时立即同步可见会话
  • 当前遗漏了同样展示真实会话的伙伴 history 路由

Confidence Score: 4/5

当前不建议合并,因为伙伴历史会话入口仍会把 Agent Island 的可见任务上报为 null,导致修复覆盖不完整。

新解析器遗漏 /bots/:botId/history/:sessionId;该路由实际展示一个会话,但 MainLayout 会清空而非上报其 session ID。

Files Needing Attention: apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts

Important Files Changed

Filename Overview
apps/desktop/src/renderer/components/layout/MainLayout.tsx 接入伙伴路由解析并在通知跳转时立即上报 session;已调查的上报值与目标路由一致。
apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts 新增伙伴主路由和 session 路由解析,但未覆盖合法的 history 会话路由。
Prompt To Fix All With AI
### Issue 1
apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts:25-28
**遗漏伙伴历史会话**

新解析器只识别 `/bots/:botId/session/:sessionId` 和伙伴主路由,但合法的 `/bots/:botId/history/:sessionId` 同样会渲染真实的只读会话。用户打开伙伴历史会话时,这里会返回 `null`,MainLayout 随后清空可见任务,而不是上报正在查看的 `sessionId`,导致该入口仍可能保留错误的灵动岛未读状态。请覆盖 history 路由,并为伙伴各类会话路由补充解析测试。

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(desktop): clear Agent Island unread ..." | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cdcacdf6f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/components/layout/MainLayout.tsx Outdated
@MagicLizi MagicLizi added the touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) label Sep 7, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@dashhuang 👋 这个 PR 还有 2 条 review conversation 没 resolve(apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts / apps/desktop/src/renderer/components/layout/MainLayout.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

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

@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径(apps/desktop/src/renderer/components/layout/MainLayout.tsx / apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts)但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@MagicLizi MagicLizi added status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) and removed status:awaiting-bot-review 等外部审查机器人表态(review-pr 自动维护,仅展示) labels Sep 7, 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.

独立审查未通过(P1×3)。伙伴消息进灵动岛可见集合后,未读会被过宽的可见会话集合清掉。

  • [P1] apps/desktop/src/renderer/components/layout/MainLayout.tsx:427routeSessionId/bots/... 上已是伙伴会话,但 splitVisibleSessionIds 仍把全局 splitGroupStore 里 ≥2 个分栏并进去。SplitGroup 只挂在 /cc-agent,离开任务页并不清 store。打开伙伴对话时会 setVisibleSession([botSession, ...splitIds]),main 把这些 id 当成被动已读,岛上未读被清、卡片被藏——那些任务并不在屏幕上。请只在 cc-agent 路由上合并分栏 id(与 resolveAgentIslandVisibleSessionIdFromPath 同一谓词)。

  • [P1] apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts:28matchPath('/bots/:botId', pathname) 把短链当成规范任务已可见。该路径也是设置(?settings=1)、邀请和非对话 spinner;侧栏进设置走 /bots/:id?settings=1,没有挂聊天。结果:打开伙伴设置就会清规范任务的岛未读。短链可留给通知交接 spinner,但 settings=1 时不要上报会话(或只认 /session//history/,短暂 /bots/:id 仍用现有通知里的 setVisibleSession(sessionId))。

  • [P1] apps/desktop/src/renderer/__tests__/agentIslandVisibleSessionRoute.test.ts:6 — 新 resolver 未 import、未测;现有 8 例仍是旧路径。请补伙伴 session/history/短链、settings=1、以及分栏合并不得作用在 bot 路由上的回归。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang

Copy link
Copy Markdown
Member Author

已在 7d22182 按本轮三项反馈统一收窄可见集合。

不变量:被动已读只包含当前路由展示的聊天。MainLayout 通过同一个纯函数计算集合:普通任务页才能合并分栏;伙伴 session/history 只包含自身;伙伴短链、设置入口、邀请和跳转等待页不从 profile 推断 canonical ID。短链完成既有跳转后由 session 路由上报,通知交接保持原有逻辑,无新增状态或重试机制。

回归覆盖从普通分栏 → 伙伴短链 → 设置 → session → history → 普通分栏的连续切换,验证残留分栏 ID 不跨页面清未读。区分短链设置页与 session 上的设置抽屉:后者仍挂载聊天。

验证:15 个定向测试、根 test:unit:related、Desktop typecheck、git diff --check 均通过。真实 macOS 灵动岛以及 Light/Dark 实机效果未验证。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d2218287f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/lib/agentIslandVisibleSessionRoute.ts Outdated
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang

Copy link
Copy Markdown
Member Author

已在 3e3795a 补齐设计台账生成结果:新增 useBotIslandVisibleSession 后 desktop.bots 可达文件数发生变化,导致 verify-checks、Windows 1/2 和 Git integration 在同一 design-inventory CLI 检查失败。生成后仅变更台账日期与新增 hook 记录,人工维护区未变。47 个台账测试、504 个 runner 检查及 Desktop 相关单测均通过。f2e96728b 的两组 Linux 单测已通过,之前的 PI fixture 竞态本轮未复现;不修改业务代码。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang

Copy link
Copy Markdown
Member Author

已推送 9c92686,同步 main 并重新生成设计台账,解决唯一的生成区块冲突;人工维护区与 main 一致,GitHub 已确认 MERGEABLE。

同步后验证:47 个台账测试与 Desktop typecheck 通过。test:unit:related 自动扩展为全量:首次继承 CN 环境导致 9 个 Global fixture 断言失败;清除区域环境后 Desktop、Mobile、maker-core 等通过。第二次仅命中与 main 相同的 WebSocket 测试分包竞态(握手后的 SERVER_HEAD 不保证在同一 data 事件到达),该包一次复跑 13 文件、439 测试全通过;未修改这些无关测试或业务代码。新 HEAD CI 待完成,真实 macOS 灵动岛及 Light/Dark 实机仍未验证。

Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@dashhuang

Copy link
Copy Markdown
Member Author

本轮 CI 收敛:不变量仍是「伙伴已通过归属校验、且窗口在前台时,才上报被动已读」;唯一上报 owner 是视图复用的 hook。当前用例覆盖查询等待/失败、迟到结果、路由切换、后台完成、重新聚焦与卸载清理。

已修复本 PR 的 Windows 测试竞态:botIslandVisibility.test.tsx 看到聊天 DOM 不代表 passive effect 已提交,立即 focus 可能调用旧的 null handler。现在用受控 Promise,在后台通过 async act 完成归属查询及 effect 提交,再触发 focus,保留后台不读和卸载清理断言。只改测试,运行逻辑不变。25 个定向测试、test:unit:related、Desktop typecheck 通过。

另外两族失败与当前 main 同代码:PI stop 测试分别异步写 approval/stop,不能保证同一扫描批次,日志最终为 completed 而非 stopped;botSkillStore 容量测试先超过 20s,未结束循环继而污染后续 fixture 并引发 ENOTEMPTY。未将无关模块修复混入本 PR,也未盲重跑旧任务;新提交 CI 将重新验证。Windows 本机及真实 macOS/Light/Dark 实机尚未验证。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4c52f14e6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/renderer/features/bots/useBotIslandVisibleSession.ts Outdated
Signed-off-by: Dash <125997726+dashhuang@users.noreply.github.com>
@MagicLizi MagicLizi added the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Sep 8, 2026
@MagicLizi
MagicLizi dismissed their stale review September 8, 2026 08:35

这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。

@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.

独立审查通过:当前 head 无 P0/P1。伙伴短链/设置不再误清分栏未读;聊天与历史在归属校验后再上报。

@MagicLizi
MagicLizi merged commit d94ddc1 into main Sep 8, 2026
20 checks passed
@MagicLizi
MagicLizi deleted the dash/bot-island-unread-fix branch September 8, 2026 09:24
@MagicLizi

Copy link
Copy Markdown
Contributor

合了。打开伙伴设置或短链时,旁边任务岛不再被误清未读。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants