Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve update logic & Fix update logic issue & Add Input for Query #3502

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

Open
Jack251970 wants to merge 47 commits into dev
base: dev
Choose a base branch
Loading
from improve_update

Conversation

Copy link
Member

@Jack251970 Jack251970 commented May 2, 2025
edited
Loading

From #3314. Resolve #2605.

Improve update logic

Improve main view model update logic.

Fix update logic issue

We should not use e.Query.RawQuery != QueryText because QueryText (Input) is different from RawQuery (Query).

Add new property Input for Query

Input is the property without trimming whitespace and it can help developer get the raw input.

Clear results when there are no update tasks

In this function, we need to reset all things because there are no update tasks.

if (ShouldClearExistingResultsForNonQuery(plugins))
{
 // No update tasks and just return
 ClearResults();
 return;
}

Test

  • Input long string fast and interface will update instantly.

Copy link
Contributor

@Copilot 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

This PR improves the update logic in the main view model by refactoring how running and current queries are tracked and by updating the QueryBuilder.Build method signature to accept separate input and trimmed text parameters.

  • Refactored MainViewModel to replace _isQueryRunning with two distinct query state variables.
  • Updated QueryBuilder.Build calls in view model, tests, and main window to pass both raw and trimmed query text.
  • Added documentation for the new Query.Input property and corresponding changes in QueryBuilder.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Flow.Launcher/ViewModel/MainViewModel.cs Refactored query state tracking and updated QueryBuilder.Build invocations.
Flow.Launcher/MainWindow.xaml.cs Updated QueryBuilder.Build call for consistency in query text handling.
Flow.Launcher.Test/QueryBuilderTest.cs Adjusted tests to accommodate the updated QueryBuilder.Build signature.
Flow.Launcher.Plugin/Query.cs Added Input property documentation.
Flow.Launcher.Core/Plugin/QueryBuilder.cs Changed Build method signature to accept both raw input and trimmed text.
Comments suppressed due to low confidence (1)

Flow.Launcher/ViewModel/MainViewModel.cs:372

  • [nitpick] Ensure that passing the untrimmed QueryText as the first parameter while the second parameter is trimmed is the intended behavior, and document this design choice for clarity.
var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins);

This comment has been minimized.

Copy link

gitstream-cm bot commented May 2, 2025

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.

Copy link
Contributor

coderabbitai bot commented May 2, 2025
edited
Loading

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds a new untrimmed input property Query.Input; updates QueryBuilder.Build to accept both raw and trimmed text and populate Input; updates callers (MainWindow, MainViewModel, ResultHelper) and tests to pass both values; refactors MainViewModel to track queries for cancellation, progress, and result gating.

Changes

Cohort / File(s) Change Summary
Query model & builder
Flow.Launcher.Plugin/Query.cs, Flow.Launcher.Core/Plugin/QueryBuilder.cs
Added public string Input { get; internal init; } to Query. Changed QueryBuilder.Build signature to Build(string input, string text, Dictionary<...>) and populate Query.Input (explicit empty string when input is null/empty).
View and VM callsites
Flow.Launcher/MainWindow.xaml.cs, Flow.Launcher/ViewModel/MainViewModel.cs
Updated calls to QueryBuilder.Build to pass raw and trimmed texts. Replaced _isQueryRunning with _progressQuery and _updateQuery; reworked cancellation, progress timing, results-updating/clearing, and gating of results-updated events by Query.Input.
Helpers
Flow.Launcher/Helper/ResultHelper.cs
Updated QueryBuilder.Build invocations to call the new three-argument overload (passing raw query and trimmed/raw as appropriate).
Tests
Flow.Launcher.Test/QueryBuilderTest.cs
Updated QueryBuilder.Build calls to the new three-argument form in tests; assertions unchanged.

Sequence Diagram(s)

