Skip to content

Conversation

Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Aug 13, 2025

Add new API Result.QuerySuggestionText

This can help developers change query suggestion text for each result.

Test

image

@prlabeler prlabeler bot added the enhancement New feature or request label Aug 13, 2025
@Jack251970 Jack251970 self-assigned this Aug 13, 2025
@Jack251970 Jack251970 added this to the 2.0.0 milestone Aug 13, 2025
Copy link

gitstream-cm bot commented Aug 13, 2025

🥷 Code experts: onesounds, Yusyuriv

Jack251970, onesounds have most 👩‍💻 activity in the files.
Yusyuriv, Jack251970 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Plugin/Result.cs

Activity based on git-commit:

Jack251970 onesounds
AUG
JUL
JUN
MAY
APR 113 additions & 70 deletions
MAR

Knowledge based on git-blame:
Jack251970: 32%

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs

Activity based on git-commit:

Jack251970 onesounds
AUG
JUL
JUN
MAY
APR 3 additions & 2 deletions 11 additions & 2 deletions
MAR

Knowledge based on git-blame:
Yusyuriv: 52%
Jack251970: 4%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

Copy link

gitstream-cm bot commented Aug 13, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

📝 Walkthrough

Walkthrough

Adds QuerySuggestionText to Result, updates Clone() to copy it, and changes QuerySuggestionBoxConverter to prefer QuerySuggestionText (falling back to Title) when producing query suggestions; suggestion assembly uses span-based concat to avoid an extra substring allocation.

Changes

Cohort / File(s) Summary of Changes
Plugin API update
Flow.Launcher.Plugin/Result.cs
Added public string QuerySuggestionText { get; set; } with XML docs specifying usage; updated Clone() to copy QuerySuggestionText. No other public members removed or modified.
UI converter adjustment
Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs
Prefer Result.QuerySuggestionText (prefixed by ActionKeywordAssigned when present) if it starts-with the current query (case-insensitive); otherwise fall back to Title with the same validation. Build final suggestion via string.Concat(queryText, selectedResultPossibleSuggestion.AsSpan(queryText.Length)) to avoid substring allocation. No exported API changes.

Sequence Diagram(s)

sequenceDiagram
  participant User as User Input
  participant Converter as QuerySuggestionBoxConverter
  participant Result as Result

  User->>Converter: provide current query text
  Converter->>Result: read QuerySuggestionText (or Title)
  Converter->>Converter: validate suggestion starts-with query (case-insensitive)
  Converter->>Converter: assemble suggestion using span-based concat
  Converter-->>User: return suggestion (or none)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • jjw24
  • VictoriousRaptor
  • Yusyuriv

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c895b2a and bf07f2e.

📒 Files selected for processing (1)
  • Flow.Launcher.Plugin/Result.cs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Plugin/Result.cs
⏰ 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). (2)
  • GitHub Check: gitStream.cm
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch QuerySuggestionText_API

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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 (6)
Flow.Launcher.Plugin/Result.cs (2)

260-265: Clarify docs: don’t include action keyword; treat whitespace as “not set”

Given the converter prepends ActionKeywordAssigned + " ", plugin authors should not include the action keyword in QuerySuggestionText. Also, “not set” should typically include whitespace.

Update the XML comments:

-        /// <remarks>When a value is not set, the <see cref="Title"/> will be used.</remarks>
+        /// <remarks>
+        /// When not set or whitespace, the <see cref="Title"/> will be used.
+        /// Do not include the action keyword prefix; Flow prepends <see cref="ActionKeywordAssigned"/> + " " automatically.
+        /// </remarks>

260-265: API addition checklist (versioning/docs)

Nice additive API. Please ensure:

  • Flow.Launcher.Plugin package version and changelog reflect the new property.
  • Plugin author docs mention the new property and usage (exclude action keyword, must align with the typed prefix).

I can draft the CHANGELOG/docs snippet if helpful.

Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (4)

36-39: Treat whitespace as “not set” to avoid blank suggestions

If a plugin sets QuerySuggestionText to spaces, it currently overrides Title. Using IsNullOrWhiteSpace better matches “not set” semantics and prevents empty-looking suggestions.

Apply this minimal change:

-            var selectedResultPossibleSuggestion = selectedResultActionKeyword +
-                (string.IsNullOrEmpty(selectedResult.QuerySuggestionText) ?
-                selectedResult.Title :
-                selectedResult.QuerySuggestionText);
+            var selectedResultPossibleSuggestion = selectedResultActionKeyword +
+                (string.IsNullOrWhiteSpace(selectedResult.QuerySuggestionText) ?
+                selectedResult.Title :
+                selectedResult.QuerySuggestionText);

36-39: Optional: guard against double-prepending the action keyword

