Skip to content

fix(ui): prevent false 'No users found' flash in profile search#748

Merged
lklimek merged 2 commits into
dashpay:v1.0-devfrom
thepastaclaw:fix/profile-search-loading-state
Mar 15, 2026
Merged

fix(ui): prevent false 'No users found' flash in profile search#748
lklimek merged 2 commits into
dashpay:v1.0-devfrom
thepastaclaw:fix/profile-search-loading-state

Conversation

@thepastaclaw
Copy link
Copy Markdown
Collaborator

@thepastaclaw thepastaclaw commented Mar 13, 2026

Issue

Closes #684

When searching public profiles, "No users found" would flash briefly before actual results appeared.

Root Cause

ProfileSearchScreen manages a loading flag that controls whether to show a spinner or the "No users found" message. The problem: loading was being cleared in two places that didn't discriminate between search results and unrelated task completions:

  1. display_message() — called by AppState for any task's success/error banner while this screen is visible. It unconditionally set self.loading = false.
  2. display_task_result() — set self.loading = false at the top of the function, before matching on the result variant. Any Message, 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 touches loading state (it's for banner side-effects, not search lifecycle)
  • display_task_result(): self.loading = false moved inside the DashPayProfileSearchResults match arm only
  • display_task_error(): New override clears loading on errors so the spinner stops appropriately

Validation

  • cargo check — clean
  • cargo clippy -- -D warnings — clean
  • Traced the full AppState dispatch path (app.rs:1100-1180) to confirm display_task_result is called for Message variants from other screens' tasks, confirming the race condition

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for DashPay profile search operations with improved feedback when searches encounter issues or fail
    • Refined loading state management to accurately track and display operation progress, providing users with consistent status indicators throughout the profile search process

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
@thepastaclaw
Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8b8674ff-b1dd-428d-b59c-ae9d849811ef

📥 Commits

Reviewing files that changed from the base of the PR and between d928288 and fb2af33.

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

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Error Handling & Loading State
src/ui/dashpay/profile_search.rs
Added display_task_error method for error handling; moved loading state clearing from display_message to after successful DashPayProfileSearchResults; added TaskError import.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Loading states once danced too soon,
Showing "nothing" to each user's tune,
Now errors clear, and timing's right,
Results appear without false fright! ✨

🚥 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 accurately describes the main change: fixing a race condition that prevents the false 'No users found' flash in profile search, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR directly addresses issue #684 by preventing the false 'No users found' flash through improved loading state management that discriminates between relevant and unrelated task completions.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the loading state management in ProfileSearchScreen and are directly related to resolving issue #684; no out-of-scope modifications detected.

✏️ 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
  • Generate coding plan for human review 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.

❤️ Share

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 13, 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.

@lklimek lklimek marked this pull request as ready for review March 15, 2026 20:54
@lklimek lklimek requested review from Copilot and lklimek March 15, 2026 20:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 loading in display_message() to avoid interference from global banner events.
  • Only clear loading in display_task_result() when receiving DashPayProfileSearchResults.
  • Add display_task_error() to clear loading on search failures while deferring banner display to AppState.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lklimek lklimek enabled auto-merge (squash) March 15, 2026 21:19
@lklimek lklimek merged commit 8e4bd9d into dashpay:v1.0-dev Mar 15, 2026
10 checks passed
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

3 participants