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 22, 19:30 UTC
fix(mobile): drafts swipe to discard and every row move animates (#23205)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 21, 2026 at 19:37 UTC
b295dd83b2f908cd4ecd6f121c9a30ce38861e93
6 files changed
+149
-58
apps/mobile/src/features/home/HomeScreen.tsx
+5
@@ -593,6 +593,11 @@ export function HomeScreen(props: HomeScreenProps) {
593
showTrailingDivider={item.showTrailingDivider}
594
onSelectPendingTask={props.onSelectPendingTask}
595
onDeletePendingTask={props.onDeletePendingTask}
596
+ fullSwipeWidth={fullSwipeWidth}
597
+ onSwipeableClose={handleSwipeableClose}
598
+ onSwipeableWillOpen={handleSwipeableWillOpen}
599
+ simultaneousSwipeGesture={homeScrollGesture}
600
+ activationKey={item.key}
601
/>
602
);
603
}
apps/mobile/src/features/home/thread-swipe-actions.tsx
+2
-1
@@ -62,6 +62,7 @@ interface ThreadSwipeAction {
62
readonly accessibilityLabel: string;
63
readonly icon: ComponentProps<typeof SymbolView>["name"];
64
readonly label: string;
65
+ readonly destructive?: boolean;
66
readonly menu?: {
67
readonly actions: MenuAction[];
68
readonly onPressAction: NonNullable<ComponentProps<typeof Menu>["onPressAction"]>;
@@ -726,7 +727,7 @@ export function ThreadSwipeActions(props: {
727
<SwipeActionButton
728
accessibilityLabel={props.primaryAction.accessibilityLabel}
729
actionsWidth={actionsWidth}
729
- tone="primary"
730
+ tone={props.primaryAction.destructive === true ? "danger" : "primary"}
731
compact={props.compact}
732
entryRange={
733
secondaryAction === null
apps/mobile/src/features/home/usePendingTaskListActions.ts
+37
-10
@@ -5,7 +5,13 @@ import { useCallback } from "react";
5
import { removeThreadOutboxMessage } from "../../state/thread-outbox-removal";
6
import { clearComposerDraftContent } from "../../state/use-composer-drafts";
7
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
8
-import { releaseEditingQueuedMessage } from "../../state/use-thread-outbox";
8
+import { appAtomRegistry } from "../../state/atom-registry";
9
+import {
10
+ editingQueuedMessageIdsAtom,
11
+ holdEditingQueuedMessage,
12
+ releaseEditingQueuedMessage,
13
+} from "../../state/use-thread-outbox";
14
+import { withThreadDismissal } from "./thread-dismissal";
15
16
export function usePendingTaskListActions(): {
17
readonly openPendingTask: (pendingTask: PendingNewTask) => void;
@@ -37,10 +43,15 @@ export function usePendingTaskListActions(): {
43
text: "Discard",
44
style: "destructive",
45
onPress: () => {
40
- clearComposerDraftContent(pendingTask.draftKey, {
41
- clearModelSelection: true,
42
- clearWorkspaceSelection: true,
43
- });
46
+ void withThreadDismissal(
47
+ pendingTask.key,
48
+ async () =>
49
+ clearComposerDraftContent(pendingTask.draftKey, {
50
+ clearModelSelection: true,
51
+ clearWorkspaceSelection: true,
52
+ }),
53
+ () => true,
54
+ );
55
},
56
},
57
]);
@@ -55,12 +66,28 @@ export function usePendingTaskListActions(): {
66
text: "Delete",
67
style: "destructive",
68
onPress: () => {
58
- // Release the edit lock only after removal succeeds, and only if
59
- // it is held for THIS task — clearing it up front (or for another
60
- // task) would let the drain deliver a mid-edit payload.
61
- void removeThreadOutboxMessage(pendingTask.message)
62
- .then(() => releaseEditingQueuedMessage(pendingTask.message.messageId))
69
+ // The row animates out before removal runs, so hold delivery from
70
+ // confirmation on: a reconnect must not send a task being deleted.
71
+ // The hold is shared with the editor, which could release it
72
+ // mid-animation, so a task open in the editor is removed at once
73
+ // and keeps its hold unless removal succeeds.
74
+ const messageId = pendingTask.message.messageId;
75
+ const heldByEditor = appAtomRegistry.get(editingQueuedMessageIdsAtom)[messageId];
76
+ holdEditingQueuedMessage(messageId);
77
+ const releaseUnlessEditing = () => {
78
+ if (!heldByEditor) releaseEditingQueuedMessage(messageId);
79
+ };
80
+ const remove = () => removeThreadOutboxMessage(pendingTask.message);
81
+ void (
82
+ heldByEditor
83
+ ? remove()
84
+ : withThreadDismissal(pendingTask.key, remove, (removed) => removed)
85
+ )
86
+ .then((removed) =>
87
+ removed ? releaseEditingQueuedMessage(messageId) : releaseUnlessEditing(),
88
+ )
89
.catch((error) => {
90
+ releaseUnlessEditing();
91
Dialog.alert(
92
"Could not delete pending task",
93
error instanceof Error ? error.message : "The pending task could not be removed.",
apps/mobile/src/features/home/useThreadListActions.ts
+18
-8
@@ -456,10 +456,15 @@ export function useThreadListActions(): {
456
// Pinning clears snooze, so older Settled or Snoozed undos would fight this pin.
457
ThreadUndo.invalidate("settle", scopedThreadKey(thread.environmentId, thread.id));
458
ThreadUndo.invalidate("snooze", scopedThreadKey(thread.environmentId, thread.id));
459
- const result = await pinMutation({
460
- environmentId: thread.environmentId,
461
- input: { threadId: thread.id, ...(orderKey !== undefined ? { orderKey } : {}) },
462
- });
459
+ const result = await withThreadDismissal(
460
+ scopedThreadKey(thread.environmentId, thread.id),
461
+ () =>
462
+ pinMutation({
463
+ environmentId: thread.environmentId,
464
+ input: { threadId: thread.id, ...(orderKey !== undefined ? { orderKey } : {}) },
465
+ }),
466
+ (result) => result._tag === "Success",
467
+ );
468
if (result._tag === "Failure") {
469
const error = Cause.squash(result.cause);
470
Dialog.alert(
@@ -484,10 +489,15 @@ export function useThreadListActions(): {
489
selectionHaptic();
490
const plan = ThreadUndo.planThreadUndo("unpin", thread);
491
const claim = ThreadUndo.begin("pin", scopedThreadKey(thread.environmentId, thread.id));
487
- const result = await unpinMutation({
488
- environmentId: thread.environmentId,
489
- input: { threadId: thread.id },
490
- });
492
+ const result = await withThreadDismissal(
493
+ scopedThreadKey(thread.environmentId, thread.id),
494
+ () =>
495
+ unpinMutation({
496
+ environmentId: thread.environmentId,
497
+ input: { threadId: thread.id },
498
+ }),
499
+ (result) => result._tag === "Success",
500
+ );
501
if (result._tag === "Failure") {
502
claim.finish();
503
const error = Cause.squash(result.cause);
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+4
@@ -585,6 +585,10 @@ function ThreadNavigationSidebarPane(
585
showPendingDivider={item.showPendingDivider}
586
onSelectPendingTask={props.onOpenPendingTask}
587
onDeletePendingTask={confirmDeletePendingTask}
588
+ fullSwipeWidth={props.width - 20}
589
+ onSwipeableClose={handleSwipeableClose}
590
+ onSwipeableWillOpen={handleSwipeableWillOpen}
591
+ simultaneousSwipeGesture={sidebarScrollGesture}
592
/>
593
);
594
}
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+83
-39
@@ -325,10 +325,34 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
325
readonly showTrailingDivider?: boolean;
326
readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
327
readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
328
+ readonly fullSwipeWidth?: number;
329
+ readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void;
330
+ readonly onSwipeableClose: (methods: SwipeableMethods) => void;
331
+ readonly activationKey?: string;
332
+ readonly simultaneousSwipeGesture?: ComponentProps<typeof ThreadSwipeable>["simultaneousWith"];
333
}) {
334
const { pendingTask, onSelectPendingTask, onDeletePendingTask } = props;
335
+ const { width: windowWidth } = useWindowDimensions();
336
+ const dormant = useSwipeRowDormant(props.activationKey);
337
+ const theme = useUniwindTheme();
338
const sidebarPane = props.pane === "sidebar";
339
+ const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, false);
340
const isDraft = pendingTask.kind === "draft";
341
+ const deleteLabel = isDraft ? "Discard" : "Delete";
342
+ const handleDelete = useCallback(
343
+ () => onDeletePendingTask(pendingTask),
344
+ [onDeletePendingTask, pendingTask],
345
+ );
346
+ const deleteAction = useMemo(
347
+ () => ({
348
+ accessibilityLabel: `${deleteLabel} ${pendingTask.title}`,
349
+ destructive: true,
350
+ icon: "trash" as const,
351
+ label: deleteLabel,
352
+ onPress: handleDelete,
353
+ }),
354
+ [deleteLabel, handleDelete, pendingTask.title],
355
+ );
356
const projectTitle = props.projectTitle ?? props.project?.title ?? pendingTask.projectTitle ?? "";
357
const branch = pendingTask.branch;
358
@@ -442,45 +466,65 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
466
{props.showPendingDivider ? (
467
<ThreadListV2SectionDivider label="Unsent" pane={props.pane} />
468
) : null}
445
- <Menu
446
- actions={isDraft ? DRAFT_TASK_MENU_ACTIONS : PENDING_TASK_MENU_ACTIONS}
447
- onPressAction={handleMenuAction}
448
- shouldOpenOnLongPress
469
+ <ThreadSwipeable
470
+ dormant={dormant}
471
+ threadKey={pendingTask.key}
472
+ backgroundColor={rowAppearance.swipeBackgroundColor}
473
+ containerStyle={rowAppearance.swipeContainerStyle}
474
+ enableTrackpadSwipe
475
+ fullSwipeAction="primary"
476
+ fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}
477
+ onDelete={handleDelete}
478
+ onSwipeableClose={props.onSwipeableClose}
479
+ onSwipeableWillOpen={props.onSwipeableWillOpen}
480
+ primaryAction={deleteAction}
481
+ secondaryAction={null}
482
+ resetKey={pendingTask.key}
483
+ simultaneousWith={props.simultaneousSwipeGesture}
484
+ threadTitle={pendingTask.title}
485
>
450
- <RowPressable
451
- accessibilityHint={
452
- isDraft
453
- ? "Opens the draft in the new task composer"
454
- : "Sends when the environment reconnects. Opens the task for editing"
455
- }
456
- accessibilityLabel={pendingTask.title}
457
- accessibilityRole="button"
458
- key={pendingTask.key}
459
- className={sidebarPane ? "bg-drawer" : "bg-screen"}
460
- interactionClassName={sidebarPane ? "bg-thread-hover" : "bg-row-hover"}
461
- onPress={() => onSelectPendingTask(pendingTask)}
462
- style={
463
- sidebarPane
464
- ? {
465
- borderRadius: SIDEBAR_V2_ROW_RADIUS,
466
- paddingHorizontal: 12,
467
- paddingVertical: 10,
468
- }
469
- : undefined
470
- }
471
- >
472
- {sidebarPane ? (
473
- rowContent
474
- ) : (
475
- <View>
476
- <View className="px-5 py-2.5">{rowContent}</View>
477
- {props.showTrailingDivider !== false ? (
478
- <View className="ml-5 h-px bg-border-subtle" />
479
- ) : null}
480
- </View>
481
- )}
482
- </RowPressable>
483
- </Menu>
486
+ {() => (
487
+ <Menu
488
+ actions={isDraft ? DRAFT_TASK_MENU_ACTIONS : PENDING_TASK_MENU_ACTIONS}
489
+ onPressAction={handleMenuAction}
490
+ shouldOpenOnLongPress
491
+ >
492
+ <RowPressable
493
+ accessibilityHint={
494
+ isDraft
495
+ ? `Opens the draft in the new task composer. Swipe left to ${deleteLabel.toLowerCase()}.`
496
+ : `Sends when the environment reconnects. Opens the task for editing. Swipe left to ${deleteLabel.toLowerCase()}.`
497
+ }
498
+ accessibilityLabel={pendingTask.title}
499
+ accessibilityRole="button"
500
+ key={pendingTask.key}
501
+ className={sidebarPane ? "bg-drawer" : "bg-screen"}
502
+ interactionClassName={sidebarPane ? "bg-thread-hover" : "bg-row-hover"}
503
+ onPress={() => onSelectPendingTask(pendingTask)}
504
+ style={
505
+ sidebarPane
506
+ ? {
507
+ borderRadius: SIDEBAR_V2_ROW_RADIUS,
508
+ paddingHorizontal: 12,
509
+ paddingVertical: 10,
510
+ }
511
+ : undefined
512
+ }
513
+ >
514
+ {sidebarPane ? (
515
+ rowContent
516
+ ) : (
517
+ <View>
518
+ <View className="px-5 py-2.5">{rowContent}</View>
519
+ {props.showTrailingDivider !== false ? (
520
+ <View className="ml-5 h-px bg-border-subtle" />
521
+ ) : null}
522
+ </View>
523
+ )}
524
+ </RowPressable>
525
+ </Menu>
526
+ )}
527
+ </ThreadSwipeable>
528
</>
529
);
530
});
@@ -1334,7 +1378,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1378
onSwipeableWillOpen={props.onSwipeableWillOpen}
1379
primaryAction={primaryAction}
1380
secondaryAction={secondaryAction}
1337
- resetKey={`${thread.environmentId}:${thread.id}:${variant}:${snoozedRow}:${thread.settledAt}:${thread.unsettledAt}:${thread.snoozedUntil}`}
1381
+ resetKey={`${thread.environmentId}:${thread.id}:${variant}:${snoozedRow}:${thread.settledAt}:${thread.unsettledAt}:${thread.snoozedUntil}:${thread.pinnedAt}`}
1382
simultaneousWith={props.simultaneousSwipeGesture}
1383
threadTitle={thread.title}
1384
>