@devries-cameron20 / t3code Mirror · read-only / commits / 59df51f6e1
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

perf(mobile): switching back to a thread lays its feed out once (#37578)

Julius Marminge committed Nov 16, 2026 at 07:47 UTC 59df51f6e19dfcd6624e4d30cb76ebb14de79347
2 files changed +20 -7
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+8 -5
@@ -120,6 +120,7 @@ import { useBarOverlap } from "../../components/ui/useBarInset";
120 import {
121 useWorkspaceContentWidth,
122 WorkspaceSettledContentWidthContext,
123 + useWorkspaceSettledContentWidth,
124 } from "../layout/workspace-content-width";
125 import { useAdaptiveWorkspaceLayout } from "../layout/adaptive-workspace-context";
126 import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
@@ -328,12 +329,14 @@ export interface ThreadDetailScreenProps {
329 // iOS questions overlay the controls; Android questions stack with child approvals.
330 const ComposerPanels = Platform.OS === "android" ? Animated.ScrollView : Animated.View;
331
331 -/** Hands the feed the screen width measured for a native column; elsewhere keeps the inherited one. */
332 +/**
333 + * Hands the feed the screen width measured for a native column; elsewhere keeps the inherited one.
334 + * Always the same element, so the feed below is not remounted when the width arrives.
335 + */
336 function ColumnWidth(props: { readonly width: number | null; readonly children: React.ReactNode }) {
333 - return props.width === null ? (
334 - props.children
335 - ) : (
336 - <WorkspaceSettledContentWidthContext value={props.width}>
337 + const inherited = useWorkspaceSettledContentWidth();
338 + return (
339 + <WorkspaceSettledContentWidthContext value={props.width ?? inherited}>
340 {props.children}
341 </WorkspaceSettledContentWidthContext>
342 );
apps/mobile/src/features/threads/ThreadFeed.tsx
+12 -2
@@ -2824,6 +2824,10 @@ const THREAD_FEED_MAINTAIN_SCROLL_AT_END = {
2824 on: { dataChange: true, itemLayout: true, layout: true },
2825 } as const;
2826
2827 +// A thread switch remounts the feed. Starting from the last split pane's size lays rows out once,
2828 +// instead of at width 0 and again when the new feed's own layout reports the same width.
2829 +let lastSplitViewport: { windowWidth: number; width: number; height: number } | null = null;
2830 +
2831 export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2832 const formatMessageTime = useMessageTimeFormatter();
2833 const { listRef, onIsAtEndChange, onHeaderMaterialVisibilityChange } = props;
@@ -2862,10 +2866,15 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
2866 });
2867 const settledPaneWidth = useWorkspaceSettledContentWidth();
2868 const splitLayout = (props.layoutVariant ?? "compact") !== "compact";
2865 - const [measuredViewportWidth, setViewportWidth] = useState(() => (splitLayout ? 0 : windowWidth));
2869 + const [initialSplitViewport] = useState(() =>
2870 + splitLayout && lastSplitViewport?.windowWidth === windowWidth ? lastSplitViewport : null,
2871 + );
2872 + const [measuredViewportWidth, setViewportWidth] = useState(() =>
2873 + splitLayout ? (initialSplitViewport?.width ?? 0) : windowWidth,
2874 + );
2875 const viewportWidth =
2876 settledPaneWidth !== null ? Math.round(settledPaneWidth) : measuredViewportWidth;
2868 - const [viewportHeight, setViewportHeight] = useState(0);
2877 + const [viewportHeight, setViewportHeight] = useState(() => initialSplitViewport?.height ?? 0);
2878 const [disclosureLayout, setDisclosureLayout] = useState<DisclosureLayout | null>(null);
2879 const disclosureMotionRef = useRef<DisclosureLayout | null>(null);
2880 const disclosureMotionTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -3567,6 +3576,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
3576 const handleViewportLayout = (event: LayoutChangeEvent) => {
3577 const nextWidth = Math.round(event.nativeEvent.layout.width);
3578 const nextHeight = Math.round(event.nativeEvent.layout.height);
3579 + if (splitLayout) lastSplitViewport = { windowWidth, width: nextWidth, height: nextHeight };
3580 setViewportWidth((current) => (Math.abs(current - nextWidth) > 1 ? nextWidth : current));
3581 setViewportHeight((current) => (Math.abs(current - nextHeight) > 1 ? nextHeight : current));
3582 };