Skip to content

feat(extensions): add Chat contribution type (SIP-214)#41205

Open
michael-s-molina wants to merge 18 commits into
apache:masterfrom
michael-s-molina:chat-contribution-type
Open

feat(extensions): add Chat contribution type (SIP-214)#41205
michael-s-molina wants to merge 18 commits into
apache:masterfrom
michael-s-molina:chat-contribution-type

Conversation

@michael-s-molina

Copy link
Copy Markdown
Member

SUMMARY

Implements the Chat contribution type described in SIP-214, co-authored with Enzo Martellucci (@EnxDev). This introduces the chat and navigation namespaces in @apache-superset/core, giving extensions a first-class API to contribute a persistent chat interface and react to page navigation events. The host manages layout, open/close state, display mode, and persistence — extensions implement the trigger and panel components and use the API to drive behavior.

These are the first two namespaces in a planned series. Surface-specific namespaces (dashboard, explore, SQL Lab, dataset) will follow in subsequent SIPs, allowing extensions to progressively access deeper contextual information. Agentic UI actions — modifying charts, editing queries, triggering workflows — are intentionally out of scope here and deferred to the Client Actions SIP.

Singleton model

Only one chat is active at a time. This is a deliberate design choice: rendering multiple chat providers simultaneously would create competing conversational experiences and introduce ambiguity for the user. Chat is treated as a deployment-level selection rather than a multi-provider composition.

Registering a chat

import { chat } from '@apache-superset/core';
import ChatTrigger from './ChatTrigger';
import ChatPanel from './ChatPanel';

chat.registerChat(
  { id: 'my-org.my-chat', name: 'My Chat' },
  ChatTrigger,
  ChatPanel,
);

The trigger is always visible in the bottom-right corner. The panel can be shown as a floating overlay or as a resizable sidebar docked beside the page content. The user's preference is persisted across reloads.

Display modes

  • 'floating' (default) — panel opens as an overlay anchored to the trigger.
  • 'panel' — the page layout splits into content + chat sidebar with a draggable divider.

Extensions can switch modes programmatically or react to user-initiated changes:

chat.setDisplayMode('panel');

chat.onDidChangeDisplayMode(mode => {
  console.log('display mode changed to', mode);
});

Navigation awareness

The navigation namespace is new in @apache-superset/core. Extensions can query the current page or subscribe to page changes, enabling context-aware chat behavior:

import { navigation } from '@apache-superset/core';

console.log(navigation.getPage()); // e.g. 'dashboard', 'explore', 'sqllab'

navigation.onDidChangePage(page => {
  console.log('navigated to', page);
});

Documentation

The Contribution Types page and a new Chat reference page (under docs/developer_docs/extensions/) cover registration, display modes, the full open/close and event API, and the navigation namespace.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen.Recording.2026-06-18.at.10.01.17.mov

TESTING INSTRUCTIONS

Manual verification

Enable the ENABLE_EXTENSIONS feature flag, then create a minimal extension with the following index.tsx:

import React from 'react';
import { chat } from '@apache-superset/core';

const Trigger = () => {
  const handleClick = () =>
    chat.isOpen() ? chat.close() : chat.open();
  return <button onClick={handleClick}>💬</button>;
};

const Panel = () => (
  <div style={{ background: '#fff', height: '100%', padding: 16 }}>
    Hello from chat
  </div>
);

chat.registerChat({ id: 'test.chat', name: 'Test Chat' }, Trigger, Panel);

ADDITIONAL INFORMATION

  • Has associated issue
  • Required feature flags: Chat host rendering is guarded by the existing ENABLE_EXTENSIONS flag
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review

bito-code-review Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Bito Review Skipped - Source Branch Not Found

Bito didn’t review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@dosubot dosubot Bot added change:frontend Requires changing the frontend doc:developer Developer documentation labels Jun 18, 2026
@github-actions github-actions Bot added doc Namespace | Anything related to documentation dependencies:npm packages labels Jun 18, 2026
@michael-s-molina michael-s-molina moved this from To Do to In Review in Superset Extensions Jun 18, 2026
Comment thread superset-frontend/src/core/navigation/index.ts Outdated
@netlify

netlify Bot commented Jun 18, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 1847608
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a343abc7578eb0008d685d2
😎 Deploy Preview https://deploy-preview-41205--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

Copy link
Copy Markdown
Contributor

The issue is valid. The any type in ComponentType<any> and ComponentProps<any> in superset-frontend/src/views/routes.tsx bypasses TypeScript's type checking, which is discouraged.

