-
-
Notifications
You must be signed in to change notification settings - Fork 366
Fix history results clear logic & Make sure results cleared #3525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR aims to fix the history results clear logic by checking the shouldClearExistingResults condition when querying history results. Key changes include:
- Removing redundant blank lines for cleaner formatting.
- Introducing a new variable, shouldClearExistingResults, to determine if existing results should be cleared.
- Updating the _resultsUpdateChannelWriter.TryWrite call to pass the additional parameters including token, reSelect, and shouldClearExistingResults.
Comments suppressed due to low confidence (2)
Flow.Launcher/ViewModel/MainViewModel.cs:1460
- Ensure that the new parameter 'shouldClearExistingResults' is correctly positioned in the _resultsUpdateChannelWriter.TryWrite call and that the method signature has been updated accordingly.
var shouldClearExistingResults = ShouldClearExistingResults(query, currentIsHomeQuery);
Flow.Launcher/ViewModel/MainViewModel.cs:1460
- [nitpick] Consider refining the comment to explicitly state that the flag determines whether to clear existing results to display only plugin-specific action keywords.
var shouldClearExistingResults = ShouldClearExistingResults(query, currentIsHomeQuery);
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
This comment has been minimized.
This comment has been minimized.
📝 Walkthrough## Walkthrough
This change introduces a private boolean `_needClearResults` in `MainViewModel` to defer clearing search results when queries are cancelled rapidly, preventing flicker. It updates `QueryResultsAsync` to set this flag on cancellation and clear results later. Additionally, `OnLoaded` in `MainWindow.xaml.cs` was changed from asynchronous to synchronous.
## Changes
| File(s) | Change Summary |
|-------------------------------------------|-----------------------------------------------------------------------------------------------|
| Flow.Launcher/ViewModel/MainViewModel.cs | Added `_needClearResults` flag to defer clearing results on cancellation; updated `QueryResultsAsync` to set this flag and conditionally clear results after plugin queries; modified `ShouldClearExistingResults` to clear results if deferred. |
| Flow.Launcher/MainWindow.xaml.cs | Changed `OnLoaded` method signature from `async void` to synchronous `void` without other logic changes. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant MainViewModel
participant ResultsUpdateChannel
User->>MainViewModel: Call QueryResultsAsync(query)
MainViewModel->>MainViewModel: Initialize resultsCleared = false
MainViewModel->>MainViewModel: Launch plugin query tasks
loop For each plugin query task
MainViewModel->>MainViewModel: Set _lastQuery, _previousIsHomeQuery
MainViewModel->>MainViewModel: resultsCleared = true
MainViewModel->>ResultsUpdateChannel: Write results
end
MainViewModel->>MainViewModel: Await all plugin tasks
alt Cancellation requested
MainViewModel->>MainViewModel: Set _needClearResults = true
MainViewModel-->>User: Return early without clearing results
else No cancellation and no resultsCleared
MainViewModel->>MainViewModel: Clear Results immediately
end
MainViewModel->>MainViewModel: On next update, ShouldClearExistingResults clears if _needClearResults true Possibly related PRs
Suggested labels
Suggested reviewers
Poem
|
This comment has been minimized.
This comment has been minimized.
@@ -1445,6 +1447,11 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) : | |||
{ | |||
App.API.LogError(ClassName, "Unable to add item to Result Update Queue"); | |||
} | |||
else | |||
{ | |||
// Only update the clear flag when we successfully write to the channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually get failure writes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should still take that into consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm we probably should take into consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But that will cause issue as below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
@@ -1376,6 +1375,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b | |||
// nothing to do here | |||
} | |||
|
|||
// If results are not cleared, we need to clear the results | |||
if (!resultsCleared) Results.Clear(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary? This could cause unexplained/unexpected flicker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must need it. This is used to make sure results are cleared when there are not any update tasks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think about one situation. Home page feature is off and you just change query text from e
to empty. You will find the results will not be cleared because there are not any update tasks. So we should force call Results.Clear()
here when it is not be called in QueryResult
or QueryHistory
functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say not any update task are you referring to one example where you toggle off home page in settings and results are not cleared?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me give you one demo video
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jjw24 It seems that I have issues when uploading video here. Please see more in Discord.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🥷 Code experts: onesounds Jack251970, onesounds have most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
Fixed flickering issue when typing very fast |
I haven't had time to sit down and think about this. Will find some in the upcoming days. |
Get it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. Forbidden patterns 🙅 (1)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: s.b. workaround(s)
If the flagged items are 🤯 false positivesIf items relate to a ...
|
I do not know why, but sometimes if I input whitespace, the results are not cleared. |
Follow on with #3524 to fix two issues in that PR.
1. Clear existing results for history results query function
We also need to check
shouldClearExistingResults
when querying history results.2. Make sure results cleared when update tasks are not called
When update tasks are not called, we need to clear results manually afterwards. This can fix an issue that results are not cleared when Home Page feature is off, and
QueryTaskAsync
andQueryHistoryTask
are not called.