diff --git a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx index 90fac17f8004a..21f8ff53ca413 100644 --- a/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx +++ b/apps/mobile/src/features/terminal/ThreadTerminalRouteScreen.tsx @@ -16,6 +16,7 @@ import { StackActions, useNavigation, type StaticScreenProps } from "@react-navi import { useAtomMount } from "@effect/atom-react"; import { useMemo, useRef, useState, useSyncExternalStore } from "react"; import { Platform, Pressable, View } from "react-native"; +import Animated, { useAnimatedStyle } from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { AppText as Text } from "../../components/ui/AppText"; import { TerminalContextSheet } from "./TerminalContextSheet"; @@ -27,6 +28,7 @@ import { KeyboardController, KeyboardStickyView, useKeyboardState, + useReanimatedKeyboardAnimation, } from "react-native-keyboard-controller"; import { @@ -445,6 +447,7 @@ function ThreadTerminal(props: { terminalId, }, gridSize: initialAttachGridSize, + resizeSettleDelayMs: Platform.OS === "android" ? 120 : 0, initialInput: pendingLaunch?.initialInput, canOperate: () => readEnvironmentScope(selectedThread.environmentId, AuthTerminalOperateScope), @@ -586,6 +589,24 @@ function ThreadTerminal(props: { const terminalBottomInset = (isKeyboardVisible ? keyboardHeight : 0) + (isAccessoryVisible ? TERMINAL_ACCESSORY_HEIGHT : 0); + const [androidBottomBarHeight, setAndroidBottomBarHeight] = useState(56); + const { height: animatedKeyboardHeight, progress: keyboardProgress } = + useReanimatedKeyboardAnimation(); + const androidViewportStyle = useAnimatedStyle(() => ({ + paddingBottom: + -animatedKeyboardHeight.value + + keyboardProgress.value * (canOperateTerminal ? TERMINAL_ACCESSORY_HEIGHT : 0) + + (1 - keyboardProgress.value) * (androidBottomBarHeight + insets.bottom), + })); + const androidBottomBarStyle = useAnimatedStyle(() => ({ + display: keyboardProgress.value === 1 ? "none" : "flex", + opacity: 1 - keyboardProgress.value, + })); + const androidAccessoryStyle = useAnimatedStyle(() => ({ + display: keyboardProgress.value === 0 ? "none" : "flex", + opacity: keyboardProgress.value, + })); + const terminalMenuSessions: ReadonlyArray = buildTerminalMenuSessions({ knownSessions: knownSessions ?? [], workspaceRoot: selectedThreadProject?.workspaceRoot ?? null, @@ -841,7 +862,6 @@ function ThreadTerminal(props: { : terminalTheme.background, // Measured top reservation is zero when UIKit already inset the body or moved the bar. paddingTop: contentTopInset, - paddingBottom: Platform.OS === "android" && !isKeyboardVisible ? insets.bottom : 0, }} > {!isEnvironmentReady ? ( @@ -897,11 +917,13 @@ function ThreadTerminal(props: { ) : ( <> - - + - {Platform.OS === "android" && !isKeyboardVisible ? ( - + {Platform.OS === "android" ? ( + { + const height = event.nativeEvent.layout.height; + if (height > 0) setAndroidBottomBarHeight(height); + }} + pointerEvents={isKeyboardVisible ? "none" : "auto"} + importantForAccessibility={isKeyboardVisible ? "no-hide-descendants" : "auto"} + style={[ + { position: "absolute", bottom: insets.bottom, left: 0, right: 0 }, + androidBottomBarStyle, + ]} + > {hasNativeTerminalSurface() ? (