To resolve this, you can replace any with unknown or a more specific type if available. Given the context, unknown is a safer alternative that forces explicit type narrowing when the component or props are used.

Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

superset-frontend/src/views/routes.tsx

type Routes = {
  path: string;
  Component: ComponentType<unknown>;
  Fallback?: ComponentType<unknown>;
  props?: ComponentProps<unknown>;
}[];

Comment thread superset-frontend/src/core/chat/ChatProvider.ts
Comment thread superset-frontend/src/core/chat/ChatProvider.ts
Comment thread superset-frontend/src/core/menus/index.ts Outdated
Comment thread superset-frontend/src/core/menus/index.ts Outdated
Comment thread superset-frontend/src/core/editors/EditorProviders.ts
Comment thread superset-frontend/src/core/editors/index.ts
Comment thread superset-frontend/src/core/editors/index.ts
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.89831% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.36%. Comparing base (74ae5a4) to head (0ad3ef2).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
superset-frontend/src/views/App.tsx 0.00% 26 Missing ⚠️
superset-frontend/src/views/routes.tsx 0.00% 4 Missing ⚠️
superset-frontend/src/core/editors/index.ts 50.00% 2 Missing ⚠️
superset-frontend/src/core/menus/index.ts 71.42% 2 Missing ⚠️
superset-frontend/src/core/views/index.ts 81.81% 2 Missing ⚠️
superset-frontend/src/core/chat/ChatHost.tsx 96.15% 1 Missing ⚠️
superset-frontend/src/core/storeUtils.ts 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41205      +/-   ##
==========================================
+ Coverage   64.33%   64.36%   +0.03%     
==========================================
  Files        2651     2657       +6     
  Lines      144766   144936     +170     
  Branches    33401    33435      +34     
==========================================
+ Hits        93131    93285     +154     
- Misses      49965    49981      +16     
  Partials     1670     1670              
