From cec36ee298282edf1d6b72051c2c51251c4938b9 Mon Sep 17 00:00:00 2001 From: belviskhoremk Date: Mon, 23 Feb 2026 16:46:51 +0000 Subject: [PATCH] fixed bugs --- src/components/ChatInterface.tsx | 89 ++-- src/lib/utils.ts | 93 +---- src/pages/ChatbotBuilderPage.tsx | 697 ++++++++++++++++++++++--------- src/pages/DashboardPage.tsx | 20 +- src/pages/MarketplacePage.tsx | 416 +++++++++--------- src/services/api.ts | 71 ++-- src/types/index.ts | 24 +- 7 files changed, 866 insertions(+), 544 deletions(-) diff --git a/src/components/ChatInterface.tsx b/src/components/ChatInterface.tsx index e8a5ef2..72c1418 100644 --- a/src/components/ChatInterface.tsx +++ b/src/components/ChatInterface.tsx @@ -9,13 +9,13 @@ interface ChatInterfaceProps { chatbotName: string welcomeMessage: string primaryColor: string + logoUrl?: string isPreview?: boolean - // BUG-09 FIX: Accept optional sessionId to persist conversations across navigation sessionId?: string } export const ChatInterface: React.FC = ({ - chatbotId, chatbotName, welcomeMessage, primaryColor, isPreview = false, sessionId: externalSessionId + chatbotId, chatbotName, welcomeMessage, primaryColor, logoUrl, isPreview = false, sessionId: externalSessionId }) => { const [messages, setMessages] = useState([ { id: '0', role: 'assistant', content: welcomeMessage } @@ -23,7 +23,6 @@ export const ChatInterface: React.FC = ({ const [input, setInput] = useState('') const [loading, setLoading] = useState(false) - // BUG-09 FIX: Use provided sessionId or persist in sessionStorage const [sessionId] = useState(() => { if (externalSessionId) return externalSessionId const storageKey = `chat-session-${chatbotId}` @@ -82,7 +81,6 @@ export const ChatInterface: React.FC = ({ } } - // IMP-08: Shift+Enter for newline, Enter to send const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() @@ -98,13 +96,50 @@ export const ChatInterface: React.FC = ({ }) } + // ── Helper: render bot avatar (logo or fallback icon) ───────────────────── + const BotAvatar: React.FC<{ size?: 'sm' | 'md' }> = ({ size = 'sm' }) => { + const sizeClasses = size === 'sm' + ? 'w-7 h-7 rounded-lg' + : 'w-8 h-8 rounded-lg' + + if (logoUrl) { + return ( + {chatbotName} + ) + } + + return ( +
+ +
+ ) + } + return (
{/* Header */} -
-
- -
+
+ {logoUrl ? ( + {chatbotName} + ) : ( +
+ +
+ )}

{chatbotName}

{isPreview && Preview mode} @@ -115,18 +150,13 @@ export const ChatInterface: React.FC = ({
{messages.map((msg) => (
- {msg.role === 'assistant' && ( -
- -
- )} + {msg.role === 'assistant' && }
+ )} style={msg.role === 'user' ? { background: primaryColor } : undefined}>

{msg.content}

{/* Sources */} @@ -145,8 +175,7 @@ export const ChatInterface: React.FC = ({ {msg.sources.map((src, i) => (

{src.document_name}

-

{src.chunk_text}

-

Relevance: {(src.score * 100).toFixed(0)}%

+

{src.chunk_text}

))}
@@ -154,21 +183,12 @@ export const ChatInterface: React.FC = ({
)}
- {msg.role === 'user' && ( -
- -
- )}
))} - {/* Typing indicator */} {loading && (
-
- -
+
@@ -178,7 +198,6 @@ export const ChatInterface: React.FC = ({
)} -
@@ -188,17 +207,17 @@ export const ChatInterface: React.FC = ({