The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): long user messages collapse like on web (#34319)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Suhail committed
Nov 20, 2026 at 01:04 UTC
910c1a8df90c0d85e2a418d1693da9e1f9647492
13 files changed
+135
-10
apps/mobile/src/features/threads/CollapsibleUserMessageBody.tsx
new
+76
@@ -0,0 +1,76 @@
1
+import { T } from "gt-react-native";
2
+import { useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
3
+import {
4
+ Pressable,
5
+ View,
6
+ type ColorValue,
7
+ type LayoutChangeEvent,
8
+ type ViewInstance,
9
+} from "react-native";
10
+import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
11
+import { AppText as Text } from "../../components/ui/AppText";
12
+
13
+const FOLDED_HEIGHT = 176;
14
+
15
+// Fold only when opening at least doubles what is on screen, matching web's useTallEnoughToFold.
16
+const isTallEnoughToFold = (height: number) => height >= FOLDED_HEIGHT * 2;
17
+
18
+export function CollapsibleUserMessageBody(props: {
19
+ readonly collapsible: boolean;
20
+ readonly expanded: boolean;
21
+ readonly onToggle: () => void;
22
+ readonly bubbleColor: ColorValue;
23
+ readonly children: ReactNode;
24
+}) {
25
+ const gradientId = `user-message-fade-${useId().replaceAll(":", "")}`;
26
+ const contentRef = useRef<ViewInstance>(null);
27
+ const [tallEnough, setTallEnough] = useState(false);
28
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- the fold depends on the rendered height; measuring before paint avoids one unfolded frame
29
+ useLayoutEffect(() => {
30
+ const height = contentRef.current?.getBoundingClientRect().height;
31
+ if (height !== undefined) setTallEnough(isTallEnoughToFold(height));
32
+ }, []);
33
+ const canCollapse = props.collapsible && tallEnough;
34
+ const collapsed = canCollapse && !props.expanded;
35
+
36
+ return (
37
+ <View>
38
+ <View style={collapsed ? { maxHeight: FOLDED_HEIGHT, overflow: "hidden" } : undefined}>
39
+ <View
40
+ ref={contentRef}
41
+ onLayout={(event: LayoutChangeEvent) => {
42
+ // Folded, Yoga reports the clipped height, which would read as short and unfold it in a loop.
43
+ if (!collapsed) setTallEnough(isTallEnoughToFold(event.nativeEvent.layout.height));
44
+ }}
45
+ >
46
+ {props.children}
47
+ </View>
48
+ {collapsed ? (
49
+ <View pointerEvents="none" className="absolute inset-x-0 bottom-0 h-7">
50
+ <Svg width="100%" height="100%">
51
+ <Defs>
52
+ <LinearGradient id={gradientId} x1="0%" x2="0%" y1="0%" y2="100%">
53
+ <Stop offset={0} stopColor={props.bubbleColor} stopOpacity={0} />
54
+ <Stop offset={1} stopColor={props.bubbleColor} stopOpacity={1} />
55
+ </LinearGradient>
56
+ </Defs>
57
+ <Rect width="100%" height="100%" fill={`url(#${gradientId})`} />
58
+ </Svg>
59
+ </View>
60
+ ) : null}
61
+ </View>
62
+ {canCollapse ? (
63
+ <Pressable
64
+ accessibilityRole="button"
65
+ accessibilityState={{ expanded: props.expanded }}
66
+ onPress={props.onToggle}
67
+ className="mt-1.5 min-h-11 items-end justify-center active:opacity-70"
68
+ >
69
+ <Text className="font-t3-medium text-xs text-user-bubble-foreground-muted">
70
+ {props.expanded ? <T>Show less</T> : <T>Show full message</T>}
71
+ </Text>
72
+ </Pressable>
73
+ ) : null}
74
+ </View>
75
+ );
76
+}
apps/mobile/src/features/threads/ThreadFeed.tsx
+36
-10
@@ -1,3 +1,4 @@
1
+import { CollapsibleUserMessageBody } from "./CollapsibleUserMessageBody";
2
import { msg, T, useGT, useLocale, useMessages } from "gt-react-native";
3
import { m } from "../../i18n/messages";
4
import { errorDisplayMessage } from "@t3tools/client-runtime/errors";
@@ -1991,6 +1992,7 @@ function renderFeedEntry(
1992
readonly onCopyWorkRow: (rowId: string, value: string) => void;
1993
readonly onToggleWorkGroup: (groupId: string, anchorKey?: string) => void;
1994
readonly onToggleWorkRow: (rowId: string, anchorKey?: string, groupId?: string) => void;
1995
+ readonly onToggleUserMessage: (rowId: string, anchorKey: string) => void;
1996
readonly onToggleTurnFold: (runId: RunId) => void;
1997
readonly onOpenTurnDiff: (checkpoint: ThreadCheckpointSummary) => void;
1998
readonly onPressPreview: (source: FilePreviewSource) => void;
@@ -2551,16 +2553,25 @@ function renderFeedEntry(
2553
<MarkdownImageAvailableWidthContext
2554
value={props.userBubbleMaxWidth - USER_BUBBLE_HORIZONTAL_PADDING * 2}
2555
>
2554
- <UserMessageContent
2555
- text={renderedText}
2556
- environmentId={props.environmentId}
2557
- context={message.context}
2558
- markdownStyles={styles}
2559
- reviewCommentColors={props.reviewCommentColors}
2560
- skills={props.skills}
2561
- linkHandlers={props.markdownLinkHandlers}
2562
- renderImage={props.renderMarkdownImage}
2563
- />
2556
+ <CollapsibleUserMessageBody
2557
+ collapsible={foldRowId === null}
2558
+ expanded={props.expandedWorkRows[`message:${message.id}`] ?? false}
2559
+ onToggle={() =>
2560
+ props.onToggleUserMessage(`message:${message.id}`, entry.id)
2561
+ }
2562
+ bubbleColor={userBubbleColor}
2563
+ >
2564
+ <UserMessageContent
2565
+ text={renderedText}
2566
+ environmentId={props.environmentId}
2567
+ context={message.context}
2568
+ markdownStyles={styles}
2569
+ reviewCommentColors={props.reviewCommentColors}
2570
+ skills={props.skills}
2571
+ linkHandlers={props.markdownLinkHandlers}
2572
+ renderImage={props.renderMarkdownImage}
2573
+ />
2574
+ </CollapsibleUserMessageBody>
2575
</MarkdownImageAvailableWidthContext>
2576
) : null}
2577
</View>
@@ -4121,6 +4132,20 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
4132
});
4133
};
4134
4135
+ const onToggleUserMessage = (rowId: string, anchorKey: string) => {
4136
+ const list = listRef.current;
4137
+ if (expandedWorkRows[rowId] && list) {
4138
+ const anchor = list.anchorVisibleContent({ key: anchorKey, hold: false });
4139
+ const nextKey = groupedFeed[groupedFeed.findIndex((item) => item.id === anchorKey) + 1]?.id;
4140
+ // Once the message top is scrolled away, collapse toward it like the web: what follows stays put.
4141
+ if (anchor && anchor.offset > 0 && nextKey) {
4142
+ onToggleWorkRow(rowId, nextKey);
4143
+ return;
4144
+ }
4145
+ }
4146
+ onToggleWorkRow(rowId, anchorKey);
4147
+ };
4148
+
4149
const onToggleTurnFold = (runId: RunId) => {
4150
preserveDisclosurePosition(`run-fold:${runId}`);
4151
setInteractionState((current) => {
@@ -4260,6 +4285,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
4285
onCopyWorkRow,
4286
onToggleWorkGroup,
4287
onToggleWorkRow,
4288
+ onToggleUserMessage,
4289
onToggleTurnFold,
4290
onOpenTurnDiff,
4291
onPressPreview,
apps/mobile/src/i18n/translations/de.json
+2
@@ -3992,6 +3992,8 @@
3992
"v": "v"
3993
}
3994
],
3995
+ "43c5fbd02c6f330a": "Weniger anzeigen",
3996
+ "918cd5477d0c0e9b": "Vollständige Nachricht anzeigen",
3997
"74fed222a72f86bc": "Fotomediathek",
3998
"f47273372ba4ed5c": "Dateien auswählen",
3999
"584c3539b9524b9a": "Anhang hinzufügen",
apps/mobile/src/i18n/translations/en.json
+2
@@ -3993,6 +3993,8 @@
3993
"v": "v"
3994
}
3995
],
3996
+ "43c5fbd02c6f330a": "Show less",
3997
+ "918cd5477d0c0e9b": "Show full message",
3998
"74fed222a72f86bc": "Photo Library",
3999
"f47273372ba4ed5c": "Choose Files",
4000
"584c3539b9524b9a": "Add attachment",
apps/mobile/src/i18n/translations/es.json
+2
@@ -3987,6 +3987,8 @@
3987
"v": "v"
3988
}
3989
],
3990
+ "43c5fbd02c6f330a": "Mostrar menos",
3991
+ "918cd5477d0c0e9b": "Mostrar el mensaje completo",
3992
"74fed222a72f86bc": "Fototeca",
3993
"f47273372ba4ed5c": "Elegir archivos",
3994
"584c3539b9524b9a": "Añadir adjunto",
apps/mobile/src/i18n/translations/fr.json
+2
@@ -3987,6 +3987,8 @@
3987
"v": "v"
3988
}
3989
],
3990
+ "43c5fbd02c6f330a": "Afficher moins",
3991
+ "918cd5477d0c0e9b": "Afficher le message complet",
3992
"74fed222a72f86bc": "Photothèque",
3993
"f47273372ba4ed5c": "Choisir des fichiers",
3994
"584c3539b9524b9a": "Ajouter une pièce jointe",
apps/mobile/src/i18n/translations/ja.json
+2
@@ -3984,6 +3984,8 @@
3984
},
3985
" からの承認"
3986
],
3987
+ "43c5fbd02c6f330a": "表示を減らす",
3988
+ "918cd5477d0c0e9b": "メッセージ全体を表示",
3989
"74fed222a72f86bc": "写真ライブラリ",
3990
"f47273372ba4ed5c": "ファイルを選択",
3991
"584c3539b9524b9a": "添付ファイルを追加",
apps/mobile/src/i18n/translations/ko.json
+2
@@ -3988,6 +3988,8 @@
3988
},
3989
"의 승인"
3990
],
3991
+ "43c5fbd02c6f330a": "간략히 보기",
3992
+ "918cd5477d0c0e9b": "전체 메시지 표시",
3993
"74fed222a72f86bc": "사진 보관함",
3994
"f47273372ba4ed5c": "파일 선택",
3995
"584c3539b9524b9a": "첨부 파일 추가",
apps/mobile/src/i18n/translations/pt-BR.json
+2
@@ -3987,6 +3987,8 @@
3987
"v": "v"
3988
}
3989
],
3990
+ "43c5fbd02c6f330a": "Mostrar menos",
3991
+ "918cd5477d0c0e9b": "Mostrar mensagem completa",
3992
"74fed222a72f86bc": "Biblioteca de Fotos",
3993
"f47273372ba4ed5c": "Escolher arquivos",
3994
"584c3539b9524b9a": "Adicionar anexo",
apps/mobile/src/i18n/translations/ru.json
+2
@@ -4041,6 +4041,8 @@
4041
"v": "v"
4042
}
4043
],
4044
+ "43c5fbd02c6f330a": "Показать меньше",
4045
+ "918cd5477d0c0e9b": "Показать сообщение полностью",
4046
"74fed222a72f86bc": "Медиатека",
4047
"f47273372ba4ed5c": "Выбрать файлы",
4048
"584c3539b9524b9a": "Добавить вложение",
apps/mobile/src/i18n/translations/sv.json
+2
@@ -3993,6 +3993,8 @@
3993
"v": "v"
3994
}
3995
],
3996
+ "43c5fbd02c6f330a": "Visa mindre",
3997
+ "918cd5477d0c0e9b": "Visa hela meddelandet",
3998
"74fed222a72f86bc": "Bildbibliotek",
3999
"f47273372ba4ed5c": "Välj filer",
4000
"584c3539b9524b9a": "Lägg till bilaga",
apps/mobile/src/i18n/translations/zh.json
+2
@@ -3990,6 +3990,8 @@
3990
},
3991
" 的批准"
3992
],
3993
+ "43c5fbd02c6f330a": "收起",
3994
+ "918cd5477d0c0e9b": "显示完整消息",
3995
"74fed222a72f86bc": "照片图库",
3996
"f47273372ba4ed5c": "选择文件",
3997
"584c3539b9524b9a": "添加附件",
apps/mobile/src/lib/filePreview.test.ts
+3
@@ -300,6 +300,9 @@ vi.mock("../features/threads/LinkRequestCard", () => ({ LinkRequestCard: () => n
300
vi.mock("../features/threads/worktree-setup-card", () => ({}));
301
vi.mock("../features/threads/CopyTextButton", () => ({ CopyTextButton: () => null }));
302
vi.mock("../features/threads/thread-work-log", () => ({ THREAD_DISCLOSURE_TRANSITION_MS: 100 }));
303
+vi.mock("../features/threads/CollapsibleUserMessageBody", () => ({
304
+ CollapsibleUserMessageBody: (props: { children: ReactNode }) => props.children,
305
+}));
306
vi.mock("../features/threads/HtmlRenderWebView", () => ({}));
307
vi.mock("../features/threads/McpAppWebView", () => ({}));
308
vi.mock("../features/layout/AdaptiveWorkspaceLayout", () => ({