fix(contacts): allow spaces in the contacts search query - #1126
Merged
Conversation
The contacts search bar is a controlled text field whose onValueChange round-trips every keystroke through InputValidator.sanitizeText, which trims. The moment the user pressed the space key, the space was the trailing character, so it was stripped before the field could render it and the query never contained a space (user report: the search bar does not let you type a space). The same flaw applied to both the My Contacts and Network tabs, which share this field. - Add InputValidator.sanitizeSearchQuery: strips control characters, normalizes whitespace runs, enforces length, but does NOT trim, so a live field does not fight the user while composing. - ContactsScreen search field uses sanitizeSearchQuery. - ContactsViewModel trims the query at match time (mirrors AnnounceStreamViewModel, which already trims before the SQL query), so trailing spaces are harmless for filtering and an all-space query is treated as empty. - validateSearchQuery routes through sanitizeSearchQuery; sanitizeText keeps its generic trimming contract for non-search callers. Regression tests: compose test typing 'Alice' then a space then 'Alice Smith' asserts the ViewModel receives the space (fails on the old code), validator unit tests for the new function, and ViewModel tests for match-time trimming. Verified: full app unit suites on both backends (12260 tests) and data suite (390 tests) green; detekt/ktlint clean.
Contributor
Greptile SummaryThis PR fixes the shared Contacts search field so users can compose multi-word queries without trailing spaces being removed after each keystroke.
Confidence Score: 5/5The PR appears safe to merge, with both shared search paths preserving live input while trimming before matching. No actionable failures remain: Contacts trims before in-memory matching, Network already trims before repository filtering, and the regression behavior is covered across the UI, sanitizer, and ViewModel layers. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[User edits shared search field] --> B[sanitizeSearchQuery]
B --> C{Selected tab}
C -->|My Contacts| D[ContactsViewModel]
C -->|Network| E[AnnounceStreamViewModel]
D --> F[Trim at in-memory match time]
E --> G[Trim before repository query]
F --> H[Filtered contacts]
G --> I[Filtered announces]
Reviews (1): Last reviewed commit: "fix(contacts): allow spaces in the conta..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
The Contacts search bar does not let you type a space (user report). Affects both the My Contacts and Network tabs, which share the one search field.
Root cause
The search field is a controlled \textfield whose onValueChange round-trips every keystroke through InputValidator.sanitizeText, which trims. The instant the user presses the space key, the space is the trailing character, so it is stripped before the field can render it and the query never contains a space. Internal spaces are unreachable for the same reason (each is trailing at the moment it is typed).
Fix
Tests
Verification