Skip to content

Remove WinRT composition (inheritance) from PaletteItem#19132

Merged
DHowett merged 9 commits intomainfrom
dev/duhowett/stop-the-palette-item-insanity
Jul 16, 2025
Merged

Remove WinRT composition (inheritance) from PaletteItem#19132
DHowett merged 9 commits intomainfrom
dev/duhowett/stop-the-palette-item-insanity

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
DHowett added a commit that referenced this pull request Jul 19, 2025
In #19132, we introduced caching for BasePaletteItem::ResolvedIcon as a
late optimization.

We actually can't cache those, because they're UI elements, with parents
and relationships and all. When you filter a list with icons and the
list elements change physical position, they're assigned new templates--
and new parents.

Fixes e7939bb
DHowett added a commit that referenced this pull request Jul 21, 2025
In #19132, we introduced caching for BasePaletteItem::ResolvedIcon as a
late optimization.

We actually can't cache those, because they're UI elements, with parents
and relationships and all. When you filter a list with icons and the
list elements change physical position, they're assigned new templates--
and new parents.

Fixes e7939bb

Co-authored-by: Eric Nelson <[email protected]>
DHowett added a commit that referenced this pull request Jul 28, 2025
The bulk of this work is changing `Command::Name` (and its descendants
like `GenerateName`) to support looking up names in English and in the
local language.

When matching a "palette item" with a "subtitle" (a new field introduced
to store the English command name when the current language is not
English), the weight of the subtitle is used only if it is greater than
the weight of the name. This ensures that we do not penalize or
over-promote results that contain similar Latin letters in both fields.

Refs #19130, #19131, #19132, #19165
Closes #7039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants