fix(ui): prevent 'No users found' flash during profile search#733
fix(ui): prevent 'No users found' flash during profile search#733thepastaclaw wants to merge 2 commits into
Conversation
|
@coderabbitai review |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe 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 for PR comments
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.
🧹 Nitpick comments (1)
src/ui/dashpay/profile_search.rs (1)
253-259: Add a small regression test for the loading transitions.This fix depends on
display_message()preservingloadingforInfoanddisplay_task_result()clearing it on completion. A focused inline#[test]would make this regression much harder to reintroduce. As per coding guidelines, "Unit tests should be inline in source files using#[test]."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/ui/dashpay/profile_search.rs` around lines 253 - 259, Add an inline unit test named something like `loading_transitions` in this source file that constructs the same type implementing `display_message`/`display_task_result` (e.g., ProfileSearch), sets `self.loading = true`, then calls `display_message(..., MessageType::Info)` and asserts `loading` remains true, calls `display_message(..., MessageType::Error)` and asserts `loading` becomes false, and finally resets `loading = true` then calls `display_task_result(...)` to assert it clears `loading` on completion; use `#[test]` on the function and reference the `display_message`, `display_task_result`, `loading`, and `MessageType` symbols to locate the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/ui/dashpay/profile_search.rs`:
- Around line 253-259: Add an inline unit test named something like
`loading_transitions` in this source file that constructs the same type
implementing `display_message`/`display_task_result` (e.g., ProfileSearch), sets
`self.loading = true`, then calls `display_message(..., MessageType::Info)` and
asserts `loading` remains true, calls `display_message(..., MessageType::Error)`
and asserts `loading` becomes false, and finally resets `loading = true` then
calls `display_task_result(...)` to assert it clears `loading` on completion;
use `#[test]` on the function and reference the `display_message`,
`display_task_result`, `loading`, and `MessageType` symbols to locate the code.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c36800ae-46da-4fb0-9345-a715cdb8e96c
📒 Files selected for processing (1)
src/ui/dashpay/profile_search.rs
Address CodeRabbit feedback on PR dashpay#733 by adding inline unit tests that verify: - Info messages preserve the loading flag (prevents 'No users found' flash) - Error messages clear the loading flag - display_task_result clears the loading flag on completion
display_message() unconditionally set loading = false, which killed the spinner if any message arrived while the search backend task was still running. This caused 'No users found' to flash briefly before results appeared. Only stop loading on error messages now — success results are handled by display_task_result(). Closes dashpay#684
7dc29a0 to
cf455dd
Compare
Move has_searched flag from search initiation to completion callbacks (display_task_result and display_message). Previously, has_searched was set immediately when the search started, causing a brief 'No users found' flash if display_message reset loading=false before results arrived. Now the flag is only set when the search actually completes (with results or an error), so the 'No users found' message only appears when there are genuinely no results. Closes dashpay#684
|
Superseded by #736 which addresses the same issue. |
Issue
Closes #684
Problem
When searching public profiles, "No users found" flashes briefly before actual results appear.
Root cause:
display_message()unconditionally setself.loading = false. During a search, informational messages (banner updates) can arrive before the actualDashPayProfileSearchResultsresult. Whenloadingis prematurely cleared whilehas_searchedis true andsearch_resultsis still empty, the UI renders the "No users found" empty state — until the real results arrive a moment later viadisplay_task_result().Fix
Only clear the loading state in
display_message()when the message is an error. The success path indisplay_task_result()already handles settingloading = falsewhen results arrive, so this is safe.Validation
cargo check— cleancargo clippy -- -D warnings— cleancargo fmt --all -- --check— cleandisplay_task_resultstill setsloading = falsefor all match arms, so no risk of a stuck spinner on successSummary by CodeRabbit