Skip to content

feat: background AI generation with session-level isolation and hard-…#349

Open
Xiao-ao-jiang-hu wants to merge 1 commit into
volcengine:mainfrom
Xiao-ao-jiang-hu:feature/background-generation-session-delete
Open

feat: background AI generation with session-level isolation and hard-…#349
Xiao-ao-jiang-hu wants to merge 1 commit into
volcengine:mainfrom
Xiao-ao-jiang-hu:feature/background-generation-session-delete

Conversation

@Xiao-ao-jiang-hu

@Xiao-ao-jiang-hu Xiao-ao-jiang-hu commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Description
Background Generation Tracking and State Management:

  • Added a backgroundGeneratingConversations array to the Redux chat-history state 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]
  • Updated the use-chat-stream hook 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:

  • Enhanced the ChatHistoryListItem component 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:

  • Refactored ChatStreamService to maintain a map of AbortController instances 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

…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

@codeCraft-Ritik codeCraft-Ritik 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.

Nice enhancement! Tracking background generation state in Redux provides a clear source of truth for active conversations, and the UI feedback with generation indicators should improve the user experience significantly. The stream management refactor also looks like a solid step toward supporting concurrent generations more reliably.

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.

[FEATURE]: Background Chat Generation

2 participants