From 569cc411c36911db3e0b1e5b5064465ee65a0bdd Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Fri, 13 Feb 2026 09:20:13 -0800 Subject: [PATCH] refactor: simplify mobile agent button interaction (#416) --- packages/ui/src/components/chat/ChatInput.tsx | 2 +- .../src/components/chat/MobileAgentButton.tsx | 47 +-------------- .../ui/src/components/chat/ModelControls.tsx | 60 +++++++++++-------- 3 files changed, 38 insertions(+), 71 deletions(-) diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index ca3f08f4..f28bda3b 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -2082,7 +2082,7 @@ export const ChatInput: React.FC = ({ onOpenSettings, scrollToBo
- setMobileControlsPanel('agent')} className="min-w-0 flex-shrink" /> + setMobileControlsPanel('agent')} className="min-w-0 flex-shrink" />
diff --git a/packages/ui/src/components/chat/MobileAgentButton.tsx b/packages/ui/src/components/chat/MobileAgentButton.tsx index 1f69c8da..eb157f30 100644 --- a/packages/ui/src/components/chat/MobileAgentButton.tsx +++ b/packages/ui/src/components/chat/MobileAgentButton.tsx @@ -6,12 +6,11 @@ import { getAgentDisplayName } from './mobileControlsUtils'; import { getAgentColor } from '@/lib/agentColors'; interface MobileAgentButtonProps { - onCycleAgent: () => void; onOpenAgentPanel: () => void; className?: string; } -export const MobileAgentButton: React.FC = ({ onCycleAgent, onOpenAgentPanel, className }) => { +export const MobileAgentButton: React.FC = ({ onOpenAgentPanel, className }) => { const { currentAgentName, getVisibleAgents } = useConfigStore(); const currentSessionId = useSessionStore((state) => state.currentSessionId); const sessionAgentName = useSessionStore((state) => @@ -23,56 +22,16 @@ export const MobileAgentButton: React.FC = ({ onCycleAge const agentLabel = getAgentDisplayName(agents, uiAgentName); const agentColor = getAgentColor(uiAgentName); - const longPressTimerRef = React.useRef | null>(null); - const isLongPressRef = React.useRef(false); - - const handlePointerDown = (event: React.PointerEvent) => { - event.preventDefault(); - isLongPressRef.current = false; - longPressTimerRef.current = setTimeout(() => { - isLongPressRef.current = true; - onOpenAgentPanel(); - }, 500); - }; - - const handlePointerUp = () => { - if (longPressTimerRef.current) { - clearTimeout(longPressTimerRef.current); - longPressTimerRef.current = null; - } - if (!isLongPressRef.current) { - onCycleAgent(); - } - }; - - const handlePointerLeave = () => { - if (longPressTimerRef.current) { - clearTimeout(longPressTimerRef.current); - longPressTimerRef.current = null; - } - }; - - React.useEffect(() => { - return () => { - if (longPressTimerRef.current) { - clearTimeout(longPressTimerRef.current); - } - }; - }, []); - return ( ); })} -
-
- - Auto-approve edits - - -
-
);