@devries-cameron20 / t3code Mirror · read-only / commits / c9d29e09ef
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 22, 04:30 UTC

fix(mobile): keep iOS thread menus short enough for drag selection (#30944)

shivam committed Nov 5, 2026 at 06:44 UTC c9d29e09efc64775eb387714d873b442da9e6967
3 files changed +183 -100
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+97 -100
@@ -73,6 +73,7 @@ import {
73 resolveThreadListV2Status,
74 resolveThreadListV2ProviderDrivers,
75 resolveThreadListV2SwipeActions,
76 + layoutThreadListV2RowMenuActions,
77 type ThreadListV2Status,
78 } from "./threadListV2";
79 import { QueuedMessageIcon } from "./queued-message-icon";
@@ -830,9 +831,9 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
831 ],
832 [snoozePresets],
833 );
833 - const arrangementMenuItems = useMemo<MenuAction[]>(
834 - () => [
835 - ...(props.reorderSupported === true
834 + const reorderMenuItems = useMemo<MenuAction[]>(
835 + () =>
836 + props.reorderSupported === true
837 ? [
838 { id: "arrange", title: "Arrange threads…", image: "line.3.horizontal" },
839 {
@@ -848,22 +849,19 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
849 attributes: { disabled: props.canMoveDown !== true },
850 } satisfies MenuAction,
851 ]
851 - : []),
852 - ...(props.pinningSupported
852 + : [],
853 + [props.canMoveDown, props.canMoveUp, props.reorderSupported],
854 + );
855 + const pinMenuItems = useMemo<MenuAction[]>(
856 + () =>
857 + props.pinningSupported
858 ? [
859 thread.pinnedAt != null
860 ? { id: "unpin", title: "Unpin", image: "pin.slash" }
861 : { id: "pin", title: "Pin", image: "pin" },
862 ]
858 - : []),
859 - ],
860 - [
861 - props.canMoveDown,
862 - props.canMoveUp,
863 - props.reorderSupported,
864 - props.pinningSupported,
865 - thread.pinnedAt,
866 - ],
863 + : [],
864 + [props.pinningSupported, thread.pinnedAt],
865 );
866 const autoSettleMenuItems = useMemo<MenuAction[]>(
867 () =>
@@ -911,66 +909,90 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
909 ],
910 [canTurnIntoProject, props.titleRegenerationSupported, thread.runtime, isRegeneratingTitle],
911 );
914 - const snoozableCardMenuActions = useMemo<MenuAction[]>(
915 - () => [
916 - { id: "settle", title: "Settle", image: "checkmark" },
917 - {
918 - id: "snooze",
919 - title: "Snooze",
920 - image: "clock",
921 - subactions: snoozePresetActions,
922 - },
923 - ...arrangementMenuItems,
924 - ...titleMenuItems,
925 - ...autoSettleMenuItems,
926 - LEGACY_MENU_ACTIONS[0]!,
927 - { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
928 - ],
929 - [arrangementMenuItems, autoSettleMenuItems, snoozePresetActions, titleMenuItems],
930 - );
931 - const cardMenuActions = useMemo<MenuAction[]>(
932 - () => [
933 - CARD_MENU_ACTIONS[0]!,
934 - ...arrangementMenuItems,
935 - ...titleMenuItems,
936 - ...autoSettleMenuItems,
937 - LEGACY_MENU_ACTIONS[0]!,
938 - ...CARD_MENU_ACTIONS.slice(1),
939 - ],
940 - [arrangementMenuItems, autoSettleMenuItems, titleMenuItems],
941 - );
942 - const slimMenuActions = useMemo<MenuAction[]>(
943 - () => [
944 - SLIM_MENU_ACTIONS[0]!,
945 - ...arrangementMenuItems.filter(
946 - (action) => action.id !== "move-up" && action.id !== "move-down",
947 - ),
948 - ...titleMenuItems,
949 - ...autoSettleMenuItems,
950 - LEGACY_MENU_ACTIONS[0]!,
951 - SLIM_MENU_ACTIONS[1]!,
952 - ],
953 - [arrangementMenuItems, autoSettleMenuItems, titleMenuItems],
954 - );
955 - const snoozedMenuActions = useMemo<MenuAction[]>(
956 - () => [
957 - SNOOZED_MENU_ACTIONS[0]!,
958 - ...titleMenuItems,
959 - ...autoSettleMenuItems,
960 - LEGACY_MENU_ACTIONS[0]!,
961 - SNOOZED_MENU_ACTIONS[1]!,
962 - ],
963 - [autoSettleMenuItems, titleMenuItems],
964 - );
965 - const legacyMenuActions = useMemo<MenuAction[]>(
966 - () => [
967 - LEGACY_MENU_ACTIONS[0]!,
968 - ...arrangementMenuItems,
969 - ...titleMenuItems,
970 - LEGACY_MENU_ACTIONS[1]!,
971 - ],
972 - [arrangementMenuItems, titleMenuItems],
973 - );
912 + const menuActions = useMemo<MenuAction[]>(() => {
913 + const nested = Platform.OS === "ios";
914 + const direct: MenuAction[] = [
915 + ...(thread.branch
916 + ? [
917 + {
918 + id: "new-thread-on-branch",
919 + title: getThreadListV2NewBranchMenuTitle(thread.branch),
920 + image: "square.and.pencil",
921 + },
922 + ]
923 + : []),
924 + { id: "copy-thread", title: "Copy thread", image: "text.bubble" },
925 + { id: "copy-thread-id", title: "Copy thread ID", image: "doc.on.doc" },
926 + ];
927 + if (snoozedRow) {
928 + return layoutThreadListV2RowMenuActions({
929 + nested,
930 + direct: [...direct, SNOOZED_MENU_ACTIONS[0]!],
931 + reorder: [],
932 + pin: [],
933 + secondary: [
934 + ...titleMenuItems,
935 + ...autoSettleMenuItems,
936 + LEGACY_MENU_ACTIONS[0]!,
937 + SNOOZED_MENU_ACTIONS[1]!,
938 + ],
939 + });
940 + }
941 + if (!props.settlementSupported) {
942 + return layoutThreadListV2RowMenuActions({
943 + nested,
944 + direct: [...direct, LEGACY_MENU_ACTIONS[0]!],
945 + reorder: reorderMenuItems,
946 + pin: pinMenuItems,
947 + secondary: [...titleMenuItems, LEGACY_MENU_ACTIONS[1]!],
948 + });
949 + }
950 + if (canUnsettle) {
951 + return layoutThreadListV2RowMenuActions({
952 + nested,
953 + direct: [...direct, SLIM_MENU_ACTIONS[0]!],
954 + reorder: reorderMenuItems.filter(
955 + (action) => action.id !== "move-up" && action.id !== "move-down",
956 + ),
957 + pin: pinMenuItems,
958 + secondary: [
959 + ...titleMenuItems,
960 + ...autoSettleMenuItems,
961 + LEGACY_MENU_ACTIONS[0]!,
962 + SLIM_MENU_ACTIONS[1]!,
963 + ],
964 + });
965 + }
966 + return layoutThreadListV2RowMenuActions({
967 + nested,
968 + direct: [
969 + ...direct,
970 + CARD_MENU_ACTIONS[0]!,
971 + ...(swipeActions.secondary === "snooze"
972 + ? [{ id: "snooze", title: "Snooze", image: "clock", subactions: snoozePresetActions }]
973 + : []),
974 + ],
975 + reorder: reorderMenuItems,
976 + pin: pinMenuItems,
977 + secondary: [
978 + ...titleMenuItems,
979 + ...autoSettleMenuItems,
980 + LEGACY_MENU_ACTIONS[0]!,
981 + CARD_MENU_ACTIONS[1]!,
982 + ],
983 + });
984 + }, [
985 + autoSettleMenuItems,
986 + canUnsettle,
987 + pinMenuItems,
988 + props.settlementSupported,
989 + reorderMenuItems,
990 + snoozePresetActions,
991 + snoozedRow,
992 + swipeActions.secondary,
993 + thread.branch,
994 + titleMenuItems,
995 + ]);
996 const handleMenuAction = useCallback(
997 ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
998 if (nativeEvent.event === "new-thread-on-branch") onNewThreadOnBranch(thread);
@@ -1485,32 +1507,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1507 threadTitle={thread.title}
1508 >
1509 {(close) => (
1488 - <Menu
1489 - actions={[
1490 - ...(thread.branch
1491 - ? [
1492 - {
1493 - id: "new-thread-on-branch",
1494 - title: getThreadListV2NewBranchMenuTitle(thread.branch),
1495 - image: "square.and.pencil",
1496 - },
1497 - ]
1498 - : []),
1499 - { id: "copy-thread", title: "Copy thread", image: "text.bubble" },
1500 - { id: "copy-thread-id", title: "Copy thread ID", image: "doc.on.doc" },
1501 - ...(snoozedRow
1502 - ? snoozedMenuActions
1503 - : !props.settlementSupported
1504 - ? legacyMenuActions
1505 - : canUnsettle
1506 - ? slimMenuActions
1507 - : swipeActions.secondary === "snooze"
1508 - ? snoozableCardMenuActions
1509 - : cardMenuActions),
1510 - ]}
1511 - onPressAction={handleMenuAction}
1512 - shouldOpenOnLongPress
1513 - >
1510 + <Menu actions={menuActions} onPressAction={handleMenuAction} shouldOpenOnLongPress>
1511 {rowContent(close)}
1512 </Menu>
1513 )}
apps/mobile/src/features/threads/threadListV2.test.ts
+49
@@ -25,6 +25,7 @@ import {
25 RunId,
26 ThreadId,
27 } from "@t3tools/contracts";
28 +import type { MenuAction } from "@react-native-menu/menu";
29 import { describe, expect, it, vi } from "vite-plus/test";
30
31 import type { PendingNewTask } from "../../state/use-pending-new-tasks";
@@ -34,6 +35,7 @@ import {
35 buildThreadListV2Items,
36 buildThreadListV2ListItems,
37 getThreadListV2OrderedSection,
38 + layoutThreadListV2RowMenuActions,
39 resolveThreadListV2SnoozeMenuSelection,
40 resolveThreadListV2SnoozePresets,
41 resolveThreadListV2Status,
@@ -99,6 +101,53 @@ describe("resolveThreadListV2SnoozePresets", () => {
101 });
102 });
103
104 +describe("layoutThreadListV2RowMenuActions", () => {
105 + const actions = (...ids: string[]): MenuAction[] => ids.map((id) => ({ id, title: id }));
106 + const leafIds = (items: readonly MenuAction[]): string[] =>
107 + items.flatMap((item) => (item.subactions ? leafIds(item.subactions) : [item.id!]));
108 +
109 + it("keeps every action once while nesting iOS secondary actions under More", () => {
110 + const full = {
111 + direct: actions("new-thread-on-branch", "copy-thread", "copy-thread-id", "settle", "snooze"),
112 + reorder: actions("arrange", "move-up", "move-down"),
113 + pin: actions("unpin"),
114 + secondary: actions("rename", "regenerate-title", "turn-into-project", "archive", "delete"),
115 + };
116 + const flat = layoutThreadListV2RowMenuActions({ ...full, nested: false });
117 + const nested = layoutThreadListV2RowMenuActions({ ...full, nested: true });
118 +
119 + expect(flat.map((action) => action.id)).toEqual(
120 + [...full.direct, ...full.reorder, ...full.pin, ...full.secondary].map((action) => action.id),
121 + );
122 + expect(nested.map((action) => action.id)).toEqual([
123 + "new-thread-on-branch",
124 + "copy-thread",
125 + "copy-thread-id",
126 + "settle",
127 + "snooze",
128 + "unpin",
129 + "more",
130 + ]);
131 + expect(nested.at(-1)?.subactions?.map((action) => action.id)).toEqual([
132 + "arrange-menu",
133 + "rename",
134 + "regenerate-title",
135 + "turn-into-project",
136 + "archive",
137 + "delete",
138 + ]);
139 + expect(leafIds(nested).toSorted()).toEqual(leafIds(flat).toSorted());
140 +
141 + // Slim rows only offer "Arrange threads…", which needs no submenu of its own.
142 + const slim = layoutThreadListV2RowMenuActions({
143 + ...full,
144 + reorder: actions("arrange"),
145 + nested: true,
146 + });
147 + expect(slim.at(-1)?.subactions?.[0]?.id).toBe("arrange");
148 + });
149 +});
150 +
151 describe("resolveThreadListV2Status", () => {
152 it("presents decoded thread waits as Waiting while preserving requests and older servers", () => {
153 const raw = makeRawThreadShell({
apps/mobile/src/features/threads/threadListV2.ts
+37
@@ -30,6 +30,7 @@ import {
30 } from "@t3tools/client-runtime/state/thread-sort";
31 import { isListedThreadLineage, type EnvironmentId, type ProjectId } from "@t3tools/contracts";
32 import type { SnoozePresetSetting } from "@t3tools/contracts/settings";
33 +import type { MenuAction } from "@react-native-menu/menu";
34
35 import type { ThreadListProvider } from "../../state/thread-list-environments";
36 import type { ThreadMoveAvailability } from "./threadOrder";
@@ -134,6 +135,42 @@ export function resolveThreadListV2SwipeActions(input: {
135 };
136 }
137
138 +// Nested keeps iOS menus short: UIKit scrolls a taller menu, and that scroll
139 +// cancels press-drag-release selection.
140 +export function layoutThreadListV2RowMenuActions(input: {
141 + readonly nested: boolean;
142 + readonly direct: readonly MenuAction[];
143 + readonly reorder: readonly MenuAction[];
144 + readonly pin: readonly MenuAction[];
145 + readonly secondary: readonly MenuAction[];
146 +}): MenuAction[] {
147 + if (!input.nested) {
148 + return [...input.direct, ...input.reorder, ...input.pin, ...input.secondary];
149 + }
150 + return [
151 + ...input.direct,
152 + ...input.pin,
153 + {
154 + id: "more",
155 + title: "More",
156 + image: "ellipsis.circle",
157 + subactions: [
158 + ...(input.reorder.length > 1
159 + ? [
160 + {
161 + id: "arrange-menu",
162 + title: "Arrange",
163 + image: "arrow.up.arrow.down",
164 + subactions: [...input.reorder],
165 + },
166 + ]
167 + : input.reorder),
168 + ...input.secondary,
169 + ],
170 + },
171 + ];
172 +}
173 +
174 export function resolveThreadListV2SnoozeGateExpiryMs(
175 thread: Pick<
176 EnvironmentThreadShell,