Skip to content

Comments

Add chatbot tab to help panel#240

Merged
apinkert merged 2 commits intoRedHatInsights:masterfrom
apinkert:va-tab
Feb 19, 2026
Merged

Add chatbot tab to help panel#240
apinkert merged 2 commits intoRedHatInsights:masterfrom
apinkert:va-tab

Conversation

@apinkert
Copy link
Collaborator

For RHCLOUD-42925. If you want to mess with this branch, you need to comment out the feature flag, platform.chrome.help-panel_chatbot in HelpPanelCustomTabs.tsx. This PR adds the virtual assistant tab that consumes the embeddable VA component exposed in astro-virtual-assistant-frontend.

Screen.Recording.2026-02-19.at.11.26.26.AM.mov

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Summary by CodeRabbit

  • New Features

    • Added a Virtual Assistant tab/panel in HelpPanel to provide in-app assistant functionality and a friendly unavailable message when not reachable.
  • Improvements

    • Improved tab rendering and ARIA attributes for better accessibility.
    • Faster tab title update responsiveness (reduced debounce) and loading fallback with spinner and graceful error messaging.
  • Tests

    • Added comprehensive tests covering VA tab visibility, rendering, title updates, ARIA states, and error handling.

Walkthrough

Adds a Virtual Assistant (VA) tab to HelpPanel: a new VAPanel component loads the remote VAEmbed via Scalprum, TabType and mapper updated, HelpPanel tab UI adjusted, a new i18n message added, and Cypress component tests and mocks extended to cover VA behavior and feature-flag gating.

Changes

Cohort / File(s) Summary
VA Panel Component & Mapping
src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx, src/components/HelpPanel/HelpPanelTabs/helpPanelTabsMapper.ts
New VAPanel component rendering a ScalprumComponent for virtualAssistant#./VAEmbed; adds TabType.va and maps it to VAPanel. Error UI logs failures and shows an i18n message.
HelpPanel Tab UI
src/components/HelpPanel/HelpPanelCustomTabs.tsx
Adds a Virtual Assistant sub-tab (OutlinedCommentsIcon) behind a feature flag; adjusts tab title rendering to use TabTitleText and sets aria-labels consistently; reduces search debounce to 100ms.
Messages / i18n
src/Messages.ts
Adds virtualAssistantNotAvailable message id helpPanel.va.notAvailable with a default message for VA unavailability.
Tests & Mocks
cypress/component/HelpPanel.cy.tsx
Adds VA-related mocks (virtualAssistant state, VAEmbed) and multiple Cypress tests validating VA tab visibility by feature flag, tab interactions, ARIA attributes, title updates, panel rendering, and manifest-load exception handling.
Other
cypress/...
Test-only mocking and setup adjustments to expose minimal VA state and embed component for component tests.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User as User
  participant UI as HelpPanel UI
  participant Tabs as Tab Router
  participant Scalprum as ScalprumComponent
  participant VA as virtualAssistant (remote)
  participant Spinner as Spinner

  User->>UI: open HelpPanel / click "Virtual Assistant" tab
  UI->>Tabs: select TabType.va
  Tabs->>Scalprum: mount ScalprumComponent for VAEmbed
  Scalprum->>Spinner: show loading fallback
  Scalprum->>VA: request module "virtualAssistant#./VAEmbed"
  alt module loads successfully
    VA-->>Scalprum: return VAEmbed component
    Scalprum-->>UI: render VAEmbed inside VAPanel
    UI-->>User: display VA panel content
  else module fails to load
    VA-->>Scalprum: error
    Scalprum-->>UI: render VAErrorElement (i18n message + console.error)
    UI-->>User: display "virtual assistant not available" message
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add chatbot tab to help panel' accurately summarizes the main change: adding a virtual assistant/chatbot tab to the help panel component.
Description check ✅ Passed The description clearly relates to the changeset by referencing the specific feature implementation (VA tab), the issue ID (RHCLOUD-42925), required configuration steps, and the underlying component consumed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx (1)

8-10: Prefix unused prop with underscore to suppress lint warnings.

The setNewActionTitle prop is required by the SubTabProps interface but intentionally unused here. Prefixing with underscore signals this is intentional.

Suggested fix
 const VAPanel: React.FC<{
   setNewActionTitle: (title: string) => void;
-}> = () => {
+}> = ({ setNewActionTitle: _setNewActionTitle }) => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx` around lines 8 - 10, The
VAPanel component declares a required prop setNewActionTitle that is unused and
triggers lint warnings; rename/prefix it with an underscore to indicate
intentional non-use—e.g., update the prop name in the VAPanel props signature
and/or the component parameter to _setNewActionTitle (referencing VAPanel and
setNewActionTitle/SubTabProps) so the unused prop is accepted but lint ignores
it.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx`:
- Line 24: The ErrorComponent prop in VAPanel is currently set to a JSX element
instance ("ErrorComponent: <Fragment />") which should be a component type that
accepts { error, errorInfo }; change it to a component type (e.g., use Fragment
without JSX or implement a small functional component) and ensure it renders
useful feedback (at least show error.message and/or errorInfo) instead of
silently swallowing failures; update the ErrorComponent assignment to reference
that component type so `@scalprum/react-core` can pass error props to it.

---