sequenceDiagram
 autonumber
 participant User
 participant MainWindow
 participant MainViewModel
 participant QueryBuilder
 participant Plugins
 User->>MainWindow: type rawInput
 MainWindow->>MainViewModel: Submit QueryText (rawInput)
 MainViewModel->>QueryBuilder: Build(rawInput, trimmedText, plugins)
 Note right of QueryBuilder #eef6ff: Populate Query.Input = rawInput\nand other Query fields
 QueryBuilder-->>MainViewModel: Query { Input, Search, RawQuery, ... }
 MainViewModel->>MainViewModel: set _progressQuery / _updateQuery
 MainViewModel->>Plugins: run plugin queries (async, cancellable)
 alt query still current
 MainViewModel->>MainWindow: show progress, update results
 else cancelled or replaced
 MainViewModel->>MainWindow: clear/hide results
 end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • taooceros
  • jjw24

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Improve update logic & Fix update logic issue & Add Input for Query" directly relates to the main changes in the pull request. The changeset includes improvements to the MainViewModel's update logic, a fix to the update logic issue by distinguishing between RawQuery and QueryText, and the addition of a new Input property to the Query class. While the title uses ampersands to join three distinct objectives, it accurately summarizes the primary changes without being misleading or overly vague, though it does cover multiple concerns rather than focusing on a single main change.
Linked Issues Check ✅ Passed The PR directly addresses the objectives from linked issue #2605, which requests support for untrimmed query input. The changeset implements this by adding a new public Input property to the Query class that preserves the raw, untrimmed user input (including whitespace), which developers and plugins can now access. Additionally, the PR improves and fixes the update logic in MainViewModel to properly use this new property for comparisons instead of relying on the trimmed RawQuery, resolving the underlying issue that motivated the feature request. The changes to QueryBuilder and throughout the codebase ensure this new property is consistently populated and used correctly.
Out of Scope Changes Check ✅ Passed All changes in the pull request are directly aligned with the stated objectives. The new Input property addition to Query.cs addresses issue #2605's core requirement. Changes to QueryBuilder.Build() method signature and updates to all call sites (MainWindow.xaml.cs, MainViewModel.cs, ResultHelper.cs, and QueryBuilderTest.cs) are necessary adaptations to support the new Input parameter. The refactoring of update logic in MainViewModel (replacing _isQueryRunning with _progressQuery and _updateQuery) and corrections to use the new Input property in comparisons are part of the documented "Improve update logic" and "Fix update logic issue" objectives. No changes appear to introduce unrelated functionality outside these stated objectives.
Description Check ✅ Passed The pull request description clearly relates to the changeset by explaining the three main objectives: improving update logic, fixing an update logic issue, and adding the Input property for Query. The description provides specific context about why the fix is necessary (distinguishing between RawQuery and QueryText), explains what the new Input property does (preserves untrimmed whitespace), and mentions clearing results when there are no update tasks. The description also includes a test note and references to related issues (#3314, #2605), all of which are relevant to the actual code changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve_update

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.

Copy link
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.

Actionable comments posted: 1

🧹 Nitpick comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)

239-265: Redundant guards – can be collapsed for clarity

The same three-part condition (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || ...) is evaluated twice, once before cloning the results and once after.
Keeping a single guard at the top of the handler avoids duplication and a tiny amount of wasted work.

- if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || e.Token.IsCancellationRequested)
- {
- return;
- }
-
- var token = e.Token == default ? _updateSource.Token : e.Token;
- ...
- if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || token.IsCancellationRequested)
- {
- return;
- }
+ var token = e.Token == default ? _updateSource.Token : e.Token;
+ if (_currentQuery == null ||
+ e.Query.RawQuery != _currentQuery.RawQuery ||
+ token.IsCancellationRequested)
+ {
+ return;
+ }

372-373: Minor readability nit – avoid double-trim

QueryText is already passed as the raw input. Calling QueryText.Trim() for the second parameter means the string is trimmed twice inside Build. You can save an allocation by trimming once:

-var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins);
+var trimmed = QueryText.Trim();
+var query = QueryBuilder.Build(QueryText, trimmed, PluginManager.NonGlobalPlugins);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8bb96d7 and 34c3cda.

