Commit Graph

4619 Commits

Author SHA1 Message Date
Dustin L. Howett
96f13a15de Use the actual process image instead of module filename to dedup session (#19415)
Apparently, `GetModuleFileNameW` returns exactly the path (or prefix, in
case of a DLL) passed to `CreateProcess` casing and all. Since we were
using it to generate the uniquing hash for Portable and Unpackaged
instances, this meant that `C:\Terminal\wt` and `C:\TeRmInAl\wt` were
considered different instances. Whoops.

Using `QueryFullProcessImageNameW` instead results in canonicalization.
Maybe the kernel does it. I don't know. What I do know is that it works
more correctly.

(`Query...` goes through the kernel, while `GetModule...` goes through
the loader. Interesting!)

Closes #19253

(cherry picked from commit 9d7ea77cc8)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgfkTus
Service-Version: 1.23
v1.23.12811.0
2025-10-08 17:53:51 -05:00
PankajBhojwani
5fa2718b2f Only do "keys" fixups for non-nested, non-iterable commands (#19408)
## Summary of the Pull Request
When we introduced action IDs, we separated "commands" from
"keybindings", and introduced fixup logic to rewrite the legacy-style
command blocks into the new version. However we don't do any ID logic
for nested and iterable commands, so make sure we don't inform the
loader for fixups in those cases.

## Validation Steps Performed
We no longer repeatedly attempt to fixup the settings file when we see a
`"keys"` entry in a nested/iterable command block

## PR Checklist
- [x] Closes #18736

(cherry picked from commit 04676bd31a)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgfjxUM
Service-Version: 1.23
2025-10-08 17:53:50 -05:00
Dustin L. Howett
e1f785cedd Remove the leading fire from the taskbar progress handler (#19403)
If the progress state hasn't been set for more than 200ms, we shouldn't
even bother flickering the old state.

This prevents applications from making the tab (and the taskbar icon)
flicker.

We were reviewing #19394 and decided that the _original_ behavior before
Leonard's throttling fix was somewhat unfortunate as well. An
application that sets an indeterminate state for 10ms and then clears it
shouldn't be able to make any part of the application flicker, fast _or_
slow.

Removing the leading fire time from the throttled function ensures that
it will only fire once every 200ms, and only with the state most
recently set. It will not debounce (so setting the progress every 150ms
will not prevent it from updating.)

Closes #19394

(cherry picked from commit 998ab586e1)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgfZOsM PVTI_lADOAF3p4s4Axadtzgfb1Nw
Service-Version: 1.23
2025-10-08 17:53:48 -05:00
Dustin L. Howett
b4270e545d Avoid reentrancy issues when dropping AppHost, even harder (#19395)
The previous fix in #19296 moved the _destruction_ of AppHost into the
tail end after we manipulate the `_windows` vector; however, it kept the
part which calls into XAML (`Close`) before the `erase`. I suspect that
we still had some reentrancy issues, where we cached an iterator before
the list was modified by another window close event.

That is:

```mermaid
sequenceDiagram
		Emperor->>Emperor: Close Window
		Emperor->>+AppHost: Close (a)
		AppHost->>XAML: Close
		XAML-->>Emperor: pump loop
		Emperor->>Emperor: Close Window
		Emperor->>+AppHost: Close (b)
		AppHost->>XAML: Close
		XAML-->>Emperor: pump loop
		AppHost->>-Emperor: Closed
		Emperor->>Emperor: erase(b)
		AppHost->>-Emperor: Closed
		Emperor->>Emperor: erase(a)
```

Moving the `Close()` to after the `erase` ensures that there are no
cached iterators that survive beyond XAML pumping the message loop.

Fixes 8d41ace3

(cherry picked from commit 5976de1600)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgfScoo
Service-Version: 1.23
2025-10-08 17:53:47 -05:00
Dustin L. Howett
a4c512f016 build: separate vpack creation from vpack publication (#19380)
This will allow us to publish vpacks without making the build fail
waiting for us to *merge* those vpacks into Windows. It also gives us
better control over when and where the vpack update gets merged.

(cherry picked from commit 6b428577b9)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgfLAk0
Service-Version: 1.23
v1.23.12681.0
2025-09-25 13:36:59 -05:00
Dustin L. Howett
77a1f5a9e7 VsDev: reject VS instances which do not actually contain devshell/devcmd (#19352)
Closes #19169

(cherry picked from commit 1926c4601c)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdI3eE
Service-Version: 1.23
2025-09-16 18:22:57 -05:00
Leonard Hecker
f486a5f7d4 Fix behavior of split-pane for existing windows (#19347)
Closes #18815

## Validation Steps Performed
* `wt -w 0 sp` splits the current tab 

(cherry picked from commit 0aee174e68)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgZrR-E
Service-Version: 1.23
2025-09-16 14:38:01 -05:00
John Cavanaugh
6dde7d3b78 Fix terminal profile schema to allow null in keybinding id (#19332)
Fixes the terminal profile jsonschema to allow for null in the id. This
is to match the current implementation when disabling a built in default
keybind.

(cherry picked from commit eb16eb26ab)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgemwL4
Service-Version: 1.23
2025-09-16 14:38:00 -05:00
Leonard Hecker
f18abeb62e 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

* In CMD run:
  ```batch
  FOR /L %N IN () DO @echo %time%
  ```
* Doesn't hang the UI 

SERVICE NOTES
This replays part of #19192 to make it compatible with throttled_func.

(cherry picked from commit dbf740cf2c)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdI2TQ PVTI_lADOAF3p4s4AxadtzgdSMv0
Service-Version: 1.23
2025-09-16 14:36:44 -05:00
Myungchul Keum
f1dad37670 Adjust "Dimidium" color scheme (#19303)
- Add Selection BG color
- Make Bright white brighter

## Summary of the Pull Request
Final tune for Dimidium color scheme before its release.

## References and Relevant Issues
#18563

## Detailed Description of the Pull Request / Additional comments
I made little change to Dimidium color scheme.

<img width="640" height="174" alt="cmp-lightness1c"
src="https://github.com/user-attachments/assets/2e4aa6ca-5864-4901-b323-2e2bb2bf00e8"
/>

![preview-terminal](https://github.com/user-attachments/assets/8a53c54d-942a-44a2-9ee7-9ff8a6d2dfab)

<img width="584" height="207" alt="image"
src="https://github.com/user-attachments/assets/b70b0759-7961-4f8f-aaa7-762fc48e425b"
/>

- Adjusted "Bright white" slightly brighter, hoping it can be
distinguished better from "White".
- Defined "Selection Background" color.

This will be the final tune for Dimidum color scheme.

(cherry picked from commit 8011f3e28c)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgeMuoU
Service-Version: 1.23
2025-09-05 14:10:24 -05:00
Leonard Hecker
5d97c3ae36 Avoid reentrancy issues when dropping AppHost (#19296)
tl;dr: ~Apphost() may pump the message loop.
That's no bueno. See comments in the diff.

Additionally, this PR enables `_assertIsMainThread` in
release to trace down mysterious crashes in those builds.

**BACKPORT NOTES**
I returned the `_assertIsMainThread` check to debug-only to remove the
assertion risk from production builds.

(cherry picked from commit 8d41ace320)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgebmmE
Service-Version: 1.23
2025-09-05 14:09:57 -05:00
Myungchul Keum
be596f16a3 Add CAM16 based color scheme "Dimidium" (#18563)
Okay, here is a challenge for the default color scheme.

This PR adds the [Dimidium] color scheme.

Refs #17818
Refs #18502

I adjusted colors using CAM16. I prioritized lightness so that all
colors (especially blue) has appropriate contrast with the background.

[Brief information about the Dimidium color scheme](https://github.com/dofuuz/dimidium/blob/main/README.md)

[Detailed explanation on crafting the color scheme with CAM16](https://dofuuz.github.io/color/2024/03/17/dimidium-terminal-color-scheme.html)

[Dimidium]: https://github.com/dofuuz/dimidium

(cherry picked from commit b6b8caba1e)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgebmKA
Service-Version: 1.23
2025-09-05 14:09:05 -05:00
Leonard Hecker
829176363c Fix CoreWindow being destroyed after handoff (#19298)
As per: https://github.com/microsoft/terminal/discussions/19280#discussioncomment-14237148

## Validation Steps Performed
* Launch wtd via handoff (spawn cmd, etc.)
* Shift+Click the tab bar + button to create a new window
* Close the initial window
* UI doesn't lock up 

(cherry picked from commit 7849b00cbd)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgeLN9w
Service-Version: 1.23
2025-09-05 13:58:36 -05:00
Dustin L. Howett
5438177a49 sb: add appId to the StoreBroker blobs (new AERO requirement) (#19290)
> _I am altering the deal. Pray I do not alter it further._
> -the AERO team, maybe

(cherry picked from commit bd14f69080)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgeF9fU
Service-Version: 1.23
2025-09-05 13:57:56 -05:00
Adaline Valentina Simonian
55cb7049ed fix: don't render bidi isolates LRI, RLI, FSI, PDI (#18942)
Skips rendering LRI, RLI, FSI, and PDI "glyphs" in the terminal.

Does not implement BIDI/RTL; that is out of scope, see #538. This is
just a hotfix to stop spamming the console with undesired character
printouts. Once BIDI support is implemented, this change will (maybe?)
no longer be necessary.

Fixes #16574.

(cherry picked from commit 59590fc665)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgeAsaA
Service-Version: 1.23
2025-09-05 13:57:55 -05:00
abutcher-gh
8701c4ffa0 TerminalControl: Support MinGW path translation style (C:\ -> C:/) (#18759)
## Summary of the Pull Request

Support drag-n-drop path translation in the style used by MinGW
programs. In particular for usage with shells like `ash` from busybox
(https://frippery.org/busybox/).

## Detailed Description of the Pull Request / Additional comments

Provides a new option "mingw" for "pathTranslationStyle".
Shown as "MinGW" with translation documented as `(C:\ -> C:/)` in the
UI.
As per the other modes, this translates `\` to `/` but stops there.
There is no prefix/drive translation.

## Validation Steps Performed

Run using `busybox ash` shell. Dragged directories and files from both
local disks and network shares onto terminal. All were appropriately
single quoted and had their backslashes replaced with forward slashes.
They were directly usable by the `ash` shell.

Language files containing the other options have been updated to include
the new one.

## PR Checklist
- [ ] Closes #xxx
- [ ] Tests added/passed
- [x] Documentation updated
   - [Docs PR #849](https://github.com/MicrosoftDocs/terminal/pull/849)
- [ ] Schema updated (if necessary)

Co-authored-by: Adam Butcher <adam@jessamine.uk>
(cherry picked from commit 6682bed311)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgeAsM0
Service-Version: 1.23
2025-09-05 13:57:53 -05:00
Dustin L. Howett
29dc1fdd9c build: remove the forced vpack submission; let us do it on our own time (#19271)
(cherry picked from commit 4f391c5e42)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgd_3-M
Service-Version: 1.23
v1.23.12371.0
2025-08-25 16:42:58 -05:00
Carlos Zamora
ca70e49cdf Add telemetry for settings UI traffic (#19156)
Adds a telemetry provider to the Terminal.Settings.Editor project as
well as new telemetry events to track traffic through the settings UI.
Specifically, the following events were added:
- `NavigatedToPage`: Event emitted when the user navigates to a page in
the settings UI
- Has a `PageId` parameter that includes the identifier of the page that
was navigated to
- (conditionally added when PageId = `page.editColorScheme`)
`SchemeName` parameter tracks the name of the color scheme that's being
edited
   - conditionally added when PageId = `page.extensions`:
- `ExtensionPackageCount`: The number of extension packages displayed
- `ProfilesModifiedCount`: The number of profiles modified by enabled
extensions
- `ProfilesAddedCount`: The number of profiles added by enabled
extensions
- `ColorSchemesAddedCount`: The number of color schemes added by enabled
extensions
   - conditionally added when PageId = `page.extensions.extensionView`:
- `FragmentSource`: The source of the fragment included in this
extension package
- `FragmentCount`: The number of fragments included in this extension
package
      - `Enabled`: The enabled status of the extension
- (conditionally added when PageID = `page.newTabMenu`) if the page is
representing a folder view
   - conditionally added when PageID = `page.profile.*`:
- `IsProfileDefaults`: if the modified profile is the profile.defaults
object
      - `ProfileGuid`: the guid of the profile that was navigated to
      - `ProfileSource`: the source of the profile that was navigated to
- conditionally added when PageID = `page.profile` (aka the base profile
page):
         - `Orphaned`: tracks if the profile was orphaned
         - `Hidden`: tracks if the profile is hidden
- (conditionally added when PageID = `page.profile.appearance`)
`HasBackgroundImage`: `if the profile has a background image defined`
- (conditionally added when PageID = `page.profile.appearance`)
`HasUnfocusedAppearance`: `if the profile has an unfocused appearance
defined`
- `AddNewProfile`: Event emitted when the user adds a new profile
`IsExtensionView` parameter tracks if the page is representing a view of
an extension
- Has a `Type` parameter that represents the type of the creation method
(i.e. empty profile, duplicate)
- `ResetApplicationState`: Event emitted when the user resets their
application state (via the UI)
- `ResetToDefaultSettings`: Event emitted when the user resets their
settings to their default value (via the UI)
- `OpenJson`: Event emitted when the user clicks the Open JSON button in
the settings UI
- Has a `SettingsTarget` parameter that represents the target settings
file (i.e. settings.json vs defaults.json)
- `CreateUnfocusedAppearance`: Event emitted when the user creates an
unfocused appearance for a profile
- `IsProfileDefaults`: if the modified profile is the profile.defaults
object
   - `ProfileGuid`: the guid of the profile that was navigated to
   - `ProfileSource`: the source of the profile that was navigated to
- `DeleteProfile`: Event emitted when the user deletes a profile
- also includes `ProfileGuid`, `ProfileSource`, `Orphaned` from the
`NavigatedToPage` section above

The page ids can be reused later as a serialized reference to the page.
We already use the one for the extensions page for the "new" badge.

(cherry picked from commit 7578209be5)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgc2p-8
Service-Version: 1.23
2025-08-25 11:23:24 -05:00
James Pack
ee9198c9a3 Ensure items is not null before checking its size so we dont crash (#19026)
Prevents a crash when no storage items are returned from a dropped path.

Terminal no longer crashes when a relative path is dragged and dropped
into the tool.

Closes #19015

(cherry picked from commit 7a9fb76955)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgd5l6I
Service-Version: 1.23
2025-08-21 17:45:35 -05:00
Leonard Hecker
eae5fbd83d Implement custom text context menus to fix crashes (#18854)
This works around a bug in WinUI where it creates a single context
menu/flyout for text elements per thread, not per `XamlRoot`, similar to
many other areas. Since the `XamlRoot` cannot change after creation,
this means that once you've opened the flyout, you're locked into that
window (= XAML root) forever. You can't open the flyout in another
window and once you've closed that window, you can't open it anywhere at
all.

Closes #18599

* Flies out right click in the
  * About dialog 
  * Search dialog 
  * Word delimiters setting 
  * Launch size setting 
* Across two windows 

(cherry picked from commit 076746a7a6)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgd5l-U
Service-Version: 1.23
2025-08-21 17:45:34 -05:00
Carlos Zamora
59ff525128 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.

(cherry picked from commit 7055b99acc)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdzQck
Service-Version: 1.23
2025-08-21 17:44:00 -05:00
Dustin L. Howett
ea8753f4ee 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.

(cherry picked from commit abaa9488d9)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdnCVw
Service-Version: 1.23
2025-08-21 17:43:59 -05:00
Leonard Hecker
829688d06a Fix a output marks performance regression (#19242)
An alternative approach for #18291. Improves perf by ~7%.

(cherry picked from commit 6b19d21845)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgdm49M
Service-Version: 1.23
2025-08-21 17:43:23 -05:00
Dustin L. Howett
a916704a6f 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.

(cherry picked from commit 0d23624fa9)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgdh6-Q
Service-Version: 1.23
2025-08-21 17:43:21 -05:00
Dustin L. Howett
9449d0b29e 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.

(cherry picked from commit 666a75bc70)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdVVHA
Service-Version: 1.23
2025-08-06 13:40:12 -05:00
Leonard Hecker
34cd29a0ce 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 

(cherry picked from commit 0a6394270e)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdR6bA
Service-Version: 1.23
2025-08-06 13:40:05 -05:00
MQY
4995af3dc1 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

(cherry picked from commit 88ab154f22)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdSbu4
Service-Version: 1.23
2025-08-06 13:40:04 -05:00
Leonard Hecker
ed022e89db Fix another VT input double-encoding issue (#19083)
Closes #17264
Closes https://github.com/microsoft/edit/issues/182

Long shot, but probably also...
Closes #18579
Closes #19082

(cherry picked from commit 97f0a06fbe)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdOWF0
Service-Version: 1.23
2025-08-01 17:43:43 -05:00
Dustin L. Howett
df34f34691 Fix overeager pre-delayed-EOL wrapping in AdaptDispatch (#18899)
AdaptDispatch has a TODO item indicating that we should *not* consider a
row wrapped until we write into the cell beyond it. We actually do have
that logic (it even refers to it!), but we still set the wrap flag when
we fill the final column.

We never removed it because it broke the old VT rendering-based ConPTY
implementation.

Now that VtEngine is gone, so can be this code and this strange
workaround for a problem nobody was quite sure what was.

This will fix, hopefully, the last of our exact line length write wrap
issues. tmux users can finally rejoice.

Closes #8976
Closes #15602

(cherry picked from commit 14993db1cb)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgaWx6A
Service-Version: 1.23
2025-08-01 17:43:42 -05:00
Leonard Hecker
9357281507 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 

(cherry picked from commit dfcc8f3c62)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdFoBM
Service-Version: 1.23
v1.23.12102.0
2025-07-29 14:05:50 -05:00
Quaylyn Rimer
edcd042913 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

(cherry picked from commit e818dafa6d)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdFukU
Service-Version: 1.23
2025-07-29 12:55:20 -05:00
Weichen Li
99c6de5bbe 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>
(cherry picked from commit 7d6e0c8b8e)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgdDF2w
Service-Version: 1.23
2025-07-29 12:55:18 -05:00
Carlos Zamora
7c593c5aac 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.

(cherry picked from commit 8c20d2052d)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgc0Dws
Service-Version: 1.23
2025-07-29 12:55:16 -05:00
Dustin L. Howett
8673cd2abb Re-enable web-source icons in Stable and Preview builds (#19137)
Disables a controversial part of #19044.

Refs #19075

(cherry picked from commit 7b841628df)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgcqq7A
Service-Version: 1.23
2025-07-29 12:55:14 -05:00
Leonard Hecker
72cad7f3e2 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...

(cherry picked from commit f2b30b4e1e)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgck4T0
Service-Version: 1.23
2025-07-29 12:55:12 -05:00
Dustin L. Howett
110e100384 version: fix the LCID in our VERSIONINFO, add descriptions to each file (#19114)
Closes #19106

(cherry picked from commit f14718f738)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgcbOIk
Service-Version: 1.23
2025-07-29 12:55:10 -05:00
Dustin L. Howett
b6c7410a33 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

(cherry picked from commit c4fbb58f69)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgcbMe0
Service-Version: 1.23
2025-07-29 12:54:50 -05:00
Dustin L. Howett
7d751a54bd 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

(cherry picked from commit 02f173d504)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgYvcQw
Service-Version: 1.23
2025-07-29 12:54:48 -05:00
Leonard Hecker
5aafc0172e 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 

(cherry picked from commit ac07afebcb)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgcO9T4
Service-Version: 1.23
2025-07-29 12:54:46 -05:00
Leonard Hecker
6157302fbd Move ConPTY handoff logic into WindowEmperor (#19088)
This changes the ConPTY handoff COM server from `REGCLS_SINGLEUSE`
to `REGCLS_MULTIPLEUSE`. The former causes a race condition, because
handoff runs concurrently with the creation of WinUI windows.
This can then result in the a window getting the wrong handoff.

It then moves the "root" of ConPTY handoff from `TerminalPage`
(WindowEmperor -> AppHost -> TerminalWindow -> TerminalPage)
into `WindowEmperor` (WindowEmperor).

Closes #19049

## Validation Steps Performed
* Launching cmd from the Start Menu shows a "Command Prompt" tab 
* Win+R -> `cmd` creates windows in the foreground 
* Win+R -> `cmd /c start /max cmd` creates a fullscreen tab 
  * This even works for multiple windows, unlike with Canary 
* Win+R -> `cmd /c start /min cmd` does not work 
  * It also doesn't work in Canary, so it's not a bug in this PR 

(cherry picked from commit a25d968fe0)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbpecU
Service-Version: 1.23
2025-07-29 12:54:45 -05:00
Leonard Hecker
8fc82582bf Preserve the cursor row during Clear Buffer (#18976)
Introduces an ABI change to the ConptyClearPseudoConsole signal.
Otherwise, we have to make it so that the API call always retains
the row the cursor is on, but I feel like that makes it worse.

Closes #18732
Closes #18878

## Validation Steps Performed
* Launch `ConsoleMonitor.exe`
* Create some text above & below the cursor in PowerShell
* Clear Buffer
* Buffer is cleared except for the cursor row 
* ...same in ConPTY 

(cherry picked from commit fc0a06c3b6)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzga5M7E
Service-Version: 1.23
2025-07-29 12:54:42 -05:00
Carlos Zamora
a8b4243a63 Fix crash when closing multiple panes simultaneously (#19023)
Fixes a crash when multiple panes were closed simultaneously (i.e. using
broadcast input).

The root cause of this crash was that we would get a null pointer
exception when trying to access a member/function off of a null
`_content`. This is because `Pane::_CloseChild()` would always pass over
the content from the non-closed pane and attempt to hook everything up
to it.

The fix was to operate similarly to `Pane::Close()` and raise a `Closed`
event and return early. Since there's no alternative content to attach
to, might as well just close the entire pane. This propagates up the
stack of listeners to update the UI appropriately and close the parent
pane and eventually the entire tab, if necessary.
 
Closes #18071
Closes #17432

## Validation Steps Performed
1. Open 2 panes
2. Use broadcast input to send "exit" to both panes
3.  Terminal doesn't crash and the tab closes gracefully

(cherry picked from commit 6bf315a4c9)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgb3LNk
Service-Version: 1.23
2025-07-29 12:54:39 -05:00
Dustin L. Howett
db9774c17e Try to get the client name during DefTerm handoff (#19014)
(cherry picked from commit cf95460a26)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbO1u8
Service-Version: 1.23
v1.23.11752.0
2025-06-24 16:48:11 -05:00
Carlos Zamora
38f28e80d0 Display a warning if SUI is unable to write to the settings file (#19027)
Adds logic to display a warning popup if the settings.json is marked as
read-only and we try to write to the settings.json file. Previously,
this scenario would crash, which definitely isn't right. However, a
simple fix of "not-crashing" wouldn't feel right either.

This leverages the existing infrastructure to display a warning dialog
when we failed to write to the settings file. The main annoyance here is
that that popup dialog is located in `TerminalWindow` and is normally
triggered from a failed `SettingsLoadEventArgs`. To get around this,
`CascadiaSettings::WriteSettingsToDisk()` now returns a boolean to
signal if the write was successful; whereas if it fails, a warning is
added to the settings object. If we fail to write to disk, the function
will return false and we'll raise an event with the settings' warnings
to `TerminalPage` which passes it along to `TerminalWindow`.

Additionally, this uses `IVectorView<SettingsLoadWarnings>` as opposed
to `IVector<SettingsLoadWarnings>` throughout the relevant code. It's
more correct as the list of warnings shouldn't be mutable and the
warnings from the `CascadiaSettings` object are retrieved in that
format.

-  Using SUI, save settings when the settings.json is set to read-only

Closes #18913

(cherry picked from commit 218c9fbe3e)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgb3QSk
Service-Version: 1.23
2025-06-24 16:48:10 -05:00
Carlos Zamora
820b10fd2b Add branding and unpackaged metadata to a few telemetry events (#18926)
## Summary of the Pull Request
Adds branding and distribution metadata to the following telemetry
events:
- ActionDispatched (branding only)
- JsonSettingsChanged
- UISettingsChanged
- SessionBecameInteractive

Also removes the settings logger output from the debugger and some
leftover debugging functions.
Adds a label to the XSettingsChanged settings value to make it easier to
read on the backend.

(cherry picked from commit b50eaa19e0)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgaj8x4
Service-Version: 1.23
2025-06-24 10:14:02 -05:00
James Holderness
2801e9af50 Indicate support for OSC 52 in the DA1 report (#19034)
## Summary of the Pull Request
Some applications that make use of the `OSC 52` clipboard sequence will
only do so if they can be certain that the terminal actually has that
functionality. Indicating our support for `OSC 52` in the `DA1` report
will give them an easy way to detect that.

## References and Relevant Issues
`OSC 52` support was added to Windows Terminal in issue #5823, and to
ConHost in issue #18949.

## Detailed Description of the Pull Request / Additional comments
Support for writing to the clipboard is indicated in the primary device
attributes report by the extension parameter `52`. This is obviously not
a standard DEC extension, but it's one that's been agreed upon by a
number of modern terminals. The extension is only reported when writing
to the clipboard is actually permitted (Windows Terminal has an option
to disable that).

## Validation Steps Performed
I've updated the Device Attributes unit test to check that we're
reporting extension `52` when clipboard access is enabled, and not
reporting it when disabled.

## PR Checklist
- [x] Closes #19017
- [x] Tests added/passed

(cherry picked from commit 00ee88400a)
Service-Card-Id: PVTI_lADOAF3p4s4Axadtzgbpe4g
Service-Version: 1.23
2025-06-24 10:07:51 -05:00
Dustin L. Howett
dcdc21381c build: adjust for changes in the Az.Accounts module (#19020)
(cherry picked from commit 4cf492e36b)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbYQ_c
Service-Version: 1.23
2025-06-24 10:07:50 -05:00
Leonard Hecker
dd2ebc5c09 Fix support for the Tencent QQPinyin IME (#19046)
(cherry picked from commit b47fdfc7e6)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbjZ8A
Service-Version: 1.23
2025-06-17 15:41:03 -05:00
Dustin L. Howett
dc3bb80c16 Gently rework icon and background image validation (#19044)
Right now, image validation accepts web-sourced icons (boo) and rejects
images whose paths begin with `\\?\`. In addition, it will warn the user
for things out of their control like images set by fragments.

This pull request adds a filesystem path validator (which accepts images
with fully-qualified paths and UNC paths), makes the URI validator
reject any web-origin URIs (only `file` and `ms-*` are allowable), and
suppresses warnings for any images that were not _directly_ set by the
user.

Since we want to avoid using fragment images that fail validation, we no
longer `Clear` each image property but rather set it to the blank or
fallback value.

This does **not** actually add support for images at absolute paths
beginning with `\\?\`. Such images are still rejected by `Image` and the
other XAML fixtures we use for images. It's better than a warning,
though.

Closes #18703
Closes #14143
Refs #18710
Refs #5204
Related to #18922 (http-origin icons will be blank everywhere and not
just the jump list ;))

(cherry picked from commit f28bb42979)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbjZlM
Service-Version: 1.23
2025-06-17 15:41:02 -05:00
Carlos Zamora
9b80830d56 Manually focus panes after swapping them (#19024)
(cherry picked from commit bd7e3179ff)
Service-Card-Id: PVTI_lADOAF3p4s4AxadtzgbeR2A
Service-Version: 1.23
2025-06-17 15:41:01 -05:00