Flag Coverage Δ
hive 39.32% <ø> (-0.01%) ⬇️
javascript 68.54% <83.89%> (+0.05%) ⬆️
mysql 58.05% <ø> (-0.01%) ⬇️
postgres 58.12% <ø> (-0.01%) ⬇️
presto 40.90% <ø> (-0.01%) ⬇️
python 59.56% <ø> (-0.01%) ⬇️
sqlite 57.78% <ø> (-0.01%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

| `onDidChangeDisplayMode(listener)` | Subscribe to display mode changes. Returns a `Disposable`. |
| `onDidRegisterChat(listener)` | Subscribe to registration events. |
| `onDidUnregisterChat(listener)` | Subscribe to unregistration events. |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@michael-s-molina would it make sense to add onDidResizePanel() here?

@bito-code-review bito-code-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Agent Run #9a27e6

Actionable Suggestions - 1
  • superset-frontend/src/core/navigation/index.ts - 1
    • CWE-20: Browser API at module load · Line 60-61
Additional Suggestions - 4
  • superset-frontend/src/views/routes.tsx - 1
    • Duplicate route registration · Line 239-239
      The `REGISTRATIONS` route is added twice: once unconditionally at line 239 and again conditionally at line 265 when `authRegistrationEnabled` is true. Remove the duplicate at line 239 to prevent redundant route registration.
      Code suggestion
      --- a/superset-frontend/src/views/routes.tsx
      +++ b/superset-frontend/src/views/routes.tsx
       @@ -236,7 +236,6 @@ const routes: Route[] = [
          { path: RoutePaths.USER_INFO, Component: UserInfo },
          { path: RoutePaths.ACTION_LOG, Component: ActionLogList },
      -  { path: RoutePaths.REGISTRATIONS, Component: UserRegistrations },
        ];
       
        if (isFeatureEnabled(FeatureFlag.TaggingSystem)) {
  • superset-frontend/src/core/chat/ChatProvider.test.ts - 2
    • Misleading test name · Line 37-37
      The test name 'returns the descriptor copy' is misleading — `getChat()` returns the original reference (ChatProvider.ts:131), not a copy. The assertion uses `toEqual` which passes due to object identity. If a true copy were intended, `toEqual` would fail since the original object would be reused.
      Code suggestion
      --- superset-frontend/src/core/chat/ChatProvider.test.ts (line 37) ---
       37:-test('registerChat sets the registration and returns the descriptor copy', () => {
      +test('registerChat sets the registration and returns the descriptor', () => {
    • Weak message assertions · Line 54-56
      Warning message assertions use only `toContain` for IDs. The test doesn't verify the 'Using X; discarding Y' message structure, so a malformed message like 'second.chat, first.chat' would pass.
      Code suggestion
      --- superset-frontend/src/core/chat/ChatProvider.test.ts (lines 54-56) ---
       54:   expect(warn).toHaveBeenCalledTimes(1);
       55:   expect(warn.mock.calls[0][0]).toContain('second.chat');
       56:   expect(warn.mock.calls[0][0]).toContain('first.chat');
      +  expect(warn.mock.calls[0][0]).toMatch(/Using ".*"; discarding ".*"/);
  • docs/developer_docs/sidebars.js - 1
    • Sidebar naming inconsistency · Line 50-51
      The 'Extension Points' category in developer_docs/sidebars.js now has 3 items (sqllab, editors, chat), but docs/sidebarTutorials.js only has 2 (sqllab, editors). Verify whether the chat extension point should also be added to the tutorials sidebar for consistency.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/src/core/chat/ChatHost.test.tsx - 1
Review Details
  • Files reviewed - 33 · Commit Range: 380e700..0ad3ef2
    • docs/developer_docs/sidebars.js
    • superset-frontend/packages/superset-core/src/chat/index.ts
    • superset-frontend/packages/superset-core/src/common/index.ts
    • superset-frontend/packages/superset-core/src/contributions/index.ts
    • superset-frontend/packages/superset-core/src/index.ts
    • superset-frontend/packages/superset-core/src/navigation/index.ts
    • superset-frontend/packages/superset-core/src/views/index.ts
    • superset-frontend/src/core/chat/ChatHost.test.tsx
    • superset-frontend/src/core/chat/ChatHost.tsx
    • superset-frontend/src/core/chat/ChatProvider.test.ts
    • superset-frontend/src/core/chat/ChatProvider.ts
    • superset-frontend/src/core/chat/index.test.ts
    • superset-frontend/src/core/chat/index.ts
    • superset-frontend/src/core/editors/EditorProviders.test.ts
    • superset-frontend/src/core/editors/EditorProviders.ts
    • superset-frontend/src/core/editors/index.ts
    • superset-frontend/src/core/index.ts
    • superset-frontend/src/core/menus/index.ts
    • superset-frontend/src/core/navigation/index.test.ts
    • superset-frontend/src/core/navigation/index.ts
    • superset-frontend/src/core/sqlLab/index.ts
    • superset-frontend/src/core/storeUtils.ts
    • superset-frontend/src/core/utils.ts
    • superset-frontend/src/core/views/index.ts
    • superset-frontend/src/extensions/ExtensionsLoader.test.ts
    • superset-frontend/src/extensions/ExtensionsStartup.test.tsx
    • superset-frontend/src/extensions/ExtensionsStartup.tsx
    • superset-frontend/src/extensions/Namespaces.ts
    • superset-frontend/src/utils/localStorageHelpers.ts
    • superset-frontend/src/views/App.tsx
    • superset-frontend/src/views/routePaths.ts
    • superset-frontend/src/views/routes.tsx
    • superset/extensions/utils.py
  • Files skipped - 4
    • docs/developer_docs/extensions/contribution-types.md - Reason: Filter setting
    • docs/developer_docs/extensions/extension-points/chat.md - Reason: Filter setting
    • superset-frontend/package-lock.json - Reason: Filter setting
    • superset-frontend/packages/superset-core/package.json - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment on lines +60 to +61
const pageEmitter = createValueEventEmitter<Page>(
derivePage(window.location.pathname),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CWE-20: Browser API at module load

Module-level code on line 61 calls window.location.pathname directly at import time, causing a ReferenceError in non-browser environments (SSR, Jest, unit tests). The pageEmitter must be initialized with a static default value ('home'), with the actual page set when useNavigationTracker runs. (See also: CWE-20)

Code Review Run #9a27e6


Should Bito avoid suggestions like this for future reviews? (Manage Rules)

  • Yes, avoid them

@EnxDev EnxDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just a few minor nits.

Thank you for all the work you've put into this.
It was a pleasure collaborating with you, and I really enjoyed working together on it!

<Suspense fallback={<Fallback />}>
<ErrorBoundary
css={css`
margin: 16px;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wath do you think to use the Antd Token here? Like theme.fontSizeLG

height: 100vh;
overflow: hidden;
`}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you think it would make sense to replace this with the Ant Design <Flex> component here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dependencies:npm doc:developer Developer documentation doc Namespace | Anything related to documentation hold:sip! packages size/XXL

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants