Skip to content

Fix/remote duplicate message - #2667

Open
kilvyken wants to merge 2 commits into
GCWing:mainfrom
kilvyken:fix/remote-duplicate-message
Open

Fix/remote duplicate message#2667
kilvyken wants to merge 2 commits into
GCWing:mainfrom
kilvyken:fix/remote-duplicate-message

Conversation

@kilvyken

Copy link
Copy Markdown

问题

通过 mobile-web(手机扫码登录)控制桌面端 agent 时,每次回复完成后,同一条回复会显示为两个相同内容的气泡。

根因

桌面端 remote\_persisted\_poll\_response 在 turn 已结束(status == "completed")且持久化快照(message\_snapshot)即将携带 final assistant 消息时,仍会返回一个 completed 状态的 active\_turn 快照。mobile-web 端对非 active 的 activeTurn 无条件渲染,导致它与消息列表中的 {turn\_id}\_assistant 持久化消息重复显示。

修改

  1. src/crates/services/services-integrations/src/remote\_connect.rs

    • remote\_persisted\_poll\_response:当 status == "completed"message\_snapshot.is\_some() 时,不再返回 completed active_turn,改为 finalize\_completed\_turn() + None(final 消息已由快照送达,快照不再冗余);无快照时保留原有兜底行为。
    • 新增回归测试 settled\_turn\_with\_already\_synced\_final\_message\_does\_not\_echo\_active\_turn
  2. src/mobile-web/src/pages/ChatPage.tsx

    • 新增 isActiveTurnCoveredByMessages:渲染 activeTurn 前检查消息列表是否已包含该 turn 的 final 消息(id 匹配 {turn\_id}\_assistant 或文本相同),包含则隐藏。判据与鸿蒙端 isPersistedAssistantDuplicate 对齐;active 流式中不受影响。

测试

  • 新增 Rust 回归测试:settled\_turn\_with\_already\_synced\_final\_message\_does\_not\_echo\_active\_turn
    • 场景:持久化 fence 将 turn 置为 completed、客户端 known_msg_count 已包含 final 消息时,poll 响应 active\_turn 必须为 None,且 snapshot 正常送达。
  • 建议运行:cargo test -p services-integrations

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.

1 participant