Skip to content

Commit 2e03cdd

Browse files
committed
feat: ai assistant component placeholders
1 parent 1576443 commit 2e03cdd

File tree

29 files changed

+59
-2436
lines changed

29 files changed

+59
-2436
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type React from 'react';
2+
3+
// Placeholder types for chat components
4+
// These will be properly typed when implemented in external packages
5+
6+
export interface AIAssistantButtonProps {
7+
className?: string;
8+
}
9+
10+
export interface ChatPanelProps {
11+
config?: {
12+
backendUrl?: string;
13+
showQuota?: boolean;
14+
enableContext?: boolean;
15+
customActions?: any[];
16+
maxMessages?: number;
17+
welcomeMessage?: string;
18+
suggestions?: string[];
19+
};
20+
context?: any;
21+
formatContext?: (context: any) => string;
22+
}
23+
24+
// Placeholder components that do nothing
25+
export const AIAssistantButtonPlaceholder: React.FC<AIAssistantButtonProps> = () => null;
26+
export const ChatPanelPlaceholder: React.FC<ChatPanelProps> = () => null;

src/components/ComponentsProvider/componentsRegistry.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
1+
import type React from 'react';
2+
13
import {AsideNavigation} from '../../containers/AsideNavigation/AsideNavigation';
24
import {ErrorBoundaryInner} from '../ErrorBoundary/ErrorBoundary';
35
import {ShardsTable} from '../ShardsTable/ShardsTable';
46
import {StaffCard} from '../User/StaffCard';
57

8+
import {AIAssistantButtonPlaceholder, ChatPanelPlaceholder} from './chatPlaceholderTypes';
9+
import type {AIAssistantButtonProps, ChatPanelProps} from './chatPlaceholderTypes';
610
import type {ComponentsRegistryTemplate} from './registry';
711
import {Registry} from './registry';
812

913
const componentsRegistryInner = new Registry()
1014
.register('StaffCard', StaffCard)
1115
.register('AsideNavigation', AsideNavigation)
1216
.register('ErrorBoundary', ErrorBoundaryInner)
13-
.register('ShardsTable', ShardsTable);
17+
.register('ShardsTable', ShardsTable)
18+
// Placeholder registrations for chat components
19+
// These will be overridden by external implementations
20+
.register(
21+
'AIAssistantButton',
22+
AIAssistantButtonPlaceholder as React.ComponentType<AIAssistantButtonProps>,
23+
)
24+
.register('ChatPanel', ChatPanelPlaceholder as React.ComponentType<ChatPanelProps>);
1425

1526
export type ComponentsRegistry = ComponentsRegistryTemplate<typeof componentsRegistryInner>;
1627

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export {ComponentsProvider} from './ComponentsProvider';
2+
export {componentsRegistry} from './componentsRegistry';
3+
export type {ComponentsRegistry} from './componentsRegistry';
4+
5+
// Export chat component types for external packages to use
6+
export type {AIAssistantButtonProps, ChatPanelProps} from './chatPlaceholderTypes';

src/containers/App/App.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import type {History} from 'history';
55
import {Helmet} from 'react-helmet-async';
66
import {connect} from 'react-redux';
77

8+
import {componentsRegistry} from '../../components/ComponentsProvider/componentsRegistry';
89
import {ErrorBoundary} from '../../components/ErrorBoundary/ErrorBoundary';
9-
import {ChatPanel} from '../../features/chat';
1010
import type {RootState} from '../../store';
1111
import {Navigation} from '../AsideNavigation/Navigation';
1212
import ReduxTooltip from '../ReduxTooltip/ReduxTooltip';
@@ -33,6 +33,9 @@ function App({
3333
children,
3434
userSettings = getUserSettings({singleClusterMode}),
3535
}: AppProps) {
36+
// Get ChatPanel from registry if it exists
37+
const ChatPanel = componentsRegistry.get('ChatPanel');
38+
3639
return (
3740
<Providers store={store} history={history}>
3841
<Helmet defaultTitle="YDB Monitoring" titleTemplate="%s — YDB Monitoring" />
@@ -44,7 +47,8 @@ function App({
4447
</ErrorBoundary>
4548
</Navigation>
4649
</ContentWrapper>
47-
<ChatPanel />
50+
{/* Render ChatPanel only if it's registered */}
51+
{ChatPanel && <ChatPanel />}
4852
<ReduxTooltip />
4953
</Providers>
5054
);

src/containers/Header/Header.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import {ArrowUpRightFromSquare, CirclePlus, PlugConnection} from '@gravity-ui/ic
44
import {Breadcrumbs, Button, Divider, Flex, Icon} from '@gravity-ui/uikit';
55
import {useLocation} from 'react-router-dom';
66

7+
import {componentsRegistry} from '../../components/ComponentsProvider/componentsRegistry';
78
import {getConnectToDBDialog} from '../../components/ConnectToDB/ConnectToDBDialog';
89
import {InternalLink} from '../../components/InternalLink';
9-
import {AIAssistantButton} from '../../features/chat/components/AIAssistantButton/AIAssistantButton';
1010
import {useAddClusterFeatureAvailable} from '../../store/reducers/capabilities/hooks';
1111
import {useClusterBaseInfo} from '../../store/reducers/cluster/cluster';
1212
import {uiFactory} from '../../uiFactory/uiFactory';
1313
import {cn} from '../../utils/cn';
14-
import {DEVELOPER_UI_TITLE, ENABLE_AI_ASSISTANT} from '../../utils/constants';
14+
import {DEVELOPER_UI_TITLE} from '../../utils/constants';
1515
import {createDeveloperUIInternalPageHref} from '../../utils/developerUI/developerUI';
16-
import {useSetting, useTypedSelector} from '../../utils/hooks';
16+
import {useTypedSelector} from '../../utils/hooks';
1717
import {useDatabaseFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
1818
import {useIsUserAllowedToMakeChanges} from '../../utils/hooks/useIsUserAllowedToMakeChanges';
1919

@@ -28,7 +28,6 @@ function Header() {
2828
const {page, pageBreadcrumbsOptions} = useTypedSelector((state) => state.header);
2929
const singleClusterMode = useTypedSelector((state) => state.singleClusterMode);
3030
const isUserAllowedToMakeChanges = useIsUserAllowedToMakeChanges();
31-
const [isAiAssistantEnabled] = useSetting(ENABLE_AI_ASSISTANT);
3231

3332
const {title: clusterTitle} = useClusterBaseInfo();
3433

@@ -40,6 +39,9 @@ function Header() {
4039
const isAddClusterAvailable =
4140
useAddClusterFeatureAvailable() && uiFactory.onAddCluster !== undefined;
4241

42+
// Get AIAssistantButton from registry if it exists
43+
const AIAssistantButton = componentsRegistry.get('AIAssistantButton');
44+
4345
const breadcrumbItems = React.useMemo(() => {
4446
let options = {...pageBreadcrumbsOptions, singleClusterMode};
4547

@@ -78,8 +80,9 @@ function Header() {
7880
);
7981
}
8082

81-
if (isAiAssistantEnabled) {
82-
elements.push(<AIAssistantButton />);
83+
// Add AI Assistant button if component is registered
84+
if (AIAssistantButton) {
85+
elements.push(<AIAssistantButton key="ai-assistant" />);
8386
}
8487

8588
if (!isClustersPage && isUserAllowedToMakeChanges) {

src/containers/UserSettings/settings.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
AUTOCOMPLETE_ON_ENTER,
99
AclSyntax,
1010
BINARY_DATA_IN_PLAIN_TEXT_DISPLAY,
11-
ENABLE_AI_ASSISTANT,
1211
ENABLE_AUTOCOMPLETE,
1312
ENABLE_CODE_ASSISTANT,
1413
ENABLE_NETWORK_TABLE_KEY,
@@ -133,12 +132,6 @@ export const enableCodeAssistantSetting: SettingProps = {
133132
description: i18n('settings.editor.codeAssistant.description'),
134133
};
135134

136-
export const enableAiAssistantSetting: SettingProps = {
137-
settingKey: ENABLE_AI_ASSISTANT,
138-
title: i18n('settings.editor.aiAssistant.title'),
139-
description: i18n('settings.editor.aiAssistant.title'),
140-
};
141-
142135
export const enableQueryStreamingSetting: SettingProps = {
143136
settingKey: ENABLE_QUERY_STREAMING,
144137
title: i18n('settings.editor.queryStreaming.title'),

src/features/chat/components/AIAssistantButton/AIAssistantButton.scss

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/features/chat/components/AIAssistantButton/AIAssistantButton.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/features/chat/components/ChatInput/ChatInput.scss

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)