makecindy / makecindy/cindy

[Bug] 被控设备恢复在线后远程会话仍持续加载

Open
#799 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 问题描述 / What happened

控制端侧边栏已缓存显示被控设备上的会话。若被控设备离线时点击该会话,页面会进入“正在从被控设备加载对话…”状态;被控设备恢复在线后,离线提示消失,但会话仍持续加载。只有重启控制端后再次点击,才能正常显示消息。

### 预期行为

被控设备恢复在线后,当前已打开的远程会话应自动重试初始历史加载并恢复展示,不应要求重启控制端。手动“重新同步”也应能恢复失败的首拉。

### 实际行为

设备恢复在线后,会话持续显示加载中,消息历史不出现。

## 环境 / Environment

- 用户反馈版本:待补充
- 控制端:Desktop,系统版本待补充
- 被控端:Desktop,系统版本待补充
- 当前源码确认:main `8aedb3a79667dd4703b208400340ef55e68a4073`

## 复现步骤 / Steps to reproduce

1. 被控端在线且已有会话,确认控制端侧边栏能看到该会话,但不要点击。
2. 使被控端下线。
3. 在控制端点击该会话,页面显示离线提示和“正在从被控设备加载对话…”。
4. 使被控端重新上线。
5. 确认离线提示消失,但会话仍持续显示加载中。
6. 重启控制端,再次点击该会话,消息历史正常加载。

## 日志与截图 / Logs & screenshots

1. 被控端在线,会话已出现在列表:

![被控端在线且会话可见](https://github.com/user-attachments/assets/db5d49ea-ae61-41a9-9528-56bd181c9adc)

2. 被控端离线时点击会话:

![离线时进入加载状态](https://github.com/user-attachments/assets/a9e8f9fe-09ba-4428-b152-b112c34caa14)

3. 被控端恢复在线后仍持续加载:

![恢复在线后仍持续加载](https://github.com/user-attachments/assets/2cd09733-e7c3-4774-8047-d2ca6fcccb57)

4. 重启控制端后正常加载:

![重启后正常加载](https://github.com/user-attachments/assets/bb24ec06-3dd9-4b5b-bd9d-53a59f82d6a7)

## 源码定位

- [`useCCAgentChat`](https://github.com/makecindy/cindy/blob/8aedb3a79667dd4703b208400340ef55e68a4073/apps/desktop/src/renderer/hooks/useCCAgentChat.ts#L369-L375) 仅在 `sessionId` 变化时调用一次 `ensureInitialMessages`。
- [`ensureInitialMessages`](https://github.com/makecindy/cindy/blob/8aedb3a79667dd4703b208400340ef55e68a4073/apps/desktop/src/renderer/lib/makerChatStore.ts#L5124-L5137) 的初始消息请求失败后会清除 in-flight 标记并保留 `historyLoaded=false`,但没有恢复事件再次触发首拉。
- [被控设备上线](https://github.com/makecindy/cindy/blob/8aedb3a79667dd4703b208400340ef55e68a4073/apps/desktop/src/renderer/features/cc-agent/hooks/useRemoteSessionSync.ts#L384-L390) 只触发 `reconcileRemoteMessages`;该方法在 [`historyLoaded=false`](https://github.com/makecindy/cindy/blob/8aedb3a79667dd4703b208400340ef55e68a4073/apps/desktop/src/renderer/lib/makerChatStore.ts#L5548-L5569) 时直接返回。
- 设备上线前后会话 origin 没有变化,[`reconcileOpenSessionOrigins`](https://github.com/makecindy/cindy/blob/8aedb3a79667dd4703b208400340ef55e68a4073/apps/desktop/src/renderer/lib/makerChatStore.ts#L5444-L5462) 也不会触发重载。
- 控制端重启会重新挂载会话视图并再次执行初始加载,因此能够恢复。

关联但不重复:#74 / #307 处理的是远程会话列表镜像的最终收敛,本问题发生在会话已显示后、打开会话的历史首拉失败路径。

## 验收标准

- 首次历史加载因被控端离线失败后,设备恢复在线能够在当前视图自动重试。
- 不切换会话、不重启控制端即可正常展示消息历史。
- “重新同步”能够恢复 `historyLoaded=false` 的失败首拉。
- 重试复用现有 in-flight 防重机制,不产生并发重复请求。
- 增加“首次请求失败 → presence online → 同一会话加载成功”的回归测试。

Contributor guide

Open the contributing guide

Research direction

Start with useCCAgentChat.ts and makerChatStore.ts, especially ensureInitialMessages and reconcileRemoteMessages, then follow the online event in useRemoteSessionSync.ts. Reproduce the failed initial load and presence recovery, then add the regression test for retrying the same session after the device comes online. Done means the current view loads history without switching sessions or restarting, while in-flight requests remain deduplicated.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, typescript
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.