Skip to content

Conversation

AWAS666
Copy link
Contributor

@AWAS666 AWAS666 commented Oct 9, 2025

Closes #3773

This is still missing some translations though and it also adds a settings panel to the url plugin.

There are some other unused properties in this plugin, not sure if these can be deleted?

Also default behaviour is http but I think https should be the state of the art at this point

@github-actions github-actions bot added this to the 2.1.0 milestone Oct 9, 2025
Copy link

gitstream-cm bot commented Oct 9, 2025

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

@coderabbitai coderabbitai bot added the enhancement New feature or request label Oct 9, 2025
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

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 user-configurable preference to use https when inferring URL schemes. Introduces a new settings property, updates URL-building logic to respect it, and exposes a checkbox in the settings UI with a new localized string.

Changes

Cohort / File(s) Change summary
URL scheme preference logic
Plugins/Flow.Launcher.Plugin.Url/Main.cs
When input lacks a scheme, prefix with GetHttpPreference() + "://", selecting https or http based on settings; adds private helper GetHttpPreference().
Settings model
Plugins/Flow.Launcher.Plugin.Url/Settings.cs
Adds public bool property AlwaysOpenWithHttps (default false).
Settings UI and i18n
Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml, Plugins/Flow.Launcher.Plugin.Url/Languages/en.xaml
Adds a checkbox bound to Settings.AlwaysOpenWithHttps and a new resource string flowlauncher_plugin_url_usehttps ("Prefer https over http").

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Plugin as Url Plugin (Main)
  participant Settings
  participant Shell as OS/Shell

  User->>Plugin: Enter URL without scheme (e.g., "example.com")
  Plugin->>Settings: Read AlwaysOpenWithHttps
  Settings-->>Plugin: true/false
  Plugin->>Plugin: scheme = (AlwaysOpenWithHttps ? "https" : "http")
  Plugin->>Shell: Open scheme + "://" + input
  Shell-->>User: Browser opens constructed URL
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • 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 clearly and concisely summarizes the core change by indicating the addition of a setting to prefer HTTPS over HTTP for URLs, matching the primary intent of the pull request without unnecessary detail.
Linked Issues Check ✅ Passed The implementation introduces the AlwaysOpenWithHttps setting, adds the corresponding resource and UI control, and updates URL normalization to use the selected preference, fully satisfying the linked enhancement request to allow preferring HTTPS while still supporting HTTP (issue #3773).
Out of Scope Changes Check ✅ Passed All modifications—adding a resource string, a settings property, UI binding, and a helper method—directly support the HTTPS preference feature and there are no unrelated changes present in this pull request.
Description Check ✅ Passed The description directly references closing the relevant issue, notes the addition of the settings panel, mentions missing translations, and explains the default behavior change, all of which are directly related to the implemented changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 b8acead and 1e3306e.

📒 Files selected for processing (2)
  • Plugins/Flow.Launcher.Plugin.Url/Main.cs (2 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Plugins/Flow.Launcher.Plugin.Url/Main.cs
🧰 Additional context used
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml

[warning] 123-123:
usehttps is not a recognized word. (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). (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (2)
Plugins/Flow.Launcher.Plugin.Url/SettingsControl.xaml (2)

22-22: LGTM!

The new RowDefinition correctly accommodates the new HTTPS preference checkbox added below. The Height="auto" is consistent with the existing row definitions.


117-124: LGTM!

The new HTTPS preference checkbox is well-implemented:

  • Follows the same layout pattern as the existing UseCustomBrowser checkbox
  • Properly positioned at Grid.Row="2" after the custom browser settings
  • Uses correct two-way binding to Settings.AlwaysOpenWithHttps
  • Maintains consistent margins and alignment with the rest of the UI

Note: Ignore the spell checker warning on usehttps—it's a resource key, not prose.


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)
Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs (1)

1-2: Remove unused imports.

Neither System.Collections.Generic nor System.Linq are used in this file.

Apply this diff:

-using System.Collections.Generic;
-using System.Linq;
-
 namespace Flow.Launcher.Plugin.Url;
Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs (1)

7-7: Consider removing the unused field.

The _viewModel field is assigned but never read. Since DataContext is set directly, the field is not needed.

Apply this diff if you want to simplify:

 public partial class URLSettings : UserControl
 {
-    private readonly SettingsViewModel _viewModel;
-
     public URLSettings(Settings settings)
     {
-        _viewModel = new SettingsViewModel(settings);
-        DataContext = _viewModel;
+        DataContext = new SettingsViewModel(settings);
         InitializeComponent();
     }
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae159d and 1a373e1.

📒 Files selected for processing (7)
  • Plugins/Flow.Launcher.Plugin.Url/Languages/de.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/Languages/en.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/Main.cs (4 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/Settings.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml (1 hunks)
  • Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs (2)
Plugins/Flow.Launcher.Plugin.Url/Settings.cs (1)
  • Settings (3-9)
Plugins/Flow.Launcher.Plugin.ProcessKiller/ViewModels/SettingsViewModel.cs (1)
  • SettingsViewModel (3-6)
Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs (2)
Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs (1)
  • SettingsViewModel (6-9)
Plugins/Flow.Launcher.Plugin.Url/Settings.cs (1)
  • Settings (3-9)
Plugins/Flow.Launcher.Plugin.Url/Main.cs (1)
Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs (2)
  • URLSettings (5-15)
  • URLSettings (9-14)
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml

[warning] 28-28:
usehttps is not a recognized word. (unrecognized-spelling)

🔇 Additional comments (8)
Plugins/Flow.Launcher.Plugin.Url/Languages/de.xaml (1)

17-19: LGTM!

The German localization for the HTTPS preference setting is properly added and the translation is accurate.

Plugins/Flow.Launcher.Plugin.Url/Settings.cs (1)

8-8: LGTM!

The new AlwaysOpenWithHttps property is well-named with a sensible default that maintains backward compatibility.

Plugins/Flow.Launcher.Plugin.Url/SettingsViewModel.cs (1)

6-9: LGTM!

The ViewModel structure is clean and follows the pattern used in other plugins (e.g., ProcessKiller plugin). The primary constructor syntax is modern and concise.

Plugins/Flow.Launcher.Plugin.Url/Languages/en.xaml (1)

18-19: LGTM!

The English localization for the HTTPS preference setting is properly added and clearly worded.

Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml (1)

1-31: LGTM!

The settings UI is properly structured with correct two-way binding for the checkbox and dynamic resource lookup for localization. The static analysis warning about "usehttps" is a false positive—it's part of a valid resource key name.

Plugins/Flow.Launcher.Plugin.Url/Main.cs (3)

66-76: LGTM!

The try-catch block properly handles URL opening failures and displays an error message to the user, improving the robustness of the plugin.


84-87: LGTM!

The GetHttpPreference() helper method is clear and concise, encapsulating the preference logic.


123-126: LGTM!

The CreateSettingPanel() implementation correctly returns a settings UI bound to the plugin's settings instance.

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 implements a user setting to prefer HTTPS over HTTP when opening URLs that don't explicitly specify a protocol. The change allows users to configure the plugin to default to HTTPS instead of HTTP for better security practices.

Key changes:

  • Added a new setting AlwaysOpenWithHttps to control protocol preference
  • Created a settings UI panel with a checkbox to toggle HTTPS preference
  • Updated URL handling logic to use the preferred protocol based on user setting

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Settings.cs Added new boolean property for HTTPS preference setting
Main.cs Updated URL protocol logic and added settings panel support
URLSettings.xaml Created settings UI with HTTPS preference checkbox
URLSettings.xaml.cs Code-behind for the settings panel
SettingsViewModel.cs View model to bind settings to the UI
Languages/en.xaml Added English translation for HTTPS preference label
Languages/de.xaml Added German translation for HTTPS preference label

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <[email protected]>
Copy link
Member

@Jack251970 Jack251970 left a comment

Choose a reason for hiding this comment

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

Please do not change the non-English language xaml files because they are updated automatically by Crowdin.

So please revert changes in de.xaml

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)
Plugins/Flow.Launcher.Plugin.Url/Main.cs (1)

84-87: Fix formatting and verify null safety.

Two concerns:

  1. Missing space after the colon in the ternary operator (for consistent formatting).
  2. Verify that _settings cannot be null when this method is called. While the plugin framework typically ensures Init() runs first, confirm that LoadSettingJsonStorage<Settings>() at line 110 never returns null, or add a null-check/default fallback.

Apply this diff to fix the formatting:

-            return _settings.AlwaysOpenWithHttps ? "https" : "http";
+            return _settings.AlwaysOpenWithHttps ? "https" : "http";

To verify null safety, run the following script:

#!/bin/bash
# Description: Check if LoadSettingJsonStorage can return null and verify plugin initialization order

# Search for LoadSettingJsonStorage implementation to check null handling
rg -n -A 10 "LoadSettingJsonStorage" --type=cs

# Search for ISettingProvider.CreateSettingPanel calls to verify if Init is guaranteed first
rg -n -B 3 -A 3 "CreateSettingPanel" --type=cs
🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.Url/Main.cs (1)

66-76: Good error handling, consider more specific exceptions.

The try/catch block prevents crashes and provides user feedback, which is appropriate for a plugin. However, catching all Exception types is very broad.

Consider catching more specific exceptions if you want to provide different error messages:

 try
 {
     Context.API.OpenUrl(raw); 
     
     return true;
 }
-catch(Exception)
+catch (UriFormatException ex)
 {
-    Context.API.ShowMsgError(Localize.flowlauncher_plugin_url_cannot_open_url(raw));
+    Context.API.ShowMsgError($"Invalid URL format: {raw}");
+    return false;
+}
+catch (Exception)
+{
+    Context.API.ShowMsgError(Localize.flowlauncher_plugin_url_cannot_open_url(raw));
     return false;
 }

Note: If the current broad catch is intentional to handle all edge cases gracefully, you can disregard this suggestion.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae3559c and a412c79.

📒 Files selected for processing (1)
  • Plugins/Flow.Launcher.Plugin.Url/Main.cs (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Plugins/Flow.Launcher.Plugin.Url/Main.cs (1)
Plugins/Flow.Launcher.Plugin.Url/URLSettings.xaml.cs (2)
  • URLSettings (5-15)
  • URLSettings (9-14)
⏰ 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: gitStream.cm
🔇 Additional comments (4)
Plugins/Flow.Launcher.Plugin.Url/Main.cs (4)

4-4: LGTM!

The import is necessary for the Control return type in CreateSettingPanel().


8-8: LGTM!

The ISettingProvider implementation is correctly added to enable settings UI integration.


62-65: LGTM! Previous critical issue resolved.

The scheme detection logic now correctly checks for both http:// and https:// explicitly, resolving the previous bug where "https" would match StartsWith("http"). URLs without an explicit scheme now get the preferred scheme prefix, while existing schemes are preserved.


123-126: Guard against _settings being null in CreateSettingPanel
Add a null check to _settings (e.g., throw or fallback) to prevent a NullReferenceException if Init() hasn’t run, or confirm with the host framework that Init() is guaranteed to execute before CreateSettingPanel().

@Jack251970
Copy link
Member

LGTM but I would like to merge it after #3944 since #3944 brings more changes and I would prefer the resolve the conflicts in this PR.

Btw, @jjw24 can #3944 be merged?

@jjw24
Copy link
Member

jjw24 commented Oct 12, 2025

Merged 3944.

Copy link
Member

@Jack251970 Jack251970 left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

@Jack251970 Jack251970 enabled auto-merge October 12, 2025 05:33
@Jack251970 Jack251970 merged commit e6c4cc2 into Flow-Launcher:dev Oct 12, 2025
8 checks passed
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.

Enhancement: Option to prefer https:// urls

4 participants