feat: background AI generation with session-level isolation and hard-…#349
Open
Xiao-ao-jiang-hu wants to merge 1 commit intovolcengine:mainfrom
Open
Conversation
…delete conversation
- Add BackgroundGenerationManager (asyncio.Semaphore(3)) so generation
tasks survive HTTP disconnects when users switch conversations
- Refactor /api/agent/chat/stream: separate background task writes to DB
while SSE generator relays from asyncio.Queue; return 429 when limit hit
- Add GET /api/agent/generation/status and DELETE /api/agent/generation/{sid}
- Add hard_delete_conversation (cascade: message_thinking -> messages ->
conversations) replacing soft delete; cancel background task before delete
- Frontend: per-conversation AbortController map so switching tabs does not
abort other conversations' background streams
- Redux: backgroundGeneratingConversations[] tracks active streams
- Chat history list item: Spin badge when conversation is generating,
dispatch deleteConversation action for immediate sidebar removal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Background Generation Tracking and State Management:
backgroundGeneratingConversationsarray to the Reduxchat-historystate to track which conversations have active background generation streams, along with actions and reducers to add or remove conversation IDs as streams start or stop. [1] [2] [3] [4]use-chat-streamhook to dispatch Redux actions when a conversation’s generation starts or ends, ensuring global state accurately reflects ongoing background activity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]UI Improvements for Generation Status:
ChatHistoryListItemcomponent to display a spinner (Spin) next to conversations that are currently generating, based on Redux state, and to immediately remove conversations from the sidebar UI upon deletion. [1] [2] [3] [4]Chat Streaming Service Refactor:
ChatStreamServiceto maintain a map ofAbortControllerinstances per conversation, allowing independent start/stop of streams for each conversation and avoiding interference between simultaneous background generations. Added methods to abort streams for a specific conversation or all conversations, and to check if a conversation is currently streaming. [1] [2] [3]These changes collectively enable more reliable, responsive, and user-friendly background AI chat generation across multiple conversations.
Closes: #348