-
-
Notifications
You must be signed in to change notification settings - Fork 328
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
New API for Record Key of Results & Fix Result Clone Issue #3194
base: dev
Are you sure you want to change the base?
Conversation
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. If the flagged items are 🤯 false positivesIf items relate to a ...
|
🥷 Code experts: no user matched threshold 10 See details
Knowledge based on git-blame:
Knowledge based on git-blame:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
📝 WalkthroughWalkthroughThe pull request introduces several enhancements to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (3)
Flow.Launcher/Storage/TopMostRecord.cs (2)
53-53
: Consider adding validation for RecordKey.While the property implementation is correct, consider adding validation to ensure RecordKey follows any required format or constraints (e.g., UUID format for Edge workspaces).
57-67
: LGTM! Robust equality comparison implementation.The implementation correctly:
- Falls back to Title/SubTitle comparison when RecordKey is empty
- Uses RecordKey for comparison when available
- Always verifies PluginID to ensure results from different plugins are distinct
Consider adding a comment explaining why PluginID is always checked, as it might not be immediately obvious to future maintainers.
Flow.Launcher.Plugin/Result.cs (1)
265-271
: LGTM! Consider adding usage examples to documentation.The documentation clearly explains the purpose of RecordKey. Consider adding code examples to demonstrate:
- When to use RecordKey vs. Title/SubTitle
- Common patterns for generating RecordKey values
- Edge workspace UUID example mentioned in PR description
/// <summary> /// The key to identify the record. This is used when FL checks whether the result is the topmost record. Or FL calculates the hashcode of the result for user selected records. /// This can be useful when your plugin will change the Title or SubTitle of the result dynamically. /// If the plugin does not specific this, FL just uses Title and SubTitle to identify this result. +/// <example> +/// <code> +/// // Example 1: Using workspace UUID as RecordKey +/// var result = new Result +/// { +/// Title = $"Workspace: {workspaceName}", +/// SubTitle = $"Contains {tabCount} tabs", +/// RecordKey = workspaceUuid // Stable identifier even when name/tab count changes +/// }; +/// </code> +/// </example> /// </summary>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
Flow.Launcher.Plugin/Result.cs
(2 hunks)Flow.Launcher/Storage/TopMostRecord.cs
(2 hunks)Flow.Launcher/Storage/UserSelectedRecord.cs
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
🔇 Additional comments (4)
Flow.Launcher/Storage/TopMostRecord.cs (1)
36-37
: LGTM! Proper propagation of RecordKey.The implementation correctly copies the RecordKey from Result to Record during creation.
Flow.Launcher/Storage/UserSelectedRecord.cs (2)
47-55
: LGTM! Consistent hash code generation logic.The implementation correctly handles both cases:
- Uses RecordKey for hash generation when available
- Falls back to Title/SubTitle combination when RecordKey is empty
68-76
: LGTM! Verify hash collision probability.The implementation correctly maintains consistency with GenerateResultHashCode while incorporating query components. However, let's verify that the hash generation doesn't increase collision probability with RecordKey.
✅ Verification successful
Hash collision probability verified - implementation is sound
The hash implementation uses a proven algorithm with a prime multiplier (31) that ensures good distribution. The RecordKey path doesn't increase collision probability compared to the Title+SubTitle path as it uses the same robust hashing strategy.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential hash collisions in the codebase # Look for instances where different RecordKeys might generate the same hash # Search for RecordKey assignments to analyze their patterns rg -g '*.cs' 'RecordKey\s*=\s*.+' -A 2Length of output: 702
Script:
#!/bin/bash # Find GenerateStaticHashCode implementation and RecordKey assignments ast-grep --pattern 'GenerateStaticHashCode($_) { $$$ }' # Find where RecordKey is populated with actual values rg -g '*.cs' '\.RecordKey\s*=\s*[^;]+;' -B 2 -A 2Length of output: 109
Script:
#!/bin/bash # Check the implementation file directly cat Flow.Launcher/Storage/UserSelectedRecord.cs # Search for GenerateStaticHashCode with broader pattern rg -g '*.cs' 'GenerateStaticHashCode' -B 2 -A 5 # Find RecordKey property definition ast-grep --pattern 'public string RecordKey { get; set; }'Length of output: 7419
Flow.Launcher.Plugin/Result.cs (1)
188-197
: LGTM! Complete property cloning.The Clone method correctly includes all new properties, including RecordKey, ensuring complete object copying.
Add
RecordKey
forResult
class.E.g. The records of plugin
Edge Workspace
have subtitles which can change based on the tab number of the edge workspace, but FL should regard these records as the same. (Full issue in cspotcode/Flow.Launcher.Plugin.EdgeWorkspaces#3)Advantages
Title
andSubTitle
of theResult
should be the properties for display, andRecordKey
can be the property for identification. That way one plugin can specify any unique key, and FL will use it, ignoring title and subtitle. Plugin can get full control and can modify title or subtitle without breakingTopmostRecord
andUserSelectedRecord
.A nullable identification field / RecordKey is also easier for non-C# plugins because it avoids extra RPC calling between C# and the external process. And in the case of Edge Workspaces, the Edge browser already assigns each workspace a unique UUID, so we can use that value for RecordKey.
More details in #3178.