Skip to content

fix(ui): prevent 'No users found' flash during profile search#733

Closed
thepastaclaw wants to merge 2 commits into
dashpay:v1.0-devfrom
thepastaclaw:fix/profile-search-no-users-flash
Closed

fix(ui): prevent 'No users found' flash during profile search#733
thepastaclaw wants to merge 2 commits into
dashpay:v1.0-devfrom
thepastaclaw:fix/profile-search-no-users-flash

Conversation

@thepastaclaw
Copy link
Copy Markdown
Collaborator

@thepastaclaw thepastaclaw commented Mar 12, 2026

Issue

Closes #684

Problem

When searching public profiles, "No users found" flashes briefly before actual results appear.

Root cause: display_message() unconditionally set self.loading = false. During a search, informational messages (banner updates) can arrive before the actual DashPayProfileSearchResults result. When loading is prematurely cleared while has_searched is true and search_results is still empty, the UI renders the "No users found" empty state — until the real results arrive a moment later via display_task_result().

Fix

Only clear the loading state in display_message() when the message is an error. The success path in display_task_result() already handles setting loading = false when results arrive, so this is safe.

Validation

  • cargo check — clean
  • cargo clippy -- -D warnings — clean
  • cargo fmt --all -- --check — clean
  • Verified that display_task_result still sets loading = false for all match arms, so no risk of a stuck spinner on success
  • Verified that error messages still correctly stop the loading state

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the profile search would briefly display a "No users found" message while loading results, creating a confusing user experience. The loading state now properly persists until results are available or an actual error occurs.

@thepastaclaw
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8ed2c909-8a03-4b04-ae98-a8765cf230da

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The display_message method in ProfileSearchScreen now conditionally clears the loading flag only when the message type is an error, preventing premature dismissal of loading state. The method signature was updated to expose the message_type parameter without underscore prefix for use in the conditional logic.

Changes

Cohort / File(s) Summary
Loading State Fix
src/ui/dashpay/profile_search.rs
Updated display_message to conditionally toggle the loading flag based on message type. Error messages now clear loading, while informational messages preserve the loading state, preventing a "No users found" flash before results arrive.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A search that flashed too quick, too soon,
"No users found!" beneath the moon—
But now we wait with patience true,
Till real results come into view! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: preventing the 'No users found' flash during profile search, which directly addresses the primary change in the changeset.
Linked Issues check ✅ Passed The pull request directly addresses issue #684 by modifying display_message() to only clear loading on errors, preventing premature empty-state rendering.
Out of Scope Changes check ✅ Passed All changes are scoped to the display_message() method in profile_search.rs and directly address the linked issue regarding the 'No users found' flash.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan for PR comments
  • Generate 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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() preserving loading for Info and display_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

📥 Commits

Reviewing files that changed from the base of the PR and between 91abb2c and fe9a717.

📒 Files selected for processing (1)
  • src/ui/dashpay/profile_search.rs

thepastaclaw added a commit to thepastaclaw/dash-evo-tool that referenced this pull request Mar 12, 2026
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
@thepastaclaw thepastaclaw force-pushed the fix/profile-search-no-users-flash branch from 7dc29a0 to cf455dd Compare March 12, 2026 12:34
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
@thepastaclaw
Copy link
Copy Markdown
Collaborator Author

Superseded by #736 which addresses the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search Public Profiles always show "No users found" at the beginning

1 participant