Skip to content

fix(intelligent-assistant): sources chip on stream end and unknown route handling - #4860

Open
rohitratannagar wants to merge 2 commits into
redhat-developer:mainfrom
rohitratannagar:fix/intelligent-assistant-notebook-sources-chip
Open

rohitratannagar wants to merge 2 commits into
redhat-developer:mainfrom
rohitratannagar:fix/intelligent-assistant-notebook-sources-chip

Conversation

@rohitratannagar

@rohitratannagar rohitratannagar commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Description

Notebook sources chip

Notebook chat did not show the RAG sources chip until the page was refreshed, even though the assistant response had finished and the server already had referenced_documents.

This change fixes three gaps in the live notebook path:

  1. SSE parsing — Flush the decoder when the stream closes and parse a trailing end frame so referenced_documents are applied even when the final chunk has no \n\n delimiter.
  2. Persisted merge — After the stream reaches complete, merge sources from refetched conversation messages when the in-memory transcript is still missing them.
  3. UI refresh — Include the source count in the PatternFly Message React key so SourcesChipModal mounts when sources arrive after tokens stop.

Root cause: The sources chip depends on referenced_documents from the SSE end event and on endContent updating on the last bot message. Trailing SSE data could be dropped on reader.done, and the message component did not remount when only sources changed (content unchanged), so the chip appeared only after a full reload from the API.

Unknown Intelligent Assistant URLs

Visiting an unrecognized path under /intelligent-assistant (for example /intelligent-assistant/sdc) previously rendered a blank screen.

The plugin router now catches unknown subpaths and:

  • Redirects to /intelligent-assistant when intelligent-assistant.chat is allowed (uses LIGHTSPEED_PATH, not app root /).
  • Shows a 404 when chat access is denied.

Test Plan

  • Open a notebook with uploaded documents and send a prompt that returns RAG sources.
  • Confirm the sources chip appears when the response completes, without refreshing the page.
  • Open the chip popover and verify document titles/links.
  • Send a follow-up message and confirm chips on earlier and latest bot replies.
  • Switch Lightspeed display mode (overlay/docked/fullscreen) and confirm sources chips remain visible.
  • Navigate to /intelligent-assistant/<unknown> with chat allowed — should land on /intelligent-assistant with the chat UI.
  • Navigate to /intelligent-assistant/<unknown> without chat permission — should show Backstage 404.

Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Parse trailing SSE end events for referenced_documents, merge persisted
sources when the stream completes, and remount chat messages when source
count changes so the sources chip appears without a page refresh.

Signed-off-by: rohitratannagar <rohitratannagar2003@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rhdh-gh-app

rhdh-gh-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-intelligent-assistant workspaces/intelligent-assistant/plugins/intelligent-assistant patch v5.2.0

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.57895% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.60%. Comparing base (0385824) to head (02dd224).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4860   +/-   ##
=======================================
  Coverage   63.59%   63.60%           
=======================================
  Files        2685     2685           
  Lines      107076   107109   +33     
  Branches    29978    29976    -2     
=======================================
+ Hits        68099    68126   +27     
- Misses      37159    37165    +6     
  Partials     1818     1818           
Flag Coverage Δ *Carryforward flag
adoption-insights 84.77% <ø> (ø) Carriedforward from f4a8f63
ai-integrations 82.63% <ø> (ø) Carriedforward from f4a8f63
app-defaults 54.82% <ø> (ø) Carriedforward from f4a8f63
augment 46.67% <ø> (ø) Carriedforward from f4a8f63
boost 84.97% <ø> (ø) Carriedforward from f4a8f63
bulk-import 73.12% <ø> (ø) Carriedforward from f4a8f63
cost-management 13.53% <ø> (ø) Carriedforward from f4a8f63
dcm 73.47% <ø> (ø) Carriedforward from f4a8f63
e2e-adoption-insights 60.00% <ø> (ø) Carriedforward from f4a8f63
e2e-extensions 62.31% <ø> (ø) Carriedforward from f4a8f63
e2e-global-header 51.82% <ø> (ø) Carriedforward from f4a8f63
e2e-homepage 61.11% <ø> (ø) Carriedforward from f4a8f63
e2e-intelligent-assistant 45.99% <ø> (-0.03%) ⬇️ Carriedforward from f4a8f63
e2e-orchestrator 49.49% <ø> (ø) Carriedforward from f4a8f63
e2e-orchestrator-plugin 49.48% <ø> (ø) Carriedforward from f4a8f63
e2e-quickstart 55.21% <ø> (ø) Carriedforward from f4a8f63
e2e-scorecard 50.00% <ø> (ø) Carriedforward from f4a8f63
e2e-theme 16.36% <ø> (ø) Carriedforward from f4a8f63
extensions 58.30% <ø> (ø) Carriedforward from f4a8f63
global-floating-action-button 71.18% <ø> (ø) Carriedforward from f4a8f63
global-header 67.76% <ø> (ø) Carriedforward from f4a8f63
homepage 55.05% <ø> (ø) Carriedforward from f4a8f63
install-dynamic-plugins 71.77% <ø> (ø) Carriedforward from f4a8f63
intelligent-assistant 78.05% <81.57%> (+0.01%) ⬆️
konflux 91.98% <ø> (ø) Carriedforward from f4a8f63
lightspeed 69.02% <ø> (ø) Carriedforward from f4a8f63
mcp-integrations 84.46% <ø> (ø) Carriedforward from f4a8f63
orchestrator 77.69% <ø> (ø) Carriedforward from f4a8f63
quickstart 63.74% <ø> (ø) Carriedforward from f4a8f63
sandbox 79.56% <ø> (ø) Carriedforward from f4a8f63
scorecard 88.71% <ø> (ø) Carriedforward from f4a8f63
theme 87.91% <ø> (ø) Carriedforward from f4a8f63
translations 5.12% <ø> (ø) Carriedforward from f4a8f63
x2a 78.44% <ø> (ø) Carriedforward from f4a8f63

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0385824...02dd224. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Handle unrecognized paths under /intelligent-assistant with RBAC-aware
redirect to LIGHTSPEED_PATH or a 404 when chat access is denied.

Co-authored-by: Cursor <cursoragent@cursor.com>
@rohitratannagar rohitratannagar changed the title fix(intelligent-assistant): show notebook sources chip when streaming completes fix(intelligent-assistant): sources chip on stream end and unknown route handling Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant