Conversation
…ace-old-search-requests-WPB-20362
…ove-code-readability-WPB-20362
…place-old-search-requests-WPB-20362 # Conflicts: # wire-ios-sync-engine/Source/UserSession/Search/SearchTask.swift
Test Results6 711 tests 6 684 ✅ 8m 52s ⏱️ Results for commit 9b89654. ♻️ This comment has been updated with latest results. Summary: workflow run #21749862433 |
…0-7b20975c44be491ed30dc6d915798f5214d023dc' into chore/delete-zmselfuser-inusersession-WPB-20362
…hore/delete-search-context-WPB-20362
There was a problem hiding this comment.
Pull request overview
This PR refactors the search infrastructure to use Swift Concurrency, modernizes SearchTask/SearchDirectory APIs, and updates UI callers and tests accordingly. The goal is to make contact/directory/service search more robust and less error‑prone while preserving existing behavior from the user’s perspective.
Changes:
- Replace the callback-based
SearchTaskimplementation (with manualtasksRemainingtracking) by an async/await–driven version that aggregates results viaSearchResult“aggregator” closures and updates theSearchUserObserverCenterdirectly. - Simplify and modernize the search entry points:
SearchDirectorynow createsSearchTaskinstances viacreateSearchTask/createLookupTask,SearchUserViewControllerperforms lookups usingawait task.start(), andSearchResultsViewController’s result handling is streamlined. - Update
SearchTaskTestsandSearchDirectoryTeststo the new concurrency APIs and result aggregation model, and slightly adjust search throttling inStartUIViewController.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
wire-ios/Wire-iOS/Sources/UserInterface/UserProfile/SearchUserViewController.swift |
Switched user lookup to an async SearchTask obtained from SearchDirectory.createLookupTask(with:), awaiting task.start() and then driving the profile UI from the returned SearchResult. |
wire-ios/Wire-iOS/Sources/UserInterface/StartUI/StartUI/StartUIViewController.swift |
Adjusted the search debounce delay in updateSearchResults(for:) from 0.2s to 0.25s to slightly smooth out search triggering. |
wire-ios/Wire-iOS/Sources/UserInterface/StartUI/StartUI/SearchResultsViewController.swift |
Simplified search result handling: pendingSearchTask is now just a Task, and handleSearchResult takes a single SearchResult and always updates the empty state. |
wire-ios-sync-engine/Tests/Source/UserSession/SearchTaskTests.swift |
Reworked tests to use async helpers (performLocalSearch, performRemoteSearch, etc.), new async Core Data setup helpers, and direct application of SearchResultAggregator closures instead of callback-based addResultHandler. |
wire-ios-sync-engine/Tests/Source/UserSession/SearchDirectoryTests.swift |
Ensures SearchDirectory.tearDown() clears the SearchUsersCache using the new initializer and dependencies. |
wire-ios-sync-engine/Source/UserSession/Search/SearchTask.swift |
Major refactor: introduces SearchTask.Type, async start() orchestrating a TaskGroup of search subtasks, transforms each subtask into an async function returning a SearchResultAggregator, and removes the old manual tasksRemaining/task identifier management in favor of Swift Concurrency primitives. |
wire-ios-sync-engine/Source/UserSession/Search/SearchResult.swift |
Adds a convenience empty initializer and a union(prependingDirectory:) helper used when prepending handle-based directory results. |
wire-ios-sync-engine/Source/UserSession/Search/SearchRequest.swift |
Minor stylistic and spacing adjustments; SearchOptions and SearchRequest behavior remains the same. |
wire-ios-sync-engine/Source/UserSession/Search/SearchDirectory.swift |
Converts SearchDirectory into a final Swift class with createSearchTask(with:) / createLookupTask(with:) factories and a tearDown() method that clears the search-user cache and resets the SearchUserObserverCenter. |
wire-ios-data-model/Source/Notifications/SearchUserObserverCenter.swift |
Makes SearchUserSnapshot final and leaves the observer center behavior intact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
wire-ios-sync-engine/Source/UserSession/Search/SearchTask.swift
Outdated
Show resolved
Hide resolved
…te-search-context-WPB-20362
…6-4b0ae052c960d7c3bc123cf79d7c61406508c4cb' into chore/delete-search-context-WPB-20362
…tor-searchtask-WPB-20362
…ctor-searchtask-WPB-20362
|



Issue
Currently
SearchTask's different subtasks for searching contacts is implemented in a fragile way (seetasksRemainingproperty). Cancelling a task can lead to an async continuation leaking.This PR refactors the code in order to make use of Swift Concurrency for a more stable implementation.
Testing
Ideally there shouldn't be any differences from the user's perspective.
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: