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({