You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2026/06/12 18:54:21 UTC
(superset) branch enxdev/chat-prototype updated: feat(extensions): add dedicated chat contribution type (#41000)
This is an automated email from the ASF dual-hosted git repository.
EnxDev pushed a commit to branch enxdev/chat-prototype
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/enxdev/chat-prototype by this push:
new 568337f3705 feat(extensions): add dedicated chat contribution type (#41000)
568337f3705 is described below
commit 568337f37058dcee38bcf20a0864ee9f8ada0fd6
Author: Enzo Martellucci <52...@users.noreply.github.com>
AuthorDate: Fri Jun 12 20:54:13 2026 +0200
feat(extensions): add dedicated chat contribution type (#41000)
---
.../packages/superset-core/package.json | 4 +
.../packages/superset-core/src/chat/index.ts | 185 ++++++++++++
.../superset-core/src/contributions/index.ts | 16 +-
.../packages/superset-core/src/index.ts | 1 +
.../packages/superset-core/src/views/index.ts | 9 -
.../src/components/ChatMount/ChatMount.test.tsx | 287 ++++++++++++++++++
.../src/components/ChatMount/index.tsx | 149 ++++++++++
.../components/ChatbotMount/ChatbotMount.test.tsx | 110 -------
.../src/components/ChatbotMount/index.tsx | 94 ------
superset-frontend/src/core/chat/index.test.ts | 331 +++++++++++++++++++++
superset-frontend/src/core/chat/index.ts | 238 +++++++++++++++
superset-frontend/src/core/chatbot/index.test.ts | 97 ------
superset-frontend/src/core/chatbot/index.ts | 70 -----
superset-frontend/src/core/index.ts | 1 +
superset-frontend/src/core/utils.ts | 29 +-
superset-frontend/src/core/views/index.test.ts | 63 +---
superset-frontend/src/core/views/index.ts | 46 ---
.../src/extensions/ExtensionsStartup.test.tsx | 1 +
.../src/extensions/ExtensionsStartup.tsx | 6 +-
superset-frontend/src/extensions/supersetGlobal.ts | 2 +
superset-frontend/src/views/App.tsx | 10 +-
superset-frontend/src/views/contributions.ts | 31 --
22 files changed, 1245 insertions(+), 535 deletions(-)
diff --git a/superset-frontend/packages/superset-core/package.json b/superset-frontend/packages/superset-core/package.json
index 0df87979aca..2866673fe5b 100644
--- a/superset-frontend/packages/superset-core/package.json
+++ b/superset-frontend/packages/superset-core/package.json
@@ -18,6 +18,10 @@
"types": "./lib/authentication/index.d.ts",
"default": "./lib/authentication/index.js"
},
+ "./chat": {
+ "types": "./lib/chat/index.d.ts",
+ "default": "./lib/chat/index.js"
+ },
"./dashboard": {
"types": "./lib/dashboard/index.d.ts",
"default": "./lib/dashboard/index.js"
diff --git a/superset-frontend/packages/superset-core/src/chat/index.ts b/superset-frontend/packages/superset-core/src/chat/index.ts
new file mode 100644
index 00000000000..612b3d28910
--- /dev/null
+++ b/superset-frontend/packages/superset-core/src/chat/index.ts
@@ -0,0 +1,185 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview Chat contribution API for Superset extensions.
+ *
+ * Chat is a dedicated contribution type (not a view): an extension registers
+ * a chat via {@link registerChat} and the host owns where and how it is
+ * mounted. The host applies singleton resolution — multiple chat extensions
+ * may register, but exactly one is active at a time.
+ *
+ * @example
+ * ```typescript
+ * import { chat } from '@apache-superset/core';
+ *
+ * chat.registerChat(
+ * { id: 'acme.chat', name: 'Acme Chat' },
+ * () => <AcmeTrigger />,
+ * () => <AcmePanel />,
+ * );
+ * ```
+ */
+
+import { ReactElement } from 'react';
+import type { Disposable, Event } from '../common';
+
+export interface Chat {
+ /** The unique identifier for the chat. */
+ id: string;
+ /** The display name of the chat. */
+ name: string;
+ /** Optional description of the chat, for display in contribution manifests. */
+ description?: string;
+}
+
+export type ChatMode = 'floating' | 'panel';
+
+/**
+ * Registers a chat provider. The host applies singleton resolution — only one
+ * chat is active at a time: the most recently registered chat wins, and
+ * disposing it restores the previously registered one. Re-registering an id
+ * replaces that registration in place.
+ *
+ * When a registration with a different id takes over the active slot (or the
+ * active chat is disposed), the host closes the panel first, firing
+ * {@link onDidClose}; an in-place same-id replacement keeps the open state.
+ *
+ * Disposing the returned Disposable unregisters the chat.
+ *
+ * @param chat The chat descriptor (id, name).
+ * @param trigger A function returning the collapsed bubble element. Owned by
+ * the extension — dynamic state such as unread counts and badges lives here.
+ * Hidden by the host when in panel mode.
+ * @param panel A function returning the chat panel element. Mounted by the
+ * host as a floating overlay in 'floating' mode, or docked at the side of
+ * the viewport in 'panel' mode (the reference host docks a fixed-width
+ * overlay at the right edge; hosts may integrate a true layout slot
+ * instead). Same component in both modes.
+ * @returns A Disposable that unregisters the chat when disposed.
+ *
+ * @example
+ * ```typescript
+ * chat.registerChat(
+ * { id: 'acme.chat', name: 'Acme Chat' },
+ * () => <AcmeTrigger />,
+ * () => <AcmePanel />,
+ * );
+ * ```
+ */
+export declare function registerChat(
+ chat: Chat,
+ trigger: () => ReactElement,
+ panel: () => ReactElement,
+): Disposable;
+
+/**
+ * Returns the active chat descriptor.
+ *
+ * @returns A copy of the active Chat descriptor, or undefined if none is
+ * registered. Mutating the returned object has no effect on the registry.
+ */
+export declare function getChat(): Chat | undefined;
+
+/**
+ * Event fired when a chat is registered.
+ */
+export declare const onDidRegisterChat: Event<Chat>;
+
+/**
+ * Event fired when a chat is unregistered.
+ */
+export declare const onDidUnregisterChat: Event<Chat>;
+
+/**
+ * Opens the active chat's panel.
+ *
+ * Acts on whichever chat is active, regardless of which extension calls it.
+ * No-op when no chat is registered or the panel is already open.
+ */
+export declare function open(): void;
+
+/**
+ * Closes the active chat's panel.
+ *
+ * Acts on whichever chat is active, regardless of which extension calls it.
+ * No-op when the panel is not open.
+ */
+export declare function close(): void;
+
+/**
+ * Returns whether the active chat's panel is currently open.
+ *
+ * @returns True if the chat panel is open.
+ */
+export declare function isOpen(): boolean;
+
+/**
+ * Event fired when the chat panel opens, with the descriptor of the chat
+ * whose panel opened. Listen to this rather than assuming your own chat is
+ * the one affected — another registration may hold the active slot.
+ */
+export declare const onDidOpen: Event<Chat>;
+
+/**
+ * Event fired when the chat panel closes, with the descriptor of the chat
+ * whose panel closed. Also fired when the host closes the panel itself, e.g.
+ * because the active chat was disposed or displaced by a different chat.
+ */
+export declare const onDidClose: Event<Chat>;
+
+/**
+ * Returns the current display mode.
+ *
+ * @returns The current ChatMode.
+ */
+export declare function getMode(): ChatMode;
+
+/**
+ * Sets the display mode.
+ *
+ * The mode is host-global and applies to whichever chat is active, regardless
+ * of which extension calls it. Hosts may also change the mode through their
+ * own controls — use onDidChangeMode to observe all changes rather than
+ * assuming the last setMode() call won.
+ *
+ * @param mode The display mode to switch to.
+ */
+export declare function setMode(mode: ChatMode): void;
+
+/**
+ * Event fired when the display mode changes, whether triggered by an
+ * extension via setMode() or by host-provided controls.
+ */
+export declare const onDidChangeMode: Event<ChatMode>;
+
+/**
+ * Event fired when the panel is resized in panel mode.
+ *
+ * The host owns the resizer handle and drag interaction; a host without a
+ * resizer never fires this event. (The reference host mounts the panel at a
+ * fixed width and does not provide a resizer, so subscribers receive no
+ * events there.) Listen to this event to adapt internal layout to the
+ * available width; do not rely on it firing.
+ */
+export declare const onDidResizePanel: Event<{ width: number }>;
+
+// TODO: client actions API — tool availability functions will be added here
+// once the client_actions SIP is finalized. The chat namespace is the
+// intended integration point between the two SIPs.
diff --git a/superset-frontend/packages/superset-core/src/contributions/index.ts b/superset-frontend/packages/superset-core/src/contributions/index.ts
index 86cf42d1959..f24ae36dba0 100644
--- a/superset-frontend/packages/superset-core/src/contributions/index.ts
+++ b/superset-frontend/packages/superset-core/src/contributions/index.ts
@@ -23,9 +23,10 @@
* This module defines the aggregate interfaces used by the extension.json
* manifest and the `superset-extensions` build command. Individual metadata
* types are defined in their respective namespace modules (commands, views,
- * menus, editors) and re-exported here for the manifest schema.
+ * menus, editors, chat) and re-exported here for the manifest schema.
*/
+import { Chat } from '../chat';
import { Command } from '../commands';
import { View } from '../views';
import { Menu } from '../menus';
@@ -43,9 +44,6 @@ export type SqlLabLocation =
| 'results'
| 'queryHistory';
-/** Valid locations within the app shell (persist across all routes). */
-export type AppLocation = 'chatbot';
-
/**
* Nested structure for view contributions by scope and location.
* @example
@@ -58,7 +56,6 @@ export type AppLocation = 'chatbot';
*/
export interface ViewContributions {
sqllab?: Partial<Record<SqlLabLocation, View[]>>;
- app?: Partial<Record<AppLocation, View[]>>;
}
/**
@@ -75,7 +72,8 @@ export interface MenuContributions {
}
/**
- * Aggregates all contributions (commands, menus, views, and editors) provided by an extension or module.
+ * Aggregates all contributions (commands, menus, views, editors, and chat)
+ * provided by an extension or module.
*/
export interface Contributions {
/** List of commands. */
@@ -86,4 +84,10 @@ export interface Contributions {
views: ViewContributions;
/** List of editors. */
editors?: Editor[];
+ /**
+ * The chat contributed by the extension — at most one per extension, since
+ * the host applies singleton resolution and renders exactly one active
+ * chat at a time.
+ */
+ chat?: Chat;
}
diff --git a/superset-frontend/packages/superset-core/src/index.ts b/superset-frontend/packages/superset-core/src/index.ts
index 79c699caff4..417a8af2e82 100644
--- a/superset-frontend/packages/superset-core/src/index.ts
+++ b/superset-frontend/packages/superset-core/src/index.ts
@@ -18,6 +18,7 @@
*/
export * as common from './common';
export * as authentication from './authentication';
+export * as chat from './chat';
export * as commands from './commands';
export * as dashboard from './dashboard';
export * as dataset from './dataset';
diff --git a/superset-frontend/packages/superset-core/src/views/index.ts b/superset-frontend/packages/superset-core/src/views/index.ts
index 33f69292065..32c27a17912 100644
--- a/superset-frontend/packages/superset-core/src/views/index.ts
+++ b/superset-frontend/packages/superset-core/src/views/index.ts
@@ -75,15 +75,6 @@ export interface View {
* () => <ResultStatsPanel />,
* );
* ```
- *
- * @example Chatbot bubble (`core.chatbot` — singleton, host renders one)
- * ```typescript
- * views.registerView(
- * { id: 'my_ext.chatbot', name: 'My Chatbot', icon: 'Bubble' },
- * 'core.chatbot',
- * () => <ChatbotApp />,
- * );
- * ```
*/
export declare function registerView(
view: View,
diff --git a/superset-frontend/src/components/ChatMount/ChatMount.test.tsx b/superset-frontend/src/components/ChatMount/ChatMount.test.tsx
new file mode 100644
index 00000000000..069768310ee
--- /dev/null
+++ b/superset-frontend/src/components/ChatMount/ChatMount.test.tsx
@@ -0,0 +1,287 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { act, render, screen } from 'spec/helpers/testing-library';
+import { chat } from 'src/core/chat';
+import ChatMount from '.';
+
+const disposables: Array<{ dispose: () => void }> = [];
+
+afterEach(() => {
+ act(() => {
+ disposables.forEach(d => d.dispose());
+ disposables.length = 0;
+ // Reset host-owned state shared across tests in this module.
+ chat.close();
+ chat.setMode('floating');
+ });
+});
+
+test('renders nothing when no chat extension is registered', () => {
+ render(<ChatMount />);
+
+ expect(screen.queryByTestId('chat-mount')).not.toBeInTheDocument();
+});
+
+test('renders the trigger bubble of the registered chat', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <button type="button">Acme Bubble</button>,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+
+ expect(screen.getByTestId('chat-mount')).toBeInTheDocument();
+ expect(screen.getByText('Acme Bubble')).toBeInTheDocument();
+ // The panel stays unmounted until the chat is opened.
+ expect(screen.queryByText('Acme Panel')).not.toBeInTheDocument();
+});
+
+test('mounts the panel when the chat opens and unmounts it on close', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <button type="button">Acme Bubble</button>,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+
+ act(() => chat.open());
+
+ expect(screen.getByText('Acme Panel')).toBeInTheDocument();
+ // In floating mode the trigger stays mounted alongside the open panel.
+ expect(screen.getByText('Acme Bubble')).toBeInTheDocument();
+
+ act(() => chat.close());
+
+ expect(screen.queryByText('Acme Panel')).not.toBeInTheDocument();
+});
+
+test('renders the last-registered chat when several are installed', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'first.chat', name: 'First Chat' },
+ () => <div>First Bubble</div>,
+ () => <div>First Panel</div>,
+ ),
+ chat.registerChat(
+ { id: 'second.chat', name: 'Second Chat' },
+ () => <div>Second Bubble</div>,
+ () => <div>Second Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+
+ // Last-loaded wins: the second registration takes over the singleton slot.
+ expect(screen.getByText('Second Bubble')).toBeInTheDocument();
+ expect(screen.queryByText('First Bubble')).not.toBeInTheDocument();
+});
+
+test('reacts to a chat registering after the initial render', () => {
+ render(<ChatMount />);
+
+ expect(screen.queryByTestId('chat-mount')).not.toBeInTheDocument();
+
+ act(() => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <button type="button">Acme Bubble</button>,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+ });
+
+ expect(screen.getByText('Acme Bubble')).toBeInTheDocument();
+});
+
+test('a takeover mounts the incoming chat closed', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'first.chat', name: 'First Chat' },
+ () => <div>First Bubble</div>,
+ () => <div>First Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+ act(() => chat.open());
+ expect(screen.getByText('First Panel')).toBeInTheDocument();
+
+ act(() => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'second.chat', name: 'Second Chat' },
+ () => <div>Second Bubble</div>,
+ () => <div>Second Panel</div>,
+ ),
+ );
+ });
+
+ // The displaced chat's open state must not leak into the winner.
+ expect(screen.getByText('Second Bubble')).toBeInTheDocument();
+ expect(screen.queryByText('Second Panel')).not.toBeInTheDocument();
+ expect(screen.queryByText('First Panel')).not.toBeInTheDocument();
+});
+
+test('panel mode docks the open panel and hides the trigger', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <button type="button">Acme Bubble</button>,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+
+ act(() => {
+ chat.setMode('panel');
+ chat.open();
+ });
+
+ expect(screen.getByText('Acme Panel')).toBeInTheDocument();
+ expect(screen.queryByText('Acme Bubble')).not.toBeInTheDocument();
+
+ act(() => chat.close());
+
+ // A closed chat in panel mode renders nothing — the trigger is hidden too.
+ expect(screen.queryByTestId('chat-mount')).not.toBeInTheDocument();
+});
+
+test('a crashing panel does not take the trigger down with it', () => {
+ const FailingPanel = () => {
+ throw new Error('panel blew up');
+ };
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <button type="button">Acme Bubble</button>,
+ () => <FailingPanel />,
+ ),
+ );
+
+ render(<ChatMount />);
+ act(() => chat.open());
+
+ // The panel's boundary contains the crash; the trigger keeps rendering so
+ // the user is not stranded without a way back.
+ expect(screen.queryByText('panel blew up')).not.toBeInTheDocument();
+ expect(screen.getByText('Acme Bubble')).toBeInTheDocument();
+});
+
+test('isolates a failing trigger so it does not crash the host', () => {
+ const FailingTrigger = () => {
+ throw new Error('chat blew up');
+ };
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <FailingTrigger />,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ // The host-owned error boundary catches the failure; render does not throw.
+ expect(() => render(<ChatMount />)).not.toThrow();
+ // The mount slot still renders (the boundary lives inside it), confirming
+ // the provider was actually exercised and contained.
+ expect(screen.getByTestId('chat-mount')).toBeInTheDocument();
+});
+
+test('isolates a chat whose provider function itself throws', () => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => {
+ throw new Error('provider blew up');
+ },
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ // ChatRenderer wraps provider() in a component so ErrorBoundary catches
+ // synchronous throws from the provider function, not just from its output.
+ expect(() => render(<ChatMount />)).not.toThrow();
+ expect(screen.getByTestId('chat-mount')).toBeInTheDocument();
+});
+
+test('recovers from a crashed chat when a different chat takes over', () => {
+ const FailingTrigger = () => {
+ throw new Error('first chat blew up');
+ };
+ disposables.push(
+ chat.registerChat(
+ { id: 'first.chat', name: 'First Chat' },
+ () => <FailingTrigger />,
+ () => <div>First Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+ expect(screen.queryByText('Second Bubble')).not.toBeInTheDocument();
+
+ act(() => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'second.chat', name: 'Second Chat' },
+ () => <div>Second Bubble</div>,
+ () => <div>Second Panel</div>,
+ ),
+ );
+ });
+
+ // The boundary is keyed per registration, so the latched crash from the
+ // first chat does not blank the second one.
+ expect(screen.getByText('Second Bubble')).toBeInTheDocument();
+});
+
+test('recovers when a crashed chat re-registers a fixed version under the same id', () => {
+ const FailingTrigger = () => {
+ throw new Error('broken release');
+ };
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <FailingTrigger />,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+
+ render(<ChatMount />);
+ expect(screen.queryByText('Fixed Bubble')).not.toBeInTheDocument();
+
+ act(() => {
+ disposables.push(
+ chat.registerChat(
+ { id: 'acme.chat', name: 'Acme Chat' },
+ () => <div>Fixed Bubble</div>,
+ () => <div>Acme Panel</div>,
+ ),
+ );
+ });
+
+ // Same id, new registrationId: the remounted boundary renders the fix.
+ expect(screen.getByText('Fixed Bubble')).toBeInTheDocument();
+});
diff --git a/superset-frontend/src/components/ChatMount/index.tsx b/superset-frontend/src/components/ChatMount/index.tsx
new file mode 100644
index 00000000000..4f9c9628738
--- /dev/null
+++ b/superset-frontend/src/components/ChatMount/index.tsx
@@ -0,0 +1,149 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { type ReactElement, useRef, useSyncExternalStore } from 'react';
+import { t } from '@apache-superset/core/translation';
+import { logging } from '@apache-superset/core/utils';
+import { css, useTheme } from '@apache-superset/core/theme';
+import { ErrorBoundary } from 'src/components/ErrorBoundary';
+import { addDangerToast } from 'src/components/MessageToasts/actions';
+import { store } from 'src/views/store';
+import { getChatSnapshot, subscribeToChatState } from 'src/core/chat';
+
+const CHAT_EDGE_MARGIN = 24;
+const PANEL_MODE_WIDTH = 400;
+
+/**
+ * Wraps a chat provider in a React component so that ErrorBoundary can catch
+ * synchronous throws from the provider function itself. Calling `provider()`
+ * inline (e.g. `{activeChat.panel()}`) would throw outside React's render
+ * boundary and crash the host.
+ */
+const ChatRenderer = ({ provider }: { provider: () => ReactElement }) =>
+ provider();
+
+const ChatMount = () => {
+ const theme = useTheme();
+ // Notify at most once per registration; a crash can re-render and would
+ // otherwise re-toast, while a replacement (new registrationId) deserves a
+ // fresh notification if it crashes too.
+ const crashNotifiedFor = useRef<number | null>(null);
+
+ // The active chat, the open state, and the display mode are read from one
+ // immutable registry snapshot so a render never mixes state from two
+ // different store versions (the tearing useSyncExternalStore prevents).
+ const {
+ open: panelOpen,
+ mode,
+ active,
+ } = useSyncExternalStore(subscribeToChatState, getChatSnapshot);
+
+ if (!active) {
+ return null;
+ }
+
+ const { registrationId } = active;
+
+ const onProviderError = (error: Error) => {
+ // Fault isolation: contain the crash, log it, surface a one-time
+ // notification, and leave the slot empty rather than parking a
+ // persistent error card.
+ logging.error('[chat] provider crashed', error);
+ if (crashNotifiedFor.current !== registrationId) {
+ crashNotifiedFor.current = registrationId;
+ store.dispatch(addDangerToast(t('The chat failed to load.')));
+ }
+ };
+
+ if (mode === 'panel') {
+ // Panel mode hides the trigger and docks the panel to the right edge.
+ // Interim approximation of the "layout slot between header and footer"
+ // from the chat API contract — the dock overlays the page until the host
+ // grows a real layout slot and resizer chrome.
+ if (!panelOpen) {
+ return null;
+ }
+ return (
+ <div
+ data-test="chat-mount"
+ css={css`
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ width: ${PANEL_MODE_WIDTH}px;
+ background: ${theme.colorBgContainer};
+ box-shadow: ${theme.boxShadow};
+ /* Above dashboard content and the toast layer, below modal dialogs. */
+ z-index: ${theme.zIndexPopupBase + 2};
+ `}
+ >
+ <ErrorBoundary
+ key={registrationId}
+ showMessage={false}
+ onError={onProviderError}
+ >
+ <ChatRenderer provider={active.panel} />
+ </ErrorBoundary>
+ </div>
+ );
+ }
+
+ return (
+ <div
+ data-test="chat-mount"
+ css={css`
+ position: fixed;
+ right: ${CHAT_EDGE_MARGIN}px;
+ bottom: ${CHAT_EDGE_MARGIN}px;
+ display: flex;
+ flex-direction: column;
+ align-items: flex-end;
+ gap: ${theme.sizeUnit * 2}px;
+ /* Above dashboard content and the toast layer, below modal dialogs. */
+ z-index: ${theme.zIndexPopupBase + 2};
+ `}
+ >
+ {/*
+ Each provider gets its own boundary so a crashing panel cannot take
+ the trigger down with it (the trigger is the user's only way back).
+ Keyed by registrationId: Superset's ErrorBoundary latches its error
+ state, so a takeover, fallback, or same-id re-registration must
+ remount the boundary to recover.
+ */}
+ {panelOpen && (
+ <ErrorBoundary
+ key={`panel-${registrationId}`}
+ showMessage={false}
+ onError={onProviderError}
+ >
+ <ChatRenderer provider={active.panel} />
+ </ErrorBoundary>
+ )}
+ <ErrorBoundary
+ key={`trigger-${registrationId}`}
+ showMessage={false}
+ onError={onProviderError}
+ >
+ <ChatRenderer provider={active.trigger} />
+ </ErrorBoundary>
+ </div>
+ );
+};
+
+export default ChatMount;
diff --git a/superset-frontend/src/components/ChatbotMount/ChatbotMount.test.tsx b/superset-frontend/src/components/ChatbotMount/ChatbotMount.test.tsx
deleted file mode 100644
index 683e32b6592..00000000000
--- a/superset-frontend/src/components/ChatbotMount/ChatbotMount.test.tsx
+++ /dev/null
@@ -1,110 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { render, screen } from 'spec/helpers/testing-library';
-import { views } from 'src/core';
-import { CHATBOT_LOCATION } from 'src/views/contributions';
-import ChatbotMount from '.';
-
-const disposables: Array<{ dispose: () => void }> = [];
-
-afterEach(() => {
- disposables.forEach(d => d.dispose());
- disposables.length = 0;
-});
-
-test('renders nothing when no chatbot extension is registered', () => {
- render(<ChatbotMount />);
-
- expect(screen.queryByTestId('chatbot-mount')).not.toBeInTheDocument();
-});
-
-test('renders the registered chatbot inside the fixed mount slot', () => {
- const provider = () => <div>My Chatbot Bubble</div>;
- disposables.push(
- views.registerView(
- { id: 'core.chatbot', name: 'Superset Chatbot' },
- CHATBOT_LOCATION,
- provider,
- ),
- );
-
- render(<ChatbotMount />);
-
- expect(screen.getByTestId('chatbot-mount')).toBeInTheDocument();
- expect(screen.getByText('My Chatbot Bubble')).toBeInTheDocument();
-});
-
-test('renders the last-registered chatbot when several are installed', () => {
- const firstProvider = () => <div>First Bubble</div>;
- const secondProvider = () => <div>Second Bubble</div>;
- disposables.push(
- views.registerView(
- { id: 'first.chatbot', name: 'First Chatbot' },
- CHATBOT_LOCATION,
- firstProvider,
- ),
- views.registerView(
- { id: 'second.chatbot', name: 'Second Chatbot' },
- CHATBOT_LOCATION,
- secondProvider,
- ),
- );
-
- render(<ChatbotMount />);
-
- // Last-loaded wins: the second registration takes over the singleton bubble.
- expect(screen.getByText('Second Bubble')).toBeInTheDocument();
- expect(screen.queryByText('First Bubble')).not.toBeInTheDocument();
-});
-
-test('isolates a failing chatbot so it does not crash the host', () => {
- const FailingChatbot = () => {
- throw new Error('chatbot blew up');
- };
- disposables.push(
- views.registerView(
- { id: 'core.chatbot', name: 'Superset Chatbot' },
- CHATBOT_LOCATION,
- () => <FailingChatbot />,
- ),
- );
-
- // The host-owned error boundary catches the failure; render does not throw.
- expect(() => render(<ChatbotMount />)).not.toThrow();
- // The mount slot still renders (the boundary lives inside it), confirming the
- // provider was actually exercised and contained.
- expect(screen.getByTestId('chatbot-mount')).toBeInTheDocument();
-});
-
-test('isolates a chatbot whose provider function itself throws', () => {
- disposables.push(
- views.registerView(
- { id: 'core.chatbot', name: 'Superset Chatbot' },
- CHATBOT_LOCATION,
- () => {
- throw new Error('provider blew up');
- },
- ),
- );
-
- // ChatbotRenderer wraps provider() in a component so ErrorBoundary catches
- // synchronous throws from the provider function, not just from its output.
- expect(() => render(<ChatbotMount />)).not.toThrow();
- expect(screen.getByTestId('chatbot-mount')).toBeInTheDocument();
-});
diff --git a/superset-frontend/src/components/ChatbotMount/index.tsx b/superset-frontend/src/components/ChatbotMount/index.tsx
deleted file mode 100644
index ddc430b563b..00000000000
--- a/superset-frontend/src/components/ChatbotMount/index.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import {
- type ReactElement,
- useMemo,
- useRef,
- useSyncExternalStore,
-} from 'react';
-import { t } from '@apache-superset/core/translation';
-import { logging } from '@apache-superset/core/utils';
-import { css, useTheme } from '@apache-superset/core/theme';
-import { ErrorBoundary } from 'src/components/ErrorBoundary';
-import { addDangerToast } from 'src/components/MessageToasts/actions';
-import { store } from 'src/views/store';
-import { getActiveChatbot } from 'src/core/chatbot';
-import { subscribeToRegistry, getRegistryVersion } from 'src/core/views';
-
-const CHATBOT_EDGE_MARGIN = 24;
-
-/**
- * Wraps the chatbot provider in a React component so that ErrorBoundary can
- * catch synchronous throws from the provider function itself. Calling
- * `provider()` inline (e.g. `{activeChatbot.provider()}`) would throw outside
- * React's render boundary and crash the host.
- */
-const ChatbotRenderer = ({ provider }: { provider: () => ReactElement }) =>
- provider();
-
-const ChatbotMount = () => {
- const theme = useTheme();
- // Notify once per mount; a crash can re-render and would otherwise re-toast.
- const crashNotified = useRef(false);
-
- // The active chatbot is a function of the view registry alone: the
- // most-recently-registered chatbot wins. Read via useSyncExternalStore so it
- // re-resolves whenever a chatbot extension registers or disposes.
- const registryVersion = useSyncExternalStore(
- subscribeToRegistry,
- getRegistryVersion,
- );
-
- const activeChatbot = useMemo(() => getActiveChatbot(), [registryVersion]);
-
- if (!activeChatbot) {
- return null;
- }
-
- return (
- <div
- data-test="chatbot-mount"
- css={css`
- position: fixed;
- right: ${CHATBOT_EDGE_MARGIN}px;
- bottom: ${CHATBOT_EDGE_MARGIN}px;
- /* Above dashboard content and the toast layer, below modal dialogs. */
- z-index: ${theme.zIndexPopupBase + 2};
- `}
- >
- <ErrorBoundary
- showMessage={false}
- onError={(error: Error) => {
- // Fault isolation: contain the crash, log it, surface a one-time
- // notification, and leave the corner empty rather than parking a
- // persistent error card.
- logging.error('[chatbot] provider crashed', error);
- if (!crashNotified.current) {
- crashNotified.current = true;
- store.dispatch(addDangerToast(t('The chatbot failed to load.')));
- }
- }}
- >
- <ChatbotRenderer provider={activeChatbot.provider} />
- </ErrorBoundary>
- </div>
- );
-};
-
-export default ChatbotMount;
diff --git a/superset-frontend/src/core/chat/index.test.ts b/superset-frontend/src/core/chat/index.test.ts
new file mode 100644
index 00000000000..b764699dc0e
--- /dev/null
+++ b/superset-frontend/src/core/chat/index.test.ts
@@ -0,0 +1,331 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { createElement } from 'react';
+import { chat, getActiveChat, getChatSnapshot } from './index';
+
+const disposables: Array<{ dispose: () => void }> = [];
+
+const trigger = () => createElement('button', null, 'Bubble');
+const panel = () => createElement('div', null, 'Panel');
+
+afterEach(() => {
+ disposables.forEach(d => d.dispose());
+ disposables.length = 0;
+ // Reset host-owned state shared across tests in this module.
+ chat.close();
+ chat.setMode('floating');
+});
+
+test('getChat returns undefined when no chat is registered', () => {
+ expect(chat.getChat()).toBeUndefined();
+ expect(getActiveChat()).toBeUndefined();
+});
+
+test('registerChat resolves the registered chat with its providers', () => {
+ const descriptor = { id: 'acme.chat', name: 'Acme Chat' };
+ disposables.push(chat.registerChat(descriptor, trigger, panel));
+
+ expect(chat.getChat()).toEqual(descriptor);
+ expect(getActiveChat()).toMatchObject({ chat: descriptor, trigger, panel });
+});
+
+test('getChat returns a copy that cannot mutate the registry', () => {
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme Chat' }, trigger, panel),
+ );
+
+ const copy = chat.getChat();
+ copy!.name = 'Hijacked';
+
+ expect(chat.getChat()?.name).toBe('Acme Chat');
+});
+
+test('the last-registered chat wins when multiple are installed', () => {
+ disposables.push(
+ chat.registerChat({ id: 'first.chat', name: 'First' }, trigger, panel),
+ chat.registerChat({ id: 'second.chat', name: 'Second' }, trigger, panel),
+ );
+
+ expect(chat.getChat()?.id).toBe('second.chat');
+});
+
+test('disposing the active chat falls back to the previous registration', () => {
+ disposables.push(
+ chat.registerChat({ id: 'first.chat', name: 'First' }, trigger, panel),
+ );
+ const second = chat.registerChat(
+ { id: 'second.chat', name: 'Second' },
+ trigger,
+ panel,
+ );
+
+ expect(chat.getChat()?.id).toBe('second.chat');
+
+ second.dispose();
+
+ expect(chat.getChat()?.id).toBe('first.chat');
+});
+
+test('re-registering an id replaces the previous registration', () => {
+ const stalePanel = () => createElement('div', null, 'Stale');
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, stalePanel),
+ chat.registerChat({ id: 'acme.chat', name: 'Acme v2' }, trigger, panel),
+ );
+
+ expect(chat.getChat()?.name).toBe('Acme v2');
+ expect(getActiveChat()?.panel).toBe(panel);
+});
+
+test('each registration gets a distinct registrationId, including same-id replacements', () => {
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, panel),
+ );
+ const first = getActiveChat()?.registrationId;
+
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme v2' }, trigger, panel),
+ );
+ const second = getActiveChat()?.registrationId;
+
+ expect(first).toBeDefined();
+ expect(second).toBeDefined();
+ expect(second).not.toBe(first);
+});
+
+test('disposing a registration twice unregisters only once', () => {
+ const unregistered = jest.fn();
+ disposables.push(chat.onDidUnregisterChat(unregistered));
+
+ const registration = chat.registerChat(
+ { id: 'acme.chat', name: 'Acme' },
+ trigger,
+ panel,
+ );
+ registration.dispose();
+ registration.dispose();
+
+ expect(unregistered).toHaveBeenCalledTimes(1);
+ expect(chat.getChat()).toBeUndefined();
+});
+
+test('onDidRegisterChat and onDidUnregisterChat fire with the descriptor', () => {
+ const registered = jest.fn();
+ const unregistered = jest.fn();
+ disposables.push(
+ chat.onDidRegisterChat(registered),
+ chat.onDidUnregisterChat(unregistered),
+ );
+
+ const descriptor = { id: 'acme.chat', name: 'Acme' };
+ const registration = chat.registerChat(descriptor, trigger, panel);
+
+ expect(registered).toHaveBeenCalledWith(descriptor);
+ expect(unregistered).not.toHaveBeenCalled();
+
+ registration.dispose();
+
+ expect(unregistered).toHaveBeenCalledWith(descriptor);
+});
+
+test('a disposed event subscription stops receiving notifications', () => {
+ const registered = jest.fn();
+ const subscription = chat.onDidRegisterChat(registered);
+ subscription.dispose();
+
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, panel),
+ );
+
+ expect(registered).not.toHaveBeenCalled();
+});
+
+test('open and close toggle the panel and fire once with the active descriptor', () => {
+ const opened = jest.fn();
+ const closed = jest.fn();
+ disposables.push(chat.onDidOpen(opened), chat.onDidClose(closed));
+
+ const descriptor = { id: 'acme.chat', name: 'Acme' };
+ disposables.push(chat.registerChat(descriptor, trigger, panel));
+
+ expect(chat.isOpen()).toBe(false);
+
+ chat.open();
+ // Opening an already-open panel is a no-op and must not re-fire.
+ chat.open();
+
+ expect(chat.isOpen()).toBe(true);
+ expect(opened).toHaveBeenCalledTimes(1);
+ expect(opened).toHaveBeenCalledWith(descriptor);
+
+ chat.close();
+ chat.close();
+
+ expect(chat.isOpen()).toBe(false);
+ expect(closed).toHaveBeenCalledTimes(1);
+ expect(closed).toHaveBeenCalledWith(descriptor);
+});
+
+test('open is a no-op while no chat is registered', () => {
+ const opened = jest.fn();
+ disposables.push(chat.onDidOpen(opened));
+
+ chat.open();
+
+ expect(chat.isOpen()).toBe(false);
+ expect(opened).not.toHaveBeenCalled();
+
+ // A registration arriving later therefore starts closed.
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, panel),
+ );
+ expect(chat.isOpen()).toBe(false);
+});
+
+test('a takeover by a different id closes the displaced chat panel', () => {
+ const closed = jest.fn();
+ disposables.push(chat.onDidClose(closed));
+
+ const first = { id: 'first.chat', name: 'First' };
+ disposables.push(chat.registerChat(first, trigger, panel));
+ chat.open();
+
+ disposables.push(
+ chat.registerChat({ id: 'second.chat', name: 'Second' }, trigger, panel),
+ );
+
+ // The incoming chat must not mount into an open state it never requested.
+ expect(chat.isOpen()).toBe(false);
+ expect(closed).toHaveBeenCalledTimes(1);
+ expect(closed).toHaveBeenCalledWith(first);
+});
+
+test('a same-id replacement keeps the open state', () => {
+ const closed = jest.fn();
+ disposables.push(chat.onDidClose(closed));
+
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, panel),
+ );
+ chat.open();
+
+ // Upgrade in place: same id, new providers.
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme v2' }, trigger, panel),
+ );
+
+ expect(chat.isOpen()).toBe(true);
+ expect(closed).not.toHaveBeenCalled();
+});
+
+test('disposing the active chat while open closes it; the fallback starts closed', () => {
+ const closed = jest.fn();
+ disposables.push(chat.onDidClose(closed));
+
+ disposables.push(
+ chat.registerChat({ id: 'first.chat', name: 'First' }, trigger, panel),
+ );
+ const second = { id: 'second.chat', name: 'Second' };
+ const registration = chat.registerChat(second, trigger, panel);
+ chat.open();
+
+ registration.dispose();
+
+ expect(chat.getChat()?.id).toBe('first.chat');
+ expect(chat.isOpen()).toBe(false);
+ expect(closed).toHaveBeenCalledTimes(1);
+ expect(closed).toHaveBeenCalledWith(second);
+});
+
+test('disposing an inactive registration leaves the open state untouched', () => {
+ const closed = jest.fn();
+ disposables.push(chat.onDidClose(closed));
+
+ const inactive = chat.registerChat(
+ { id: 'first.chat', name: 'First' },
+ trigger,
+ panel,
+ );
+ disposables.push(
+ chat.registerChat({ id: 'second.chat', name: 'Second' }, trigger, panel),
+ );
+ chat.open();
+
+ inactive.dispose();
+
+ expect(chat.isOpen()).toBe(true);
+ expect(closed).not.toHaveBeenCalled();
+});
+
+test('disposing the last chat while open resets the open state', () => {
+ const registration = chat.registerChat(
+ { id: 'acme.chat', name: 'Acme' },
+ trigger,
+ panel,
+ );
+ chat.open();
+ expect(chat.isOpen()).toBe(true);
+
+ registration.dispose();
+
+ expect(chat.isOpen()).toBe(false);
+
+ // A registration arriving much later must not inherit a stale open state.
+ disposables.push(
+ chat.registerChat({ id: 'late.chat', name: 'Late' }, trigger, panel),
+ );
+ expect(chat.isOpen()).toBe(false);
+});
+
+test('mode defaults to floating and setMode fires only on change', () => {
+ const modeChanged = jest.fn();
+ disposables.push(chat.onDidChangeMode(modeChanged));
+
+ expect(chat.getMode()).toBe('floating');
+
+ // Setting the current mode is a no-op.
+ chat.setMode('floating');
+ expect(modeChanged).not.toHaveBeenCalled();
+
+ chat.setMode('panel');
+ expect(chat.getMode()).toBe('panel');
+ expect(modeChanged).toHaveBeenCalledWith('panel');
+});
+
+test('the snapshot is immutable per version and consistent with the registry', () => {
+ const before = getChatSnapshot();
+
+ disposables.push(
+ chat.registerChat({ id: 'acme.chat', name: 'Acme' }, trigger, panel),
+ );
+ chat.open();
+
+ const after = getChatSnapshot();
+ // Unchanged references for old snapshots; a new object per change.
+ expect(after).not.toBe(before);
+ expect(before.active).toBeUndefined();
+ expect(after).toMatchObject({
+ open: true,
+ mode: 'floating',
+ active: getActiveChat(),
+ });
+ expect(after.version).toBeGreaterThan(before.version);
+ // Stable reference between changes.
+ expect(getChatSnapshot()).toBe(after);
+});
diff --git a/superset-frontend/src/core/chat/index.ts b/superset-frontend/src/core/chat/index.ts
new file mode 100644
index 00000000000..fea100e3ec1
--- /dev/null
+++ b/superset-frontend/src/core/chat/index.ts
@@ -0,0 +1,238 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview Host implementation of the `chat` contribution type.
+ *
+ * Chat is a dedicated contribution type, not a view: extensions register via
+ * the public `chat.registerChat()` and the host owns mounting, open/close
+ * state, and the display mode. Multiple chat extensions may register, but the
+ * host applies singleton resolution — the most-recently-registered chat is
+ * active; disposing it falls back to the previous one.
+ *
+ * Open-state policy across active-chat transitions: when the active chat's
+ * identity changes — a takeover by a different id, disposal falling back to a
+ * different id, or disposal of the last chat — the panel is closed (firing
+ * `onDidClose`) so the incoming chat never mounts into an open state it did
+ * not request. A same-id re-registration is an upgrade in place and keeps the
+ * open state.
+ *
+ * The public namespace (`chat`) is exposed to extensions on
+ * `window.superset`; the other exports are host-internal accessors for
+ * ChatMount and are NOT part of the public `@apache-superset/core` API.
+ */
+
+import { ReactElement } from 'react';
+import type { chat as chatApi } from '@apache-superset/core';
+import { Disposable } from '../models';
+import { createEmitter, createEventEmitter } from '../utils';
+
+type Chat = chatApi.Chat;
+type ChatMode = chatApi.ChatMode;
+
+/** A registered chat: its descriptor plus the host-mountable providers. */
+export interface RegisteredChat {
+ /** The chat descriptor passed to `registerChat`. */
+ chat: Chat;
+ /** Renders the collapsed bubble. Hidden by the host in panel mode. */
+ trigger: () => ReactElement;
+ /** Renders the chat panel, mounted per the current {@link ChatMode}. */
+ panel: () => ReactElement;
+ /**
+ * Unique per registration (a same-id re-registration gets a new one). The
+ * host UI keys mounts and fault containment on it, so a replacement resets
+ * crashed error boundaries instead of inheriting their latched state.
+ */
+ registrationId: number;
+}
+
+/**
+ * Immutable snapshot of the whole chat state, rebuilt on every change.
+ * Returned by reference from `getChatSnapshot` so `useSyncExternalStore`
+ * consumers read registrations, open state, and mode from one consistent
+ * object instead of tearing across separate live reads.
+ */
+export interface ChatSnapshot {
+ /** Monotonic change counter, useful as a memo/effect dependency. */
+ version: number;
+ /** Whether the active chat's panel is open. */
+ open: boolean;
+ /** The current display mode. */
+ mode: ChatMode;
+ /** The active registration, or undefined when none is registered. */
+ active: RegisteredChat | undefined;
+}
+
+/** Registration order is the singleton-resolution order: last entry wins. */
+const registrations: RegisteredChat[] = [];
+
+let panelOpen = false;
+let nextRegistrationId = 1;
+
+const registerEmitter = createEventEmitter<Chat>();
+const unregisterEmitter = createEventEmitter<Chat>();
+const openEmitter = createEventEmitter<Chat>();
+const closeEmitter = createEventEmitter<Chat>();
+const resizePanelEmitter = createEventEmitter<{ width: number }>();
+const modeEmitter = createEmitter<ChatMode>('floating');
+
+/**
+ * Host-internal: resolves the active chat with its providers.
+ * The most-recently-registered chat wins; when it is disposed the previous
+ * registration takes over the slot again.
+ */
+export const getActiveChat = (): RegisteredChat | undefined =>
+ registrations[registrations.length - 1];
+
+let snapshot: ChatSnapshot = {
+ version: 0,
+ open: false,
+ mode: modeEmitter.getCurrent(),
+ active: undefined,
+};
+
+const stateSubscribers = new Set<() => void>();
+
+const notifyState = () => {
+ snapshot = {
+ version: snapshot.version + 1,
+ open: panelOpen,
+ mode: modeEmitter.getCurrent(),
+ active: getActiveChat(),
+ };
+ stateSubscribers.forEach(fn => fn());
+};
+
+export const subscribeToChatState = (listener: () => void): (() => void) => {
+ stateSubscribers.add(listener);
+ return () => {
+ stateSubscribers.delete(listener);
+ };
+};
+
+export const getChatSnapshot = (): ChatSnapshot => snapshot;
+
+/** Closes the panel and fires `onDidClose` with the chat that was closed. */
+const closePanel = (closedChat: Chat) => {
+ panelOpen = false;
+ closeEmitter.fire(closedChat);
+};
+
+const registerChat: typeof chatApi.registerChat = (
+ chat: Chat,
+ trigger: () => ReactElement,
+ panel: () => ReactElement,
+): Disposable => {
+ const previousActive = getActiveChat();
+
+ // Re-registering an id replaces the previous entry and moves it to the
+ // most-recent position, mirroring the view registry's same-id semantics.
+ const existingIndex = registrations.findIndex(r => r.chat.id === chat.id);
+ if (existingIndex !== -1) {
+ registrations.splice(existingIndex, 1);
+ }
+
+ const entry: RegisteredChat = {
+ chat,
+ trigger,
+ panel,
+ registrationId: nextRegistrationId,
+ };
+ nextRegistrationId += 1;
+ registrations.push(entry);
+ registerEmitter.fire(chat);
+
+ // A takeover by a different id closes the displaced chat's panel so the
+ // incoming chat never mounts already-open; a same-id replacement is an
+ // upgrade in place and keeps the open state.
+ if (panelOpen && previousActive && previousActive.chat.id !== chat.id) {
+ closePanel(previousActive.chat);
+ }
+ notifyState();
+
+ return new Disposable(() => {
+ const index = registrations.indexOf(entry);
+ if (index === -1) {
+ // Already removed — replaced by a same-id registration or disposed twice.
+ return;
+ }
+ const wasActive = getActiveChat() === entry;
+ registrations.splice(index, 1);
+ unregisterEmitter.fire(chat);
+ // Disposing the active chat closes its panel; the fallback chat (if any)
+ // starts closed. Disposing an inactive registration leaves the open
+ // state of the active chat untouched.
+ if (panelOpen && wasActive) {
+ closePanel(chat);
+ }
+ notifyState();
+ });
+};
+
+const getChat: typeof chatApi.getChat = (): Chat | undefined => {
+ const active = getActiveChat();
+ // Copy so extensions cannot mutate another extension's descriptor.
+ return active ? { ...active.chat } : undefined;
+};
+
+const open: typeof chatApi.open = (): void => {
+ const active = getActiveChat();
+ // Open state only exists while a chat is registered; opening an empty slot
+ // would otherwise leak `open` into a future, unrelated registration.
+ if (panelOpen || !active) return;
+ panelOpen = true;
+ openEmitter.fire(active.chat);
+ notifyState();
+};
+
+const close: typeof chatApi.close = (): void => {
+ const active = getActiveChat();
+ if (!panelOpen || !active) return;
+ closePanel(active.chat);
+ notifyState();
+};
+
+const isOpen: typeof chatApi.isOpen = (): boolean => panelOpen;
+
+const getMode: typeof chatApi.getMode = (): ChatMode =>
+ modeEmitter.getCurrent();
+
+const setMode: typeof chatApi.setMode = (mode: ChatMode): void => {
+ if (mode === modeEmitter.getCurrent()) return;
+ modeEmitter.fire(mode);
+ notifyState();
+};
+
+export const chat: typeof chatApi = {
+ registerChat,
+ getChat,
+ onDidRegisterChat: registerEmitter.event,
+ onDidUnregisterChat: unregisterEmitter.event,
+ open,
+ close,
+ isOpen,
+ onDidOpen: openEmitter.event,
+ onDidClose: closeEmitter.event,
+ getMode,
+ setMode,
+ onDidChangeMode: modeEmitter.event,
+ // The host fires this from its panel resizer; until that chrome exists the
+ // event is exposed but never fires.
+ onDidResizePanel: resizePanelEmitter.event,
+};
diff --git a/superset-frontend/src/core/chatbot/index.test.ts b/superset-frontend/src/core/chatbot/index.test.ts
deleted file mode 100644
index 7b6eb00b0ac..00000000000
--- a/superset-frontend/src/core/chatbot/index.test.ts
+++ /dev/null
@@ -1,97 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { createElement } from 'react';
-import { views } from 'src/core/views';
-import { CHATBOT_LOCATION } from 'src/views/contributions';
-import { getActiveChatbot } from './index';
-
-const disposables: Array<{ dispose: () => void }> = [];
-
-afterEach(() => {
- disposables.forEach(d => d.dispose());
- disposables.length = 0;
-});
-
-test('getActiveChatbot returns undefined when no chatbot is registered', () => {
- expect(getActiveChatbot()).toBeUndefined();
-});
-
-test('getActiveChatbot resolves the single registered chatbot', () => {
- const provider = () => createElement('div', null, 'Chatbot');
- disposables.push(
- views.registerView(
- { id: 'core.chatbot', name: 'Superset Chatbot' },
- CHATBOT_LOCATION,
- provider,
- ),
- );
-
- const active = getActiveChatbot();
- expect(active).toEqual({ id: 'core.chatbot', provider });
-});
-
-test('getActiveChatbot picks the last-to-register when multiple are installed', () => {
- const firstProvider = () => createElement('div', null, 'First');
- const secondProvider = () => createElement('div', null, 'Second');
- disposables.push(
- views.registerView(
- { id: 'first.chatbot', name: 'First Chatbot' },
- CHATBOT_LOCATION,
- firstProvider,
- ),
- views.registerView(
- { id: 'second.chatbot', name: 'Second Chatbot' },
- CHATBOT_LOCATION,
- secondProvider,
- ),
- );
-
- // Last-loaded wins: the most-recently-registered chatbot takes the slot.
- const active = getActiveChatbot();
- expect(active?.id).toBe('second.chatbot');
- expect(active?.provider).toBe(secondProvider);
-});
-
-test('getActiveChatbot ignores views registered at other locations', () => {
- const provider = () => createElement('div', null, 'Panel');
- disposables.push(
- views.registerView(
- { id: 'some.panel', name: 'Some Panel' },
- 'sqllab.panels',
- provider,
- ),
- );
-
- expect(getActiveChatbot()).toBeUndefined();
-});
-
-test('getActiveChatbot stops resolving a chatbot once it is disposed', () => {
- const provider = () => createElement('div', null, 'Chatbot');
- const disposable = views.registerView(
- { id: 'core.chatbot', name: 'Superset Chatbot' },
- CHATBOT_LOCATION,
- provider,
- );
-
- expect(getActiveChatbot()?.id).toBe('core.chatbot');
-
- disposable.dispose();
-
- expect(getActiveChatbot()).toBeUndefined();
-});
diff --git a/superset-frontend/src/core/chatbot/index.ts b/superset-frontend/src/core/chatbot/index.ts
deleted file mode 100644
index eded52c85a3..00000000000
--- a/superset-frontend/src/core/chatbot/index.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * @fileoverview Host-internal resolver for the exclusive `core.chatbot`
- * contribution area.
- *
- * `core.chatbot` is a singleton contribution area: multiple chatbot
- * extensions may register a view there, but the host renders exactly one.
- * This module owns the host-side selection policy.
- *
- * This is host-internal infrastructure — it is NOT part of the public
- * `@apache-superset/core` API. Extensions register via the public
- * `views.registerView()`; only the host resolves which one is active.
- */
-
-import { ReactElement } from 'react';
-import { CHATBOT_LOCATION } from 'src/views/contributions';
-import { getRegisteredViewIds, getViewProvider } from 'src/core/views';
-
-/**
- * The resolved active chatbot: a view id paired with its renderable provider.
- */
-export interface ActiveChatbot {
- /** The registered view id of the selected chatbot. */
- id: string;
- /** The provider that renders the chatbot's React element. */
- provider: () => ReactElement;
-}
-
-/**
- * Resolves which single chatbot extension is currently active.
- *
- * Selection policy:
- * - If no chatbot is registered, returns `undefined` — the corner stays empty.
- * - Otherwise the most-recently-registered (last-loaded) chatbot wins. When a
- * second chatbot extension loads, it takes over the singleton bubble.
- *
- * @returns The active chatbot's id and provider, or `undefined` if none.
- */
-export const getActiveChatbot = (): ActiveChatbot | undefined => {
- const registeredIds = getRegisteredViewIds(CHATBOT_LOCATION);
- if (registeredIds.length === 0) {
- return undefined;
- }
-
- // `getRegisteredViewIds` returns ids in registration order, so the last entry
- // is the most-recently-loaded chatbot. `getViewProvider` reads the same
- // synchronous registry maps, so the id always has a live provider; the final
- // guard is cheap defensiveness, not a fallback path.
- const selectedId = registeredIds[registeredIds.length - 1];
-
- const provider = getViewProvider(CHATBOT_LOCATION, selectedId);
- return provider ? { id: selectedId, provider } : undefined;
-};
diff --git a/superset-frontend/src/core/index.ts b/superset-frontend/src/core/index.ts
index d259597457c..dfe304eee54 100644
--- a/superset-frontend/src/core/index.ts
+++ b/superset-frontend/src/core/index.ts
@@ -27,6 +27,7 @@ export const core: typeof coreType = {
};
export * from './authentication';
+export * from './chat';
export * from './commands';
export * from './dashboard';
export * from './dataset';
diff --git a/superset-frontend/src/core/utils.ts b/superset-frontend/src/core/utils.ts
index fe54011caec..c6c9474dfd7 100644
--- a/superset-frontend/src/core/utils.ts
+++ b/superset-frontend/src/core/utils.ts
@@ -51,9 +51,20 @@ export interface Emitter<T> {
getCurrent: () => T;
}
-export function createEmitter<T>(initial: T): Emitter<T> {
+/**
+ * A current-value-less event emitter for pure notifications (e.g. "a chat
+ * was registered", "the panel opened") where a "latest value" reading makes
+ * no sense. {@link createEmitter} layers value tracking on top of this.
+ */
+export interface EventEmitter<T> {
+ /** Subscribe to events; conforms to the public `Event<T>` shape. */
+ event: EventSubscriber<T>;
+ /** Notify all current subscribers with `value`. */
+ fire: (value: T) => void;
+}
+
+export function createEventEmitter<T>(): EventEmitter<T> {
const listeners = new Set<(e: T) => void>();
- let current = initial;
return {
event: (listener, thisArgs) => {
@@ -64,9 +75,21 @@ export function createEmitter<T>(initial: T): Emitter<T> {
});
},
fire: value => {
- current = value;
listeners.forEach(fn => fn(value));
},
+ };
+}
+
+export function createEmitter<T>(initial: T): Emitter<T> {
+ const { event, fire } = createEventEmitter<T>();
+ let current = initial;
+
+ return {
+ event,
+ fire: value => {
+ current = value;
+ fire(value);
+ },
getCurrent: () => current,
};
}
diff --git a/superset-frontend/src/core/views/index.test.ts b/superset-frontend/src/core/views/index.test.ts
index 1112beb6491..d98a05b7f4f 100644
--- a/superset-frontend/src/core/views/index.test.ts
+++ b/superset-frontend/src/core/views/index.test.ts
@@ -17,12 +17,7 @@
* under the License.
*/
import React from 'react';
-import {
- views,
- resolveView,
- getViewProvider,
- getRegisteredViewIds,
-} from './index';
+import { views, resolveView } from './index';
const disposables: Array<{ dispose: () => void }> = [];
@@ -115,59 +110,3 @@ test('dispose removes the view registration', () => {
expect(views.getViews('sqllab.panels')).toBeUndefined();
});
-
-test('getViewProvider returns the registered provider for a matching location', () => {
- const provider = () => React.createElement('div', null, 'Test');
- disposables.push(
- views.registerView(
- { id: 'test.provider', name: 'Test Provider' },
- 'core.chatbot',
- provider,
- ),
- );
-
- expect(getViewProvider('core.chatbot', 'test.provider')).toBe(provider);
-});
-
-test('getViewProvider returns undefined when the location does not match', () => {
- const provider = () => React.createElement('div', null, 'Test');
- disposables.push(
- views.registerView(
- { id: 'test.provider', name: 'Test Provider' },
- 'sqllab.panels',
- provider,
- ),
- );
-
- // Registered, but at a different location.
- expect(getViewProvider('core.chatbot', 'test.provider')).toBeUndefined();
-});
-
-test('getViewProvider returns undefined for an unknown id', () => {
- expect(getViewProvider('core.chatbot', 'nonexistent')).toBeUndefined();
-});
-
-test('getRegisteredViewIds returns ids in registration order', () => {
- const provider = () => React.createElement('div', null, 'Test');
- disposables.push(
- views.registerView(
- { id: 'first.chatbot', name: 'First' },
- 'core.chatbot',
- provider,
- ),
- views.registerView(
- { id: 'second.chatbot', name: 'Second' },
- 'core.chatbot',
- provider,
- ),
- );
-
- expect(getRegisteredViewIds('core.chatbot')).toEqual([
- 'first.chatbot',
- 'second.chatbot',
- ]);
-});
-
-test('getRegisteredViewIds returns an empty array for an unused location', () => {
- expect(getRegisteredViewIds('core.chatbot')).toEqual([]);
-});
diff --git a/superset-frontend/src/core/views/index.ts b/superset-frontend/src/core/views/index.ts
index bc3bea3588f..8f726432cce 100644
--- a/superset-frontend/src/core/views/index.ts
+++ b/superset-frontend/src/core/views/index.ts
@@ -39,27 +39,6 @@ const viewRegistry: Map<
const locationIndex: Map<string, Set<string>> = new Map();
-/**
- * Monotonic version of the view registry. Bumped on every registration or
- * disposal so consumers can re-derive state via React's `useSyncExternalStore`.
- */
-let registryVersion = 0;
-const registrySubscribers = new Set<() => void>();
-
-const notifyRegistry = () => {
- registryVersion += 1;
- registrySubscribers.forEach(fn => fn());
-};
-
-export const subscribeToRegistry = (listener: () => void): (() => void) => {
- registrySubscribers.add(listener);
- return () => {
- registrySubscribers.delete(listener);
- };
-};
-
-export const getRegistryVersion = () => registryVersion;
-
const registerView: typeof viewsApi.registerView = (
view: View,
location: string,
@@ -78,13 +57,10 @@ const registerView: typeof viewsApi.registerView = (
ids.add(id);
locationIndex.set(location, ids);
- notifyRegistry();
-
return new Disposable(() => {
const registeredLocation = viewRegistry.get(id)?.location ?? location;
viewRegistry.delete(id);
locationIndex.get(registeredLocation)?.delete(id);
- notifyRegistry();
});
};
@@ -107,28 +83,6 @@ const getViews: typeof viewsApi.getViews = (
.filter((c): c is View => !!c);
};
-/**
- * Host-internal: returns the provider for a registered view id at a location.
- * Not part of the public `@apache-superset/core` API — `getViews` stays
- * descriptor-only so extensions cannot render each other's views directly.
- */
-export const getViewProvider = (
- location: string,
- id: string,
-): (() => ReactElement) | undefined => {
- const entry = viewRegistry.get(id);
- if (entry?.location !== location) {
- return undefined;
- }
- return entry.provider;
-};
-
-/** Host-internal: view ids at a location in registration order. */
-export const getRegisteredViewIds = (location: string): string[] => {
- const ids = locationIndex.get(location);
- return ids ? Array.from(ids) : [];
-};
-
export const views: typeof viewsApi = {
registerView,
getViews,
diff --git a/superset-frontend/src/extensions/ExtensionsStartup.test.tsx b/superset-frontend/src/extensions/ExtensionsStartup.test.tsx
index bdc646423bf..59ec6100bfe 100644
--- a/superset-frontend/src/extensions/ExtensionsStartup.test.tsx
+++ b/superset-frontend/src/extensions/ExtensionsStartup.test.tsx
@@ -97,6 +97,7 @@ test('sets up global superset object when user is logged in', async () => {
// Verify the global superset object is set up
expect((window as any).superset).toBeDefined();
expect((window as any).superset.authentication).toBeDefined();
+ expect((window as any).superset.chat).toBeDefined();
expect((window as any).superset.core).toBeDefined();
expect((window as any).superset.commands).toBeDefined();
expect((window as any).superset.extensions).toBeDefined();
diff --git a/superset-frontend/src/extensions/ExtensionsStartup.tsx b/superset-frontend/src/extensions/ExtensionsStartup.tsx
index 87abcd4192e..703f80f9235 100644
--- a/superset-frontend/src/extensions/ExtensionsStartup.tsx
+++ b/superset-frontend/src/extensions/ExtensionsStartup.tsx
@@ -22,6 +22,7 @@ import { logging } from '@apache-superset/core/utils';
import { FeatureFlag, isFeatureEnabled } from '@superset-ui/core';
import {
authentication,
+ chat,
core,
commands,
dashboard,
@@ -90,6 +91,7 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
// as that would leak un-contracted symbols onto window.superset.
window.superset = {
authentication,
+ chat,
core,
commands,
dashboard,
@@ -104,8 +106,8 @@ const ExtensionsStartup: React.FC<{ children?: React.ReactNode }> = ({
};
// Render the host immediately; extension bundles load in the background.
- // ChatbotMount re-resolves reactively once the chatbot extension registers
- // (via subscribeToRegistry / getRegistryVersion), so the bubble appears
+ // ChatMount re-resolves reactively once a chat extension registers (via
+ // subscribeToChatState / getChatSnapshot), so the bubble appears
// without blocking the UI.
setInitialized(true);
diff --git a/superset-frontend/src/extensions/supersetGlobal.ts b/superset-frontend/src/extensions/supersetGlobal.ts
index 70e5786e999..cd2993491a1 100644
--- a/superset-frontend/src/extensions/supersetGlobal.ts
+++ b/superset-frontend/src/extensions/supersetGlobal.ts
@@ -28,6 +28,7 @@
import type {
authentication,
+ chat,
commands,
core,
dashboard,
@@ -45,6 +46,7 @@ import type {
export interface SupersetGlobal {
authentication: typeof authentication;
core: typeof core;
+ chat: typeof chat;
commands: typeof commands;
dashboard: typeof dashboard;
dataset: typeof dataset;
diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx
index 0ea9014f575..6a5c08672ee 100644
--- a/superset-frontend/src/views/App.tsx
+++ b/superset-frontend/src/views/App.tsx
@@ -40,7 +40,7 @@ import { logEvent } from 'src/logger/actions';
import { store } from 'src/views/store';
import { FeatureFlag, isFeatureEnabled } from '@superset-ui/core';
import ExtensionsStartup from 'src/extensions/ExtensionsStartup';
-import ChatbotMount from 'src/components/ChatbotMount';
+import ChatMount from 'src/components/ChatMount';
import { RootContextProviders } from './RootContextProviders';
import { ScrollToTop } from './ScrollToTop';
@@ -115,12 +115,12 @@ const App = () => (
))}
</Switch>
{/*
- The singleton chatbot bubble. Rendered as a sibling of the route
- Switch — inside ExtensionsStartup so chatbot extensions have been
- loaded and registered, but outside the Switch so the bubble persists
+ The singleton chat slot. Rendered as a sibling of the route
+ Switch — inside ExtensionsStartup so chat extensions have been
+ loaded and registered, but outside the Switch so the chat persists
across route changes.
*/}
- {isFeatureEnabled(FeatureFlag.EnableExtensions) && <ChatbotMount />}
+ {isFeatureEnabled(FeatureFlag.EnableExtensions) && <ChatMount />}
</ExtensionsStartup>
<ToastContainer />
</RootContextProviders>
diff --git a/superset-frontend/src/views/contributions.ts b/superset-frontend/src/views/contributions.ts
deleted file mode 100644
index 12770b699bc..00000000000
--- a/superset-frontend/src/views/contributions.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * View locations for app-shell extension integration.
- *
- * These define locations that persist across all routes, mirroring the `app`
- * scope of the `ViewContributions` manifest schema.
- */
-export const AppViewLocations = {
- app: {
- chatbot: 'core.chatbot',
- },
-} as const;
-
-export const CHATBOT_LOCATION = AppViewLocations.app.chatbot;