fix(ui): prevent false 'No users found' flash in profile search#748
Conversation
The loading state was being cleared by display_message() and at the top of display_task_result() for ALL result variants. When unrelated backend tasks completed while a profile search was in progress, they would clear the loading flag, causing 'No users found' to flash briefly before actual results arrived. Fix: only clear loading state when we receive our specific DashPayProfileSearchResults variant or on task error. Unrelated task completions no longer interfere with the search spinner. Closes dashpay#684
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe changes improve error handling and loading state management in ProfileSearchScreen by adding a display_task_error method and adjusting when loading state is cleared—moving it from display_message to after successful DashPayProfileSearchResults completion, with TaskError import support added. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Pull request overview
Prevents a brief, incorrect “No users found” message during public profile searches by ensuring the screen’s loading state is only cleared by the profile-search task result/error, not by unrelated task completions.
Changes:
- Stop mutating
loadingindisplay_message()to avoid interference from global banner events. - Only clear
loadingindisplay_task_result()when receivingDashPayProfileSearchResults. - Add
display_task_error()to clearloadingon search failures while deferring banner display toAppState.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issue
Closes #684
When searching public profiles, "No users found" would flash briefly before actual results appeared.
Root Cause
ProfileSearchScreenmanages aloadingflag that controls whether to show a spinner or the "No users found" message. The problem:loadingwas being cleared in two places that didn't discriminate between search results and unrelated task completions:display_message()— called byAppStatefor any task's success/error banner while this screen is visible. It unconditionally setself.loading = false.display_task_result()— setself.loading = falseat the top of the function, before matching on the result variant. AnyMessage,Refresh, or other variant from a concurrent task would clear loading.When another backend task completed while a profile search was in flight, the loading flag was cleared prematurely → empty results +
has_searched = true+loading = false→ "No users found" shown before real results arrived.Fix
display_message(): No longer touchesloadingstate (it's for banner side-effects, not search lifecycle)display_task_result():self.loading = falsemoved inside theDashPayProfileSearchResultsmatch arm onlydisplay_task_error(): New override clearsloadingon errors so the spinner stops appropriatelyValidation
cargo check— cleancargo clippy -- -D warnings— cleanAppStatedispatch path (app.rs:1100-1180) to confirmdisplay_task_resultis called forMessagevariants from other screens' tasks, confirming the race conditionSummary by CodeRabbit