Skip to content

Commit 3444b8a

Browse files
fix(mobile): stop alerting that shared content vanished after sending it
Since #10435, sending a new task clears the composer draft synchronously but defers the navigation by a frame. The share import effect re-ran in that frame: the draft's importedShareIds receipt was gone, the inbox entry had already been consumed, so the share looked unavailable and the screen raised "Shared content unavailable" over a task that had just sent fine. Remember the share this screen consumed and treat it as imported for the rest of the screen's life, independent of the draft's receipt. Co-Authored-By: Claude Code <noreply@anthropic.com>
1 parent aac6d0a commit 3444b8a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

apps/mobile/src/features/threads/NewTaskDraftScreen.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ export function NewTaskDraftScreen(props: {
323323
latestIncomingShareIdRef.current = props.incomingShareId;
324324
const isImportingShare = importingShareKey !== null;
325325
const alertedUnavailableIncomingShareIdRef = useRef<string | null>(null);
326+
// The share this screen already moved into its draft. Sending clears the
327+
// draft (and its importedShareIds receipt) a frame before the screen leaves,
328+
// and the inbox entry is long gone by then; without this the re-render in
329+
// between reads as "shared content vanished" and alerts on every send.
330+
const consumedIncomingShareIdRef = useRef<string | null>(null);
326331
const incomingShare = props.incomingShareId ? getShare(props.incomingShareId) : null;
327332
const requestedInitialProjectAvailable = Boolean(
328333
props.initialProjectRef?.environmentId &&
@@ -416,8 +421,9 @@ export function NewTaskDraftScreen(props: {
416421
}, [navigation, preventRemove, submitNavigationAction]);
417422
const hasImportedIncomingShare = Boolean(
418423
props.incomingShareId &&
419-
flow.draftKey &&
420-
getComposerDraftSnapshot(flow.draftKey).importedShareIds?.includes(props.incomingShareId),
424+
(consumedIncomingShareIdRef.current === props.incomingShareId ||
425+
(flow.draftKey &&
426+
getComposerDraftSnapshot(flow.draftKey).importedShareIds?.includes(props.incomingShareId))),
421427
);
422428
const isIncomingShareUnavailable = Boolean(
423429
props.incomingShareId &&
@@ -747,6 +753,7 @@ export function NewTaskDraftScreen(props: {
747753
}
748754
await consumeShare(shareId);
749755
didConsumeShare = true;
756+
consumedIncomingShareIdRef.current = shareId;
750757
// The consumed inbox draft was the last owner of files that never made
751758
// it into the composer draft (unsupported server, oversize, limit
752759
// skips). Release them before any early return: an unmount or a

0 commit comments

Comments
 (0)