The best way to control Claude Code, Codex and more from any computer or phone
perf(mobile): stop menu fault logging and whole-list re-renders on Home (#24646)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 24, 2026 at 18:32 UTC
62eb35b163d636d3c87181367976eac5622e9933
7 files changed
+246
-214
apps/mobile/src/features/home/HomeScreen.tsx
+33
-95
@@ -2,7 +2,6 @@ import { useActiveNewTask } from "../../state/active-new-task";
2
import { AppActivityIndicator } from "../../components/ui/AppActivityIndicator";
3
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
4
import type { ThreadMoveDestination } from "../threads/threadOrder";
5
-import { computeThreadMoveAvailability } from "../threads/threadOrder";
5
import type { LegendListRef } from "@legendapp/list/react-native";
6
import { AnimatedLegendList } from "@legendapp/list/reanimated";
7
import { THREAD_SIDEBAR_ROW_LAYOUT } from "../threads/threadListAnimations";
@@ -54,6 +53,7 @@ import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspace
53
import { useThreadSearch } from "../../state/queries";
54
import { requestThreadMessageJump } from "../threads/threadMessageJump";
55
import { useThreadListSearchMatches } from "../threads/useThreadListSearchMatches";
56
+import { useThreadListV2 } from "../threads/useThreadListV2";
57
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
58
import { usePendingThreadOrder } from "../../state/thread-order";
59
import { threadListEnvironmentsAtom } from "../../state/server";
@@ -71,11 +71,7 @@ import { useThreadRowProviderInstanceResolver } from "../threads/thread-provider
71
import { useOpenThreadPullRequests } from "../threads/use-open-thread-pull-requests";
72
import type { ThreadPrPresentation } from "../../state/thread-pr-presentation";
73
import {
74
- buildThreadListV2Items,
75
- getThreadListV2OrderedSection,
76
- buildThreadListV2ListItems,
74
threadListV2ListItemsAreEqual,
78
- threadListInboxReturns,
75
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
76
THREAD_LIST_V2_SETTLED_PAGE_COUNT,
77
type ThreadListV2ListItem,
@@ -300,7 +296,6 @@ export function HomeScreen(props: HomeScreenProps) {
296
: [];
297
const threadSearch = useThreadSearch(searchEnvironmentIds, props.searchQuery);
298
const threadSearchMatchByKey = useThreadListSearchMatches(props.threads, threadSearch);
303
- const matchedThreadKeys = new Set(threadSearchMatchByKey.keys());
299
const handleSwipeableWillOpen = (methods: SwipeableMethods) => {
300
if (openSwipeableRef.current !== methods) {
301
openSwipeableRef.current?.close();
@@ -397,14 +392,6 @@ export function HomeScreen(props: HomeScreenProps) {
392
),
393
),
394
);
400
- const v2ScopedProjectKeys =
401
- v2ScopedProjectGroup === null
402
- ? null
403
- : new Set(
404
- v2ScopedProjectGroup.projectRefs.map((projectRef) =>
405
- scopedProjectKey(projectRef.environmentId, projectRef.projectId),
406
- ),
407
- );
395
const handleSettleThread = props.onSettleThread;
396
const handleSnoozeThread = props.onSnoozeThread;
397
const handleUnsnoozeThread = props.onUnsnoozeThread;
@@ -462,54 +449,32 @@ export function HomeScreen(props: HomeScreenProps) {
449
} = listEnvironments;
450
const resolveProviderInstance = useThreadRowProviderInstanceResolver(providersByEnvironmentId);
451
const pendingOrder = usePendingThreadOrder(nowMinute, snoozeWakeTick);
465
- // Up/down menu availability for every card, computed once per section per
466
- // rebuild (see computeThreadMoveAvailability): per-thread planner calls made
467
- // list construction quadratic, and this list rebuilds on every minute tick.
468
- const threadMoveAvailability = (() => {
469
- const sectionAvailability = (section: "pinned" | "active") =>
470
- computeThreadMoveAvailability({
471
- allThreads: props.threads,
472
- section,
473
- pendingOrder,
474
- reorderableEnvironmentIds:
475
- section === "pinned" ? pinReorderEnvironmentIds : activeReorderEnvironmentIds,
476
- ordered: getThreadListV2OrderedSection({
477
- threads: props.threads,
478
- section,
479
- pendingOrder,
480
- now,
481
- settlementEnvironmentIds,
482
- snoozeEnvironmentIds,
483
- queuedThreadKeys,
484
- }),
485
- });
486
- return new Map([
487
- ...sectionAvailability("pinned"),
488
- ...(workingShelfEnabled ? [] : sectionAvailability("active")),
489
- ]);
490
- })();
491
- const threadListV2Layout = (() => {
492
- threadListInboxReturns.observe(workingShelfEnabled ? props.threads : null);
493
- return buildThreadListV2Items({
494
- pendingOrder,
495
- threads: props.threads.filter((thread) => thread.archivedAt === null),
496
- environmentId: props.selectedEnvironmentId,
497
- projectRefs: v2ScopedProjectGroup === null ? null : v2ScopedProjectGroup.projectRefs,
498
- searchQuery: props.searchQuery,
499
- matchedThreadKeys,
500
- settlementEnvironmentIds,
501
- snoozeEnvironmentIds,
502
- queuedThreadKeys,
503
- settledLimit: settledVisibleCount,
504
- now,
505
- workingShelfEnabled,
506
- workingShelfExpanded,
507
- inboxReturnAt: threadListInboxReturns.returnedAt,
508
- snoozedShelfExpanded,
509
- settledShelfExpanded,
510
- selectedThreadKey,
511
- });
512
- })();
452
+ const {
453
+ layout: threadListV2Layout,
454
+ items: threadListV2Items,
455
+ contentOnlyThreadKeys,
456
+ } = useThreadListV2({
457
+ threads: props.threads,
458
+ pendingTasks: props.pendingTasks,
459
+ environmentId: props.selectedEnvironmentId,
460
+ projectRefs: v2ScopedProjectGroup === null ? null : v2ScopedProjectGroup.projectRefs,
461
+ searchQuery: props.searchQuery,
462
+ searchMatches: threadSearchMatchByKey,
463
+ settlementEnvironmentIds,
464
+ snoozeEnvironmentIds,
465
+ pinReorderEnvironmentIds,
466
+ activeReorderEnvironmentIds,
467
+ queuedThreadKeys,
468
+ settledLimit: settledVisibleCount,
469
+ now,
470
+ pendingOrder,
471
+ shelfPreferencesLoaded,
472
+ workingShelfEnabled,
473
+ workingShelfExpanded,
474
+ snoozedShelfExpanded,
475
+ settledShelfExpanded,
476
+ selectedThreadKey,
477
+ });
478
const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
479
useEffect(() => {
480
if (nextSnoozeWakeAt === null) return;
@@ -525,47 +490,20 @@ export function HomeScreen(props: HomeScreenProps) {
490
// unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
491
// range) the boundary string is identical and the chain would die.
492
}, [nextSnoozeWakeAt, snoozeWakeTick]);
528
- const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
529
- const v2PendingTasks = props.pendingTasks.filter(
530
- (pendingTask) =>
531
- (props.selectedEnvironmentId === null ||
532
- pendingTask.environmentId === props.selectedEnvironmentId) &&
533
- (v2ScopedProjectKeys === null ||
534
- v2ScopedProjectKeys.has(
535
- scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
536
- )) &&
537
- (v2SearchQuery.length === 0 || pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
538
- );
539
- const threadListV2Items = buildThreadListV2ListItems({
540
- items: threadListV2Layout.items,
541
- pendingTasks: v2PendingTasks,
542
- workingCount: threadListV2Layout.workingCount,
543
- workingShelfExpanded,
544
- workingShelfHeaderIndex: threadListV2Layout.workingShelfHeaderIndex,
545
- snoozedCount: threadListV2Layout.snoozedCount,
546
- snoozedShelfExpanded,
547
- snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
548
- settledCount: threadListV2Layout.settledCount,
549
- settledShelfExpanded,
550
- settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
551
- snoozeLabelNow: `${nowMinute}:00.000Z`,
552
- snoozeEnvironmentIds,
553
- queuedThreadKeys,
554
- moveAvailability: threadMoveAvailability,
555
- shelfPreferencesLoading: !shelfPreferencesLoaded,
556
- });
557
-
493
+ // Called as `props.onSelectThread(...)`, the compiler would cache this handler on the whole
494
+ // props object, which is new on every render of Home's parent.
495
+ const { onSelectThread } = props;
496
// A row listed for a message match opens the thread at that message, by
497
// tap or by shortcut.
498
const selectThread = (thread: EnvironmentThreadShell) => {
499
const key = threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id });
562
- const messageId = threadListV2Layout.contentOnlyThreadKeys.has(key)
500
+ const messageId = contentOnlyThreadKeys.has(key)
501
? threadSearchMatchByKey.get(key)?.messageId
502
: undefined;
503
if (messageId) {
504
requestThreadMessageJump(scopedThreadKey(thread.environmentId, thread.id), messageId);
505
}
568
- props.onSelectThread(thread);
506
+ onSelectThread(thread);
507
};
508
useThreadJumpShortcuts(threadListV2Items, selectThread);
509
useEffect(() => {
@@ -670,7 +608,7 @@ export function HomeScreen(props: HomeScreenProps) {
608
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
609
searchMatch={
610
// Only rows listed for their messages show one and open at it.
673
- threadListV2Layout.contentOnlyThreadKeys.has(
611
+ contentOnlyThreadKeys.has(
612
threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id }),
613
)
614
? threadSearchMatchByKey.get(
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+40
-104
@@ -3,7 +3,6 @@ import { ThreadUndoNotice } from "../home/ThreadUndoNotice";
3
import { useAndroidControlSizing } from "../../components/ui/useAndroidControlSizing";
4
import { resolveScratchProjectScopeKey } from "@t3tools/client-runtime/state/project-grouping";
5
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
6
-import { computeThreadMoveAvailability } from "./threadOrder";
6
import type {
7
EnvironmentProject,
8
EnvironmentThreadShell,
@@ -41,6 +40,7 @@ import { useQueuedThreadKeys } from "../../state/use-thread-outbox";
40
import { useWorkspaceState } from "../../state/workspace";
41
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
42
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
43
+import { useThreadListV2 } from "./useThreadListV2";
44
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
45
import { requestThreadMessageJump } from "./threadMessageJump";
46
import { useThreadListSearchMatches } from "./useThreadListSearchMatches";
@@ -72,12 +72,8 @@ import {
72
import { useThreadRowProviderInstanceResolver } from "./thread-provider-instance";
73
import type { ThreadPrPresentation } from "../../state/thread-pr-presentation";
74
import {
75
- buildThreadListV2Items,
76
- getThreadListV2OrderedSection,
77
- buildThreadListV2ListItems,
75
isThreadListV2ListItem,
76
threadListV2ListItemsAreEqual,
80
- threadListInboxReturns,
77
THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
78
THREAD_LIST_V2_SETTLED_PAGE_COUNT,
79
type ThreadListV2ListItem,
@@ -190,7 +186,6 @@ function ThreadNavigationSidebarPane(
186
// This map reaches LegendList's extraData, which re-renders every row whenever it changes
187
// identity; the hook keeps it stable.
188
const threadSearchMatchByKey = useThreadListSearchMatches(threads, threadSearch);
193
- const matchedThreadKeys = new Set(threadSearchMatchByKey.keys());
189
const projectScopeKey = options.selectedProjectKey;
190
const resolvedProjectKey = resolveScratchProjectScopeKey(projectScopeKey, projects, {
191
sidebarProjectGroupingMode: options.projectGroupingMode,
@@ -232,14 +227,6 @@ function ThreadNavigationSidebarPane(
227
const selectedProjectScope =
228
projectScopes.find((scope) => scope.key === resolvedProjectKey) ?? null;
229
const selectedProjectKey = selectedProjectScope?.key ?? null;
235
- const selectedProjectRefs =
236
- selectedProjectScope === null
237
- ? null
238
- : new Set(
239
- selectedProjectScope.projectRefs.map((projectRef) =>
240
- scopedProjectKey(projectRef.environmentId, projectRef.projectId),
241
- ),
242
- );
230
const projectByKey = useMemo(() => {
231
const map = new Map<string, EnvironmentProject>();
232
for (const project of projects) {
@@ -294,54 +281,32 @@ function ThreadNavigationSidebarPane(
281
} = listEnvironments;
282
const resolveProviderInstance = useThreadRowProviderInstanceResolver(providersByEnvironmentId);
283
const pendingOrder = usePendingThreadOrder(nowMinute, snoozeWakeTick);
297
- // Up/down menu availability for every card, computed once per section per
298
- // rebuild (see computeThreadMoveAvailability): per-thread planner calls made
299
- // list construction quadratic, and this list rebuilds on every minute tick.
300
- const threadMoveAvailability = (() => {
301
- const sectionAvailability = (section: "pinned" | "active") =>
302
- computeThreadMoveAvailability({
303
- allThreads: threads,
304
- section,
305
- pendingOrder,
306
- reorderableEnvironmentIds:
307
- section === "pinned" ? pinReorderEnvironmentIds : activeReorderEnvironmentIds,
308
- ordered: getThreadListV2OrderedSection({
309
- threads,
310
- section,
311
- pendingOrder,
312
- now,
313
- settlementEnvironmentIds,
314
- snoozeEnvironmentIds,
315
- queuedThreadKeys,
316
- }),
317
- });
318
- return new Map([
319
- ...sectionAvailability("pinned"),
320
- ...(workingShelfEnabled ? [] : sectionAvailability("active")),
321
- ]);
322
- })();
323
- const threadListV2Layout = (() => {
324
- threadListInboxReturns.observe(workingShelfEnabled ? threads : null);
325
- return buildThreadListV2Items({
326
- pendingOrder,
327
- threads: threads.filter((thread) => thread.archivedAt === null),
328
- environmentId: options.selectedEnvironmentId,
329
- projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,
330
- searchQuery: props.searchQuery,
331
- matchedThreadKeys,
332
- settlementEnvironmentIds,
333
- snoozeEnvironmentIds,
334
- queuedThreadKeys,
335
- settledLimit: settledVisibleCount,
336
- now,
337
- workingShelfEnabled,
338
- workingShelfExpanded,
339
- inboxReturnAt: threadListInboxReturns.returnedAt,
340
- snoozedShelfExpanded,
341
- settledShelfExpanded,
342
- selectedThreadKey: props.selectedThreadKey ?? null,
343
- });
344
- })();
284
+ const {
285
+ layout: threadListV2Layout,
286
+ items: threadListV2Items,
287
+ contentOnlyThreadKeys,
288
+ } = useThreadListV2({
289
+ threads,
290
+ pendingTasks,
291
+ environmentId: options.selectedEnvironmentId,
292
+ projectRefs: selectedProjectScope === null ? null : selectedProjectScope.projectRefs,
293
+ searchQuery: props.searchQuery,
294
+ searchMatches: threadSearchMatchByKey,
295
+ settlementEnvironmentIds,
296
+ snoozeEnvironmentIds,
297
+ pinReorderEnvironmentIds,
298
+ activeReorderEnvironmentIds,
299
+ queuedThreadKeys,
300
+ settledLimit: settledVisibleCount,
301
+ now,
302
+ pendingOrder,
303
+ shelfPreferencesLoaded,
304
+ workingShelfEnabled,
305
+ workingShelfExpanded,
306
+ snoozedShelfExpanded,
307
+ settledShelfExpanded,
308
+ selectedThreadKey: props.selectedThreadKey ?? null,
309
+ });
310
const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
311
useEffect(() => {
312
if (nextSnoozeWakeAt === null) return;
@@ -357,46 +322,17 @@ function ThreadNavigationSidebarPane(
322
// unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
323
// range) the boundary string is identical and the chain would die.
324
}, [nextSnoozeWakeAt, snoozeWakeTick]);
360
- const listItems = ((): readonly SidebarListItem[] => {
361
- const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
362
- const v2PendingTasks = pendingTasks.filter(
363
- (pendingTask) =>
364
- (options.selectedEnvironmentId === null ||
365
- pendingTask.environmentId === options.selectedEnvironmentId) &&
366
- (selectedProjectRefs === null ||
367
- selectedProjectRefs.has(
368
- scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
369
- )) &&
370
- (v2SearchQuery.length === 0 ||
371
- pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
372
- );
373
- const items: SidebarListItem[] = buildThreadListV2ListItems({
374
- items: threadListV2Layout.items,
375
- pendingTasks: v2PendingTasks,
376
- workingCount: threadListV2Layout.workingCount,
377
- workingShelfExpanded,
378
- workingShelfHeaderIndex: threadListV2Layout.workingShelfHeaderIndex,
379
- snoozedCount: threadListV2Layout.snoozedCount,
380
- snoozedShelfExpanded,
381
- snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
382
- settledCount: threadListV2Layout.settledCount,
383
- settledShelfExpanded,
384
- settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
385
- snoozeLabelNow: `${nowMinute}:00.000Z`,
386
- snoozeEnvironmentIds,
387
- queuedThreadKeys,
388
- moveAvailability: threadMoveAvailability,
389
- shelfPreferencesLoading: !shelfPreferencesLoaded,
390
- });
391
- if (settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0) {
392
- items.push({
393
- type: "v2-show-more",
394
- key: "v2-show-more",
395
- hiddenCount: threadListV2Layout.hiddenSettledCount,
396
- });
397
- }
398
- return items;
399
- })();
325
+ const listItems: readonly SidebarListItem[] =
326
+ settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0
327
+ ? [
328
+ ...threadListV2Items,
329
+ {
330
+ type: "v2-show-more",
331
+ key: "v2-show-more",
332
+ hiddenCount: threadListV2Layout.hiddenSettledCount,
333
+ },
334
+ ]
335
+ : threadListV2Items;
336
const listMenuActions = [
337
{
338
id: "environment",
@@ -503,7 +439,7 @@ function ThreadNavigationSidebarPane(
439
// tap or by shortcut.
440
const handleSelectThread = (thread: EnvironmentThreadShell) => {
441
const key = threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id });
506
- const messageId = threadListV2Layout.contentOnlyThreadKeys.has(key)
442
+ const messageId = contentOnlyThreadKeys.has(key)
443
? threadSearchMatchByKey.get(key)?.messageId
444
: undefined;
445
if (messageId) {
@@ -634,7 +570,7 @@ function ThreadNavigationSidebarPane(
570
environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
571
searchMatch={
572
// Only rows listed for their messages show one and open at it.
637
- threadListV2Layout.contentOnlyThreadKeys.has(
573
+ contentOnlyThreadKeys.has(
574
threadSearchMatchKey({ environmentId: thread.environmentId, threadId: thread.id }),
575
)
576
? threadSearchMatchByKey.get(
apps/mobile/src/features/threads/useThreadListV2.ts
new
+139
@@ -0,0 +1,139 @@
1
+import type { EnvironmentId } from "@t3tools/contracts";
2
+import { useMemo } from "react";
3
+
4
+import { scopedProjectKey } from "../../lib/scopedEntities";
5
+import type { PendingNewTask } from "../../state/use-pending-new-tasks";
6
+import {
7
+ buildThreadListV2Items,
8
+ buildThreadListV2ListItems,
9
+ getThreadListV2OrderedSection,
10
+ threadListInboxReturns,
11
+} from "./threadListV2";
12
+import { computeThreadMoveAvailability } from "./threadOrder";
13
+
14
+/**
15
+ * Screens' select handlers read the content-only key set; a fresh one per list rebuild gave
16
+ * every row a new handler whenever any thread shell changed. Keyed by a string, the set keeps
17
+ * its identity until its keys change.
18
+ */
19
+function useKeySet(newlineSeparatedKeys: string): ReadonlySet<string> {
20
+ return useMemo(
21
+ () => new Set(newlineSeparatedKeys.length === 0 ? [] : newlineSeparatedKeys.split("\n")),
22
+ [newlineSeparatedKeys],
23
+ );
24
+}
25
+
26
+type LayoutInput = Parameters<typeof buildThreadListV2Items>[0];
27
+
28
+/**
29
+ * Home's and the thread sidebar's thread list. Its result is one value a screen only reads:
30
+ * built inline, the list's inputs stayed open to mutation across the screen's other hooks, so
31
+ * the React Compiler cached none of it and every render of the screen re-rendered every row.
32
+ */
33
+export function useThreadListV2(input: {
34
+ readonly threads: LayoutInput["threads"];
35
+ readonly pendingTasks: ReadonlyArray<PendingNewTask>;
36
+ readonly environmentId: EnvironmentId | null;
37
+ readonly projectRefs: LayoutInput["projectRefs"];
38
+ readonly searchQuery: string;
39
+ /** Threads that match the search by content, keyed like `threadSearchMatchKey`. */
40
+ readonly searchMatches: ReadonlyMap<string, unknown>;
41
+ readonly settlementEnvironmentIds: ReadonlySet<EnvironmentId>;
42
+ readonly snoozeEnvironmentIds: ReadonlySet<EnvironmentId>;
43
+ readonly pinReorderEnvironmentIds: ReadonlySet<EnvironmentId>;
44
+ readonly activeReorderEnvironmentIds: ReadonlySet<EnvironmentId>;
45
+ readonly queuedThreadKeys: ReadonlySet<string>;
46
+ readonly settledLimit: number;
47
+ readonly now: string;
48
+ readonly pendingOrder: LayoutInput["pendingOrder"];
49
+ readonly shelfPreferencesLoaded: boolean;
50
+ readonly workingShelfEnabled: boolean;
51
+ readonly workingShelfExpanded: boolean;
52
+ readonly snoozedShelfExpanded: boolean;
53
+ readonly settledShelfExpanded: boolean;
54
+ readonly selectedThreadKey: string | null;
55
+}) {
56
+ const { threads, workingShelfEnabled } = input;
57
+ // Observed once per change to the threads: that is when a thread can stop working.
58
+ const inboxReturnAt = useMemo(
59
+ () => threadListInboxReturns.observe(workingShelfEnabled ? threads : null),
60
+ [threads, workingShelfEnabled],
61
+ );
62
+ // Up/down menu availability for every card, computed once per section per
63
+ // rebuild (see computeThreadMoveAvailability): per-thread planner calls made
64
+ // list construction quadratic, and this list rebuilds on every minute tick.
65
+ const sectionAvailability = (section: "pinned" | "active") =>
66
+ computeThreadMoveAvailability({
67
+ allThreads: threads,
68
+ section,
69
+ pendingOrder: input.pendingOrder,
70
+ reorderableEnvironmentIds:
71
+ section === "pinned" ? input.pinReorderEnvironmentIds : input.activeReorderEnvironmentIds,
72
+ ordered: getThreadListV2OrderedSection({
73
+ threads,
74
+ section,
75
+ pendingOrder: input.pendingOrder,
76
+ now: input.now,
77
+ settlementEnvironmentIds: input.settlementEnvironmentIds,
78
+ snoozeEnvironmentIds: input.snoozeEnvironmentIds,
79
+ queuedThreadKeys: input.queuedThreadKeys,
80
+ }),
81
+ });
82
+ const moveAvailability = new Map([
83
+ ...sectionAvailability("pinned"),
84
+ ...(workingShelfEnabled ? [] : sectionAvailability("active")),
85
+ ]);
86
+ const layout = buildThreadListV2Items({
87
+ pendingOrder: input.pendingOrder,
88
+ threads: threads.filter((thread) => thread.archivedAt === null),
89
+ environmentId: input.environmentId,
90
+ projectRefs: input.projectRefs,
91
+ searchQuery: input.searchQuery,
92
+ matchedThreadKeys: new Set(input.searchMatches.keys()),
93
+ settlementEnvironmentIds: input.settlementEnvironmentIds,
94
+ snoozeEnvironmentIds: input.snoozeEnvironmentIds,
95
+ queuedThreadKeys: input.queuedThreadKeys,
96
+ settledLimit: input.settledLimit,
97
+ now: input.now,
98
+ workingShelfEnabled,
99
+ workingShelfExpanded: input.workingShelfExpanded,
100
+ inboxReturnAt,
101
+ snoozedShelfExpanded: input.snoozedShelfExpanded,
102
+ settledShelfExpanded: input.settledShelfExpanded,
103
+ selectedThreadKey: input.selectedThreadKey,
104
+ });
105
+ const contentOnlyThreadKeys = useKeySet([...layout.contentOnlyThreadKeys].sort().join("\n"));
106
+ const scopedProjectKeys =
107
+ input.projectRefs == null
108
+ ? null
109
+ : new Set(input.projectRefs.map((ref) => scopedProjectKey(ref.environmentId, ref.projectId)));
110
+ const searchQuery = input.searchQuery.trim().toLocaleLowerCase();
111
+ const pendingTasks = input.pendingTasks.filter(
112
+ (pendingTask) =>
113
+ (input.environmentId === null || pendingTask.environmentId === input.environmentId) &&
114
+ (scopedProjectKeys === null ||
115
+ scopedProjectKeys.has(
116
+ scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
117
+ )) &&
118
+ (searchQuery.length === 0 || pendingTask.title.toLocaleLowerCase().includes(searchQuery)),
119
+ );
120
+ const items = buildThreadListV2ListItems({
121
+ items: layout.items,
122
+ pendingTasks,
123
+ workingCount: layout.workingCount,
124
+ workingShelfExpanded: input.workingShelfExpanded,
125
+ workingShelfHeaderIndex: layout.workingShelfHeaderIndex,
126
+ snoozedCount: layout.snoozedCount,
127
+ snoozedShelfExpanded: input.snoozedShelfExpanded,
128
+ snoozedShelfHeaderIndex: layout.snoozedShelfHeaderIndex,
129
+ settledCount: layout.settledCount,
130
+ settledShelfExpanded: input.settledShelfExpanded,
131
+ settledShelfHeaderIndex: layout.settledShelfHeaderIndex,
132
+ snoozeLabelNow: `${input.now.slice(0, 16)}:00.000Z`,
133
+ snoozeEnvironmentIds: input.snoozeEnvironmentIds,
134
+ queuedThreadKeys: input.queuedThreadKeys,
135
+ moveAvailability,
136
+ shelfPreferencesLoading: !input.shelfPreferencesLoaded,
137
+ });
138
+ return { layout, items, contentOnlyThreadKeys };
139
+}
packages/client-runtime/src/state/threadInbox.test.ts
+9
-6
@@ -32,13 +32,16 @@ function thread(id: string, working: boolean) {
32
describe("createInboxReturnTracker", () => {
33
it("stamps a thread when it stops working, but never on the first observation", () => {
34
const tracker = createInboxReturnTracker();
35
- tracker.observe([thread("a", true), thread("b", false)]);
36
- expect(tracker.returnedAt(thread("a", true))).toBeUndefined();
37
- expect(tracker.returnedAt(thread("b", false))).toBeUndefined();
35
+ const first = tracker.observe([thread("a", true), thread("b", false)]);
36
+ expect(first(thread("a", true))).toBeUndefined();
37
+ expect(first(thread("b", false))).toBeUndefined();
38
39
- tracker.observe([thread("a", false), thread("b", false)]);
40
- expect(tracker.returnedAt(thread("a", false))).toBeDefined();
41
- expect(tracker.returnedAt(thread("b", false))).toBeUndefined();
39
+ const second = tracker.observe([thread("a", false), thread("b", false)]);
40
+ expect(second(thread("a", false))).toBeDefined();
41
+ expect(second(thread("b", false))).toBeUndefined();
42
+ expect(tracker.returnedAt(thread("a", false))).toBe(second(thread("a", false)));
43
+ // An earlier observation keeps its answer, so lists built from it stay valid.
44
+ expect(first(thread("a", false))).toBeUndefined();
45
});
46
});
47
packages/client-runtime/src/state/threadInbox.ts
+9
-4
@@ -88,8 +88,9 @@ function sortNewestFirst<T extends Pick<EnvironmentThreadShell, "id" | "environm
88
89
/**
90
* Keep one at module scope so the inbox order survives routes that unmount the
91
- * list. Call `observe` with every thread shell on each list rebuild, or with
92
- * null to reset while the beta is off.
91
+ * list. Call `observe` with every thread shell whenever the shells change, or
92
+ * with null to reset while the beta is off. It returns the return times as of
93
+ * that observation, which stay fixed so a list built from them can be cached.
94
*/
95
export function createInboxReturnTracker() {
96
const keyOf = (thread: Pick<EnvironmentThreadShell, "environmentId" | "id">) =>
@@ -97,11 +98,13 @@ export function createInboxReturnTracker() {
98
let lastWorkingKeys: ReadonlySet<string> | null = null;
99
const returns = new Map<string, number>();
100
return {
100
- observe(threads: ReadonlyArray<WorkingThreadInput & InboxThreadInput> | null): void {
101
+ observe(
102
+ threads: ReadonlyArray<WorkingThreadInput & InboxThreadInput> | null,
103
+ ): (thread: Pick<EnvironmentThreadShell, "environmentId" | "id">) => number | undefined {
104
if (threads === null) {
105
lastWorkingKeys = null;
106
returns.clear();
104
- return;
107
+ return () => undefined;
108
}
109
const working = new Set<string>();
110
const present = new Set<string>();
@@ -119,6 +122,8 @@ export function createInboxReturnTracker() {
122
if (present.has(key) && !working.has(key)) returns.set(key, at);
123
}
124
lastWorkingKeys = working;
125
+ const observed = new Map(returns);
126
+ return (thread) => observed.get(keyOf(thread));
127
},
128
returnedAt: (thread: Pick<EnvironmentThreadShell, "environmentId" | "id">) =>
129
returns.get(keyOf(thread)),
patches/@react-native-menu__menu@2.0.0.patch
+13
-2
@@ -343,10 +343,21 @@ index 5c4e0da4292b15d3a27b5ea1555f11452a470815..475a99b2a3b1800c9d3e3e5f77a64f55
343
+ }
344
}
345
diff --git a/ios/Shared/RCTMenuItem.swift b/ios/Shared/RCTMenuItem.swift
346
-index bb6bb2b7ad56135089f267587c974b166760539d..949b3f7ec49af7ba26d966a8923a51f619443d5a 100644
346
+index bb6bb2b7ad56135089f267587c974b166760539d..5675067ecb2db0239b74c66ff2e095471a721699 100644
347
--- a/ios/Shared/RCTMenuItem.swift
348
+++ b/ios/Shared/RCTMenuItem.swift
349
-@@ -103,10 +103,18 @@ class RCTMenuAction {
349
+@@ -27,7 +27,9 @@ class RCTMenuAction {
350
+ self.identifier = UIAction.Identifier(rawValue: identifier as String);
351
+ }
352
+
353
+- if let image = details["image"] as? NSString {
354
++ // Fabric sends an absent image as "", and every asset lookup for "" logs a
355
++ // CoreUI fault with a backtrace.
356
++ if let image = details["image"] as? NSString, image.length > 0 {
357
+ self.image = UIImage(systemName: image as String);
358
+ if self.image === nil {
359
+ self.image = UIImage(named: image as String)
360
+@@ -103,10 +105,18 @@ class RCTMenuAction {
361
subMenuActions.append(subaction.createUIMenuElement(handler))
362
}
363
var menu: UIMenu;
pnpm-lock.yaml
+3
-3
@@ -356,7 +356,7 @@ patchedDependencies:
356
'@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
357
'@pierre/diffs@1.5.2': 2ec81ba1e8ce4681095a3473c2bf78e630417740c622720ef624febb467c25fc
358
'@react-native-ai/apple@0.12.0': 2d09870c2848d185cb05b53ed823a46e12dba519324d8dd8e584e28731990f9d
359
- '@react-native-menu/menu@2.0.0': a4866ecfcd44f318043de839d20110c17e14909004900f002ffe12050376f2ba
359
+ '@react-native-menu/menu@2.0.0': 910ec1bf22aa85a96fcf12299cd823bc30f702dd9b2d77b564d10b9ed709f7f6
360
'@react-navigation/native-stack@7.21.0': 990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42
361
alchemy@2.0.0-beta.80: bea1b6c0c0b23157fd5f439a1d7feff430f28ac1621ba135d8a13eeec60ccacd
362
app-builder-lib@26.16.1: a28c2dfcfc2b90d6c6247e199e6537391db9ecd941854c650910d607442512d3
@@ -550,7 +550,7 @@ importers:
550
version: 3.1.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
551
'@react-native-menu/menu':
552
specifier: 2.0.0
553
- version: 2.0.0(patch_hash=a4866ecfcd44f318043de839d20110c17e14909004900f002ffe12050376f2ba)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
553
+ version: 2.0.0(patch_hash=910ec1bf22aa85a96fcf12299cd823bc30f702dd9b2d77b564d10b9ed709f7f6)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
554
'@react-navigation/elements':
555
specifier: 2.9.45
556
version: 2.9.45(d8845bac868f4d8a58c8a8f12ad0d4a5)
@@ -15465,7 +15465,7 @@ snapshots:
15465
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)
15466
optional: true
15467
15468
- '@react-native-menu/menu@2.0.0(patch_hash=a4866ecfcd44f318043de839d20110c17e14909004900f002ffe12050376f2ba)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
15468
+ '@react-native-menu/menu@2.0.0(patch_hash=910ec1bf22aa85a96fcf12299cd823bc30f702dd9b2d77b564d10b9ed709f7f6)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)':
15469
dependencies:
15470
react: 19.3.0
15471
react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)