diff --git a/src/components/FloatingChatButton.tsx b/src/components/FloatingChatButton.tsx index 90c58007..6bd109e8 100644 --- a/src/components/FloatingChatButton.tsx +++ b/src/components/FloatingChatButton.tsx @@ -4,12 +4,14 @@ import { MessageCircle, X } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useGlobalChat } from '@/hooks/useGlobalChat'; import { useAppContext } from '@/hooks/useAppContext'; +import { useIsMobile } from '@/hooks/useIsMobile'; import { cn } from '@/lib/utils'; export function FloatingChatButton() { const { isOpen, setIsOpen, hasUnread } = useGlobalChat(); const { config } = useAppContext(); const location = useLocation(); + const isMobile = useIsMobile(); const [isHovered, setIsHovered] = useState(false); const [isHiddenTemporarily, setIsHiddenTemporarily] = useState(false); @@ -28,6 +30,12 @@ export function FloatingChatButton() { return null; } + // On mobile, only show on home screen (/ or /giftcard) + const isHomePage = location.pathname === '/' || location.pathname === '/giftcard'; + if (isMobile && !isHomePage) { + return null; + } + // Don't render if temporarily hidden if (isHiddenTemporarily) { return null; diff --git a/src/components/GlobalChatPane.tsx b/src/components/GlobalChatPane.tsx index 7fa59de5..1e68ff45 100644 --- a/src/components/GlobalChatPane.tsx +++ b/src/components/GlobalChatPane.tsx @@ -80,7 +80,12 @@ function ChatMessage({ message }: { message: GlobalChatMessage }) { ); } -export function GlobalChatPane() { +interface GlobalChatPaneProps { + /** When true, renders inline without fixed positioning (for embedding in ProjectView) */ + embedded?: boolean; +} + +export function GlobalChatPane({ embedded = false }: GlobalChatPaneProps) { const { t } = useTranslation(); const { messages, @@ -188,18 +193,132 @@ export function GlobalChatPane() { } }, [handleSend, isMobile]); - // Don't render if disabled or not open - if (config.globalChatEnabled === false || !isOpen) { + // For non-embedded mode: Don't render if disabled or not open + if (!embedded && (config.globalChatEnabled === false || !isOpen)) { return null; } - // Don't render on settings pages - if (location.pathname.startsWith('/settings')) { + // For non-embedded mode: Don't render on settings pages + if (!embedded && location.pathname.startsWith('/settings')) { return null; } const hasProviders = settings.providers.length > 0; + // Embedded mode: Render inline without fixed positioning + if (embedded) { + return ( +
+ {/* Header */} +
+

{t('globalChat')}

+
+ {messages.length > 0 && ( + + + + + {t('clearChat')} + + )} +
+
+ + {/* Messages */} +
+ {messages.length === 0 ? ( +
+
+

{t('globalChatWelcome')}

+

{t('globalChatDescription')}

+
+
+ ) : ( + messages.map((message) => ( + + )) + )} + + {isLoading && messages[messages.length - 1]?.role !== 'assistant' && ( +
+
+ +
+
+ )} +
+ + {/* Scroll to bottom button */} + {showScrollToBottom && ( + + )} + + {/* Input */} +
+
+ +
+
+