Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5de29f9
rudimentary support for dynamic lists
zadjii Dec 13, 2024
0012c16
that was important
zadjii Dec 13, 2024
642d98d
damn it's done? Just like that?
zadjii Dec 13, 2024
09b63d6
actually just renaming and moving files around
zadjii Dec 13, 2024
275b0af
The dumbest possible 'but it works'
zadjii Dec 13, 2024
9bf4d2e
show a loading bar while we're loading up
zadjii Dec 13, 2024
ad9635c
progressively filter the results we already had
zadjii Dec 13, 2024
2016bcb
add a couple commands that missed TRA
zadjii Dec 13, 2024
113a6c6
Merge branch 'dev/migrie/f/main-apps' into dev/migrie/f/TRA-dynamic-l…
zadjii Dec 13, 2024
2cc5399
Wire up the buttons, and ctrl+k
zadjii Dec 13, 2024
2d032b1
Merge remote-tracking branch 'origin/main' into dev/migrie/f/TRA-dyna…
zadjii Dec 13, 2024
038ac0a
Merge branch 'dev/migrie/f/TRA-dynamic-lists' into dev/migrie/f/ux-nits
zadjii Dec 13, 2024
bd6140d
Yea that was a bit of a footgun huh
zadjii Dec 13, 2024
c96c93b
Add window icons to WW. Fix an IconBox bug.
zadjii Dec 14, 2024
a3f4d55
marginally better at selecting the first element
zadjii Dec 14, 2024
1a3c740
mostly notes
zadjii Dec 14, 2024
3f9c9b8
iconography and string touch-ups
zadjii Dec 14, 2024
cd9dbc5
yea missed that that's obvious
zadjii Dec 14, 2024
a407eb5
stash: couple stability improvements
zadjii Dec 15, 2024
c91adc2
Oh IEnumerable is so much better
zadjii Dec 15, 2024
956c798
ANCESTOR: ItemsChanged might come in on a BG thread, watch out
zadjii Dec 16, 2024
abbaefb
Merge branch 'main' into dev/migrie/f/TRA-dynamic-lists
zadjii Dec 16, 2024
34282b3
Stop the .Count()
zadjii Dec 16, 2024
b217728
Merge remote-tracking branch 'origin/main' into dev/migrie/f/TRA-dyna…
zadjii Dec 16, 2024
b9d8b7e
Merge branch 'dev/migrie/f/TRA-dynamic-lists' into dev/migrie/f/ux-ni…
zadjii Dec 16, 2024
70773b0
Another collection of nits:
zadjii Dec 14, 2024
cd57e30
"Cherry-pick" from 0b789adae, dev/migrie/f/stash-forms-should-submit
zadjii Dec 16, 2024
a8bbc70
Merge remote-tracking branch 'origin/main' into dev/migrie/f/ux-nits-pr
zadjii Dec 16, 2024
8ff54d4
Update src/modules/cmdpal/Exts/Microsoft.CmdPal.Ext.Shell/Properties/…
zadjii-msft Dec 16, 2024
0b00cdc
Dismiss after launching an app
zadjii Dec 16, 2024
7d98ac7
Merge branch 'dev/migrie/f/ux-nits-pr' of https://github.com/zadjii-m…
zadjii Dec 16, 2024
8f21516
messages
zadjii Dec 16, 2024
08f7977
make private
zadjii Dec 18, 2024
f56693c
Merge remote-tracking branch 'origin/main' into dev/migrie/f/ux-nits-pr
zadjii Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ internal async Task Launch()
public override CommandResult Invoke()
{
_ = Launch();
return CommandResult.GoHome();
return CommandResult.Dismiss();
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: should we clean up the file name -- 'AppAction' made sense in Wox land as Wox has actions, but since we are aiming for command palette vibes, probably should be AppCommand.cs

Copy link
Owner Author

Choose a reason for hiding this comment

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

We need to make a pass over a lot more than just this file - definitely better to do in a separate PR

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ShellListPage(SettingsManager settingsManager)
Icon = new("\uE756");
Id = "com.microsoft.cmdpal.shell";
Name = Resources.cmd_plugin_name;
PlaceholderText = Resources.list_placeholder_text;
_helper = new(settingsManager);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@
<value>All entries using the Windows Terminal force the Windows Terminal as the console host regardless of the system settings</value>
</data>
<data name="shell_command_name" xml:space="preserve">
<value>Execute shell commands</value>
<value>Run commands</value>
</data>
<data name="generic_run_command" xml:space="preserve">
<value>Run</value>
</data>
<data name="settings_page_name" xml:space="preserve">
<value>Settings</value>
</data>
<data name="list_placeholder_text" xml:space="preserve">
<value>Type the name of a command to run</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,27 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.CmdPal.Ext.WindowsServices.Helpers;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
using Microsoft.UI.Windowing;

namespace Microsoft.CmdPal.Ext.WindowsServices;

internal sealed partial class ServicesListPage : DynamicListPage
{
public ServicesListPage()
{
Icon = new(string.Empty);
Icon = new("%windir%\\system32\\filemgmt.dll");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know why this line gives me a lot of joy.

Name = "Windows Services";
}

public override void UpdateSearchText(string oldSearch, string newSearch)
{
RaiseItemsChanged(0);
}
public override void UpdateSearchText(string oldSearch, string newSearch) => RaiseItemsChanged(0);

public override IListItem[] GetItems()
{
ListItem[] items = ServiceHelper.Search(SearchText).ToArray();
var items = ServiceHelper.Search(SearchText).ToArray();

return items;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.CmdPal.UI.ViewModels;
public partial class CommandItemViewModel : ExtensionObjectViewModel
{
private readonly ExtensionObject<ICommandItem> _commandItemModel = new(null);
private CommandContextItemViewModel? _defaultCommandContextItem;

// These are properties that are "observable" from the extension object
// itself, in the sense that they get raised by PropChanged events from the
Expand Down Expand Up @@ -40,21 +41,10 @@ public List<CommandContextItemViewModel> AllCommands
{
get
{
var command = _commandItemModel.Unsafe?.Command;
var model = new CommandContextItem(command!)
{
};
CommandContextItemViewModel defaultCommand = new(model, PageContext)
{
Name = Name,
Title = Name,
Subtitle = Subtitle,
Icon = Icon,

// TODO this probably should just be a CommandContextItemViewModel(CommandItemViewModel) ctor, or a copy ctor or whatever
};

var l = new List<CommandContextItemViewModel> { defaultCommand };
List<CommandContextItemViewModel> l = _defaultCommandContextItem == null ?
[_defaultCommandContextItem] :
new();

l.AddRange(MoreCommands);
return l;
}
Expand All @@ -76,15 +66,25 @@ public override void InitializeProperties()
}

Command = new(model.Command);

Name = model.Command?.Name ?? string.Empty;
Title = model.Title;
Subtitle = model.Subtitle;
Icon = model.Icon;
MoreCommands = model.MoreCommands
.Where(contextItem => contextItem is ICommandContextItem)
.Select(contextItem => (contextItem as ICommandContextItem)!)
.Select(contextItem => new CommandContextItemViewModel(contextItem, PageContext))
.ToList();

var listIcon = model.Icon;
Icon = !string.IsNullOrEmpty(listIcon.Icon) ?
listIcon :
Command.Unsafe!.Icon;

var more = model.MoreCommands;
if (more != null)
{
MoreCommands = more
.Where(contextItem => contextItem is ICommandContextItem)
.Select(contextItem => (contextItem as ICommandContextItem)!)
.Select(contextItem => new CommandContextItemViewModel(contextItem, PageContext))
.ToList();
}

// Here, we're already theoretically in the async context, so we can
// use Initialize straight up
Expand All @@ -93,6 +93,17 @@ public override void InitializeProperties()
contextItem.InitializeProperties();
});

_defaultCommandContextItem = new(new CommandContextItem(model.Command!), PageContext)
{
Name = Name,
Title = Name,
Subtitle = Subtitle,
Icon = Icon,
Command = new(model.Command),

// TODO this probably should just be a CommandContextItemViewModel(CommandItemViewModel) ctor, or a copy ctor or whatever
};

model.PropChanged += Model_PropChanged;

// _initialized = true;
Expand Down Expand Up @@ -130,7 +141,8 @@ protected virtual void FetchProperty(string propertyName)
this.Subtitle = model.Subtitle;
break;
case nameof(Icon):
this.Icon = model.Icon;
var listIcon = model.Icon;
Icon = !string.IsNullOrEmpty(listIcon.Icon) ? listIcon : Command.Unsafe!.Icon;
break;

// TODO! MoreCommands array, which needs to also raise HasMoreCommands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using Microsoft.CmdPal.Ext.Apps.Programs;
using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.Extensions.Helpers;
Expand All @@ -29,7 +30,8 @@ public partial class MainListPage : DynamicListPage
public MainListPage(IServiceProvider serviceProvider)
{
Name = "Command Palette";

Icon = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory.ToString(), "Assets\\StoreLogo.scale-200.png"));
ShowDetails = true;
_serviceProvider = serviceProvider;

var tlcManager = _serviceProvider.GetService<TopLevelCommandManager>()!;
Expand Down Expand Up @@ -66,6 +68,7 @@ public override IListItem[] GetItems()
public override void UpdateSearchText(string oldSearch, string newSearch)
{
/* handle changes to the filter text here */
Debug.WriteLine($"UpdateSearchText '{oldSearch}' -> '{newSearch}'");

foreach (var command in _commands)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public void HandleSubmit(IAdaptiveActionElement action, JsonObject inputs)
if (model != null)
{
var result = model.SubmitForm(inputString);

// TODO Handle results
WeakReferenceMessenger.Default.Send<HandleCommandResultMessage>(new(new(result)));
}
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

namespace Microsoft.CmdPal.UI.ViewModels.Messages;

// Want to know what a record is? here is a TLDR
// https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record
public record NavigateToDetailsMessage(ListItemViewModel ListItem)
/// <summary>
/// Used to perform a list item's secondary command when the user presses ctrl+enter in the search box
/// </summary>
public record ActivateSecondaryCommandMessage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this just a to do?

{
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CmdPal.UI.ViewModels.BuiltinCommands;

namespace Microsoft.CmdPal.UI.ViewModels.Messages;

public record DismissMessage()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.CmdPal.Extensions;
using Microsoft.CmdPal.UI.ViewModels.Models;

namespace Microsoft.CmdPal.UI.ViewModels.Messages;

public record HandleCommandResultMessage(ExtensionObject<ICommandResult> Result)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Microsoft.CmdPal.UI.ViewModels.Messages;

/// <summary>
/// Used to perform a list item's secondary command when the user presses ctrl+enter in the search box
/// </summary>
public record OpenContextMenuMessage
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the purposes of all the messages? Looks like all the bodies are empty -- what do we use these for?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh I guess this is referred to elsewhere -- not sure exactly what for

Copy link
Collaborator

Choose a reason for hiding this comment

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

@joadoumie these represent the objects of the messages themselves that get passed to the MVVM Toolkit Messenger we use to do communication across components/layers of the application. Many of them don't have extra parameters, like this one, and are just a signal that some event has happened. In this case, it's a request to open the context menu. It's coming from the keyboard handlers in the searchbox (iirc) in order to trigger opening the menu in the ActionBar as they're two independent UI controls now.

}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Somewhere in here seeing the shortcut getting trimmed:
image

Copy link
Owner Author

Choose a reason for hiding this comment

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

woah what
image
@niels9001 any ideas?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, we might have a few hardcoded heights. Will tackle that in a separate PR once this gets in.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</ResourceDictionary>
</UserControl.Resources>

<Grid Padding="8" ColumnSpacing="8">
<Grid Padding="8" ColumnSpacing="8" MinHeight="56">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -78,10 +78,10 @@
Height="40"
Padding="8,4,8,4"
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
Tapped="PrimaryButton_Tapped"
Visibility="{x:Bind ViewModel.PrimaryAction.Name, Converter={StaticResource StringNotEmptyToVisibilityConverter}, Mode=OneWay}">

<StackPanel Orientation="Horizontal" Spacing="8">
<!-- <FontIcon Glyph="&#xEA3A;" /> -->
<cpcontrols:IconBox
Width="16"
Height="16"
Expand All @@ -108,10 +108,9 @@
Height="40"
Padding="8,4,8,4"
x:Load="{x:Bind IsLoaded, Mode=OneWay}"
Tapped="SecondaryButton_Tapped"
Visibility="{x:Bind ViewModel.HasSecondaryCommand, Mode=OneWay}">
<StackPanel Orientation="Horizontal" Spacing="8">
<!-- <FontIcon Glyph="&#xEA3A;" /> -->

<cpcontrols:IconBox
Width="16"
Height="16"
Expand Down
Loading