4680 Commits

Author SHA1 Message Date
Carlos Zamora
7055b99acc
Fix names and types of a few telemetry events (#19257)
Fixes a few issues with some telemetry events:
- The macro is organized as such: `TraceLoggingX(value, argName,
[argDescription])`. A few args had a description set on the spot where
the name should be. I added a name for a few of these.
- `TraceLoggingBool` --> `TraceLoggingInt32` for `themeChoice` (we
shouldn't be casting the evaluated int as a bool; it loses some of the
data we care about)
- improves the description for `themeChoice` to include information
about the legacy values

Checked through all our telemetry events and all of the args have a
proper name set. We tend to use `TraceLoggingValue` too which
automatically figures out the type that's being used, so that's also
handled.
2025-08-19 19:13:58 +00:00
Dustin L. Howett
837e86c18c
Bust TerminalSettingsCache down to a plain old C++ class (#19254) 2025-08-19 09:35:27 -05:00
Leonard Hecker
e97388cb27
Fix SnapOnOutput not always snapping (#19247)
`IsOn` is the blinker on/off state, which `IsVisible`
is the actual cursor visibility on/off state.

## Validation Steps Performed
* Run bash/zsh in WSL
* (Repeatedly) Quickly scroll right and press A-Z
* Scrolls to the left 
2025-08-15 20:34:29 +00:00
Carlos Zamora
1b2aad6504
Add SSH folder to NTM for dynamic SSH profiles (#19239)
Automatically generates an "SSH" folder in the new tab menu that
contains all profiles generated by the SSH profile generator. This
folder is created if the SSH generator created some profiles and the
folder hasn't been created before. Detecting if the folder was generated
is done via the new `bool ApplicationState::SSHFolderGenerated`. The
logic is similar to `SettingsLoader::DisableDeletedProfiles()`.

Found a bug on new tab menu's folder inlining feature where we were
counting the number of raw entries to determine whether to inline or
not. Since the folder only contained the match profiles entry, this bug
made it so that the profile entries would always be inlined. The fix was
very simple: count the number of _resolved_ entries instead of the raw
entries. This can be pulled into its own PR and serviced, if desired.

## References and Relevant Issues
#18814 
#14042 

## Validation Steps Performed
 Existing users get an SSH folder if profiles were generated

## PR Checklist
Closes #19043
2025-08-13 15:43:27 -07:00
Dustin L. Howett
abaa9488d9
Switch to the @Local view on TerminalDependencies (#19243)
Due to an unexpected decision on behalf of the Azure Artifacts folks,
the default view for a feed with upstream sources reports all packages,
even if they are not actually populated into the feed.

This results in (uncontrolled) 401 errors whenever a new package appears
upstream, because the feed tells our users and our build system that it
is available, but fails when the download actually begins because it is
not allowed to "write" the upstream version to the feed.
2025-08-13 16:27:01 +00:00
Leonard Hecker
6b19d21845
Fix a output marks performance regression (#19242)
An alternative approach for #18291. Improves perf by ~7%.
2025-08-13 18:10:18 +02:00
Dustin L. Howett
0d23624fa9
Use a new API to propagate foreground state to child processes (#19192)
Windows 11 uses some additional signals to determine what the user cares
about and give it a bit of a QoS boost. One of those signals is whether
it is associated with a window that is in the foreground or which has
input focus.

Association today takes two forms:
- Process has a window which is in the foreground or which has input
  focus
- Process has a *parent* that meets the above criterion.

Console applications that are spawned "inside" terminal by handoff do
not fall into either bucket. They don't have a window. Their parent is
`dllhost` or `explorer`, who is definitely not in focus.

We are piloting a new API that allows us to associate those processes
with Terminal's window.

When Terminal is in focus, it will attach every process from the active
tab to its QoS group. This means that whatever is running in that tab
is put into the "foreground" bucket, and everything running in other
background tabs is not.

When Terminal is out of focus, it attaches every process to its QoS
group. This ensures that they all go into the "background" bucket
together, following the window.
2025-08-13 00:09:50 +00:00
Leonard Hecker
8a05910e3c
Implement snap-on-input/output for conhost (#17453)
This extends our current behavior in conhost to scroll to the
cursor position when typing. This is especially relevant in WSL,
where this won't happen at all, otherwise.

Closes #18073
Closes MSFT:49027268
2025-08-12 12:22:33 -07:00
Windows Console Service Bot
a0f7b332fa
Localization Updates - multi line paste - 08/09/2025 03:04:06 (#19230) 2025-08-12 10:39:45 -05:00
Leonard Hecker
0c064905b3
Revert "ConPTY: Emit DSR CPR on resize (#19089)" (#19237)
This reverts commit c55aca508beadebc080b0c76b7322de80a294968
because it is unaware of the VT state and may inject the DSR CPR
while e.g. a DCS is going on.

Reopens #18725
2025-08-11 17:48:35 +00:00
Leonard Hecker
e2f3e53064
Don't trim bracketed pastes (#19067)
* Moves clipboard writing from `ControlCore` to `TerminalPage`.
  This requires adding a bunch of event types and logic.
  This is technically not needed anymore after changing the
  direction of this PR, but I kept it because it's better.
* Add a `WarnAboutMultiLinePaste` enum to differentiate between
  "paste without warning always/never/if-bracketed-paste-disabled".

Closes #13014
Closes https://github.com/microsoft/edit/issues/279

## Validation Steps Performed
* Launch Microsoft Edit and copy text with a trailing newline
* Paste it with Ctrl+Shift+V
* It's pasted as it was copied 
* Changing the setting to "always" always warns 

Co-authored-by: Dustin L. Howett <duhowett@microsoft.com>
2025-08-08 20:53:42 +00:00
Leonard Hecker
5b41f14660
Disable WIN32IM on shutdown (#19229)
Closes #19153

## Validation Steps Performed
I tried reproducing the issue on Windows 10 and couldn't.
I'm not sure what I did wrong. But I tested it under a
debugger with VtPipeTerm and it wrote the sequences to stdout.
2025-08-08 19:48:52 +02:00
Windows Console Service Bot
514da89b63
Localization Updates - main - 08/06/2025 03:04:16 (#19219) 2025-08-07 07:30:29 -05:00
Dustin L. Howett
6c2f38c732
Profiles Editor: make sure we notify the IconPath property (#19223)
There were instances where changing the icon or resetting it did not
result in the text box changing.

Regressed in #19143
2025-08-06 16:09:47 -07:00
Leonard Hecker
6fb70eb510
Throttle incoming handoffs so WinUI can layout them (#19220)
As explained in the diff itself.

Closes #13136

## Validation Steps Performed
* In conhost, with `wtd` not running, execute:
  ```pwsh
1..10 | % { wt -w 1 nt --title=$_ pwsh -NoExit -Command "Get-Date
-Format HH:mm:ss.ffff" }
  ```
* Every tab is up and running immediately 
2025-08-06 18:55:29 +00:00
Leonard Hecker
c55aca508b
ConPTY: Emit DSR CPR on resize (#19089)
This will help terminals with a reflow behavior unlike
the one implemented in ConPTY, such as VS Code.

Closes #18725

## Validation Steps Performed
* Tested under a debugger 
* Use PowerShell 5 and reflow lines in the ConPTY buffer until they're
  pushed outside the top viewport. Then type something in the prompt.
  Cursor is in a consistent position, even if slightly off. 
2025-08-06 13:06:44 +02:00
Dustin L. Howett
666a75bc70
Fix hot reload for icon, bell, close on exit; regressed in #16172 (#19217)
In #16172, we removed the propagation of the profile down into the
Terminal Pane Content.

It was holding on to the profile from the _old_ settings model (😱).

This also broke background image hot reload.
2025-08-05 21:18:43 +00:00
Dustin L. Howett
c0f9a198c6
Rewrite media resource handling (relative path icons, web URLs) (#19143)
This pull request broadly rewrites how we handle all media resources in
the Terminal settings model.

## What is a media resource?

A media resource is any JSON property that refers to a file on disk,
including:

- `icon` on profile
- `backgroundImage` on profile (appearance)
- `pixelShaderPath` and `pixelShaderImagePath` on profile (appearance)
- `icon` on command and the new tab menu entries

The last two bullet points were newly discovered during the course of
this work.

## Description of Changes

In every place the settings model used to store a string for a media
path, it now stores an `IMediaResource`.

A media resource must be _resolved_ before it's used. When resolved, it
can report whether it is `Ok` (found, valid) and what the final
normalized path was.

This allows the settings model to apply some new behaviors.

One of those new behaviors is resolving media paths _relative to the
JSON file that referred to them._ This means fragments and user settings
can now contain _local_ images, pixel shaders and more and refer to them
by filename.

Relative path support requires us to track the path from which every
media resource "container" was read[^2]. For "big" objects like Profile,
we track it directly in the object and for each layer. This means that
fragments **updating** a profile pass their relative base path into the
mix. For some of the entries such as those in `newTabMenu`, we just wing
it (#19191). For everything that is recursively owned by a parent that
has a path (say each Command inside an ActionMap), we pass it in from
the parent during media resolution.

During resolution, we now track _exactly which layer_ an icon,
background image, or pixel shader path came from and read the "base
path" from only that layer. The base path is not inherited.

Another new behavior is in the handling of web and other URLs.

Canonical and a few other WSL distributors had to resort to web URLs for
icons because we did not support loading them from the package. Julia
tried to use `ms-appx://JuliaPackageNameHere/path/to/icon` for the same
reason. Neither was intended, and of the two the second _should_ have
worked but never could[^1].

For both `http(s?)` URLs and `ms-appx://` URLs which specify a package
name, we now strip everything except the filename. As an example...

If my fragment specifies `https://example.net/assets/foo.ico`, and my
fragment was loaded from `C:\Fragments`, Terminal will look *only* at
`C:\Fragments\foo.ico`.

This works today for Julia (they put their icon in the fragment folder
hoping that one day we would support this.) It will require some work
from existing WSL distributors.

I'm told that this is similar to how XML schema documents work.

Now, icons are special. They support _Emoji_ and _Segoe Icons_. This PR
adds an early pass to avoid resolving anything that looks like an
emoji.

This PR intentionally expands the heuristic definition of an emoji. It
used to only cover 1-2 code unit emoji, which prevented the use of any
emoji more complicated than "man in business suite levitating."

An icon path will now be considered an emoji or symbol icon if it is
composed of a single grapheme cluster (as measured by ICU.)

This is not perfect, as it errs on the side of allowing too many
things... but each of those things is technically a single grapheme
cluster and is a perfectly legal FontIcon ;)

Profile icons are _even more special_ than icons. They have an
additional fallback behavior which we had to preserve. When a profile
icon fails validation, or is expressly set to `null`, we fall back to
the EXE specified in the command line.

Because we do this fallback during resolution, _and the icon may be
inherited by any higher profile,_ we can only resolve it against the
commandline at the same level as the failed or nulled icon.

Therefore, if you specify `icon: null` in your `defaults` profile, it
will only ever resolve to `cmd.exe` for any profile that inherits it
(unless you change `defaults.commandline`).

This change expands support for the magic keywords `desktopWallpaper`
and `none` to all media paths (yes, even `pixelShaderPath`... but also,
`pixelShaderImagePath`!) It also expands support for _environment
variables_ to all of those places. Yes, we had like forty different
handlers for different types of string path. They are now uniform.

## Resource Validation

Media resources which are not found are "rejected". If a rejected
resource lives in _user_ settings, we will generate a warning and
display it.

In the future, we could detect this in the Settings UI and display a
warning inline.

## Surprises

I learned that `Windows.Foundation.Uri` parses file paths into `file://`
URIs, but does not offer you a way to get the original file path back
out. If you pass `C:\hello world`, _`Uri.Path`_ will return
`/C:/hello%20world`. I kid you not.

As a workaround, we bail out of URL handling if the `:` is too close to
the start (indicating an absolute file path).

## Testing

I added a narow test hook in the media resource resolver, which is
removed completely by link-time code generation. It is a real joy.

The test cases are all new and hopefully comprehensive.

Closes #19075
Closes #16295
Closes #10359 (except it doesn't support fonts)
Supersedes #16949 somewhat (`WT_SETTINGS_DIR`)
Refs #18679

Refs #19215 (future work)
Refs #19201 (future work)
Refs #19191 (future work)

[^1]: Handling a `ms-appx` path requires us to _add their package to our
dependency graph_ for the entire duration during which the resource will
be used. For us, that could be any time (like opening the command
palette for the first time!)

[^2]: We don't bother tracking where the defaults came from, because we
control everything about them.
2025-08-05 20:47:50 +00:00
Dustin L. Howett
a258d7d3df
Fix title being stuck after toggling "showTerminalTitleInTitlebar" (#19212)
We already have the logic to fall back when the setting is disabled, we
just _also_ had a terrible eventing architecture and never used the
`Title` getter that was smart enough to figure it out.

This pull request somewhat disentangles the mess that is title handling.
For example, TerminalPage had a facility to get its current title! It
was never used. Once we started using it, it wouldn't work for the
Settings page... because it only read the title out of the active
control.

Closes #12871
Closes #19139 (superseded)

---------

Co-authored-by: techypanda <jonathan_wright@hotmail.com>
2025-08-04 17:46:55 -07:00
Leonard Hecker
0a6394270e
Fix WSL PATH corruption & potential use-after-free (#19211)
Closes #19152

## Validation Steps Performed
* Set `PATH` on a linux profile
* `PATH` isn't messed up inside WSL 
2025-08-04 22:42:26 +00:00
MQY
88ab154f22
Prevent cursor repositioning during mouse selection (#19182)
- Modify the cursor repositioning logic to check if a selection is in
progress
- Only reposition the cursor when the mouse is used for positioning, not
during selection operations

Closes #19181
2025-08-04 21:09:08 +00:00
Leonard Hecker
dbf740cf2c
Extend lead/trail edge support for throttled_func (#19210)
You can now create throttled functions which trigger both on the leading
and trailing edge. This was then also ported to `ThrottledFunc` for
`DispatcherQueue`s and used for title/taskbar updates.

Closes #19188

## Validation Steps Performed
* In CMD run:
  ```batch
  FOR /L %N IN () DO @echo %time%
  ```
* Doesn't hang the UI 
2025-08-04 20:25:37 +02:00
Leonard Hecker
9ab7cf312f
Remove dependency on .NET 6 and Framework 4.8 (#19199)
* .NET 6 is EOL
* Framework 4.7.2 comes by default with VS, but 4.8 doesn't
2025-08-04 13:09:22 -05:00
zwJimRaynor
a5d916f5d3
Update the version of WinUI required by the Canary appinstaller (#19048) 2025-07-29 14:12:13 -05:00
Leonard Hecker
dfcc8f3c62
Fix use-after-free when disabling the ASB (#19186)
Closes #17515

## Validation Steps Performed
* Disable the ASB while there's a pending cooked read
* Type some text
* No crash 
2025-07-29 13:48:33 -05:00
Quaylyn Rimer
e818dafa6d
Fix scrollbar marks not appearing until scroll or resize (#19185)
This PR resolves an issue where scrollbar marks created by shell
integration sequences (OSC 133 FTCS, OSC 1337 iTerm2, and OSC 9;12
ConEmu sequences) were not visible on the scrollbar until the user
manually scrolled.

The problem was that while marks were being created in the buffer
correctly, the UI wasn't being notified to refresh the scrollbar
display. The fix adds a new NotifyShellIntegrationMark() method to the
ITerminalApi interface that calls _NotifyScrollEvent() to trigger
scrollbar refresh, and updates all shell integration sequence handlers
in AdaptDispatch to call this notification method after creating marks.
This ensures scrollbar marks appear immediately when shell integration
sequences are processed, bringing feature parity between auto-detected
and shell-integration-based marks.

Closes #19104
2025-07-29 12:20:47 -05:00
Leonard Hecker
0c3002c1b9
Remove ColorHelper (#19187)
Most of `ColorHelper` was unused and one of them had UB.

Related to #19183

## Validation Steps Performed
* Set a custom tabRow theme color
  Split button looks similar to before 
* White/black FG color decision for colored
  tabs is similar to before 
2025-07-29 11:35:48 -05:00
Weichen Li
7d6e0c8b8e
Fix WSLENV environment variable duplication in ConptyConnection (#19167)
This PR fixes issue #7130 where WT_SESSION and WT_PROFILE_ID environment
variables were being duplicated in the WSLENV environment variable when
multiple terminal sessions were created.

The previous implementation always appended WT_SESSION:WT_PROFILE_ID: to
WSLENV without checking if these variables already existed, causing
duplication.

Closes #7130

Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
2025-07-29 01:47:06 +00:00
Dustin L. Howett
65788d9099
Filter Command Palette in English in addition to local language (#19166)
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
2025-07-28 19:08:48 +00:00
Windows Console Service Bot
671440206c
Localization Updates - main - 07/25/2025 16:15:20 (#19174)
scroll to zoom + scroll to do opacity
2025-07-25 16:52:27 +00:00
Dustin L. Howett
482980c336
Command: realize resource-key names when they are requested, not at load (#19165)
Right now, when a Command's name is `{"key": "ResourceName"}` we resolve
the resource immediately at load time. That prevents us from looking it
up later in another language if we need to.

This pull request introduces an intermediate representation for command
names which is be resolved during `Command::Name`.

Refs #7039
2025-07-24 12:53:09 -05:00
Carlos Zamora
7ab5978b58
Partially revert the key chord styling in actions page (#19164)
Reverts most of the styling changes done in #19001 to the key chords
displayed in the SUI's Actions page. The `CornerRadius` was kept at the
updated value of `ControlCornerRadius` for consistency.

The only other changes in #19001 that were kept for this page include:
- `EditButtonIconSize`: 15 --> 14
- `AccentEditButtonStyle` > `Padding`: 3 --> 4
- Command name's `FontWeight` reduced to `Normal`
- `AddNewButton` > `Margin` added (set to `0,12,0,0` to provide spacing
between breadcrumb header and button)
2025-07-23 18:21:23 -05:00
Niels Laute
48b796f102
[UX] Settings UI refinements (#19001)
This PR is a (first) design pass on the Terminal settings UX to bring
consistency and alignment with the rest of the OS and other settings
surfaces.

High-level changes include:
- Using WinUI brushes vs. UWP/OS brushes. [See brushes overview in the
WinUI 3 Gallery:](winui3gallery://item/Color).
- Updating pixel values for margins, fontsizes, paddings etc. using
units of 4. See [the design guidelines for more
info](https://learn.microsoft.com/en-us/windows/apps/design/basics/content-basics).
- Adding rounded corners on various elements to be consistent with the
Windows 11 look and feel (using the ControlCornerRadius or
OverlayCornerRadius WinUI resources as much as possible).
- Decreasing the page header titles / breadcrumb so it feels a bit less
cramped.
- Fixing a bug where the title of the page was not aligned with the
content when resizing the window (note to self: should fix this in
PowerToys too):
- Ensuring the subheader texts for settings categories are inline with
the rest of the OS (== decreasing the fontsize).

---------

Co-authored-by: Carlos Zamora <carlos.zamora@microsoft.com>
2025-07-23 10:07:11 -07:00
Dustin L. Howett
f22295ef2c
Merge TabBase+TerminalTab into just Tab (#19136)
This removes the need to construct two objects per tab (TabBase, Actual
Tab) and the other overhead inherent in WinRT composition-based
inheritance.

Important renames:

- `GetTerminalTabImpl` -> `GetTabImpl`

This pull request does not rename `TerminalTabStatus`; that is left as
work for a future PR.

Closes #17529
2025-07-22 08:04:19 -07:00
HO-COOH
cb0289fff2
Center text in the Default Terminal dropdown (#19072)
This is a small UI fix so that we center the default terminal application ComboBox text.
2025-07-21 17:35:09 -05:00
Carlos Zamora
8c20d2052d
Add telemetry for new tab menu traffic (#19142)
## Summary of the Pull Request
Adds new telemetry events to track traffic through the new tab menu.
Specifically, the following events are added:
- `NewTabMenuDefaultButtonClicked`: Event emitted when the default
button from the new tab split button is invoked
- `NewTabMenuOpened`: Event emitted when the new tab menu is opened
- `NewTabMenuClosed`: Event emitted when the new tab menu is closed
- `NewTabMenuItemClicked`: Event emitted when an item from the new tab
menu is invoked
- Has an `ItemType` parameter that can be set to `Settings`,
`CommandPalette`, `About, `Profile`, `Action`
- Has a `TabCount` parameter that keeps tracked of the number of tabs in
the window before changing the state
- `NewTabMenuCreatedNewTerminalSession`: Event emitted when a new
terminal was created via the new tab menu
- Has a `SessionType` parameter that can be set to `ElevatedWindow`,
`Window`, `Pane`, `Tab`
- Instead of `TabCount`, has a `NewTabCount` that keeps track of the
_new_ number of tabs after the session has been created
- `NewTabMenuItemElevateSubmenuItemClicked`: Event emitted when the
elevate submenu item from the new tab menu is invoked

## Validation Steps Performed
Used TVPP to see events generated from interacting with the new tab
menu.
2025-07-21 15:33:52 -07:00
Paulina Kalicka
452fa87937
feat: add option to adjust opacity with Ctrl+Shift+scroll (#19151)
## Summary of the Pull Request
This PR introduces an experimental setting that allows to toggle opacity
changes with scrolling.

## References and Relevant Issues
#3793

## Detailed Description of the Pull Request / Additional comments
By default, holding Ctrl + Shift while scrolling changes the terminal's
opacity. This PR adds an option to disable that behavior.

## Validation Steps Performed
I built the project locally and verified that the new feature works as
intended.

## PR Checklist
- [x] Resolves
https://github.com/microsoft/terminal/issues/3793#issuecomment-3085684640
- [x] Tests ~~added/~~ passed
- [x] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it here:
https://github.com/MicrosoftDocs/terminal/pull/873
- [X] Schema updated (if necessary)
2025-07-21 15:24:46 -07:00
Dustin L. Howett
3979e82c2b
Remove IconElement caching from PaletteItem (#19149)
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 e7939bb4e

Co-authored-by: Eric Nelson <e82.eric@gmail.com>
2025-07-21 15:11:26 -07:00
Dustin L. Howett
fedf7b3b6c
Undo the damage done to FilteredCommand in #17330 (#19148)
PR #17330 changed FilteredCommand so that FilteredTask could derive from
it. It also **did not** implement FilteredTask as a derived class.

We've been carrying around the debt of a decision we un-decided for like
a year.
2025-07-18 17:09:12 -07:00
Paulina Kalicka
a04e410a39
feat: add option to enable zoom with ctrl + scroll (#19127)
This PR adds a new global setting `scrollToZoom` that allows users to
enable font zooming with scrolling. When disabled, **this setting
prevents accidental font size changes** that can occur when users scroll
while holding the Ctrl key.

Note: after disabling this setting, users may still change font size
using `Ctrl+` and `Ctrl-` keyboard shortcuts. Other Ctrl+Scroll
functionality (like transparency adjustments) remains unaffected.

## Validation Steps Performed

- Verified the setting can be toggled in the Settings UI (Interaction
tab)
- Confirmed that when disabled, holding Ctrl and scrolling no longer
changes font size
- Validated that the setting persists across terminal restarts

---

Note: I used the existing `FocusFollowMouse` setting as a reference for
implementing this.

Closes #11710
Closes #3793
Closes #11906
Closes #3990
2025-07-17 22:09:52 +00:00
Dustin L. Howett
7b841628df
Re-enable web-source icons in Stable and Preview builds (#19137)
Disables a controversial part of #19044.

Refs #19075
2025-07-17 02:13:12 +00:00
Dustin L. Howett
5b63e24c73
ci: turn on SARIF reporting unconditionally for check-spelling (#19135)
The logic currently present occasionally fails to enable reporting for
some PRs.
2025-07-16 15:10:06 -07:00
Dustin L. Howett
e7939bb4e3
Remove WinRT composition (inheritance) from PaletteItem (#19132)
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
- [x] Tab Switcher still live-updates when it is in use
- [x] Command searching still works
- [x] Commandline mode still works
- [x] Suggestions control still works
2025-07-16 15:09:17 -05:00
Dustin L. Howett
bdf44322f8
Expose a library's Resource Loader, allow a user to "subset" it (#19131)
This pull request elevates ScopedResourceLoader to the API surface of
LibraryResources, which will allow any library resource consumer to
directly interact with its resource loader.

One of those new interactions is to make a sub-context with a specific
narrowed-down qualifier. Like this:

```c++
auto englishOnlyLoader = GetLibraryResourceLoader().WithQualifier(L"language", L"en-us");
/* auto foo = */ englishOnlyLoader.GetLocalizedString(USES_RESOURCE(L"AppName"));
```
2025-07-14 22:43:48 +00:00
Leonard Hecker
f2b30b4e1e
Improve TSF color filtering logic (re: QQPinyin) (#19117)
If an IME provider sets both `crText` and `crBk` we should respect this,
but the previous logic would incorrectly assert for `crLine !=
TF_CT_NONE`.

## Validation Steps Performed
 I'm not aware which TSF even sets these colors in a
way that's compatible with us in the first place...
2025-07-14 17:19:10 -05:00
Dustin L. Howett
0cbb6b1f2f
Rewrite HighlightedTextControl and remove HighlightedText (#19130)
`HighlightedTextControl` is a XAML user control that contains a text
block and takes vector of `HighlightedText`. `HighlightedText` uses
tuples `(string, boolean)`. Allocating an entire object to store a
string and an integer felt like a waste, especially when we were doing
it thousands of times for the command palette _and just to pass them
into another object that stores a string and a few more integers
(`Run`)._

The new `HighlightedTextControl` is a standard templated control, and
supports styling of both the inner text block and of the highlighted
runs.

It no longer takes a `HighlightedText`, but rather a standard string and
a set of runs (tuple `(int start, int end)`); these can be stored more
efficiently, and this change moves the construction of text and runs
directly into `HighlightedTextControl` itself as an implementation
detail rather than an API contract.

### XAML Properties

- `Text`: the string to highlight
- `HighlightedRuns`: a vector of `(start, end)` pairs, indicating which
  regions are intended to be highlighted. Can be empty (which indicates
  there is no highlight and that the entire string is styled normally.)
- `TextBlockStyle`: the `Style` applied to the inner text block;
  optional; allows consumers to change how both normal and highlighted
  text looks.
- `HighlightedRunStyle`: a `Style` applied only to the highlighted runs;
  optional; allows consumers to change how highlighted text looks. If
  left NULL, highlighted runs will be bold.

`HighlightedRunStyle` is a little bodgy. It only applies to `Run`
objects (which is fine, and XAML somewhat supports), but since `Run` is
not a `FrameworkElement`, it _doesn't actually have a `Style` member._
We need to crack open the style and apply it manually, entry by entry.
`FontWeight` is special because XAML is a special little flower.
2025-07-14 20:40:20 +00:00
Dustin L. Howett
f14718f738
version: fix the LCID in our VERSIONINFO, add descriptions to each file (#19114)
Closes #19106
2025-07-09 16:36:13 -05:00
Dustin L. Howett
c4fbb58f69
During session save, use the profile's GUID rather than its Name (#19113)
This will prevent Terminal from erroneously selecting a hidden (deleted,
disabled or otherwise) profile of the same name during restoration and
subsequently using the wrong settings.

I am not certain why we used the name at all!

Closes #19105
2025-07-09 15:42:23 -05:00
Dustin L. Howett
02f173d504
Include the hash of the SID in the Window Class and Mutant (#19109)
Right now, we do not use a sufficiently unique name to disambiguate
Terminal instances running on the same desktop.

Mutexes (mutants) are named objects that live in the user's session,
under `Sessions\1\BaseNamedObjects` (for the local desktop session).
When multiple users are logged into the same session--such as with "Run
as different user"--they share a local BaseNamedObjects namespace. Ugh.

We cannot use [`CreatePrivateNamespace`] as it requires a boundary
descriptor, and the only boundary descriptors supported by the current
API are based on package identity. I also fear that
`CreatePrivateNamespace` is subject to a race condition with
`OpenPrivateNamespace`; Create will not Open an existing one, so we
would need to back off and retry either opening or creating. Yuck.

After this commit, we will hash the user's SID into the name of both the
window class and the mutant, right after the path hash (if running
unpackaged).

Closes #18704

[`CreatePrivateNamespace`]:
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createprivatenamespacea
2025-07-08 17:27:21 -05:00
Leonard Hecker
ac07afebcb
Fix a crash during commandline handoff (#19096)
The crash occurs because WinRT `abort()`s when it encounters
a `std::wstring_view` without null-terminator.

Closes #19093

## Validation Steps Performed
* Set `wtd` as the default terminal
* Launch `cmd`
* Launch `wtd`
* 2 windows 
2025-07-03 22:19:12 +00:00