@devries-cameron20 / t3code Mirror · read-only / commits / 0b72c07870
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 00:30 UTC

fix(mobile): /usage-limits panel no longer hides its close button under the header when the keyboard is open (#20910)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

shivam committed Oct 20, 2026 at 08:22 UTC 0b72c07870acdfad442cfa754a29406f672343f3
2 files changed +66 -12
apps/mobile/src/features/threads/ComposerUsageLimits.tsx
+4 -7
@@ -1,5 +1,5 @@
1 import type { EnvironmentId, UsageLimitsReport } from "@t3tools/contracts";
2 -import { Pressable, ScrollView, useWindowDimensions, View } from "react-native";
2 +import { Pressable, ScrollView, View } from "react-native";
3
4 import { SymbolView } from "../../components/ui/AppSymbol";
5 import { AppText as Text } from "../../components/ui/AppText";
@@ -10,14 +10,15 @@ const DRIVER_LABEL: Partial<Record<string, string>> = { codex: "Codex", claudeAg
10 export function ComposerUsageLimits({
11 report,
12 environmentId,
13 + maxHeight,
14 onClose,
15 }: {
16 readonly report: UsageLimitsReport;
17 readonly environmentId: EnvironmentId;
18 + readonly maxHeight: number;
19 readonly onClose: () => void;
20 }) {
21 const now = Date.parse(report.createdAt);
20 - const { height } = useWindowDimensions();
22 const close = (
23 <Pressable
24 accessibilityLabel="Dismiss usage limits"
@@ -31,11 +32,7 @@ export function ComposerUsageLimits({
32 );
33 return (
34 <View className="overflow-hidden rounded-[20px] border-continuous bg-card">
34 - <ScrollView
35 - bounces={false}
36 - showsVerticalScrollIndicator={false}
37 - style={{ maxHeight: Math.round(height * 0.4) }}
38 - >
35 + <ScrollView bounces={false} showsVerticalScrollIndicator={false} style={{ maxHeight }}>
36 {report.accounts.map((account, index) => {
37 const resetCreditInput =
38 account.resetCreditInput ??
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+62 -5
@@ -66,6 +66,7 @@ import {
66 useWindowDimensions,
67 View,
68 type GestureResponderEvent,
69 + type LayoutChangeEvent,
70 type ViewInstance,
71 } from "react-native";
72 import {
@@ -319,6 +320,9 @@ function useStreamingHaptics(threadId: ThreadId, feed: ReadonlyArray<ThreadFeedE
320 }, [threadId, feed]);
321 }
322
323 +const USAGE_LIMITS_PANEL_GAP = 12;
324 +const USAGE_LIMITS_PANEL_MIN_HEIGHT = 44;
325 +
326 const USER_INPUT_TOGGLE_TIMING = {
327 duration: USER_INPUT_TOGGLE_DURATION_MS,
328 easing: Easing.out(Easing.cubic),
@@ -668,10 +672,11 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
672 setLastKnownKeyboardHeight(liveKeyboardHeight);
673 }
674 }, [lastKnownKeyboardHeight, liveKeyboardHeight]);
675 + const reservedKeyboardHeight =
676 + lastKnownKeyboardHeight > 0 ? lastKnownKeyboardHeight : ESTIMATED_KEYBOARD_HEIGHT;
677 const pendingUserInputMaxHeight = derivePendingUserInputMaxHeight({
678 windowHeight,
673 - keyboardHeight:
674 - lastKnownKeyboardHeight > 0 ? lastKnownKeyboardHeight : ESTIMATED_KEYBOARD_HEIGHT,
679 + keyboardHeight: reservedKeyboardHeight,
680 navigationHeaderHeight,
681 composerOverlapHeight: composerBottomInset,
682 });
@@ -692,6 +697,51 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
697 -nativeInsetOvercount,
698 Platform.OS === "ios" ? COMPOSER_TRANSITION_DURATION_MS : 0,
699 );
700 + // Android lays the screen out below its opaque header and reports a zero
701 + // header height, so the window height overstates the room by the header.
702 + const [screenHeight, setScreenHeight] = useState<number | null>(null);
703 + const handleScreenLayout = useCallback((event: LayoutChangeEvent) => {
704 + setScreenHeight(event.nativeEvent.layout.height);
705 + }, []);
706 + const screenAreaHeight = screenHeight ?? windowHeight;
707 + // The usage panel stacks with the composer and any approval card, so it gets
708 + // whatever room they leave below the header. Measured only while it is open
709 + // so typing in the composer does not re-render the screen.
710 + const usageLimitsOpen = usageLimitsReport !== null && activeUserInputRequestId === null;
711 + const [usageLimitsLayout, setUsageLimitsLayout] = useState({ overlay: 0, panel: 0 });
712 + const handleComposerOverlayLayout = useCallback(
713 + (event: LayoutChangeEvent) => {
714 + onComposerLayout(event);
715 + if (!usageLimitsOpen) return;
716 + const overlay = event.nativeEvent.layout.height;
717 + setUsageLimitsLayout((current) =>
718 + current.overlay === overlay ? current : { ...current, overlay },
719 + );
720 + },
721 + [onComposerLayout, usageLimitsOpen],
722 + );
723 + const handleUsageLimitsLayout = useCallback((event: LayoutChangeEvent) => {
724 + const panel = event.nativeEvent.layout.height;
725 + setUsageLimitsLayout((current) => (current.panel === panel ? current : { ...current, panel }));
726 + }, []);
727 + const overlayBesideUsageLimits =
728 + usageLimitsLayout.overlay > 0
729 + ? usageLimitsLayout.overlay - usageLimitsLayout.panel
730 + : composerOverlapHeight;
731 + // The keyboard is reserved even while closed, like the question card, so the
732 + // panel never grows over the header while the keyboard animates. The floor
733 + // keeps the close row on screen when the stack below leaves no room at all.
734 + const usageLimitsMaxHeight = Math.max(
735 + USAGE_LIMITS_PANEL_MIN_HEIGHT,
736 + Math.min(
737 + Math.round(screenAreaHeight * 0.4),
738 + screenAreaHeight -
739 + navigationHeaderHeight -
740 + reservedKeyboardHeight -
741 + overlayBesideUsageLimits -
742 + USAGE_LIMITS_PANEL_GAP * 2,
743 + ),
744 + );
745 const userInputCardProgress = useSharedValue(1);
746 const userInputInsetProgress = useSharedValue(1);
747 const userInputCardCoverage = useSharedValue(0);
@@ -1037,7 +1087,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
1087 };
1088
1089 return (
1040 - <View className="flex-1">
1090 + <View className="flex-1" onLayout={handleScreenLayout}>
1091 {!usesNativeWorkspaceColumns ? <NativeLayoutObserver onChange={setScreenMetrics} /> : null}
1092 <ThreadVisitWatermark
1093 environmentId={props.environmentId}
@@ -1157,7 +1207,11 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
1207 {/* No paddingTop here: the overlay's measured height becomes the
1208 list's bottom inset, so any padding above the pill/composer
1209 pushes the resting content floor up by the same amount. */}
1160 - <View ref={composerOverlayRef} onLayout={onComposerLayout} className="w-full">
1210 + <View
1211 + ref={composerOverlayRef}
1212 + onLayout={handleComposerOverlayLayout}
1213 + className="w-full"
1214 + >
1215 <FloatingWorkingControl
1216 colorScheme={isDarkMode ? "dark" : "light"}
1217 status={floatingStatus}
@@ -1233,13 +1287,16 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
1287 ) : null}
1288 {usageLimitsReport && activeUserInputRequestId === null ? (
1289 <Animated.View
1236 - className="shrink-0 px-4 pb-3"
1290 + className="shrink-0 px-4"
1291 + style={{ paddingBottom: USAGE_LIMITS_PANEL_GAP }}
1292 + onLayout={handleUsageLimitsLayout}
1293 entering={FadeInDown.duration(220)}
1294 exiting={FadeOut.duration(140)}
1295 >
1296 <ComposerUsageLimits
1297 report={usageLimitsReport}
1298 environmentId={props.environmentId}
1299 + maxHeight={usageLimitsMaxHeight}
1300 onClose={dismissUsageLimits}
1301 />
1302 </Animated.View>