CmdPal: Add settings to control which fallbacks are enabled (#40505)

This adds settings to each provider to allow us to control if individual
fallback items are enabled or not, regardless of the provider being
enabled.

This is relevant to _all the threads where disabling fallback commands
came up_

This just adds another section to each provider's settings page, with a
list of the fallback commands.

This also has nothing to do with the "top-level apps search", which is
not really a fallback command - it's its own thing.

Ref #38288. Doesn't close that, because this only controls
enable/disable, not ranking.

From here, we should be able to add a dedicated page in the SUI that
shows all the fallbacks across all providers. That's where we'll enable
the ordering.
This commit is contained in:
Mike Griese
2025-07-09 22:01:38 -05:00
committed by GitHub
parent 5c6166bc9f
commit cfa5f75862
18 changed files with 178 additions and 26 deletions

View File

@@ -15,6 +15,8 @@ namespace Microsoft.CmdPal.Ext.Indexer;
internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System.IDisposable
{
private static readonly NoOpCommand _baseCommandWithId = new() { Id = "com.microsoft.indexer.fallback" };
private readonly CompositeFormat fallbackItemSearchPageTitleCompositeFormat = CompositeFormat.Parse(Resources.Indexer_fallback_searchPage_title);
private readonly SearchEngine _searchEngine = new();
@@ -22,10 +24,11 @@ internal sealed partial class FallbackOpenFileItem : FallbackCommandItem, System
private uint _queryCookie = 10;
public FallbackOpenFileItem()
: base(new NoOpCommand(), Resources.Indexer_Find_Path_fallback_display_title)
: base(_baseCommandWithId, Resources.Indexer_Find_Path_fallback_display_title)
{
Title = string.Empty;
Subtitle = string.Empty;
Icon = Icons.FileExplorer;
}
public override void UpdateQuery(string query)

View File

@@ -6,7 +6,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using ManagedCommon;
using Microsoft.CmdPal.Ext.Indexer.Commands;
using Microsoft.CmdPal.Ext.Indexer.Data;

View File

@@ -15,7 +15,9 @@ internal sealed partial class FallbackExecuteItem : FallbackCommandItem
private readonly SettingsManager _settings;
public FallbackExecuteItem(SettingsManager settings)
: base(new ExecuteItem(string.Empty, settings), Resources.shell_command_display_title)
: base(
new ExecuteItem(string.Empty, settings) { Id = "com.microsoft.run.fallback" },
Resources.shell_command_display_title)
{
_settings = settings;
_executeItem = (ExecuteItem)this.Command!;

View File

@@ -17,7 +17,7 @@ internal sealed partial class FallbackExecuteSearchItem : FallbackCommandItem
private static readonly CompositeFormat PluginOpen = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_open);
public FallbackExecuteSearchItem(SettingsManager settings)
: base(new SearchWebCommand(string.Empty, settings), Resources.command_item_title)
: base(new SearchWebCommand(string.Empty, settings) { Id = "com.microsoft.websearch.fallback" }, Resources.command_item_title)
{
_executeItem = (SearchWebCommand)this.Command!;
Title = string.Empty;

View File

@@ -7,7 +7,6 @@ using System.Globalization;
using System.Text;
using Microsoft.CmdPal.Ext.WebSearch.Commands;
using Microsoft.CmdPal.Ext.WebSearch.Helpers;
using Microsoft.CmdPal.Ext.WebSearch.Properties;
using Microsoft.CommandPalette.Extensions.Toolkit;
using BrowserInfo = Microsoft.CmdPal.Ext.WebSearch.Helpers.DefaultBrowserInfo;
@@ -20,7 +19,7 @@ internal sealed partial class FallbackOpenURLItem : FallbackCommandItem
private static readonly CompositeFormat PluginOpenUrlInBrowser = System.Text.CompositeFormat.Parse(Properties.Resources.plugin_open_url_in_browser);
public FallbackOpenURLItem(SettingsManager settings)
: base(new OpenURLCommand(string.Empty, settings), string.Empty)
: base(new OpenURLCommand(string.Empty, settings), Properties.Resources.open_url_fallback_title)
{
_executeItem = (OpenURLCommand)this.Command!;
Title = string.Empty;

View File

@@ -132,6 +132,15 @@ namespace Microsoft.CmdPal.Ext.WebSearch.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Open URL.
/// </summary>
public static string open_url_fallback_title {
get {
return ResourceManager.GetString("open_url_fallback_title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to the default browser.
/// </summary>

View File

@@ -178,4 +178,7 @@
<data name="settings_page_name" xml:space="preserve">
<value>Settings</value>
</data>
<data name="open_url_fallback_title" xml:space="preserve">
<value>Open URL</value>
</data>
</root>