Skip to content

fix: resume analysis streams after chat disconnects - #104

Merged
hustcc merged 3 commits into
mainfrom
fix/chat-stream-reconnect
Nov 26, 2026
Merged

hustcc merged 3 commits into
mainfrom
fix/chat-stream-reconnect

Conversation

@hustcc

@hustcc hustcc commented Nov 25, 2026

Copy link
Copy Markdown
Member

@hustcc
hustcc force-pushed the fix/chat-stream-reconnect branch from 18e24c8 to 0ae7e4b Compare November 25, 2026 14:01
@hustcc
hustcc requested review from lxfu1 and yvonneyx and a balanced review from Copilot and removed request for Copilot November 25, 2026 14:05

Copilot AI 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.

🟡 Changes recommended

Snapshot replay can duplicate live text chunks, and reader cancellation clears the running indicator and stops completion tracking while analysis continues in the background.

2 open issues
What changed in this PR

This PR lets chats reconnect to ongoing analysis without cancelling background work, supporting the session-switching workflow tracked in #45.

Changes:

  • Buffer analysis chunks and expose snapshots through a new reconnect API.
  • Replay buffered chunks and resume live streaming after loading chat history.
  • Keep analysis running when a renderer stream disconnects.
File Description
src/​shared/​api.ts Defines the stream snapshot type and reconnect API.
src/​renderer/​components/​chat/​ipc-chat-transport.ts Adds snapshot replay and live reconnection; removes cancellation on disconnect.
src/​renderer/​components/​chat/​chat.tsx Attempts stream recovery after loading conversation history.
src/​preload/​index.ts Exposes reconnect through the typed IPC bridge.
src/​main/​services/​analysis/​index.ts Buffers active-task chunks and provides reconnect snapshots.
src/​main/​ipc/​index.ts Handles reconnect requests and forwards stream events.

Review effort: Balanced

@yvonneyx

Copy link
Copy Markdown
Contributor

@hustcc 发送和重连的 IPC 订阅应该还能共用一套逻辑,简化一些,也能防止两路同时存在会有重复chunk的问题。合适的话我补个commit到这个 pr。

@hustcc

hustcc commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

@yvonneyx transport 中新增 commit 的改动还是把 getMessage 和 reconnect 耦合在一起了,看看是否必要,没有必要就不去耦合了。

@hustcc
hustcc merged commit 1c28c02 into main Nov 26, 2026
2 checks passed
@hustcc
hustcc deleted the fix/chat-stream-reconnect branch November 26, 2026 10:06
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