From 395a7a76bb67177fbdbe7d672f877dcd81e75039 Mon Sep 17 00:00:00 2001 From: MK Fain Date: Wed, 3 Dec 2025 21:57:41 -0600 Subject: [PATCH] feat(mobile): improve GlobalChatPane behavior on mobile screens - Hide FloatingChatButton on mobile for all pages except home (/ and /giftcard) - Add Building/Chatting toggle on mobile Chat tab in ProjectView - Add embedded mode to GlobalChatPane for inline rendering without fixed positioning - Add translations for "building" and "chatting" in all locales (en, pt, zh, ha, yo, ig) --- src/components/FloatingChatButton.tsx | 8 ++ src/components/GlobalChatPane.tsx | 129 +++++++++++++++++++++++++- src/locales/en.json | 4 +- src/locales/ha.json | 4 +- src/locales/ig.json | 4 +- src/locales/pt.json | 4 +- src/locales/yo.json | 4 +- src/locales/zh.json | 4 +- src/pages/ProjectView.tsx | 81 ++++++++++++---- 9 files changed, 211 insertions(+), 31 deletions(-) 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 */} +
+
+ +
+
+