📒 Files selected for processing (5)
  • Flow.Launcher.Core/Plugin/QueryBuilder.cs (3 hunks)
  • Flow.Launcher.Plugin/Query.cs (1 hunks)
  • Flow.Launcher.Test/QueryBuilderTest.cs (3 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (11)
Flow.Launcher.Plugin/Query.cs (1)

10-14: Good addition of the Input property with clear documentation

The new Input property with appropriate XML documentation clearly explains its purpose and usage guidance. The warning about using Search property instead is consistent with the documentation for RawQuery.

Flow.Launcher/MainWindow.xaml.cs (1)

411-411: Updated QueryBuilder.Build call with proper parameters

The call has been correctly updated to pass both the raw query text and the trimmed text as separate parameters, aligning with the updated method signature in QueryBuilder.cs.

Flow.Launcher.Test/QueryBuilderTest.cs (3)

19-19: Test adjusted to use updated QueryBuilder.Build signature

The test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.


42-42: Test adjusted to use updated QueryBuilder.Build signature

The test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.


54-54: Test adjusted to use updated QueryBuilder.Build signature

The test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.

Flow.Launcher.Core/Plugin/QueryBuilder.cs (4)

9-9: Method signature updated to include the raw input parameter

The Build method signature has been enhanced to accept the raw input as a separate parameter, which will be used to populate the new Input property on the Query class.


14-15: Minor formatting change

Small formatting adjustment with no functional impact.


25-26: Additional whitespace added for readability

Small formatting improvement to enhance code readability.

Also applies to: 32-33


42-42: Correctly setting the new Input property

The new Input property is properly populated with the raw input parameter, completing the implementation of this feature.

Flow.Launcher/ViewModel/MainViewModel.cs (2)

1274-1281: Potential visibility race on _runningQuery

_runningQuery is written on the UI thread and later read from a Task.Delay continuation running on a ThreadPool thread.
Although reference assignments are atomic, without volatile/Interlocked there is no publish-happens-before relation; the ThreadPool may observe a stale value.

If correctness depends on the most recent write, consider:

private volatile Query _runningQuery;

or guarding access with a lock/Interlocked.Exchange.

Would you verify if stale reads could surface in practice? If so, I can help prepare a patch.


1396-1397: Verify parameter order matches QueryBuilder.Build signature

Just a sanity check: Build(rawInput, processedText, nonGlobalPlugins) is expected.
Confirm that QueryText (raw) and queryBuilder.ToString().Trim() (processed) are in the correct order to ensure Query.Input holds the unmodified user text.

@Jack251970 Jack251970 changed the title (削除) Improve update logic (削除ここまで) (追記) Improve update logic & Fix update logic issue (追記ここまで) May 2, 2025
@prlabeler prlabeler bot added the bug Something isn't working label May 2, 2025
@Jack251970 Jack251970 added this to the 1.20.0 milestone May 2, 2025

This comment has been minimized.

Copy link
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.

Actionable comments posted: 0

♻️ Duplicate comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)

35-36: Improved state tracking with dedicated Query objects

This is a good improvement over using a boolean flag. Tracking queries as objects allows for more precise state management and validation.

The existing suggestion to rename these variables to _progressQuery and _updateQuery to more clearly indicate their purposes is still valid.


1254-1255: ⚠️ Potential issue

Compile-time error: TaskScheduler is not awaitable

await TaskScheduler.Default; will not compile because TaskScheduler does not implement GetAwaiter().

-// Switch to ThreadPool thread
-await TaskScheduler.Default;
+// Switch to ThreadPool thread
+await Task.Yield(); // or `await Task.Run(() => {}, _updateSource.Token);`
🧹 Nitpick comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)

260-263: Redundant validation check

This is a duplicate of the check on line 240. While it's valid to verify conditions haven't changed, consider extracting this validation to a helper method to avoid duplication.

