From 7d69229cd76447b92ee66f472f760994d00817ae Mon Sep 17 00:00:00 2001
From: Matthias Nott <mnott@mnsoft.org>
Date: Sat, 07 Mar 2026 14:14:56 +0100
Subject: [PATCH] fix: reliable scroll-to-bottom, keyboard-aware project picker

---
 components/SessionDrawer.tsx |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/components/SessionDrawer.tsx b/components/SessionDrawer.tsx
index d7a1998..be58cef 100644
--- a/components/SessionDrawer.tsx
+++ b/components/SessionDrawer.tsx
@@ -9,9 +9,7 @@
   Animated,
   Dimensions,
   Keyboard,
-  KeyboardAvoidingView,
   LayoutAnimation,
-  Platform,
   Pressable,
   ScrollView,
   StyleSheet,
@@ -276,6 +274,18 @@
   const slideAnim = useRef(new Animated.Value(-DRAWER_WIDTH)).current;
   const fadeAnim = useRef(new Animated.Value(0)).current;
   const [rendered, setRendered] = useState(false);
+  const [keyboardHeight, setKeyboardHeight] = useState(0);
+  const pickerScrollRef = useRef<ScrollView>(null);
+
+  useEffect(() => {
+    const showSub = Keyboard.addListener("keyboardWillShow", (e) => {
+      setKeyboardHeight(e.endCoordinates.height);
+    });
+    const hideSub = Keyboard.addListener("keyboardWillHide", () => {
+      setKeyboardHeight(0);
+    });
+    return () => { showSub.remove(); hideSub.remove(); };
+  }, []);
 
   // Local ordering: merge server sessions while preserving user's drag order
   const [orderedSessions, setOrderedSessions] = useState<WsSession[]>([]);
@@ -473,11 +483,7 @@
             elevation: 20,
           }}
         >
-          <KeyboardAvoidingView
-            style={{ flex: 1 }}
-            behavior={Platform.OS === "ios" ? "padding" : undefined}
-          >
-          <GestureHandlerRootView style={{ flex: 1 }}>
+          <GestureHandlerRootView style={{ flex: 1, paddingBottom: keyboardHeight }}>
             {/* Header */}
             <View
               style={{
@@ -564,6 +570,7 @@
 
               {showProjectPicker && (
                 <ScrollView
+                  ref={pickerScrollRef}
                   style={{
                     marginHorizontal: 12,
                     borderRadius: 12,
@@ -630,6 +637,9 @@
                       autoCapitalize="none"
                       autoCorrect={false}
                       returnKeyType="go"
+                      onFocus={() => {
+                        setTimeout(() => pickerScrollRef.current?.scrollToEnd({ animated: true }), 100);
+                      }}
                       onSubmitEditing={() => {
                         if (customPath.trim()) launchSession({ path: customPath.trim() });
                       }}
@@ -679,7 +689,6 @@
               </Text>
             </View>
           </GestureHandlerRootView>
-          </KeyboardAvoidingView>
         </Animated.View>
       </View>
     </View>

--
Gitblit v1.3.1