refactor(chat): unify streaming state flow and improve chat viewport + mention UX#1327
Conversation
…unctions and integrating new stream handling utilities for improved performance
…re event processing for improved performance and maintainability
… interrupt request processing in NewChatPage for improved performance and maintainability
…nd contentType for enhanced report panel state management
…new chat routes for improved user experience and error handling
…r improved chat UI structure and functionality
…ed readability and maintainability
…fect for improved user experience
…avior consistency
|
@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…d segment rendering for improved message display
…dling and text processing for better user interaction
… trigger slot and enhanced visibility handling
Description
shareTokenandcontentTypeso report/thread context resets correctly.ChatViewport/NestedScroll, then simplified layout and scroll behavior for more consistent UX.TruncatedNameWithTooltipcomponent in model selector.Motivation and Context
FIX #
Screenshots
API Changes
Change Type
Testing Performed
Checklist
High-level PR Summary
This PR implements a comprehensive chat state unification system that introduces graceful turn cancellation with exponential backoff retry logic. The backend now tracks cancel requests with timestamps and attempt counts, exposes new
/cancel-active-turnand/turn-statusendpoints, and emits real-timeturn-statusSSE events (idle,busy,cancelling). The frontend refactors stream processing into shared pipelines, adds automatic retry logic withTURN_CANCELLINGerror handling, and reorganizes UI components for consistent viewport behavior across chat, free-chat, and public-chat contexts. The changes ensure concurrent request blocking is handled smoothly with client-side retry hints rather than hard failures.⏱️ Estimated Review Time: 1-3 hours
💡 Review Order Suggestion
surfsense_backend/app/agents/new_chat/middleware/busy_mutex.pysurfsense_backend/app/schemas/new_chat.pysurfsense_backend/app/routes/new_chat_routes.pysurfsense_backend/app/services/new_streaming_service.pysurfsense_backend/app/tasks/chat/stream_new_chat.pysurfsense_backend/tests/unit/agents/new_chat/test_busy_mutex.pysurfsense_backend/tests/unit/test_stream_new_chat_contract.pysurfsense_web/lib/chat/streaming-state.tssurfsense_web/lib/chat/chat-error-classifier.tssurfsense_web/lib/chat/chat-request-errors.tssurfsense_web/lib/chat/stream-flush.tssurfsense_web/lib/chat/stream-pipeline.tssurfsense_web/lib/chat/stream-side-effects.tssurfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsxsurfsense_web/components/assistant-ui/chat-viewport.tsxsurfsense_web/components/assistant-ui/nested-scroll.tsxsurfsense_web/components/assistant-ui/thread.tsxsurfsense_web/components/assistant-ui/tool-fallback.tsxsurfsense_web/components/free-chat/free-thread.tsxsurfsense_web/components/public-chat/public-thread.tsxsurfsense_web/atoms/chat/current-thread.atom.tssurfsense_web/components/assistant-ui/thread-scroll-to-bottom.tsxsurfsense_web/atoms/chat/current-thread.atom.tssurfsense_web/components/assistant-ui/thread-scroll-to-bottom.tsx