Skip to content

fix(backup): defer auto backup during streaming response#13307

Merged
DeJeune merged 1 commit intomainfrom
fix/13216-defer-backup-during-streaming
Mar 9, 2026
Merged

fix(backup): defer auto backup during streaming response#13307
DeJeune merged 1 commit intomainfrom
fix/13216-defer-backup-during-streaming

Conversation

@GeorgeDong32
Copy link
Copy Markdown
Collaborator

What this PR does

Before this PR:

  • Auto backup (WebDAV, S3, local) could trigger during an ongoing streaming response
  • This caused incomplete conversation state to be saved
  • Synced devices would receive truncated/unusable conversations
  • Users experienced "half-response" frozen state with no way to recover

After this PR:

  • Auto backup checks if any topic is currently streaming before starting
  • Backup is deferred until all streaming responses complete
  • Conversations are only backed up in consistent states
  • No more conversation truncation or freeze issues during backup

Fixes #13216

Why we need it and why it was done in this way

The issue occurs when auto backup triggers during an active streaming response. The backup captures an incomplete state of the conversation, which then syncs to other devices and causes permanent corruption.

Tradeoffs made:

  • Backup is deferred rather than cancelled - ensures backup still happens eventually
  • Simple state check (loadingByTopic) rather than complex queuing mechanism
  • Minimal code change to reduce risk

Alternatives considered:

  • Pause streaming during backup - would affect user experience
  • Queue backup requests - more complex implementation
  • Skip backup entirely if streaming - could miss backup window

Breaking changes

None

Special notes for your reviewer

The fix adds a streaming detection check in performAutoBackup function. It checks the Redux state loadingByTopic to determine if any topic is currently receiving a streaming response. If streaming is detected, the backup is deferred (the next scheduled backup will handle it).

Checklist

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: N/A - minimal bug fix
  • Upgrade: N/A - no data schema changes
  • Documentation: N/A - internal bug fix, no user-facing changes to document
  • Self-review: Completed

Release note

Fix auto backup interrupting streaming responses, preventing conversation truncation and freeze issues

- Add streaming detection in performAutoBackup function
- Check loadingByTopic state before starting backup
- Defer backup if any topic is currently streaming to prevent
  saving incomplete conversation state
- Apply to all backup types: WebDAV, S3, and local

Closes: #13216
Copy link
Copy Markdown
Contributor

@cherry-ai-bot cherry-ai-bot bot left a comment

Choose a reason for hiding this comment

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

Nice fix overall. Minimal and clear change that addresses backup consistency during streaming. I left one minor inline suggestion to default loadingByTopic to an empty object before Object.values for extra safety during state transitions.


// Check if any topic is currently streaming/loading
const state = store.getState()
const anyTopicLoading = Object.values(state.messages.loadingByTopic).some((loading) => loading === true)
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.

Nit: Consider defaulting loadingByTopic to {} before Object.values for extra safety during partial hydration.

@DeJeune DeJeune requested a review from zhibisora March 9, 2026 10:11
Copy link
Copy Markdown
Collaborator

@zhibisora zhibisora left a comment

Choose a reason for hiding this comment

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

Thanks for the focused fix — this addresses the core data-consistency issue by preventing auto backup from running during an active stream, which is the important part here.\n\nApproved. I left one non-blocking suggestion about the reschedule strategy: resets the timer by a full interval, so a future refinement could retry shortly after streaming finishes to match the defer-until-complete behavior more closely.


if (anyTopicLoading) {
logger.info(`${logPrefix} Streaming in progress, deferring backup`)
scheduleNextBackup('fromNow', backupType)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggestion: This fixes the corruption risk well. As a follow-up, consider retrying soon after streaming finishes (or using a short backoff) instead of rescheduling from . With longer sync intervals, postpones a due backup by a full cycle, while a pending-or-short-retry approach would stay closer to the PR description of deferring until streaming completes.

@DeJeune DeJeune merged commit 7d21b0d into main Mar 9, 2026
21 checks passed
@DeJeune DeJeune deleted the fix/13216-defer-backup-during-streaming branch March 9, 2026 12:07
@kangfenmao kangfenmao mentioned this pull request Mar 13, 2026
6 tasks
kangfenmao added a commit that referenced this pull request Mar 13, 2026
### What this PR does

Before this PR:
- Version is 1.7.24

After this PR:
- Version is 1.7.25
- Release notes updated in `electron-builder.yml`

### Why we need it and why it was done in this way

Standard release workflow: collect commits since v1.7.24, generate
bilingual release notes, bump version.

The following tradeoffs were made:
N/A

The following alternatives were considered:
N/A

### Breaking changes

**Action Required**: The built-in filesystem MCP server now requires
manual approval for write/edit/delete operations by default.

### Special notes for your reviewer

**Included commits since v1.7.24:**

✨ New Features:
- feat(websearch): add Querit search provider (#13050)
- feat(minapp,provider): add MiniMax Agent, IMA mini apps and MiniMax
Global, Z.ai providers (#13099)
- feat(provider): add agent support filter for provider list (#11932)
- feat(agent): add custom environment variables to agent configuration
(#13357)
- feat: add GPT-5.4 support (#13293)
- feat(gemini): add thought signature persistence (#13100)

🐛 Bug Fixes:
- fix: secure built-in filesystem MCP root handling (#13294)
- fix: check underlying tool permissions for hub invoke/exec (#13282)
- fix: remove approval countdown timers and add system notifications
(#13281)
- fix: agent tool status not stopping on abort (#13111)
- fix: resolve spawn ENOENT on Windows for Code Tools (#13405)
- fix: Use default assistant for topic auto-renaming (#13387)
- fix(backup): defer auto backup during streaming response (#13307)
- fix(ui): fix Move To submenu overflow (#13399)
- fix: render xml fenced svg blocks as svg previews (#13431)
- fix: correct Gemini reasoning params (#13388)
- fix: improve Qwen 3.5 reasoning model detection (#13235)
- fix: upgrade xAI web search to Responses API (#12812)
- fix(api-server): relax chat completion validation (#13279)
- fix: install or uninstall button state issues (#13114)
- fix: improve update dialog behavior (#13363)
- fix: auto-convert reasoning_effort to reasoningEffort (#12831)

### Checklist

- [x] PR: The PR description is expressive enough and will help future
contributors
- [x] Code: Write code that humans can understand and Keep it simple
- [x] Refactor: You have left the code cleaner than you found it (Boy
Scout Rule)
- [x] Upgrade: Impact of this change on upgrade flows was considered and
addressed if required
- [x] Documentation: A user-guide update was considered and is present
(link) or not required.
- [x] Self-review: I have reviewed my own code before requesting review
from others

### Release note

```release-note
See release notes in electron-builder.yml
```

---------

Signed-off-by: kangfenmao <[email protected]>
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.

[Bug]: Auto WebDAV Backup Interrupts Streaming Response Causing Conversation Truncation and Freeze

3 participants