fix(backup): defer auto backup during streaming response#13307
Conversation
- 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
|
|
||
| // Check if any topic is currently streaming/loading | ||
| const state = store.getState() | ||
| const anyTopicLoading = Object.values(state.messages.loadingByTopic).some((loading) => loading === true) |
There was a problem hiding this comment.
Nit: Consider defaulting loadingByTopic to {} before Object.values for extra safety during partial hydration.
zhibisora
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
### 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]>
What this PR does
Before this PR:
After this PR:
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:
loadingByTopic) rather than complex queuing mechanismAlternatives considered:
Breaking changes
None
Special notes for your reviewer
The fix adds a streaming detection check in
performAutoBackupfunction. It checks the Redux stateloadingByTopicto 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
Release note