-if (_updateQuery == null || e.Query.RawQuery != _updateQuery.RawQuery || token.IsCancellationRequested)
-{
- return;
-}
+if (IsQueryMismatchOrCancelled(_updateQuery, e.Query, token))
+{
+ return;
+}
// Add this helper method to the class
+private bool IsQueryMismatchOrCancelled(Query currentQuery, Query eventQuery, CancellationToken token)
+{
+ return currentQuery == null || eventQuery.RawQuery != currentQuery.RawQuery || token.IsCancellationRequested;
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 381334f and 1381748.

📒 Files selected for processing (1)
  • Flow.Launcher/ViewModel/MainViewModel.cs (9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream workflow automation
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (9)
Flow.Launcher/ViewModel/MainViewModel.cs (9)

240-240: Fixed update logic comparison

This fixes the core issue where the update logic incorrectly compared e.Query.RawQuery with QueryText instead of comparing equivalent objects.


373-373: Updated QueryBuilder.Build call with Input parameter

Correctly updated to pass both raw input and trimmed text to match the updated signature.


1221-1221: Reset query state before processing

Good practice to initialize the query state before starting a new query process.


1241-1246: Early return optimization for changed queries

This is a good optimization to prevent processing outdated queries when user input changes rapidly.


1251-1252: Improved query state tracking

Setting both the progress and update query objects provides better tracking of the query lifecycle.


1291-1302: Progress bar visibility linked to query state

Good implementation of delayed progress bar visibility that also checks if the query is still active before showing it.


1325-1332: Reset progress query after completion

Properly manages the progress state and progress bar visibility after query execution completes.


1334-1338: Added safety with try-finally block

The finally block ensures the query state is cleaned up even if an exception occurs, preventing state leakage.


1414-1414: Updated call to match new QueryBuilder.Build signature

Correctly updated to provide both the original input and the processed query string.

@Jack251970 Jack251970 removed this from the 1.20.0 milestone May 4, 2025
Copy link
Member Author

Jack251970 commented May 4, 2025
edited
Loading

@jjw24 (削除) I am not sure if this PR can resolve #3508. (削除ここまで)

Copy link
Member

jjw24 commented May 4, 2025

Until we can actually figure out what's causing it.

Jack251970 reacted with thumbs up emoji

@jjw24 jjw24 added this to the Future milestone May 4, 2025

This comment has been minimized.

Copy link

gitstream-cm bot commented May 5, 2025

🥷 Code experts: theClueless

Jack251970 has most 👩‍💻 activity in the files.
Jack251970, theClueless have most 🧠 knowledge in the files.

See details

Flow.Launcher.Core/Plugin/QueryBuilder.cs

Activity based on git-commit:

Jack251970
MAY 3 additions & 3 deletions
APR
MAR
FEB
JAN
DEC

Knowledge based on git-blame:
theClueless: 53%
Jack251970: 7%

Flow.Launcher.Plugin/Query.cs

Activity based on git-commit:

Jack251970
MAY 4 additions & 3 deletions
APR
MAR
FEB 6 additions & 6 deletions
JAN 1 additions & 13 deletions
DEC

Knowledge based on git-blame:
Jack251970: 11%

Flow.Launcher.Test/QueryBuilderTest.cs

Activity based on git-commit:

Jack251970
MAY
APR
MAR
FEB 20 additions & 19 deletions
JAN
DEC

Knowledge based on git-blame:
theClueless: 57%
Jack251970: 31%

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

Jack251970
MAY 0 additions & 4 deletions
APR 69 additions & 45 deletions
MAR 1141 additions & 1076 deletions
FEB 1 additions & 1 deletions
JAN
DEC 5 additions & 10 deletions

Knowledge based on git-blame:
Jack251970: 65%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970
MAY 171 additions & 75 deletions
APR 35 additions & 28 deletions
MAR 695 additions & 628 deletions
FEB 63 additions & 21 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions

Knowledge based on git-blame:
Jack251970: 36%

To learn more about /:\ gitStream - Visit our Docs

This comment has been minimized.

This comment has been minimized.

Copy link
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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f49a86a and e01109d.

📒 Files selected for processing (2)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher/MainWindow.xaml.cs
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024年12月08日T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.

Applied to files:

  • Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (1)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
  • Query (9-62)
  • QueryBuilder (7-63)
Flow.Launcher.Plugin/Query.cs (2)
  • Query (8-113)
  • ToString (112-112)
Flow.Launcher.Core/Plugin/PluginManager.cs (5)
  • PluginManager (23-821)
  • PluginManager (161-167)
  • ICollection (305-328)
  • ICollection (330-333)
  • PluginPair (459-462)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

This comment has been minimized.

Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (6)
Flow.Launcher/ViewModel/MainViewModel.cs (6)

39-40: Naming and intent are clear; keep.

The split between progress tracking and update gating reads well. Consider brief XML docs to cement intent for future maintainers.


286-293: Harden ResultsUpdated gating and avoid mixed-token checks.

Use the resolved token for both the cancellation check and keep comparisons ordinal for perf/correctness on raw text.

- if (_updateQuery == null || e.Query.Input != _updateQuery.Input || e.Token.IsCancellationRequested)
+ var token = e.Token == default ? _updateToken : e.Token;
+ if (token.IsCancellationRequested
+ || _updateQuery == null
+ || !string.Equals(e.Query.Input, _updateQuery.Input, StringComparison.Ordinal))
 {
 return;
 }
-
- var token = e.Token == default ? _updateToken : e.Token;

1417-1436: Progress-bar trigger: compare with ordinal and consider snapshot.

Use ordinal comparison for raw text; if you adopt the input snapshot above, compare against it for extra safety.

- if (_progressQuery != null && _progressQuery.Input == query.Input)
+ if (_progressQuery != null &&
+ string.Equals(_progressQuery.Input, query.Input, StringComparison.Ordinal))
 {
 ProgressBarVisibility = Visibility.Visible;
 }

1687-1702: Minor: _lastQuery is never null in ctor; simplify null-propagation.

You can drop the null-conditional on _lastQuery for a tiny clarity bump. Not a blocker.

Based on learnings

- if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
+ if (_lastQuery.ActionKeyword != query?.ActionKeyword)

1350-1415: Potential cross-thread property updates (minor).

Property assignments (e.g., PluginIconPath, SearchIconVisibility) happen after the thread hop in the current code. With the compile fix above (use Task.Yield), you’ll continue on the UI context and avoid cross-thread UI-binding surprises.


286-323: Use ordinal comparisons consistently for raw text.

All string-equality checks on Input/RawQuery should be StringComparison.Ordinal.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e01109d and 61ee542.

📒 Files selected for processing (1)
  • Flow.Launcher/ViewModel/MainViewModel.cs (8 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024年12月08日T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.

Applied to files:

  • Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (1)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
  • Query (9-62)
  • QueryBuilder (7-63)
Flow.Launcher.Plugin/Query.cs (2)
  • Query (8-113)
  • ToString (112-112)
Flow.Launcher.Core/Plugin/PluginManager.cs (3)
  • PluginManager (23-821)
  • PluginManager (161-167)
  • PluginPair (459-462)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (14)
Flow.Launcher/ViewModel/MainViewModel.cs (14)

444-452: Correct: Build now receives both Input (untrimmed) and text (trimmed).

This aligns Backspace with the new QueryBuilder API and preserves user input semantics.


1337-1345: Don’t abort after shortcut expansion (stale guard).

ConstructQueryAsync can rewrite QueryText (builtin/custom shortcuts). Comparing query.Input with the live QueryText right after that will often differ and prematurely return, yielding an empty/stale result pane after expansions.

Apply this to snapshot the input before constructing the query and relax the guard to allow either the original input or the expanded RawQuery:

- var query = await ConstructQueryAsync(QueryText, Settings.CustomShortcuts, Settings.BuiltinShortcuts);
+ var inputSnapshot = QueryText;
+ var query = await ConstructQueryAsync(inputSnapshot, Settings.CustomShortcuts, Settings.BuiltinShortcuts);
@@
- // Check if the input text matches the query text
- if (query.Input != QueryText) return;
+ // Short-circuit only if user has typed something new unrelated to this query
+ var currentText = QueryText;
+ if (!string.Equals(currentText, inputSnapshot, StringComparison.Ordinal) &&
+ !string.Equals(currentText, query.RawQuery, StringComparison.Ordinal))
+ {
+ return;
+ }

1485-1499: Result-clearing logic looks correct; good early return when no update tasks.

This prevents stale results when home-page plugins are all disabled or absent.

If you want to be extra sure, test with:

  • ShowHistoryResultsForHomePage = false
  • All home plugins disabled
  • Enter/clear text to confirm the view clears.

1596-1599: Good: Build for whitespace path sets both Input and RawQuery empty.

This keeps IsHomeQuery true and avoids null queries.


1618-1619: Good: pass the method parameter as Input to avoid races.

Using queryText here ensures the built Query carries the exact input used for construction.


217-277: Channel consumer resiliency looks fine; continuation restarts on fault.

No action needed.


571-588: UI navigation helpers unchanged; LGTM.

Selection and preview update wiring remains consistent.

Also applies to: 607-622


1510-1517: ClearResults helper is cohesive and idempotent.

Approach to collapse/clear/reset states is sound.


1523-1572: Per-plugin query path is correct; good use of Task.Yield and cloning.

No issues spotted.


327-338: Clock/date timer ok.

PeriodicTimer loop is simple and cancellation-free as intended.


1951-1958: Dialog focus restore is guarded and logged; ok.

No changes requested.


2276-2303: Dispose pattern correct; writers completed and tasks disposed.

Looks good.


1379-1381: Compile-time error: TaskScheduler is not awaitable.

await TaskScheduler.Default; won’t compile and also risks property updates off the UI thread. Use an awaitable construct; you don’t need to hop threads here since plugin work is already offloaded per-plugin.

- // Switch to ThreadPool thread
- await TaskScheduler.Default;
+ // Yield once without changing context (plugin queries run on background tasks)
+ await Task.Yield();

1335-1499: No extra await TaskScheduler.Default or stale-query guards found
Only the await at MainViewModel.cs:1380 and the input guard at 1363 exist.

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.

@Jack251970 Jack251970 changed the title (削除) Improve update logic & Fix update logic issue & Input for Query (削除ここまで) (追記) Improve update logic & Fix update logic issue & Add Input for Query (追記ここまで) Sep 29, 2025
@Jack251970 Jack251970 modified the milestones: Future, 2.1.0 Sep 29, 2025

This comment has been minimized.

Updated comments across multiple files to standardize the phrasing from "work around" to "workaround" for consistency and clarity. Changes were made in `Directory.Build.props`, `Flow.Launcher.csproj`, and `MainWindow.xaml.cs`. These updates are non-functional and only affect documentation within the codebase.

This comment has been minimized.

Copy link
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.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Flow.Launcher/MainWindow.xaml.cs (1)

862-862: Fix forbidden pattern: "work around" → "workaround".

The phrase "work around" should be written as one word to comply with the project's style guidelines.

Apply this diff:

- // Initialize call twice to work around multi-display alignment issue- https://github.com/Flow-Launcher/Flow.Launcher/issues/2910
+ // Initialize call twice to workaround multi-display alignment issue- https://github.com/Flow-Launcher/Flow.Launcher/issues/2910
🧹 Nitpick comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)

1483-1495: Remove duplicate assignment of _progressQuery = null.

The _progressQuery field is set to null at line 1483 within the try block and again at line 1494 in the finally block. The finally block assignment is sufficient to ensure cleanup in all cases.

Apply this diff:

 if (currentCancellationToken.IsCancellationRequested) return;
 
 // this should happen once after all queries are done so progress bar should continue
 // until the end of all querying
- _progressQuery = null;
 
 if (!currentCancellationToken.IsCancellationRequested)
 {
 // update to hidden if this is still the current query
 ProgressBarVisibility = Visibility.Hidden;
 }
 }
 finally
 {
 // this make sures progress query is null when this query is canceled
 _progressQuery = null;
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61ee542 and 51be8d0.

📒 Files selected for processing (2)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024年12月08日T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.

Applied to files:

  • Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (2)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Plugin/Query.cs (2)
  • Query (8-113)
  • ToString (112-112)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
  • Query (9-62)
  • QueryBuilder (7-63)
Flow.Launcher.Core/Plugin/PluginManager.cs (5)
  • PluginManager (23-821)
  • PluginManager (161-167)
  • ICollection (305-328)
  • ICollection (330-333)
  • PluginPair (459-462)
Flow.Launcher/MainWindow.xaml.cs (2)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (1)
  • QueryBuilder (7-63)
Flow.Launcher.Core/Plugin/PluginManager.cs (2)
  • PluginManager (23-821)
  • PluginManager (161-167)
🪛 GitHub Actions: Check Spelling
Flow.Launcher/MainWindow.xaml.cs

[error] 862-862: Forbidden pattern: 'work around' matches a line_forbidden.patterns entry: '\bwork[- ]arounds?\b'

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (8)
Flow.Launcher/MainWindow.xaml.cs (1)

479-479: LGTM! Correct usage of the new QueryBuilder.Build signature.

The call correctly passes the untrimmed QueryTextBox.Text as the input parameter and the trimmed version as the text parameter, aligning with the new Input property feature.

Flow.Launcher/ViewModel/MainViewModel.cs (7)

39-40: LGTM! Query-based tracking improves state management.

Replacing the boolean _isQueryRunning with Query-based tracking fields provides more precise cancellation and state management by tracking which specific query is in progress.


286-286: LGTM! Correct use of Input property for stale query detection.

The guard now compares e.Query.Input with _updateQuery.Input, which correctly identifies stale queries by comparing the untrimmed original input rather than the trimmed/expanded RawQuery.

Based on PR objectives and author clarification to reviewer taooceros.


444-444: LGTM! Correct usage of the new QueryBuilder.Build signature.

The call correctly passes QueryText (untrimmed) as the input parameter and QueryText.Trim() as the text parameter.


1375-1376: Verify that await TaskScheduler.Default; compiles in your environment.

The code await TaskScheduler.Default; is not standard awaitable syntax. TaskScheduler does not implement GetAwaiter() in the standard .NET libraries.

If this compiles in your environment, you may be using a Visual Studio extension or custom awaiter. However, this will fail in most standard .NET environments.

Standard alternatives for switching to ThreadPool:

If the current syntax doesn't compile or you want more portable code, use:

-// Switch to ThreadPool thread
-await TaskScheduler.Default;
+// Switch to ThreadPool thread
+await Task.Run(() => { });

Or if you only need to yield execution without guaranteeing a thread switch:

-// Switch to ThreadPool thread
-await TaskScheduler.Default;
+// Yield execution
+await Task.Yield();

Note: Task.Yield() queues continuation but doesn't guarantee thread switch, while Task.Run(() => { }) ensures execution on ThreadPool.

Based on past review comments indicating this was discussed with reviewer taooceros.


1424-1434: LGTM! Correct progress bar timing with Input property comparison.

The progress bar logic correctly uses _progressQuery.Input == query.Input to verify that the current query is still active before showing the progress indicator.


1594-1594: LGTM! Correct handling of empty input.

For empty or whitespace input, both the input and text parameters are set to string.Empty, correctly indicating a home query with no user input.


1614-1614: LGTM! Correctly uses method parameter to avoid race condition.

The call correctly passes the immutable queryText parameter (not the mutable QueryText property) as the input argument, preventing race conditions where the property value could change between query construction and validation.

Based on past review comments indicating this race condition was previously flagged and fixed.

This comment has been minimized.

This comment has been minimized.

Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 2
⚠️ non-alpha-in-dictionary 2

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)

\bwork[- ]arounds?\b
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link
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.

Actionable comments posted: 0

♻️ Duplicate comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)

1421-1423: Compile error: TaskScheduler is not awaitable; replace with an awaitable switch-off-UI

await TaskScheduler.Default; won’t compile. Use an awaitable construct to leave the UI context.

Apply one of:

- // Switch to ThreadPool thread
- await TaskScheduler.Default;
+ // Switch off the UI context before heavy work
+ await Task.Delay(0).ConfigureAwait(false);

Or:

- // Switch to ThreadPool thread
- await TaskScheduler.Default;
+ // Switch to ThreadPool thread
+ await Task.Run(static () => { }, currentCancellationToken).ConfigureAwait(false);
🧹 Nitpick comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)

287-293: Normalize token before guard check

Use the normalized token for the cancellation guard to avoid evaluating e.Token twice and to respect the fallback to _updateToken.

Apply:

- if (_updateQuery == null || e.Query.Input != _updateQuery.Input || e.Token.IsCancellationRequested)
- {
- return;
- }
-
- var token = e.Token == default ? _updateToken : e.Token;
+ var token = e.Token == default ? _updateToken : e.Token;
+ if (_updateQuery == null || e.Query.Input != _updateQuery.Input || token.IsCancellationRequested)
+ {
+ return;
+ }

1470-1481: UI-bound property set from background thread

ContinueWith runs on TaskScheduler.Default; set ProgressBarVisibility via Dispatcher to avoid cross-thread UI-binding issues.

 _ = Task.Delay(200, currentCancellationToken).ContinueWith(_ =>
 {
 // start the progress bar if query takes more than 200 ms and this is the current running query and it didn't finish yet
 if (_progressQuery != null && _progressQuery.Input == query.Input)
 {
- ProgressBarVisibility = Visibility.Visible;
+ Application.Current?.Dispatcher.Invoke(() => ProgressBarVisibility = Visibility.Visible);
 }
 },
 currentCancellationToken,
 TaskContinuationOptions.NotOnCanceled,
 TaskScheduler.Default);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae76b53 and 3ef5238.

