From 60c02b276a5c865c393b15bf5ae423f63d8c90af Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sat, 4 Jul 2026 14:29:11 -0700 Subject: [PATCH] Derive newThreadTarget from the full thread history, not search matches Co-Authored-By: Claude Fable 5 --- apps/mobile/src/features/home/homeThreadList.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/mobile/src/features/home/homeThreadList.ts b/apps/mobile/src/features/home/homeThreadList.ts index cada956d8bb..42da712e322 100644 --- a/apps/mobile/src/features/home/homeThreadList.ts +++ b/apps/mobile/src/features/home/homeThreadList.ts @@ -216,12 +216,15 @@ export function buildHomeThreadGroups(input: { : sortedThreads; // Sorted newest-first, so the first thread whose project is a group member - // marks the machine the user last worked on. - const lastActiveProject = Arr.findFirst(sortedThreads, (thread) => - group.projects.some( - (project) => - project.environmentId === thread.environmentId && project.id === thread.projectId, - ), + // marks the machine the user last worked on. Derived from the FULL history + // (not the search-filtered subset) so the target is stable across queries. + const lastActiveProject = Arr.findFirst( + sortThreads(group.threads, input.threadSortOrder), + (thread) => + group.projects.some( + (project) => + project.environmentId === thread.environmentId && project.id === thread.projectId, + ), ).pipe( Option.flatMap((thread) => Arr.findFirst(