Add Custom Template shell option to Shell plugin - #4580
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a ChangesCustom template shell
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ShellSetting
participant Settings
participant Main
participant ProcessStartInfo
User->>ShellSetting: select CustomTemplate and configure fields
ShellSetting->>Settings: store executable path and argument template
Settings->>Main: provide CustomTemplateShellConfig
Main->>ProcessStartInfo: set expanded executable and substituted arguments
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Flow.Launcher.Test/Plugins/ShellPluginTest.cs (1)
308-356: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd
Shell.CustomTemplateto common test cases.To ensure the new custom template behavior is fully validated against standard shell baselines (like setting the correct working directory and
UseShellExecuteflag), consider adding[TestCase(Shell.CustomTemplate)]to the shared common tests.💡 Proposed change
[TestCase(Shell.Cmd)] [TestCase(Shell.Powershell)] [TestCase(Shell.Pwsh)] [TestCase(Shell.RunCommand)] + [TestCase(Shell.CustomTemplate)] public void SetsWorkingDirectory(Shell shell) { var info = Create(shell: shell); var expected = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); Assert.That(info.WorkingDirectory, Is.EqualTo(expected)); } [TestCase(Shell.Cmd)] [TestCase(Shell.Powershell)] [TestCase(Shell.Pwsh)] [TestCase(Shell.RunCommand)] + [TestCase(Shell.CustomTemplate)] public void SetsUseShellExecute(Shell shell) { var info = Create(shell: shell); Assert.That(info.UseShellExecute, Is.True); } [TestCase(Shell.Cmd)] [TestCase(Shell.Powershell)] [TestCase(Shell.Pwsh)] [TestCase(Shell.RunCommand)] + [TestCase(Shell.CustomTemplate)] public void ExpandsEnvironmentVariables(Shell shell) { var info = Create( command: "%USERPROFILE%\\test", shell: shell); var expandedPath = Environment.ExpandEnvironmentVariables("%USERPROFILE%\\test"); switch (shell) { case Shell.Cmd: Assert.That(info.Arguments, Is.EqualTo($"/c {expandedPath}")); break; case Shell.Powershell: case Shell.Pwsh: Assert.That(info.ArgumentList, Does.Contain(expandedPath + ";")); break; case Shell.RunCommand: + case Shell.CustomTemplate: Assert.That(info.FileName, Is.EqualTo(expandedPath)); break; } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Flow.Launcher.Test/Plugins/ShellPluginTest.cs` around lines 308 - 356, Add [TestCase(Shell.CustomTemplate)] to the shared SetsWorkingDirectory, SetsUseShellExecute, and ExpandsEnvironmentVariables tests so the custom template follows the same baseline assertions as the other shell values. Preserve the existing test setup and assertions.Plugins/Flow.Launcher.Plugin.Shell/Main.cs (1)
450-456: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExpand environment variables for custom paths and templates.
Users often rely on environment variables like
%LOCALAPPDATA%or%ProgramFiles%to define executable paths, especially for apps installed in user directories or portable setups. To provide feature parity with how commands are treated elsewhere in the plugin, consider expanding environment variables in the configuration strings.💡 Proposed change
- info.FileName = config.ExecutablePath; + info.FileName = Environment.ExpandEnvironmentVariables(config.ExecutablePath); var template = string.IsNullOrEmpty(config.ArgumentsTemplate) ? "{command}" - : config.ArgumentsTemplate; + : Environment.ExpandEnvironmentVariables(config.ArgumentsTemplate); info.Arguments = template.Replace("{command}", command);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Plugins/Flow.Launcher.Plugin.Shell/Main.cs` around lines 450 - 456, Expand environment variables in the configured executable path and arguments template before assigning them in the command setup flow. Update the logic around config.ExecutablePath, config.ArgumentsTemplate, and template so both custom configuration strings support variables such as %LOCALAPPDATA% while preserving the existing default "{command}" behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Plugins/Flow.Launcher.Plugin.Shell/Settings.cs`:
- Around line 145-150: Update CustomTemplateShellConfig to inherit BaseModel and
make ExecutablePath and ArgumentsTemplate observable by raising
OnPropertyChanged in their setters, so programmatic changes such as
BrowseExecutablePath_Click refresh the bound UI controls.
---
Nitpick comments:
In `@Flow.Launcher.Test/Plugins/ShellPluginTest.cs`:
- Around line 308-356: Add [TestCase(Shell.CustomTemplate)] to the shared
SetsWorkingDirectory, SetsUseShellExecute, and ExpandsEnvironmentVariables tests
so the custom template follows the same baseline assertions as the other shell
values. Preserve the existing test setup and assertions.
In `@Plugins/Flow.Launcher.Plugin.Shell/Main.cs`:
- Around line 450-456: Expand environment variables in the configured executable
path and arguments template before assigning them in the command setup flow.
Update the logic around config.ExecutablePath, config.ArgumentsTemplate, and
template so both custom configuration strings support variables such as
%LOCALAPPDATA% while preserving the existing default "{command}" behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aae87e58-bdb7-47ab-8a99-4dc1f541b199
📒 Files selected for processing (8)
Flow.Launcher.Test/Plugins/ShellPluginTest.csPlugins/Flow.Launcher.Plugin.Shell/Converters/LeaveShellOpenOrCloseShellAfterPressEnabledConverter.csPlugins/Flow.Launcher.Plugin.Shell/Languages/en.xamlPlugins/Flow.Launcher.Plugin.Shell/Main.csPlugins/Flow.Launcher.Plugin.Shell/Settings.csPlugins/Flow.Launcher.Plugin.Shell/ViewModels/ShellSettingViewModel.csPlugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xamlPlugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xaml.cs
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
a34f902 to
393aa16
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Plugins/Flow.Launcher.Plugin.Shell/Main.cs`:
- Around line 450-456: Update the custom configuration handling near the
ProcessStartInfo assignments to expand environment variables in
config.ExecutablePath and config.ArgumentsTemplate, then trim the executable
path and remove surrounding quotes before assigning info.FileName. Apply the
same variable expansion to the arguments template before replacing {command},
preserving the existing default template behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 563c3bb9-9fff-4584-81c2-fba14fed6c24
📒 Files selected for processing (8)
Flow.Launcher.Test/Plugins/ShellPluginTest.csPlugins/Flow.Launcher.Plugin.Shell/Converters/LeaveShellOpenOrCloseShellAfterPressEnabledConverter.csPlugins/Flow.Launcher.Plugin.Shell/Languages/en.xamlPlugins/Flow.Launcher.Plugin.Shell/Main.csPlugins/Flow.Launcher.Plugin.Shell/Settings.csPlugins/Flow.Launcher.Plugin.Shell/ViewModels/ShellSettingViewModel.csPlugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xamlPlugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xaml.cs
🚧 Files skipped from review as they are similar to previous changes (6)
- Plugins/Flow.Launcher.Plugin.Shell/Converters/LeaveShellOpenOrCloseShellAfterPressEnabledConverter.cs
- Plugins/Flow.Launcher.Plugin.Shell/Languages/en.xaml
- Plugins/Flow.Launcher.Plugin.Shell/Settings.cs
- Plugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xaml.cs
- Plugins/Flow.Launcher.Plugin.Shell/ViewModels/ShellSettingViewModel.cs
- Plugins/Flow.Launcher.Plugin.Shell/Views/ShellSetting.xaml
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Adds a "Custom Template" entry to the shell selection dropdown. Users can provide any executable path and an arguments template using {command} as a placeholder. Falls back to RunCommand behavior when no executable path is configured.
Leave Shell Open, Close After Press, and Use Windows Terminal checkboxes are disabled for Custom Template - the user has to manually implement those
Use Windows Terminal is also now correctly disabled for RunCommand, which never supported it.
…shell configuration
393aa16 to
3e16478
Compare
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
a3786b0 to
a9bb628
Compare
… default template Now catches empty filename in Execute instead of trying to do a run command. Adjusted defaults for executable path and arguement template to be an example to the user and made tooltips match Empty argument templates are now accepted to give full control to the user
a9bb628 to
62d3edb
Compare
Adds a "Custom Template" entry to the shell selection dropdown.
Should resolve #187 (The most upvoted feature request) - users can fully control shell configuration with this.
Users can provide any executable path and an arguments template using {command} as a placeholder.
Browse button calls OpenFileDialog for executable file path.
Shows error message when command ran with no executable path is set, though empty arguments templates are accepted for full user control.
Leave Shell Open, Close After Press, and Use Windows Terminal settings are disabled for Custom Template - the user has to manually implement those.
Use Windows Terminal is also now correctly disabled for RunCommand, which never supported it.
Summary by cubic
Adds a Custom Template shell so you can run commands with any executable using a simple {command} placeholder. If no executable is set, we show an error and do not run.
Summary of changes
RunCommandandCustomTemplate.CustomTemplate.Shell.CustomTemplateandSettings.CustomTemplateShellConfigwith example defaults: ExecutablePath "cmd.exe", ArgumentsTemplate/k "{command}".{command}, and allows empty templates.RunCommand/default template when no executable was set.RunCommand: users can target any executable; no new elevation paths beyond existing “Run as Admin”.FileNameempty, trim and quote stripping, env var expansion (path, template, and command), working directory,UseShellExecute, and admin verb.Release Note
Choose any app to run your commands with a simple {command} template, with a clear error if no app is set.
Written for commit 62d3edb. Summary will update on new commits.