📒 Files selected for processing (3)
  • Flow.Launcher/Helper/ResultHelper.cs (1 hunks)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024年12月08日T21:12:12.060Z
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024年12月08日T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.

Applied to files:

  • Flow.Launcher/ViewModel/MainViewModel.cs
🧬 Code graph analysis (3)
Flow.Launcher/Helper/ResultHelper.cs (1)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (1)
  • QueryBuilder (7-63)
Flow.Launcher/ViewModel/MainViewModel.cs (3)
Flow.Launcher.Plugin/Query.cs (2)
  • Query (8-113)
  • ToString (112-112)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (2)
  • Query (9-62)
  • QueryBuilder (7-63)
Flow.Launcher.Core/Plugin/PluginManager.cs (5)
  • PluginManager (24-1044)
  • PluginManager (168-174)
  • ICollection (366-386)
  • ICollection (388-391)
  • PluginPair (616-619)
Flow.Launcher/MainWindow.xaml.cs (2)
Flow.Launcher.Core/Plugin/QueryBuilder.cs (1)
  • QueryBuilder (7-63)
Flow.Launcher.Core/Plugin/PluginManager.cs (2)
  • PluginManager (24-1044)
  • PluginManager (168-174)
🪛 GitHub Actions: Check Spelling
Flow.Launcher/ViewModel/MainViewModel.cs

