-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Flow Launcher Theme Selector plugin #2448
base: dev
Are you sure you want to change the base?
Flow Launcher Theme Selector plugin #2448
Conversation
Great idea. I think this plugin would be best served by publishing to the Store. We can have a look at exposing the needed methods via the API. |
I feel like we can allow this plugin to be built in. Thememanager is pretty internal. |
Well yes and no, it's directly referencing the core project, ideal design is to have even the default plugins as self contained. |
Some of our internal stuff uses the plugin interface for receiving query, which I think is a pretty good idea. I am not sure whether exposing everything to the interface is a very good idea. PublicAPI sometimes can be the curse as we may want to maintain backward compatibility. |
Well I think at least this functionality is a good one to enable plugins to use. Remember the more plugins we pack the more we need to maintain and the bigger the size eventually get. More ideal to encourage plugin development. |
well a plugin only takes 400k size...which should be pretty neglectable. and this feature seems to be good to built in. |
@Odotocodot isn't you also need to add the plugin folder to the solution? |
This comment has been minimized.
This comment has been minimized.
What about putting this functionality in the Sys plugin since it has flow related functionalities like open log file and reload data etc. |
Sorry ive been busy with uni!
So move to be inside the sys plugin?
Im not sure its needed? or im confused... its be a while |
I would say ideally exposing the methods via the plugin API would be the best so people can build plugin around it, but this change can be complicated, so putting it in the Sys plugin is the next best option. |
I've moved the theme selector plugin into the sys plugin now, though I have only done the english translation. |
WalkthroughWalkthroughThe updates enhance the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Main
participant ThemeSelector
User->>Main: Query for theme change
Main->>ThemeSelector: Initialize and query themes
ThemeSelector-->>Main: Returns available themes
Main-->>User: Displays theme options
User->>Main: Select a theme
Main->>ThemeSelector: Apply selected theme
ThemeSelector-->>Main: Theme applied
Main-->>User: Confirmation of theme change
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (4)
Files skipped from review due to trivial changes (1)
Additional comments not posted (9)
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@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 ...
|
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: 2
Outside diff range and nitpick comments (3)
Plugins/Flow.Launcher.Plugin.Sys/ThemeSelector.cs (2)
11-11
: Consider renaming the constantKeyword
to something more specific to avoid potential naming conflicts and increase clarity.
56-83
: The methodsCreateThemeResult
are well implemented and provide a clear way to create result objects. Consider adding XML documentation to these methods to improve code maintainability.Plugins/Flow.Launcher.Plugin.Sys/Languages/en.xaml (1)
30-30
: Ensure the command description aligns with the functionality of setting themes. It might be helpful to specify that this command allows for dynamic theme switching.
public List<Result> Query(Query query) | ||
{ | ||
if (query.IsReQuery) | ||
{ | ||
LoadThemes(); | ||
} | ||
|
||
string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..]; | ||
|
||
if (string.IsNullOrWhiteSpace(search)) | ||
{ | ||
return themes.Select(CreateThemeResult) | ||
.OrderBy(x => x.Title) | ||
.ToList(); | ||
} | ||
|
||
return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme))) | ||
.Where(x => x.matchResult.IsSearchPrecisionScoreMet()) | ||
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) | ||
.OrderBy(x => x.Title) | ||
.ToList(); | ||
} |
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.
The Query
method handles theme search effectively. However, consider caching the result of query.Search.IndexOf(Keyword, StringComparison.Ordinal)
to avoid recalculating it multiple times.
- string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..];
+ int keywordIndex = query.Search.IndexOf(Keyword, StringComparison.Ordinal);
+ string search = query.Search[(keywordIndex + Keyword.Length + 1)..];
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public List<Result> Query(Query query) | |
{ | |
if (query.IsReQuery) | |
{ | |
LoadThemes(); | |
} | |
string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..]; | |
if (string.IsNullOrWhiteSpace(search)) | |
{ | |
return themes.Select(CreateThemeResult) | |
.OrderBy(x => x.Title) | |
.ToList(); | |
} | |
return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme))) | |
.Where(x => x.matchResult.IsSearchPrecisionScoreMet()) | |
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) | |
.OrderBy(x => x.Title) | |
.ToList(); | |
} | |
public List<Result> Query(Query query) | |
{ | |
if (query.IsReQuery) | |
{ | |
LoadThemes(); | |
} | |
int keywordIndex = query.Search.IndexOf(Keyword, StringComparison.Ordinal); | |
string search = query.Search[(keywordIndex + Keyword.Length + 1)..]; | |
if (string.IsNullOrWhiteSpace(search)) | |
{ | |
return themes.Select(CreateThemeResult) | |
.OrderBy(x => x.Title) | |
.ToList(); | |
} | |
return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme))) | |
.Where(x => x.matchResult.IsSearchPrecisionScoreMet()) | |
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData)) | |
.OrderBy(x => x.Title) | |
.ToList(); | |
} |
private void LoadThemes() | ||
=> themes = ThemeManager.Instance.LoadAvailableThemes().Select(Path.GetFileNameWithoutExtension); |
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.
Tip
Codebase Verification
The LoadAvailableThemes
method in Flow.Launcher.Core/Resource/Theme.cs
currently does not include any exception handling for cases where the theme directories might not be accessible or other potential issues (e.g., IO exceptions). It would be prudent to add exception handling to ensure robustness.
- Location:
Flow.Launcher.Core/Resource/Theme.cs
- Method:
LoadAvailableThemes
Analysis chain
The method LoadThemes
efficiently loads themes using LINQ. Ensure ThemeManager.Instance.LoadAvailableThemes()
handles exceptions if the themes directory is not accessible.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if ThemeManager handles exceptions during theme loading.
cat Plugins/Flow.Launcher.Plugin.Sys/ThemeManager.cs | grep -A 10 "LoadAvailableThemes"
Length of output: 168
Script:
#!/bin/bash
# Locate the file containing the ThemeManager class
fd ThemeManager.cs
# Once located, inspect the LoadAvailableThemes method
ast-grep --lang cs --pattern 'class ThemeManager { $$$ LoadAvailableThemes() { $$$ } $$$ }'
Length of output: 503
Script:
#!/bin/bash
# Search for the LoadAvailableThemes method in the ThemeManager.cs file
rg 'LoadAvailableThemes' Flow.Launcher.Core/Resource/ThemeManager.cs -A 20
Length of output: 74
Script:
#!/bin/bash
# Search for all method definitions in the ThemeManager.cs file
rg '^\s*(public|private|protected|internal)\s+\w+\s+\w+\s*\(' Flow.Launcher.Core/Resource/ThemeManager.cs
Length of output: 107
Script:
#!/bin/bash
# Search for all method definitions across the entire repository to locate the correct method for loading themes
rg '^\s*(public|private|protected|internal)\s+\w+\s+\w+\s*\('
Length of output: 81184
Script:
#!/bin/bash
# Search for the LoadAvailableThemes method across the entire repository
rg 'LoadAvailableThemes'
Length of output: 431
Script:
#!/bin/bash
# Inspect the LoadAvailableThemes method in Flow.Launcher.Core/Resource/Theme.cs
rg 'LoadAvailableThemes' Flow.Launcher.Core/Resource/Theme.cs -A 20
Length of output: 882
A plugin to quickly change the current Flow Launcher theme.
If someone has a better suggestion for the default action keyword rather than
flowtheme
, would love to hear it. Was a bit apprehensive in using theme 🤷♂️ .Summary by CodeRabbit
New Features
Enhancements