feat: add typing indicator with ChatBubble component
- Add ChatBubble component for reusable chat bubble styling - Add TypingIndicator component with animated dots (. .. ...) - Show typing indicator after 500ms delay while waiting for AI response - Refactor ChatMessage to use ChatBubble component - Add isWaitingForResponse state to ChatStore
This commit is contained in:
@@ -13,14 +13,17 @@ export type MessageData = {
|
||||
|
||||
interface ChatState {
|
||||
messages: MessageData[];
|
||||
isWaitingForResponse: boolean;
|
||||
addMessages: (messages: MessageData[]) => void;
|
||||
addMessage: (message: MessageData) => void;
|
||||
updateMessage: (id: string, updates: Partial<MessageData>) => void;
|
||||
clearMessages: () => void;
|
||||
setWaitingForResponse: (waiting: boolean) => void;
|
||||
}
|
||||
|
||||
export const useChatStore = create<ChatState>((set) => ({
|
||||
messages: [],
|
||||
isWaitingForResponse: false,
|
||||
addMessages(messages) {
|
||||
set((state) => ({ messages: [...state.messages, ...messages] }));
|
||||
},
|
||||
@@ -37,6 +40,9 @@ export const useChatStore = create<ChatState>((set) => ({
|
||||
clearMessages: () => {
|
||||
set({ messages: [] });
|
||||
},
|
||||
setWaitingForResponse: (waiting: boolean) => {
|
||||
set({ isWaitingForResponse: waiting });
|
||||
},
|
||||
}));
|
||||
|
||||
// Helper to convert server ChatMessage to client MessageData
|
||||
|
||||
Reference in New Issue
Block a user