@devries-cameron20 / t3code Mirror · read-only / commits / d6e574f7db
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 21, 09:45 UTC

fix(mobile): a settled thread's gap closes right away on every thread list (#37554)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Nov 16, 2026 at 00:10 UTC d6e574f7db25326d602ad9e537b4e0a52a2efeb2
5 files changed +78 -45
apps/mobile/src/features/home/HomeScreen.tsx
+2 -2
@@ -7,7 +7,7 @@ import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSi
7 import type { ThreadMoveDestination } from "../threads/threadOrder";
8 import type { LegendListRef } from "@legendapp/list/react-native";
9 import { AnimatedLegendList } from "@legendapp/list/reanimated";
10 -import { THREAD_SIDEBAR_ROW_LAYOUT } from "../threads/threadListAnimations";
10 +import { THREAD_LIST_ROW_LAYOUT } from "../threads/threadListAnimations";
11 import {
12 type EnvironmentProject,
13 type EnvironmentThreadShell,
@@ -753,7 +753,7 @@ export function HomeScreen(props: HomeScreenProps) {
753 <SwipeableScrollGateProvider enabled={swipeEnabled} activation={swipeRowActivation}>
754 <GestureDetector gesture={homeScrollGesture}>
755 <AnimatedLegendList
756 - itemLayoutAnimation={sidebarSurface ? THREAD_SIDEBAR_ROW_LAYOUT : undefined}
756 + itemLayoutAnimation={THREAD_LIST_ROW_LAYOUT}
757 ref={listRef}
758 onLoad={() => {
759 settleLaunchSplashHomeRows();
apps/mobile/src/features/home/thread-swipe-actions.tsx
+70 -39
@@ -236,6 +236,8 @@ interface ThreadSwipeableProps {
236 /** Omitted uses Delete only with the built-in Delete secondary action; otherwise it uses primary. */
237 readonly fullSwipeAction?: "delete" | "primary";
238 readonly fullSwipeWidth: number;
239 + /** The list animates item layout; collapse in one step so its transition moves siblings once. */
240 + readonly listAnimatesLayout?: boolean;
241 readonly onDelete: () => void;
242 readonly onSwipeableClose?: (methods: SwipeableMethods) => void;
243 readonly onSwipeableWillOpen?: (methods: SwipeableMethods) => void;
@@ -249,6 +251,8 @@ interface ThreadSwipeableProps {
251 readonly threadTitle: string;
252 }
253
254 +const COLLAPSED_ROW_STYLE = { height: 0, overflow: "hidden" } as const;
255 +
256 export function ThreadSwipeable(props: ThreadSwipeableProps) {
257 const swipeableRef = useRef<SwipeableMethods | null>(null);
258 const hasSecondaryAction = props.secondaryAction !== null;
@@ -269,6 +273,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
273 );
274 const contentRef = useRef(content);
275 const [isDismissing, setIsDismissing] = useState(false);
276 + const [collapsedInList, setCollapsedInList] = useState(false);
277 const dismissing = useSharedValue(false);
278 const rowHeight = useSharedValue(0);
279 const rowWidth = useSharedValue(props.fullSwipeWidth);
@@ -278,6 +283,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
283 const primaryAction = props.primaryAction;
284 const onDelete = props.onDelete;
285 const onSwipeableClose = props.onSwipeableClose;
286 + const listAnimatesLayout = props.listAnimatesLayout === true;
287
288 const restoreRow = useCallback(() => {
289 if (!mountedRef.current) return;
@@ -294,6 +300,7 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
300 dismissing.set(false);
301 })(swipeableRef.current);
302 setIsDismissing(false);
303 + setCollapsedInList(false);
304 }, [actionOpacity, collapse, dismissing, fallbackTranslation]);
305
306 const finishDismiss = useCallback((id?: number) => {
@@ -302,6 +309,14 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
309 pendingDismissRef.current = null;
310 pending.resolve();
311 }, []);
312 + const collapseInList = useCallback(
313 + (id: number) => {
314 + if (!mountedRef.current || pendingDismissRef.current?.id !== id) return;
315 + setCollapsedInList(true);
316 + finishDismiss(id);
317 + },
318 + [finishDismiss],
319 + );
320
321 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- cancels the row's Reanimated animations and settles a pending dismissal on unmount
322 useLayoutEffect(() => {
@@ -346,6 +361,12 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
361 translation.set(
362 withTiming(Math.min(translation.value, -rowWidth.value), timing, (finished) => {
363 if (!finished) return;
364 + // LegendList re-measures rows only on React commits, so a UI-thread height animation
365 + // reaches it in late jumps. Collapse through React and let its transition move rows.
366 + if (listAnimatesLayout) {
367 + runOnJS(collapseInList)(id);
368 + return;
369 + }
370 collapse.set(
371 withTiming(1, { ...timing, duration: 180 }, (collapsed) => {
372 if (collapsed) runOnJS(finishDismiss)(id);
@@ -354,7 +375,15 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
375 }),
376 );
377 },
357 - [actionOpacity, collapse, dismissing, finishDismiss, rowWidth],
378 + [
379 + actionOpacity,
380 + collapse,
381 + collapseInList,
382 + dismissing,
383 + finishDismiss,
384 + listAnimatesLayout,
385 + rowWidth,
386 + ],
387 );
388 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- registers this row's animated dismissal in the module-level thread dismissal registry
389 useLayoutEffect(
@@ -503,45 +532,47 @@ export function ThreadSwipeable(props: ThreadSwipeableProps) {
532 );
533
534 return (
506 - <Animated.View style={dismissStyle}>
507 - <View
508 - onLayout={({ nativeEvent: { layout } }) => {
509 - rowHeight.set(layout.height);
510 - setMeasuredRowHeight(layout.height);
511 - rowWidth.set(layout.width);
512 - }}
513 - >
514 - <ReanimatedSwipeable
515 - ref={swipeableRef}
516 - animationOptions={THREAD_SWIPE_SPRING}
517 - childrenContainerStyle={childrenContainerStyle}
518 - containerStyle={swipeableContainerStyle}
519 - dragOffsetFromRight={-8}
520 - enabled={!props.dormant && !isDismissing && props.enabled !== false && gateEnabled}
521 - enableTrackpadTwoFingerGesture={props.enableTrackpadSwipe ?? true}
522 - // Reject vertical pans via patched RNGH failOffsetY; simultaneous trackpad scrolls otherwise open rows on horizontal drift.
523 - failOffsetY={FAIL_OFFSET_Y}
524 - friction={1}
525 - onSwipeableClose={handleSwipeableClose}
526 - onSwipeableRelease={handleRelease}
527 - onSwipeableOpenStartDrag={handleWillOpen}
528 - onSwipeableWillOpen={handleWillOpen}
529 - overshootFriction={1}
530 - overshootRight
531 - renderRightActions={renderRightActions}
532 - rightThreshold={actionsWidth * 0.42}
533 - // Only iPad trackpad pans need rows to swipe while the list scrolls; on Android touch it
534 - // lets a diagonal swipe scroll the list, which the scroll gate turns into a closed row.
535 - simultaneousWith={Platform.OS === "ios" ? props.simultaneousWith : undefined}
535 + <View style={collapsedInList ? COLLAPSED_ROW_STYLE : undefined}>
536 + <Animated.View style={dismissStyle}>
537 + <View
538 + onLayout={({ nativeEvent: { layout } }) => {
539 + rowHeight.set(layout.height);
540 + setMeasuredRowHeight(layout.height);
541 + rowWidth.set(layout.width);
542 + }}
543 >
537 - {
538 - /* oxlint-disable react/refs -- The render callback receives a close/open handler; only invoking that handler accesses the ref. */
539 - props.children(close)
540 - /* oxlint-enable react/refs */
541 - }
542 - </ReanimatedSwipeable>
543 - </View>
544 - </Animated.View>
544 + <ReanimatedSwipeable
545 + ref={swipeableRef}
546 + animationOptions={THREAD_SWIPE_SPRING}
547 + childrenContainerStyle={childrenContainerStyle}
548 + containerStyle={swipeableContainerStyle}
549 + dragOffsetFromRight={-8}
550 + enabled={!props.dormant && !isDismissing && props.enabled !== false && gateEnabled}
551 + enableTrackpadTwoFingerGesture={props.enableTrackpadSwipe ?? true}
552 + // Reject vertical pans via patched RNGH failOffsetY; simultaneous trackpad scrolls otherwise open rows on horizontal drift.
553 + failOffsetY={FAIL_OFFSET_Y}
554 + friction={1}
555 + onSwipeableClose={handleSwipeableClose}
556 + onSwipeableRelease={handleRelease}
557 + onSwipeableOpenStartDrag={handleWillOpen}
558 + onSwipeableWillOpen={handleWillOpen}
559 + overshootFriction={1}
560 + overshootRight
561 + renderRightActions={renderRightActions}
562 + rightThreshold={actionsWidth * 0.42}
563 + // Only iPad trackpad pans need rows to swipe while the list scrolls; on Android touch it
564 + // lets a diagonal swipe scroll the list, which the scroll gate turns into a closed row.
565 + simultaneousWith={Platform.OS === "ios" ? props.simultaneousWith : undefined}
566 + >
567 + {
568 + /* oxlint-disable react/refs -- The render callback receives a close/open handler; only invoking that handler accesses the ref. */
569 + props.children(close)
570 + /* oxlint-enable react/refs */
571 + }
572 + </ReanimatedSwipeable>
573 + </View>
574 + </Animated.View>
575 + </View>
576 );
577 }
578
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+3 -3
@@ -12,7 +12,7 @@ import type {
12 } from "@t3tools/client-runtime/state/shell";
13 import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
14 import { AnimatedLegendList } from "@legendapp/list/reanimated";
15 -import { THREAD_SIDEBAR_ROW_LAYOUT } from "./threadListAnimations";
15 +import { THREAD_LIST_ROW_LAYOUT } from "./threadListAnimations";
16 import { useAtomValue } from "@effect/atom-react";
17 import { useMemo, useRef, useState } from "react";
18 import { Platform, StyleSheet, View } from "react-native";
@@ -605,7 +605,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
605 <GestureDetector gesture={sidebarScrollGesture}>
606 <AnimatedLegendList
607 renderScrollComponent={NativeScrollView}
608 - itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
608 + itemLayoutAnimation={THREAD_LIST_ROW_LAYOUT}
609 data={listItems}
610 drawDistance={500}
611 estimatedItemSize={64}
@@ -662,7 +662,7 @@ function ThreadNavigationSidebarPane(props: ThreadNavigationSidebarProps) {
662 <GestureDetector gesture={sidebarScrollGesture}>
663 {/* oxlint-disable-next-line t3code/require-registered-list-scroll -- The Android sidebar has no native header to register with. */}
664 <AnimatedLegendList
665 - itemLayoutAnimation={THREAD_SIDEBAR_ROW_LAYOUT}
665 + itemLayoutAnimation={THREAD_LIST_ROW_LAYOUT}
666 data={listItems}
667 drawDistance={500}
668 estimatedItemSize={64}
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+2
@@ -600,6 +600,7 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
600 enableTrackpadSwipe
601 fullSwipeAction="primary"
602 fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}
603 + listAnimatesLayout
604 onDelete={handleDelete}
605 onSwipeableClose={props.onSwipeableClose}
606 onSwipeableWillOpen={props.onSwipeableWillOpen}
@@ -1591,6 +1592,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1592 enableTrackpadSwipe
1593 fullSwipeAction="primary"
1594 fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}
1595 + listAnimatesLayout
1596 onDelete={handleDelete}
1597 onSwipeableClose={props.onSwipeableClose}
1598 onSwipeableWillOpen={props.onSwipeableWillOpen}
apps/mobile/src/features/threads/threadListAnimations.ts
+1 -1
@@ -1,5 +1,5 @@
1 import { LinearTransition, ReduceMotion } from "react-native-reanimated";
2
3 -export const THREAD_SIDEBAR_ROW_LAYOUT = LinearTransition.duration(180).reduceMotion(
3 +export const THREAD_LIST_ROW_LAYOUT = LinearTransition.duration(180).reduceMotion(
4 ReduceMotion.System,
5 );