From eaf19cc62f9fac8af8b6863e86c874affc523369 Mon Sep 17 00:00:00 2001 From: gsxdsm Date: Wed, 11 Feb 2026 10:08:15 -0800 Subject: [PATCH] fix(chat): fix session return button on mobile. add double-click to switch to chat and auto-focus draft (#384) --- packages/ui/src/components/chat/ChatInput.tsx | 17 +++++ .../chat/MobileSessionStatusBar.tsx | 16 +++++ .../ui/src/components/layout/MainLayout.tsx | 25 +++---- .../ui/src/components/layout/VSCodeLayout.tsx | 69 ++++++++++--------- .../src/components/session/SessionSidebar.tsx | 10 +++ 5 files changed, 90 insertions(+), 47 deletions(-) diff --git a/packages/ui/src/components/chat/ChatInput.tsx b/packages/ui/src/components/chat/ChatInput.tsx index 70540287..d5456fef 100644 --- a/packages/ui/src/components/chat/ChatInput.tsx +++ b/packages/ui/src/components/chat/ChatInput.tsx @@ -224,6 +224,23 @@ export const ChatInput: React.FC = ({ onOpenSettings, scrollToBo } }, [currentSessionId, persistChatDraft, message]); + // Focus textarea when new session draft is opened + const prevNewSessionDraftOpenRef = React.useRef(newSessionDraftOpen); + React.useEffect(() => { + if (!prevNewSessionDraftOpenRef.current && newSessionDraftOpen) { + // New session draft just opened - focus the textarea + requestAnimationFrame(() => { + if (isMobile) { + // On mobile, use preventScroll to avoid viewport jumping + textareaRef.current?.focus({ preventScroll: true }); + } else { + textareaRef.current?.focus(); + } + }); + } + prevNewSessionDraftOpenRef.current = newSessionDraftOpen; + }, [newSessionDraftOpen, isMobile]); + // Persist chat input draft to localStorage (only if setting enabled) React.useEffect(() => { if (!persistChatDraft) { diff --git a/packages/ui/src/components/chat/MobileSessionStatusBar.tsx b/packages/ui/src/components/chat/MobileSessionStatusBar.tsx index 75053f83..e3c5959a 100644 --- a/packages/ui/src/components/chat/MobileSessionStatusBar.tsx +++ b/packages/ui/src/components/chat/MobileSessionStatusBar.tsx @@ -183,6 +183,7 @@ function SessionItem({ getSessionAgentName, getSessionTitle, onClick, + onDoubleClick, needsAttention }: { session: SessionWithStatus; @@ -190,6 +191,7 @@ function SessionItem({ getSessionAgentName: (s: Session) => string; getSessionTitle: (s: Session) => string; onClick: () => void; + onDoubleClick?: () => void; needsAttention: (sessionId: string) => boolean; }) { const agentName = getSessionAgentName(session); @@ -200,6 +202,10 @@ function SessionItem({