Skip to content

Remove WinRT composition (inheritance) from PaletteItem #19132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 16, 2025

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Jul 15, 2025

Right now, we construct two objects for every palette item: the
derived type and the base type. It's unnnecessary.

This pull request replaces WinRT composition with a good old-fashioned
enum ThingType.

This also removes many of our palette items from our IDL. The only ones
that are necessary to expose via our WinRT API surface are the ones that
are used in XAML documents.

I originally removed the caching for Command.Name, but it turns out
that something calls Name roughly 17 times per command and having
the generator running that often is a serious waste of CPU.

Validation Steps

  • Tab Switcher still live-updates when it is in use
  • Command searching still works
  • Commandline mode still works
  • Suggestions control still works
DHowett added 5 commits July 15, 2025 17:16
Right now, we construct **two objects** for every palette item: the
derived type and the base type. It's unnnecessary.

This also removes many of our palette items from our IDL. The only ones
that are necessary to expose via our WinRT API surface are the ones that
are used in XAML documents.
@DHowett
Copy link
Member Author

DHowett commented Jul 15, 2025

The tests are probably exploded rigth now.

@DHowett DHowett marked this pull request as draft July 15, 2025 22:58
@DHowett
Copy link
Member Author

DHowett commented Jul 15, 2025

Yes, we should cache the name. Name is called roughly 100,000,000 times when you open the command palette (holy shit)

@DHowett
Copy link
Member Author

DHowett commented Jul 15, 2025

(Specifically: it is called 2386 times for a small repertoire of only 110 or so commands...)

@DHowett DHowett marked this pull request as ready for review July 15, 2025 23:26
@DHowett DHowett requested review from carlos-zamora and lhecker and removed request for carlos-zamora July 16, 2025 15:32
{
return NestedItemTemplate();
}
__fallthrough;
Copy link
Member

Choose a reason for hiding this comment

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

[[fallthrough]], I believe. But why not just do a break instead?

Comment on lines 16 to 19
const auto icon = Microsoft::Terminal::UI::IconPathConverter::IconWUX(static_cast<T*>(this)->Icon());
icon.Width(16);
icon.Height(16);
return icon;
Copy link
Member

Choose a reason for hiding this comment

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

Is this also called hundreds of times? It looks immutable at first glance.

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Image

Comment on lines +106 to +108
if (auto tab = _tab.get())
{
if (auto terminalTab = tab.try_as<winrt::TerminalApp::TerminalTab>())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (auto tab = _tab.get())
{
if (auto terminalTab = tab.try_as<winrt::TerminalApp::TerminalTab>())
if (const auto tab = _tab.get())
{
if (const auto terminalTab = tab.try_as<winrt::TerminalApp::TerminalTab>())
@DHowett DHowett merged commit e7939bb into main Jul 16, 2025
19 checks passed
@DHowett DHowett deleted the dev/duhowett/stop-the-palette-item-insanity branch July 16, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants