Make the feature default to be off

This commit is contained in:
Gordon Lam (SH)
2025-06-30 11:00:55 +08:00
parent e9af20a1d6
commit 41cfa20163
3 changed files with 13 additions and 11 deletions

View File

@@ -14,6 +14,15 @@ namespace Microsoft.CmdPal.Ext.Indexer.Data;
internal sealed partial class IndexerListItem : ListItem
{
internal static readonly bool IsActionsFeatureEnabled = GetFeatureFlag();
private static bool GetFeatureFlag()
{
var env = System.Environment.GetEnvironmentVariable("CMDPAL_ENABLE_ACTIONS_LIST");
return !string.IsNullOrEmpty(env) &&
(env == "1" || env.Equals("true", System.StringComparison.OrdinalIgnoreCase));
}
internal string FilePath { get; private set; }
public IndexerListItem(
@@ -44,8 +53,8 @@ internal sealed partial class IndexerListItem : ListItem
IContextItem[] moreCommands = [
..context,
new CommandContextItem(new OpenWithCommand(indexerItem))];
/*
if (ApiInformation.IsApiContractPresent("Windows.AI.Actions.ActionsContract", 4))
if (IsActionsFeatureEnabled && ApiInformation.IsApiContractPresent("Windows.AI.Actions.ActionsContract", 4))
{
var actionsListContextItem = new ActionsListContextItem(indexerItem.FullPath);
if (actionsListContextItem.AnyActions())
@@ -56,7 +65,6 @@ internal sealed partial class IndexerListItem : ListItem
];
}
}
*/
MoreCommands = [
.. moreCommands,

View File

@@ -20,12 +20,10 @@ public partial class IndexerCommandsProvider : CommandProvider
DisplayName = Resources.IndexerCommandsProvider_DisplayName;
Icon = Icons.FileExplorer;
/*
if (ApiInformation.IsApiContractPresent("Windows.AI.Actions.ActionsContract", 4))
if (IndexerListItem.IsActionsFeatureEnabled && ApiInformation.IsApiContractPresent("Windows.AI.Actions.ActionsContract", 4))
{
_ = ActionRuntimeManager.InstanceAsync;
}
*/
}
public override ICommandItem[] TopLevelCommands()

View File

@@ -19,10 +19,10 @@ namespace Microsoft.CmdPal.Ext.Indexer.Pages;
internal sealed partial class ActionsListContextItem : CommandContextItem, IDisposable
{
// private static ActionRuntime actionRuntime;
private readonly string fullPath;
private readonly List<CommandContextItem> actions = [];
private static readonly Lock UpdateMoreCommandsLock = new();
private static ActionRuntime actionRuntime;
public ActionsListContextItem(string fullPath)
: base(new NoOpCommand())
@@ -43,7 +43,6 @@ internal sealed partial class ActionsListContextItem : CommandContextItem, IDisp
private void UpdateMoreCommands()
{
/*
lock (UpdateMoreCommandsLock)
{
if (actionRuntime == null)
@@ -96,12 +95,10 @@ internal sealed partial class ActionsListContextItem : CommandContextItem, IDisp
{
Logger.LogError($"Error updating commands: {ex.Message}");
}
*/
}
public void Dispose()
{
/*
lock (UpdateMoreCommandsLock)
{
if (actionRuntime != null)
@@ -109,6 +106,5 @@ internal sealed partial class ActionsListContextItem : CommandContextItem, IDisp
actionRuntime.ActionCatalog.Changed -= ActionCatalog_Changed;
}
}
*/
}
}