Skip to content

feat(dashbot): enable streaming responses in dashbot (#1202)#1344

Open
AbdelrahmanELBORGY wants to merge 1 commit intofoss42:mainfrom
AbdelrahmanELBORGY:feat-dashbot-streaming
Open

feat(dashbot): enable streaming responses in dashbot (#1202)#1344
AbdelrahmanELBORGY wants to merge 1 commit intofoss42:mainfrom
AbdelrahmanELBORGY:feat-dashbot-streaming

Conversation

@AbdelrahmanELBORGY
Copy link
Contributor

PR Description

This PR resolves #1202 by fully wiring up and enabling real-time streaming AI responses in Dashbot. This significantly improves the perceived responsiveness of the chat interface, eliminating the sluggish experience of waiting for the entire payload to generate.

Key Implementation Details:

  • Enabled Streaming: Updated the AI request builder in chat_viewmodel.dart to utilize stream: true and implemented the corresponding streamChat() method in ChatRemoteRepository to yield chunks over SSE.
  • Partial Extraction (Safe JSON Parsing): To mitigate the key risk of FormatException errors from mid-stream JSON chunks, this PR implements the Partial extraction approach:
    • A StringBuffer and Regex-based parser progressively extract the explanation text as chunks arrive, feeding it to currentStreamingResponse for a seamless real-time typing effect.
    • The structured JSON parsing for the actions array is safely deferred until the stream is fully closed, guaranteeing logical integrity and preventing mid-stream crashes.

Visual Proof

StreamingDashbot

Related Issues

Checklist

  • I have gone through the contributing guide
  • I have updated my branch and synced it with project main branch before making this PR
  • I am using the latest Flutter stable branch
  • I have run the tests (flutter test test/dashbot/) and all relevant tests are passing

Added/updated tests?

  • Yes
    • Added a Streaming Tests group in chat_viewmodel_test.dart.
    • Added test coverage explicitly verifying that explanation tokens are extracted progressively from partial chunks.
    • Verified that actions are only parsed after the stream is fully closed.
    • Updated existing Dashbot tests to align with the new typed message architecture.

OS on which you have developed and tested the feature?

  • Windows

feat(dashbot): enable streaming and fix raw JSON leakage in UI (foss42#1202)
- Added comprehensive streaming tests to verify partial JSON chunk parsing.
- Updated existing Dashbot tests to support the new typed message architecture.
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]: Enable Streaming Responses in Dashbot

1 participant