#586
fix(threads): avoid quadratic overlap check during resume hydration
Summary
Long thread resume could become very slow because overlap detection in resume hydration used nested scans:
items.some(...)+localItems.some(...)(quadratic in combined list size)
This change replaces that with a Set of local item IDs and O(1) membership checks.
What changed
- In
buildResumeHydrationPlan(src/features/threads/utils/threadActionHelpers.ts):- build
localItemIds = new Set(localItems.map(item => item.id)) - replace nested overlap check with
items.some(item => localItemIds.has(item.id))
- build
Why
For long threads, this removes a hot O(n²) path during resume while keeping behavior identical.
Validation
npm run -s typechecknpm run -s test -- src/features/threads/hooks/useThreadActions.test.tsx src/features/threads/hooks/useThreads.integration.test.tsx src/features/app/hooks/useRemoteThreadRefreshOnFocus.test.tsx src/utils/threadItems.test.ts- Built and tested
aarch64AppImage locally.