diff --git a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ParametersViewModels.cs b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ParametersViewModels.cs
index 7d52ec9b30..d3069a7d5c 100644
--- a/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ParametersViewModels.cs
+++ b/src/modules/cmdpal/Core/Microsoft.CmdPal.Core.ViewModels/ParametersViewModels.cs
@@ -15,9 +15,18 @@ using Windows.Foundation;
namespace Microsoft.CmdPal.Core.ViewModels;
+///
+/// View models for parameters. This file has both the viewmodels for all the
+/// different run types, and the page view model.
+///
+
#pragma warning disable SA1402 // File may only contain a single type
#pragma warning disable SA1649 // File name should match first type name
+///
+/// Base class for all parameter run view models. This includes both labels and
+/// parameters that accept values.
+///
public abstract partial class ParameterRunViewModel : ExtensionObjectViewModel
{
private ExtensionObject _model;
@@ -68,6 +77,10 @@ public abstract partial class ParameterRunViewModel : ExtensionObjectViewModel
}
}
+///
+/// View model for label runs. This is a non-interactive run that just displays
+/// text.
+///
public partial class LabelRunViewModel : ParameterRunViewModel
{
private ExtensionObject _model;
@@ -84,10 +97,6 @@ public partial class LabelRunViewModel : ParameterRunViewModel
{
base.InitializeProperties();
- // if (IsInitialized)
- // {
- // return;
- // }
var labelRun = _model.Unsafe;
if (labelRun == null)
{
@@ -99,6 +108,24 @@ public partial class LabelRunViewModel : ParameterRunViewModel
Initialized = InitializedState.Initialized;
}
+
+ protected override void FetchProperty(string propertyName)
+ {
+ var model = this._model.Unsafe;
+ if (model is null)
+ {
+ return; // throw?
+ }
+
+ switch (propertyName)
+ {
+ case nameof(ILabelRun.Text):
+ Text = model.Text;
+ break;
+ }
+
+ UpdateProperty(propertyName);
+ }
}
public partial class ParameterValueRunViewModel : ParameterRunViewModel
@@ -119,10 +146,6 @@ public partial class ParameterValueRunViewModel : ParameterRunViewModel
{
base.InitializeProperties();
- // if (IsInitialized)
- // {
- // return;
- // }
var valueRun = _model.Unsafe;
if (valueRun == null)
{
@@ -178,10 +201,6 @@ public partial class StringParameterRunViewModel : ParameterValueRunViewModel
{
base.InitializeProperties();
- // if (IsInitialized)
- // {
- // return;
- // }
var stringRun = _model.Unsafe;
if (stringRun == null)
{
@@ -271,10 +290,6 @@ public partial class CommandParameterRunViewModel : ParameterValueRunViewModel,
{
base.InitializeProperties();
- // if (IsInitialized)
- // {
- // return;
- // }
var commandRun = _model.Unsafe;
if (commandRun == null)
{
@@ -390,15 +405,10 @@ public partial class ParametersPageViewModel : PageViewModel, IDisposable
IsInitialized &&
IsLoading == false &&
!NeedsAnyValues()
-
- // FilteredItems.Count == 0 &&
- // (!_isFetching) &&
;
private readonly Lock _listLock = new();
- public event TypedEventHandler? ItemsUpdated;
-
public ParametersPageViewModel(IParametersPage model, TaskScheduler scheduler, AppExtensionHost host)
: base(model, scheduler, host)
{
@@ -423,8 +433,6 @@ public partial class ParametersPageViewModel : PageViewModel, IDisposable
Command.SlowInitializeProperties();
FetchItems();
-
- // model.ItemsChanged += Model_ItemsChanged; // TODO!
}
//// Run on background thread, from InitializeAsync or Model_ItemsChanged
@@ -488,8 +496,7 @@ public partial class ParametersPageViewModel : PageViewModel, IDisposable
() =>
{
CoreLogger.LogDebug($"raising parameter items changed, {Items.Count} parameters");
- ItemsUpdated?.Invoke(this, EventArgs.Empty);
- OnPropertyChanged(nameof(Items)); // TODO! hack
+ OnPropertyChanged(nameof(Items)); // This _could_ be promoted to a dedicated ItemsUpdated, but meh
UpdateCommand();
WeakReferenceMessenger.Default.Send(new FocusSearchBoxMessage());
@@ -589,30 +596,12 @@ public partial class ParametersPageViewModel : PageViewModel, IDisposable
public void Dispose()
{
GC.SuppressFinalize(this);
-
- // TODO!
-
- // _cancellationTokenSource?.Cancel();
- // _cancellationTokenSource?.Dispose();
- // _cancellationTokenSource = null;
-
- // _fetchItemsCancellationTokenSource?.Cancel();
- // _fetchItemsCancellationTokenSource?.Dispose();
- // _fetchItemsCancellationTokenSource = null;
}
protected override void UnsafeCleanup()
{
base.UnsafeCleanup();
- // _cancellationTokenSource?.Cancel();
- // _fetchItemsCancellationTokenSource?.Cancel();
- var model = _model.Unsafe;
- if (model is not null)
- {
- // model.ItemsChanged -= Model_ItemsChanged;
- }
-
lock (_listLock)
{
foreach (var item in Items)
diff --git a/src/modules/cmdpal/doc/command-pal-anatomy/command-palette-anatomy.md b/src/modules/cmdpal/doc/command-pal-anatomy/command-palette-anatomy.md
index d46c5c8f8e..d730288268 100644
--- a/src/modules/cmdpal/doc/command-pal-anatomy/command-palette-anatomy.md
+++ b/src/modules/cmdpal/doc/command-pal-anatomy/command-palette-anatomy.md
@@ -60,7 +60,7 @@ A markdown page is a page inside of command palette that displays markdown conte
```csharp
interface IMarkdownPage requires IPage {
- String[] Bodies(); // TODO! should this be an IBody, so we can make it observable?
+ String[] Bodies();
IDetails Details();
IContextItem[] Commands { get; };
}
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/DraftB.cs b/src/modules/cmdpal/doc/initial-sdk-spec/drafts/DraftB.cs
similarity index 100%
rename from src/modules/cmdpal/doc/initial-sdk-spec/DraftB.cs
rename to src/modules/cmdpal/doc/initial-sdk-spec/drafts/DraftB.cs
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/ParametersPage-draft-D.md b/src/modules/cmdpal/doc/initial-sdk-spec/drafts/ParametersPage-draft-D.md
similarity index 100%
rename from src/modules/cmdpal/doc/initial-sdk-spec/ParametersPage-draft-D.md
rename to src/modules/cmdpal/doc/initial-sdk-spec/drafts/ParametersPage-draft-D.md
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/PlainRichSearch-draft-C.md b/src/modules/cmdpal/doc/initial-sdk-spec/drafts/PlainRichSearch-draft-C.md
similarity index 100%
rename from src/modules/cmdpal/doc/initial-sdk-spec/PlainRichSearch-draft-C.md
rename to src/modules/cmdpal/doc/initial-sdk-spec/drafts/PlainRichSearch-draft-C.md
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/PrefixSearch-draft-B.md b/src/modules/cmdpal/doc/initial-sdk-spec/drafts/PrefixSearch-draft-B.md
similarity index 100%
rename from src/modules/cmdpal/doc/initial-sdk-spec/PrefixSearch-draft-B.md
rename to src/modules/cmdpal/doc/initial-sdk-spec/drafts/PrefixSearch-draft-B.md
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/RichSearchBox-draft-A.md b/src/modules/cmdpal/doc/initial-sdk-spec/drafts/RichSearchBox-draft-A.md
similarity index 100%
rename from src/modules/cmdpal/doc/initial-sdk-spec/RichSearchBox-draft-A.md
rename to src/modules/cmdpal/doc/initial-sdk-spec/drafts/RichSearchBox-draft-A.md
diff --git a/src/modules/cmdpal/doc/initial-sdk-spec/initial-sdk-spec.md b/src/modules/cmdpal/doc/initial-sdk-spec/initial-sdk-spec.md
index 3dd4b21bcd..e5a9ea4963 100644
--- a/src/modules/cmdpal/doc/initial-sdk-spec/initial-sdk-spec.md
+++ b/src/modules/cmdpal/doc/initial-sdk-spec/initial-sdk-spec.md
@@ -1,7 +1,7 @@
---
author: Mike Griese
created on: 2024-07-19
-last updated: 2025-09-04
+last updated: 2025-11-21
issue id: n/a
---
@@ -2210,10 +2210,9 @@ Extensions will often want to provide rich search experiences for their users.
This addenda is broken into multiple draft specs currently. These represent
different approaches to the same goals.
-* **A**: [Rich Search Box](./RichSearchBox-draft-A.md)
-* **B**: [Prefix Search](./PrefixSearch-draft-B.md)
-* **C**: [ZWSP tokens](./PlainRichSearch-draft-C.md)
-
+* **A**: [Rich Search Box](./drafts/RichSearchBox-draft-A.md)
+* **B**: [Prefix Search](./drafts/PrefixSearch-draft-B.md)
+* **C**: [ZWSP tokens](./drafts/PlainRichSearch-draft-C.md)
### Nov 2025 status
diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/FilePickerParameterRun.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/FilePickerParameterRun.cs
index 7580725dde..a0d9085ebe 100644
--- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/FilePickerParameterRun.cs
+++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Parameters/FilePickerParameterRun.cs
@@ -9,11 +9,18 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit;
public partial class FilePickerParameterRun : CommandParameterRun
{
+ public static readonly IconInfo AddIcon = new("\uE710"); // Add
+
public StorageFile? File { get; private set; }
public override object? Value => File;
- public override string? DisplayText { get => File != null ? File.DisplayName : "Select a file"; }
+ public override string? DisplayText
+ {
+ get => File != null ?
+ File.Name :
+ Properties.Resources.FilePickerParameterRun_PlaceholderText;
+ }
public Action? SetupFilePicker { get; set; }
@@ -23,15 +30,12 @@ public partial class FilePickerParameterRun : CommandParameterRun
command.FileSelected += (s, file) =>
{
File = file;
-
- // Value = file != null ? file : (object?)null;
- // OnPropertyChanged(nameof(Value));
OnPropertyChanged(nameof(NeedsValue));
OnPropertyChanged(nameof(DisplayText));
};
command.RequestCustomizePicker += ConfigureFilePicker;
- PlaceholderText = "Select a file";
- Icon = new IconInfo("\uE710"); // Add
+ PlaceholderText = Properties.Resources.FilePickerParameterRun_PlaceholderText;
+ Icon = AddIcon;
Command = command;
}
@@ -42,9 +46,9 @@ public partial class FilePickerParameterRun : CommandParameterRun
private sealed partial class FilePickerCommand : InvokableCommand, IRequiresHostHwnd
{
- public override IconInfo Icon => new("\uE710"); // Add
+ public override IconInfo Icon => FilePickerParameterRun.AddIcon;
- public override string Name => "Pick a file";
+ public override string Name => Properties.Resources.FilePickerParameterRun_PlaceholderText;
public event EventHandler? FileSelected;
@@ -83,7 +87,3 @@ public partial class FilePickerParameterRun : CommandParameterRun
picker.FileTypeFilter.Add("*");
}
}
-
-#pragma warning restore SA1649 // File name should match first type name
-#pragma warning restore SA1402 // File may only contain a single type
-#nullable disable
diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs
index e2fd310a60..f2346022d3 100644
--- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs
+++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -114,6 +114,15 @@ namespace Microsoft.CommandPalette.Extensions.Toolkit.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Select a file.
+ ///
+ internal static string FilePickerParameterRun_PlaceholderText {
+ get {
+ return ResourceManager.GetString("FilePickerParameterRun_PlaceholderText", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Open.
///
diff --git a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.resx b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.resx
index 40fdb2c813..1dd299f188 100644
--- a/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.resx
+++ b/src/modules/cmdpal/extensionsdk/Microsoft.CommandPalette.Extensions.Toolkit/Properties/Resources.resx
@@ -157,4 +157,7 @@
Copy failed ({0}). Please try again.
{0} is the error message
+
+ Select a file
+
\ No newline at end of file