[warning] 27-13: Unrecognized spelling: 'NKORE'. (unrecognized-spelling)

Flow.Launcher/MainWindow.xaml.cs

[warning] 29-13: Unrecognized spelling: 'NKORE'. (unrecognized-spelling)


[warning] 119-36: Unrecognized spelling: 'Wnd'. (unrecognized-spelling)


[warning] 377-43: Unrecognized spelling: 'Wnd'. (unrecognized-spelling)


[warning] 590-27: Unrecognized spelling: 'Wnd'. (unrecognized-spelling)


[warning] 592-27: Unrecognized spelling: 'Wnd'. (unrecognized-spelling)


[warning] 816-25: Unrecognized spelling: 'gamemode'. (unrecognized-spelling)


[warning] 817-25: Unrecognized spelling: 'gamemode'. (unrecognized-spelling)


[warning] 820-32: Unrecognized spelling: 'gamemode'. (unrecognized-spelling)


[warning] 823-30: Unrecognized spelling: 'positionreset'. (unrecognized-spelling)


[warning] 826-37: Unrecognized spelling: 'positionreset'. (unrecognized-spelling)


[warning] 842-21: Unrecognized spelling: 'gamemode'. (unrecognized-spelling)


[warning] 843-26: Unrecognized spelling: 'positionreset'. (unrecognized-spelling)