Nitpick comments:
In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx`:
- Around line 8-10: The VAPanel component declares a required prop
setNewActionTitle that is unused and triggers lint warnings; rename/prefix it
with an underscore to indicate intentional non-use—e.g., update the prop name in
the VAPanel props signature and/or the component parameter to _setNewActionTitle
(referencing VAPanel and setNewActionTitle/SubTabProps) so the unused prop is
accepted but lint ignores it.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx (2)

10-26: Move console.error into a useEffect to log only once on mount.

The console.error call in the render body will execute on every re-render, potentially spamming the console with duplicate messages if the parent component re-renders.

♻️ Suggested fix
+import React, { useEffect } from 'react';
-import React from 'react';
 import { Content, Spinner, Stack, StackItem } from '@patternfly/react-core';
 ...

 const VAErrorElement: React.FC = () => {
   const intl = useIntl();

-  // Log error on render
-  console.error('VA Panel: Virtual Assistant module failed to load');
+  useEffect(() => {
+    console.error('VA Panel: Virtual Assistant module failed to load');
+  }, []);

   return (
     ...
   );
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx` around lines 10 - 26, The
console.error call inside the VAErrorElement render causes logging on every
re-render; move it into a React effect so it logs only once on mount: in
VAErrorElement (which uses useIntl and messages.virtualAssistantNotAvailable)
remove the inline console.error and add a useEffect(() => { console.error('VA
Panel: Virtual Assistant module failed to load'); }, []); (import or reference
React.useEffect as needed) so the error is emitted once when the component
mounts.

28-30: Unused prop setNewActionTitle.

The prop is declared in the component's type signature but never used. Either remove it from the type if it's not needed, or implement the intended functionality.

♻️ Option 1: Remove unused prop
-const VAPanel: React.FC<{
-  setNewActionTitle: (title: string) => void;
-}> = () => {
+const VAPanel: React.FC = () => {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx` around lines 28 - 30, The
VAPanel component type declares a prop setNewActionTitle that is never used;
either remove this prop from VAPanel's React.FC type signature or implement its
intended behavior where new action titles are set (e.g., call
setNewActionTitle(...) from the handler that creates or updates an action).
Locate the VAPanel declaration and either delete setNewActionTitle from the prop
type object or wire the prop into the relevant function/handler inside VAPanel
so the prop is consumed.
cypress/component/HelpPanel.cy.tsx (1)

515-516: Outdated comment: ErrorComponent is no longer an empty Fragment.

The comment states the ErrorComponent falls back to an "empty Fragment," but the actual implementation in VAPanel.tsx uses VAErrorElement which renders a visible error message. Update the comment to reflect the current behavior.

📝 Suggested fix
     // Click on the Virtual Assistant tab - this will try to load the ScalprumComponent
-    // but will gracefully fall back to the ErrorComponent (empty Fragment)
+    // but will gracefully fall back to the VAErrorElement which displays an error message
     cy.get('[data-ouia-component-id="help-panel-subtab-va"]').click();

-    // Since the ScalprumComponent will fail to load but has ErrorComponent: <Fragment />
-    // we just verify that the tab switching worked and no crash occurred
+    // Verify that the tab switching worked and no crash occurred
     cy.get('[data-ouia-component-id="help-panel-subtab-va"]').should('have.attr', 'aria-selected', 'true');
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cypress/component/HelpPanel.cy.tsx` around lines 515 - 516, The comment in
HelpPanel.cy.tsx incorrectly says the ScalprumComponent's ErrorComponent is an
"empty Fragment"; update that comment to reflect the current implementation in
VAPanel.tsx where ErrorComponent renders a visible error via VAErrorElement
(i.e., state that the ErrorComponent displays a visible error message rather
than being an empty Fragment), and keep the rest of the note about verifying tab
switching and no crash intact; reference ScalprumComponent, ErrorComponent,
VAPanel.tsx, and VAErrorElement when editing the comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx`:
- Line 44: The ErrorComponent prop is being passed an element instance instead
of a component type and the Scalprum error details are not being captured;
change the prop value from "ErrorComponent: <VAErrorElement />" to
"ErrorComponent: VAErrorElement" and update the VAErrorElement component to
accept the expected props signature ({ error, errorInfo }) and inside
VAErrorElement capture and log the provided error and errorInfo as well as any
Scalprum-specific error details (e.g., from the errorInfo or Scalprum context)
so the full error payload is preserved and emitted to your logging mechanism.

---

Nitpick comments:
In `@cypress/component/HelpPanel.cy.tsx`:
- Around line 515-516: The comment in HelpPanel.cy.tsx incorrectly says the
ScalprumComponent's ErrorComponent is an "empty Fragment"; update that comment
to reflect the current implementation in VAPanel.tsx where ErrorComponent
renders a visible error via VAErrorElement (i.e., state that the ErrorComponent
displays a visible error message rather than being an empty Fragment), and keep
the rest of the note about verifying tab switching and no crash intact;
reference ScalprumComponent, ErrorComponent, VAPanel.tsx, and VAErrorElement
when editing the comment.

In `@src/components/HelpPanel/HelpPanelTabs/VAPanel.tsx`:
- Around line 10-26: The console.error call inside the VAErrorElement render
causes logging on every re-render; move it into a React effect so it logs only
once on mount: in VAErrorElement (which uses useIntl and
messages.virtualAssistantNotAvailable) remove the inline console.error and add a
useEffect(() => { console.error('VA Panel: Virtual Assistant module failed to
load'); }, []); (import or reference React.useEffect as needed) so the error is
emitted once when the component mounts.
- Around line 28-30: The VAPanel component type declares a prop
setNewActionTitle that is never used; either remove this prop from VAPanel's
React.FC type signature or implement its intended behavior where new action
titles are set (e.g., call setNewActionTitle(...) from the handler that creates
or updates an action). Locate the VAPanel declaration and either delete
setNewActionTitle from the prop type object or wire the prop into the relevant
function/handler inside VAPanel so the prop is consumed.

Copy link
Collaborator

@InsaneZein InsaneZein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apinkert apinkert merged commit c80a1d4 into RedHatInsights:master Feb 19, 2026
9 checks passed
@apinkert apinkert deleted the va-tab branch February 19, 2026 18:38
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.

2 participants