Skip to content

Commit 75bbee7

Browse files
committed
fix: chat reducer placeholder
1 parent 24259d1 commit 75bbee7

File tree

6 files changed

+69
-8
lines changed

6 files changed

+69
-8
lines changed

src/lib.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export {
77
export {AsideNavigation} from './containers/AsideNavigation/AsideNavigation';
88

99
export {configureStore, rootReducer} from './store';
10+
export type {ConfigureStoreOptions} from './store';
1011
export {default as appRoutes} from './routes';
1112

1213
export {YdbEmbeddedAPI} from './services/api';
@@ -52,3 +53,7 @@ export type {
5253

5354
// Re-export chat component types from ComponentsProvider
5455
export type {AIAssistantButtonProps, ChatPanelProps} from './components/ComponentsProvider';
56+
57+
// Export placeholder chat reducer and actions
58+
// These can be overridden by external implementations
59+
export {chatReducer, chatActions} from './store/reducers/chat/chatPlaceholder';

src/services/api/aiAssist.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {ChatDelta, ChatMessage, QuotaInfo} from '../../features/chat/types/chat';
21
import {aiAssistBackend as AI_ASSISTANT_BACKEND} from '../../store';
2+
import type {ChatDelta, ChatMessage, QuotaInfo} from '../../types/chat';
33

44
import {BaseYdbAPI} from './base';
55

@@ -48,7 +48,6 @@ export class AIAssistAPI extends BaseYdbAPI {
4848
const decoder = new TextDecoder();
4949
let buffer = '';
5050

51-
// eslint-disable-next-line no-constant-condition
5251
while (true) {
5352
const {done, value} = await reader.read();
5453
if (done) {

src/store/configureStore.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,40 @@ export const aiAssistBackend = window.ai_assist_backend;
5555

5656
const isSingleClusterMode = `${metaBackend}` === 'undefined';
5757

58+
export interface ConfigureStoreOptions {
59+
aRootReducer?: typeof rootReducer;
60+
singleClusterMode?: boolean;
61+
api?: YdbEmbeddedAPI;
62+
additionalReducers?: Record<string, Reducer>;
63+
}
64+
5865
export function configureStore({
5966
aRootReducer = rootReducer,
6067
singleClusterMode = isSingleClusterMode,
6168
api = new YdbEmbeddedAPI({webVersion, withCredentials: !customBackend}),
62-
} = {}) {
69+
additionalReducers = {},
70+
}: ConfigureStoreOptions = {}) {
6371
({backend, basename, clusterName} = getUrlData({
6472
singleClusterMode,
6573
customBackend,
6674
}));
6775
const history = createBrowserHistory({basename});
6876

69-
const store = _configureStore(aRootReducer, history, {singleClusterMode}, [
70-
storeApi.middleware,
71-
]);
77+
// Merge root reducer with additional reducers
78+
const mergedReducer =
79+
Object.keys(additionalReducers).length > 0
80+
? {
81+
...aRootReducer,
82+
...additionalReducers,
83+
}
84+
: aRootReducer;
85+
86+
const store = _configureStore(
87+
mergedReducer as typeof rootReducer,
88+
history,
89+
{singleClusterMode},
90+
[storeApi.middleware],
91+
);
7292
listenForHistoryChange(store, history);
7393

7494
window.api = api;

src/store/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export {
1212
export {rootReducer} from './reducers';
1313

1414
export type {AppDispatch, GetState, RootState} from './defaultStore';
15+
export type {ConfigureStoreOptions} from './configureStore';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import {createSlice} from '@reduxjs/toolkit';
2+
3+
import type {ChatState} from '../../../types/chat';
4+
5+
// Placeholder chat reducer
6+
// This will be overridden when chat feature is implemented in external packages
7+
8+
const initialState: ChatState = {
9+
messages: [],
10+
isStreaming: false,
11+
error: null,
12+
sessionId: null,
13+
isOpen: false,
14+
needsNewAssistantMessage: false,
15+
currentStreamingMessageId: undefined,
16+
};
17+
18+
const chatPlaceholderSlice = createSlice({
19+
name: 'chat',
20+
initialState,
21+
reducers: {
22+
// Placeholder actions that do nothing
23+
openChat: () => initialState,
24+
closeChat: () => initialState,
25+
toggleChat: () => initialState,
26+
addMessage: () => initialState,
27+
updateMessage: () => initialState,
28+
clearMessages: () => initialState,
29+
startStreaming: () => initialState,
30+
stopStreaming: () => initialState,
31+
setError: () => initialState,
32+
clearError: () => initialState,
33+
},
34+
});
35+
36+
export const chatActions = chatPlaceholderSlice.actions;
37+
export const chatReducer = chatPlaceholderSlice.reducer;

src/store/reducers/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {combineReducers} from '@reduxjs/toolkit';
22

3-
import {chatReducer} from '../../features/chat/store/chatSlice';
4-
53
import {api} from './api';
64
import authentication from './authentication/authentication';
5+
import {chatReducer} from './chat/chatPlaceholder';
76
import cluster from './cluster/cluster';
87
import clusters from './clusters/clusters';
98
import executeTopQueries from './executeTopQueries/executeTopQueries';

0 commit comments

Comments
 (0)