If a plugin mistakenly includes the action keyword in QuerySuggestionText, this can lead to duplicated prefixes. We can avoid that without breaking existing behavior.

Alternative refactor for these lines:

-            var selectedResultPossibleSuggestion = selectedResultActionKeyword +
-                (string.IsNullOrEmpty(selectedResult.QuerySuggestionText) ?
-                selectedResult.Title :
-                selectedResult.QuerySuggestionText);
+            var suggestionCore = string.IsNullOrWhiteSpace(selectedResult.QuerySuggestionText)
+                ? selectedResult.Title
+                : selectedResult.QuerySuggestionText;
+
+            var selectedResultPossibleSuggestion =
+                string.IsNullOrEmpty(selectedResultActionKeyword)
+                || suggestionCore.StartsWith(selectedResultActionKeyword, StringComparison.CurrentCultureIgnoreCase)
+                    ? suggestionCore
+                    : selectedResultActionKeyword + suggestionCore;

This keeps the auto-prefixing but avoids doubling it when the plugin already prefixed.


46-46: Use AsSpan() on both arguments for broader overload support

Using string.Concat(queryText.AsSpan(), ...) ensures the compiler selects the ReadOnlySpan overload on all supported TFMs and keeps the no-substring-allocation benefit.

Apply:

-            selectedItem.QuerySuggestionText = string.Concat(queryText, selectedResultPossibleSuggestion.AsSpan(queryText.Length));
+            selectedItem.QuerySuggestionText = string.Concat(queryText.AsSpan(), selectedResultPossibleSuggestion.AsSpan(queryText.Length));

36-39: Add unit tests for new behavior

Please add tests covering:

  • Prefers QuerySuggestionText over Title.
  • Falls back when QuerySuggestionText is null/whitespace.
  • Action keyword is auto-prefixed and not duplicated.
  • Case-insensitive StartsWith handling.
  • No suggestion when prefix doesn’t match.

I can draft test cases targeting QuerySuggestionBoxConverter to validate these scenarios. Let me know your preferred test framework/project layout.

Also applies to: 46-46

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc42cd6 and 8c6f9c9.

📒 Files selected for processing (2)
  • Flow.Launcher.Plugin/Result.cs (1 hunks)
  • Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (1 hunks)
⏰ 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). (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build

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: 2

🧹 Nitpick comments (1)
Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (1)

51-61: Fix misleading comment and guard against null/whitespace Title

The comment mentions QuerySuggestionText while this branch handles Title. Also, guard against null/whitespace Title to avoid generating a malformed candidate.

-            // Then check Title as suggestion
+            // Then check Title as suggestion
             if (string.IsNullOrEmpty(selectedResultPossibleSuggestion))
             {
-                selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title;
-
-                // If this QuerySuggestionText does not start with the queryText, set it to null
-                if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
-                {
-                    selectedResultPossibleSuggestion = null;
-                }
+                if (!string.IsNullOrWhiteSpace(selectedResult.Title))
+                {
+                    selectedResultPossibleSuggestion = selectedResultActionKeyword + selectedResult.Title;
+                    // If this Title does not start with the queryText, set it to null
+                    if (!selectedResultPossibleSuggestion.StartsWith(queryText, StringComparison.CurrentCultureIgnoreCase))
+                    {
+                        selectedResultPossibleSuggestion = 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 8c6f9c9 and c895b2a.

📒 Files selected for processing (2)
  • Flow.Launcher.Plugin/Result.cs (2 hunks)
  • Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Flow.Launcher.Plugin/Result.cs
⏰ 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). (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (1)
Flow.Launcher/Converters/QuerySuggestionBoxConverter.cs (1)

68-68: No changes needed: TFM supports the overload and span slicing is already safe

All projects target .NET 9.0, which includes string.Concat(string, ReadOnlySpan<char>), and the preceding StartsWith(queryText) check guarantees selectedResultPossibleSuggestion.Length >= queryText.Length, so AsSpan(queryText.Length) cannot go out of range. Keeping the existing code is correct.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

/// <remarks>When a value is not set, the <see cref="Title"/> will be used.</remarks>
/// <remarks>
/// When a value is not set, the <see cref="Title"/> will be used.
/// Please include the action keyword prefix when necessary because Flow does not prepend it automatically.
Copy link
Member

Choose a reason for hiding this comment

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

👍

@Jack251970 Jack251970 merged commit d8ef491 into dev Aug 20, 2025
10 checks passed
@Jack251970 Jack251970 deleted the QuerySuggestionText_API branch August 20, 2025 08:45
TBM13 pushed a commit to TBM13/Flow.Launcher that referenced this pull request Aug 28, 2025
…ionText_API

Add new api Result.QuerySuggestionText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants