@devries-cameron20 / t3code Mirror · read-only / commits / 12c495af49
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, 11:00 UTC

fix(mobile): sending a message no longer shifts the feed before it settles (#37267)

Julius Marminge committed Nov 15, 2026 at 08:26 UTC 12c495af49825d21a128aa578373990cd109c9eb
6 files changed +129 -15
apps/mobile/src/components/ComposerAttachmentStrip.tsx
+8
@@ -18,6 +18,7 @@ import {
18 type DraftComposerImageAttachment,
19 } from "../lib/composerImages";
20 import { resolveOwnedComposerAttachmentFileUri } from "../lib/composerAttachmentFiles";
21 +import { rememberDraftImage } from "../lib/sentImageHandoff";
22 import { VideoAttachmentTile } from "./VideoAttachmentTile";
23 import { type MediaActionsSource } from "../lib/mediaActionsSource";
24 import { PresentationSource } from "./ui/NativePresentation";
@@ -161,6 +162,13 @@ function ComposerImageAttachment(
162 style={style}
163 className="bg-subtle"
164 resizeMode="cover"
165 + onLoad={({ nativeEvent: { source } }) => {
166 + if (previewUri !== null)
167 + rememberDraftImage(attachment.id, {
168 + uri: previewUri,
169 + aspectRatio: source.width / source.height,
170 + });
171 + }}
172 />
173 </Pressable>
174 </PresentationSource>
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+10 -4
@@ -882,6 +882,11 @@ function ThreadDetailBody(
882 return null;
883 })();
884 const showWorkingControl = floatingStatus !== null;
885 + // A pending message holds the pill's row for its Starting/Working pill. Worktree setup reports
886 + // progress in the feed instead, so holding the row there only leaves a gap that later closes.
887 + const worktreeSetupInFeed =
888 + props.worktreeSetup?.snapshot.phase === "running" ||
889 + (props.creationState?.kind === "preparing" && props.creationState.preparingWorktree);
890 const showFloatingStatus =
891 showWorkingControl ||
892 queuedCount > 0 ||
@@ -889,10 +894,11 @@ function ThreadDetailBody(
894 devicePreviews.length > 0 ||
895 browserTabs.tabs.length > 0 ||
896 props.connectionStateLabel !== "connected" ||
892 - props.queuedMessages.length > 0 ||
893 - props.selectedThreadFeed.some(
894 - (entry) => "acknowledged" in entry && entry.acknowledged === true,
895 - );
897 + (!worktreeSetupInFeed &&
898 + (props.queuedMessages.length > 0 ||
899 + props.selectedThreadFeed.some(
900 + (entry) => "acknowledged" in entry && entry.acknowledged === true,
901 + )));
902 const selectedThreadFeed = props.selectedThreadFeed;
903 // A palette message result opens the thread at that message: earlier
904 // history loads until the message is in the feed, which then scrolls to it.
apps/mobile/src/features/threads/ThreadFeed.tsx
+52 -10
@@ -137,6 +137,11 @@ import { assetImageSource } from "../../lib/assetImageSource";
137 import { composerImageGallery } from "../../lib/composerImageGallery";
138 import { isFileBackedComposerAttachment } from "../../lib/composerImages";
139 import { useLocalAttachmentPreview } from "../../lib/localAttachmentPreview";
140 +import {
141 + rememberSentImage,
142 + sentImageHandoff,
143 + type SentImageHandoff,
144 +} from "../../lib/sentImageHandoff";
145 import { messageImageGallery } from "./messageImageGallery";
146 import { MARKDOWN_IMAGE_MAX_WIDTH, resolveMarkdownImageDisplaySize } from "./markdownImageSize";
147 import { FilePreviewModal, type FilePreviewSource } from "../../components/ui/FilePreviewModal";
@@ -483,12 +488,18 @@ function MessageImage(props: {
488 readonly maxWidth?: number;
489 readonly height?: number;
490 readonly accessibilityLabel: string;
491 + readonly handoff?: SentImageHandoff;
492 readonly onPress: () => void;
487 - readonly onLoad?: () => void;
493 + readonly onLoad?: (size: { readonly width: number; readonly height: number }) => void;
494 readonly onError?: () => void;
495 }) {
496 const imageStyle = useResolveClassNames(props.className);
491 - const [size, setSize] = useState<{ width: number; height: number } | null>(null);
497 + const [loadedSize, setSize] = useState<{ width: number; height: number } | null>(null);
498 + // Until it loads, assume a handed-off image is a photo larger than the bubble's caps.
499 + const size =
500 + loadedSize ??
501 + (props.handoff ? { width: props.handoff.aspectRatio * 4096, height: 4096 } : null);
502 + const contentFit = props.maxWidth === undefined ? "cover" : "contain";
503 const displaySize =
504 props.maxWidth !== undefined && size !== null
505 ? resolveMarkdownImageDisplaySize({
@@ -519,10 +530,12 @@ function MessageImage(props: {
530 source={props.source}
531 cachePolicy="memory-disk"
532 style={{ width: "100%", height: "100%" }}
522 - contentFit={props.maxWidth === undefined ? "cover" : "contain"}
533 + contentFit={contentFit}
534 + placeholder={props.handoff ? { uri: props.handoff.uri } : undefined}
535 + placeholderContentFit={contentFit}
536 onLoad={(event) => {
537 if (props.maxWidth !== undefined) setSize(event.source);
525 - props.onLoad?.();
538 + props.onLoad?.(event.source);
539 }}
540 onError={props.onError}
541 />
@@ -538,6 +551,8 @@ function MessageAttachmentImage(props: {
551 readonly className: string;
552 readonly maxWidth?: number;
553 readonly height?: number;
554 + readonly handoff?: SentImageHandoff;
555 + readonly onImageLoad?: (image: SentImageHandoff) => void;
556 readonly onPressPreview: (source: FilePreviewSource) => void;
557 }) {
558 const withGallery = useFilePreviewGallery();
@@ -551,8 +566,15 @@ function MessageAttachmentImage(props: {
566 const uri = useAssetUrl(props.environmentId, resource);
567 const refreshAssetUrl = useRefreshAssetUrl(props.environmentId, resource);
568 const retriedImage = useRef(false);
569 + const { handoff } = props;
570 + const source =
571 + uri !== null
572 + ? assetImageSource(props.environmentId, resource, uri)
573 + : handoff !== undefined
574 + ? { uri: handoff.uri }
575 + : null;
576
555 - if (uri === null) {
577 + if (source === null) {
578 return (
579 <View
580 className={`${props.className} items-center justify-center`}
@@ -573,11 +595,12 @@ function MessageAttachmentImage(props: {
595 <PresentationSource identifier={sourceIdentifier}>
596 <MessageImage
597 key={props.attachmentId}
576 - source={assetImageSource(props.environmentId, resource, uri)}
598 + source={source}
599 className={props.className}
600 maxWidth={props.maxWidth}
601 height={props.height}
602 accessibilityLabel={`Open ${props.name}`}
603 + {...handoffProps(handoff)}
604 onPress={() =>
605 props.onPressPreview(
606 withGallery({
@@ -595,8 +618,10 @@ function MessageAttachmentImage(props: {
618 }),
619 )
620 }
598 - onLoad={() => {
621 + onLoad={(size) => {
622 retriedImage.current = false;
623 + if (handoff)
624 + props.onImageLoad?.({ uri: handoff.uri, aspectRatio: size.width / size.height });
625 }}
626 onError={() => {
627 if (retriedImage.current) return;
@@ -835,7 +860,10 @@ function MessageAttachmentFile(props: {
860 );
861 }
862
863 +const handoffProps = (handoff: SentImageHandoff | undefined) => (handoff ? { handoff } : {});
864 +
865 function UserMessageMedia(props: {
866 + readonly messageId: string;
867 readonly attachments: ReadonlyArray<ChatAttachment>;
868 readonly pendingAttachments: QueuedThreadMessage["attachments"];
869 readonly environmentId: EnvironmentId;
@@ -870,6 +898,8 @@ function UserMessageMedia(props: {
898 name={attachment.name}
899 mimeType={attachment.mimeType}
900 {...imageProps(index)}
901 + {...handoffProps(sentImageHandoff(props.messageId, index, attachment.id))}
902 + onImageLoad={(loaded) => rememberSentImage(props.messageId, index, loaded)}
903 onPressPreview={props.onPressPreview}
904 />
905 ) : !image && attachment.uploadedAttachmentId ? (
@@ -886,6 +916,8 @@ function UserMessageMedia(props: {
916 <PendingMessageMedia
917 attachment={attachment}
918 {...imageProps(index)}
919 + {...handoffProps(sentImageHandoff(props.messageId, index, attachment.id))}
920 + onImageLoad={(image) => rememberSentImage(props.messageId, index, image)}
921 onPressPreview={props.onPressPreview}
922 onPlaybackStart={props.onPlaybackStart}
923 />
@@ -902,6 +934,7 @@ function UserMessageMedia(props: {
934 name={attachment.name}
935 mimeType={attachment.mimeType}
936 {...imageProps(props.pendingAttachments.length + index)}
937 + {...handoffProps(sentImageHandoff(props.messageId, index))}
938 onPressPreview={props.onPressPreview}
939 />
940 ) : isFileAttachment(attachment) ? (
@@ -968,23 +1001,31 @@ function PendingMessageMedia(props: {
1001 readonly className: string;
1002 readonly maxWidth?: number;
1003 readonly height?: number;
1004 + readonly handoff?: SentImageHandoff;
1005 + readonly onImageLoad?: (image: SentImageHandoff) => void;
1006 readonly onPressPreview: (source: FilePreviewSource) => void;
1007 readonly onPlaybackStart: () => void;
1008 }) {
1009 const withGallery = useFilePreviewGallery();
975 - const { attachment } = props;
1010 + const { attachment, handoff } = props;
1011 const fileBacked = isFileBackedComposerAttachment(attachment);
1012 const preview = useLocalAttachmentPreview(fileBacked ? attachment : null);
1013 if (isImageAttachment(attachment)) {
979 - const uri = fileBacked ? preview.uri : (attachment.dataUrl ?? attachment.previewUri);
1014 + // The composer already showed this image; reuse its pixels and shape instead of a blank box.
1015 + const uri =
1016 + handoff?.uri ?? (fileBacked ? preview.uri : (attachment.dataUrl ?? attachment.previewUri));
1017 return (
1018 <MessageImage
1019 key={attachment.id}
983 - source={uri === null ? undefined : { uri }}
1020 + source={uri == null ? undefined : { uri }}
1021 className={props.className}
1022 maxWidth={props.maxWidth}
1023 height={props.height}
1024 accessibilityLabel={`Open ${attachment.name}`}
1025 + {...handoffProps(handoff)}
1026 + onLoad={(size) => {
1027 + if (uri) props.onImageLoad?.({ uri, aspectRatio: size.width / size.height });
1028 + }}
1029 onPress={() => {
1030 const source = composerImageGallery([attachment])[0];
1031 if (source) props.onPressPreview(withGallery(source));
@@ -2061,6 +2102,7 @@ function renderFeedEntry(
2102 style={{ width: props.duoColumns ? "85%" : props.userBubbleMaxWidth }}
2103 >
2104 <UserMessageMedia
2105 + messageId={message.id}
2106 attachments={mediaAttachments}
2107 pendingAttachments={pendingMedia}
2108 environmentId={props.environmentId}
apps/mobile/src/features/threads/ThreadRouteScreen.tsx
+4 -1
@@ -964,7 +964,10 @@ function ThreadRouteContent(
964 // Shown in the header subtitle so the composer's status slot doesn't jump while history syncs.
965 const threadSyncLabel = useDelayedStatus(
966 selectedThread === null ? "" : scopedThreadKey(selectedThread.environmentId, selectedThread.id),
967 - threadSyncStatusLabel(selectedThreadDetailState.status, contentPresentation.kind),
967 + // A thread this client is creating has nothing older to sync.
968 + creationState === null
969 + ? threadSyncStatusLabel(selectedThreadDetailState.status, contentPresentation.kind)
970 + : null,
971 );
972 const inspectorHeader = props.inspectorPresentation ? (
973 <ThreadInspectorHeader
apps/mobile/src/features/threads/worktree-setup-card.tsx
+19
@@ -1,5 +1,6 @@
1 import { Button } from "../../components/ui/Button";
2 import {
3 + WORKTREE_SETUP_STAGE_ORDER,
4 worktreeSetupStageLabel,
5 type WorktreeSetupSnapshot,
6 type WorktreeSetupStage,
@@ -148,12 +149,30 @@ export function WorktreeSetupCard(props: WorktreeSetupCardProps) {
149 }
150
151 /** Holds the card's place until the server publishes the first setup snapshot. */
152 +// Same rows the first snapshot brings, so the card keeps its height when that snapshot lands.
153 +const PREPARING_STAGES: ReadonlyArray<WorktreeSetupStage> = WORKTREE_SETUP_STAGE_ORDER.filter(
154 + (id) => id !== "agent",
155 +).map((id) => ({
156 + id,
157 + status: "pending",
158 + startedAt: null,
159 + endedAt: null,
160 + percent: null,
161 + detail: null,
162 + tail: [],
163 +}));
164 +
165 export function WorktreePreparingHeader() {
166 return (
167 <View className="py-1">
168 <View className="min-h-11 flex-row items-center border-b border-border px-1">
169 <HeaderLabel label="Setting up worktree…" active />
170 </View>
171 + <View className="pt-1 pb-2">
172 + {PREPARING_STAGES.map((stage) => (
173 + <StageRow key={stage.id} stage={stage} scriptName={null} now={0} compact />
174 + ))}
175 + </View>
176 </View>
177 );
178 }
apps/mobile/src/lib/sentImageHandoff.ts new
+36
@@ -0,0 +1,36 @@
1 +export interface SentImageHandoff {
2 + readonly uri: string;
3 + readonly aspectRatio: number;
4 +}
5 +
6 +// A sent image's local pixels and shape, so the pending bubble and then the delivered copy open at
7 +// their final size over pixels already on screen instead of a placeholder that later resizes.
8 +// The server re-ids attachments into the thread, so delivered images match by message and position.
9 +const MAX_ENTRIES = 64;
10 +const images = new Map<string, SentImageHandoff>();
11 +
12 +function remember(key: string, image: SentImageHandoff) {
13 + if (!Number.isFinite(image.aspectRatio) || image.aspectRatio <= 0) return;
14 + images.delete(key);
15 + images.set(key, image);
16 + if (images.size > MAX_ENTRIES) images.delete(images.keys().next().value!);
17 +}
18 +
19 +export function rememberDraftImage(attachmentId: string, image: SentImageHandoff): void {
20 + remember(`draft:${attachmentId}`, image);
21 +}
22 +
23 +export function rememberSentImage(messageId: string, index: number, image: SentImageHandoff): void {
24 + remember(`message:${messageId}:${index}`, image);
25 +}
26 +
27 +export function sentImageHandoff(
28 + messageId: string,
29 + index: number,
30 + draftAttachmentId?: string,
31 +): SentImageHandoff | undefined {
32 + return (
33 + images.get(`message:${messageId}:${index}`) ??
34 + (draftAttachmentId === undefined ? undefined : images.get(`draft:${draftAttachmentId}`))
35 + );
36 +}