fix(chat): fix session return button on mobile. add double-click to switch to chat and auto-focus draft (#384)

This commit is contained in:
gsxdsm
2026-02-11 20:08:15 +02:00
committed by GitHub
parent 3afe0bb45d
commit eaf19cc62f
5 changed files with 90 additions and 47 deletions
@@ -224,6 +224,23 @@ export const ChatInput: React.FC<ChatInputProps> = ({ 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) {