From fc325fa79155d466be49d9dab7ea118d094f8a0a Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Sun, 8 Jun 2025 00:32:32 +0000 Subject: [PATCH 1/3] feat: add mobile new chat button to chat title bar - Add mobile-only new chat button positioned in top right of chat title bar - Uses SquarePenIcon for consistency with sidebar design - Only visible on mobile devices using useIsMobile() hook - Navigates to home page and focuses message input when tapped - Includes proper accessibility with aria-label Fixes #100 Co-authored-by: AnthonyRonning --- frontend/src/routes/_auth.chat.$chatId.tsx | 29 ++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx index 3e6a093ba..351e4fa56 100644 --- a/frontend/src/routes/_auth.chat.$chatId.tsx +++ b/frontend/src/routes/_auth.chat.$chatId.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState, useCallback } from "react"; import { createFileRoute } from "@tanstack/react-router"; -import { AsteriskIcon, Check, Copy, UserIcon, ChevronDown } from "lucide-react"; +import { AsteriskIcon, Check, Copy, UserIcon, ChevronDown, SquarePenIcon } from "lucide-react"; import ChatBox from "@/components/ChatBox"; import { useOpenAI } from "@/ai/useOpenAi"; import { useLocalState } from "@/state/useLocalState"; @@ -12,6 +12,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { BillingStatus } from "@/billing/billingApi"; import { useNavigate } from "@tanstack/react-router"; +import { useIsMobile } from "@/utils/utils"; export const Route = createFileRoute("/_auth/chat/$chatId")({ component: ChatComponent @@ -84,12 +85,24 @@ function ChatComponent() { const queryClient = useQueryClient(); const [showScrollButton, setShowScrollButton] = useState(false); const navigate = useNavigate(); + const isMobile = useIsMobile(); const [error, setError] = useState(""); const [isSummarizing, setIsSummarizing] = useState(false); const chatContainerRef = useRef(null); + // Handle mobile new chat + const handleMobileNewChat = useCallback(async () => { + try { + await navigate({ to: "/" }); + // Ensure element is available after navigation + setTimeout(() => document.getElementById("message")?.focus(), 0); + } catch (error) { + console.error("Navigation failed:", error); + } + }, [navigate]); + // Memoize the scroll handler const handleScroll = useCallback(() => { const container = chatContainerRef.current; @@ -578,7 +591,19 @@ END OF INSTRUCTIONS`; ref={chatContainerRef} className="flex-1 min-h-0 overflow-y-auto flex flex-col relative" > -
+
+ {/* Mobile new chat button */} + {isMobile && ( + + )}

{localChat.title}

From 4adce8eec2868f9e84fe8985b5b1a34d6844364b Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 05:50:29 +0000 Subject: [PATCH 2/3] feat: update mobile new chat button styling and behavior - Change variant from "ghost" to "outline" to match left panel button - Change size from "sm" to "icon" for consistency - Update behavior to check current pathname before navigation - Add useLocation import for pathname checking This ensures identical styling and behavior between mobile and desktop new chat buttons. Co-authored-by: AnthonyRonning --- frontend/src/routes/_auth.chat.$chatId.tsx | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/frontend/src/routes/_auth.chat.$chatId.tsx b/frontend/src/routes/_auth.chat.$chatId.tsx index 351e4fa56..d154af8d3 100644 --- a/frontend/src/routes/_auth.chat.$chatId.tsx +++ b/frontend/src/routes/_auth.chat.$chatId.tsx @@ -11,7 +11,7 @@ import { Sidebar, SidebarToggle } from "@/components/Sidebar"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; import { BillingStatus } from "@/billing/billingApi"; -import { useNavigate } from "@tanstack/react-router"; +import { useNavigate, useLocation } from "@tanstack/react-router"; import { useIsMobile } from "@/utils/utils"; export const Route = createFileRoute("/_auth/chat/$chatId")({ @@ -85,6 +85,7 @@ function ChatComponent() { const queryClient = useQueryClient(); const [showScrollButton, setShowScrollButton] = useState(false); const navigate = useNavigate(); + const location = useLocation(); const isMobile = useIsMobile(); const [error, setError] = useState(""); @@ -92,16 +93,21 @@ function ChatComponent() { const chatContainerRef = useRef(null); - // Handle mobile new chat + // Handle mobile new chat (matching sidebar behavior) const handleMobileNewChat = useCallback(async () => { - try { - await navigate({ to: "/" }); - // Ensure element is available after navigation - setTimeout(() => document.getElementById("message")?.focus(), 0); - } catch (error) { - console.error("Navigation failed:", error); + // If we're already on "/", focus the chat box + if (location.pathname === "/") { + document.getElementById("message")?.focus(); + } else { + try { + await navigate({ to: "/" }); + // Ensure element is available after navigation + setTimeout(() => document.getElementById("message")?.focus(), 0); + } catch (error) { + console.error("Navigation failed:", error); + } } - }, [navigate]); + }, [navigate, location.pathname]); // Memoize the scroll handler const handleScroll = useCallback(() => { @@ -595,9 +601,9 @@ END OF INSTRUCTIONS`; {/* Mobile new chat button */} {isMobile && ( )} -

+

{localChat.title}