-
-
Notifications
You must be signed in to change notification settings - Fork 393
Fix clearing of results logic & minor adjustment to results update #3524
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Potential race condition when updating
_lastQuery
/_previousIsHomeQuery
QueryTaskAsync
runs once per plugin and executes in parallel.Each invocation updates the shared fields
_lastQuery
and_previousIsHomeQuery
:This means later-finishing plugin tasks from the previous query (or simply slower plugins) can overwrite these fields after a new query has already started, causing
RequireClearExistingResults
to make a decision based on stale data.Suggestion
Example (outside the tasks):
Then pass
clearExistingResultsRequired
as a parameter intoQueryTaskAsync
.This removes any cross-thread contention and ensures the flag is computed exactly once per user query.
Uh oh!
There was an error while loading. Please reload this page.
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.
Not applicable in this instance because we always want to determine whether to clear results based on the current and previous query type (action keyword, global or home page) that will be push to the channel immediately.
That is correct expectation the upcoming query should determine whether results are to be cleared. RequireClearExistingResults should make decision based on the immediate previous and current query that will be pushed through to channel even if they come later due to slowness, i.e. if GitHub search query comes late and is from an action keyword, and the previous query is from global action keyword then results still need to be cleared.
Let's keep this comment open so can refer back to in the future if needed.
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 I understand your explanation about the design intention. The behavior you describe makes sense - each plugin task needs to independently evaluate whether to clear results based on the immediate previous and current query state when the results are pushed to the channel, regardless of timing.
This is important for situations like your GitHub example, where a late-arriving query with a different action keyword type still needs to clear existing results appropriately.
I noticed the method is called
ShouldClearExistingResults
in the code but appears asRequireClearExistingResults
in the diff. Is this just a naming difference from development, or is there something else I should be aware of?(•‿•)
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.
You looking at outdated diff.
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.
🧩 Analysis chain
@jjw24 You're absolutely right. I was referencing an outdated diff. Thanks for pointing that out - I'll make sure to check the latest code in future reviews.
🏁 Script executed:
Length of output: 150
@jjw24 You're right - I was looking at an outdated diff. Thank you for the correction. I can now see that the method is consistently named
ShouldClearExistingResults
in the code, and the variable name in the current code isshouldClearExistingResults
. I appreciate you pointing this out, and I'll make sure to reference the most current code in future reviews.🧬 Code Graph Analysis Results
Relevant snippet from
Flow.Launcher/ViewModel/MainViewModel.cs
(lines 710-758):Relevant snippet from
Flow.Launcher/ViewModel/MainViewModel.cs
(lines 600-720):This snippet shows the usage of the method
ShouldClearExistingResults
inside theQueryResultsAsync
method:Summary of
ShouldClearExistingResults
method inMainViewModel.cs
:Purpose:
Determines if existing search results should be cleared when a new query is executed. This is necessary because results from plugins with action keywords and global plugins are handled separately, and mixing them requires clearing old results to avoid stale or irrelevant data.
Parameters:
Query query
: The current query object containing the action keyword and raw query.bool currentIsHomeQuery
: Indicates if the current query is a home query (empty raw query).Returns:
bool
: Returnstrue
if existing results should be cleared, otherwisefalse
.Logic:
Usage:
Called during the query execution process (
QueryResultsAsync
) to decide whether to clear existing results before adding new ones.Additional context:
ShouldClearExistingResults
is used internally inQueryResultsAsync
to manage the results update queue.ShouldClearExistingResults
vsRequireClearExistingResults
) appears to be a naming difference in the diff or code review context; the actual method in the current code is namedShouldClearExistingResults
.MainViewModel
.No other code snippets from the provided list are directly relevant to the naming or behavior of
ShouldClearExistingResults
orRequireClearExistingResults
inMainViewModel.cs
.