[warning] 848-26: Unrecognized spelling: 'positionreset'. (unrecognized-spelling)


[warning] 966-64: Unrecognized spelling: 'XRatio'. (unrecognized-spelling)


[warning] 967-63: Unrecognized spelling: 'YRatio'. (unrecognized-spelling)


[warning] 1181-20: Unrecognized spelling: 'clocksb'. (unrecognized-spelling)


[warning] 1182-20: Unrecognized spelling: 'clocksb'. (unrecognized-spelling)


[warning] 1183-19: Unrecognized spelling: 'iconsb'. (unrecognized-spelling)


[warning] 1184-19: Unrecognized spelling: 'iconsb'. (unrecognized-spelling)


[warning] 1189-20: Unrecognized spelling: 'clocksb'. (unrecognized-spelling)


[warning] 1190-19: Unrecognized spelling: 'iconsb'. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (4)
Flow.Launcher/Helper/ResultHelper.cs (1)

23-23: Build call update is correct

Passing rawQuery as both Input and Text aligns with the new signature and is appropriate for history re-query. LGTM.

Flow.Launcher/MainWindow.xaml.cs (1)

480-480: Correct use of Input vs trimmed Text

Using QueryTextBox.Text (Input) with its Trim() (Text) ensures accurate Search parsing without losing user input. Looks good.

Flow.Launcher/ViewModel/MainViewModel.cs (2)

40-42: Clear split of query state tracking

Replacing a single running flag with _progressQuery and _updateQuery clarifies responsibilities for progress gating vs update routing. Good change.


1640-1641: Correct propagation of original input into QueryBuilder

Passing the pre-expansion queryText as Input and the expanded-trimmed text as Text is the right contract for Query.Input vs RawQuery/Search. LGTM.

Also applies to: 1660-1661

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

Reviewers

@jjw24 jjw24 jjw24 left review comments

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Copilot code review Copilot Copilot left review comments

@taooceros taooceros Awaiting requested review from taooceros

At least 1 approving review is required to merge this pull request.

Labels

10 min review bug Something isn't working enhancement New feature or request review in progress Indicates that a review is in progress for this PR

Projects

None yet

Milestone

2.1.0

Development

Successfully merging this pull request may close these issues.

Enhancement: Support Untrimmed query for Flow Launcher's Query

AltStyle によって変換されたページ (->オリジナル) /