Commit Graph

564 Commits

Author SHA1 Message Date
Leonard Hecker
cbc857bdf7 Decommit memory on cls (#20889)
While the changes are complex, they are straightforward,
except for one bit: The complete refactor of `ScrollRows`.

The reason it became necessary is that moving the viewport to the top
during `ClearScrollback` may wrap the source range across the buffer's
end. VT/conhost scrolling keeps src/dst ranges within logical bounds,
where choosing the copy direction is sufficient.

For instance: Imagine we have physical rows `A B C` and I call
`ScrollRows(2, 2, -2)` then this should result in `C, A, C`.
However, the old logic would produce `C C C`, because it copies
`2 (C) -> 0 (A)` and then `0 (A) -> 1 (B)`. By the time the 2nd copy
runs, the contents of row A have already been overwritten by C.

This is the classic difference between a `memmove` and a `scroll array`.
`ScrollRows` has never been an actual scroll function. The name stems
more from `ScrollConsoleScreenBuffer`, which turn refers to historical
bit blit scrolling.

Part of #18290

## Validation Steps Performed
* `cls` = memory use 📉
2026-11-07 00:21:25 +01:00
Leonard Hecker
ff3fb7b423 Conhost font sizing for AtlasEngine (#19905)
This PR does 3 things:
* Provide a way to combine AtlasEngine's support for font sizes with
  GdiEngine's use of cell sizes (it doesn't support font sizes at all)
* Fix the DIP roundtrip issues in conhost due to float -> int casts
* Fix the roundtrip issues due to desired font -> actual font
  -> desired font feedback loops; it now uses the desired font
  permanently for settings, DPI changes, etc

Breaking changes:
* `GetCurrentConsoleFont(Ex)` now report the desired (configured)
  font settings instead of the actual ones. This better matches
  modern behavior with font fallback etc. I expect this to break
  some applications, although I cannot imagine why it would.
* TrueType fonts won't store a width value in the registry anymore

Totally works. Just trust me bro.

This PR doesn't yet include the logic to hook it up to Windows Terminal.
It's just for that new inbox conhost renderer. Huh what? Who said that!

## Validation Steps Performed
* Settings store X=0 for TrueType font sizes ⚠️ (intentional!)
* Ctrl+Scroll font sizing tracks GdiEngine relatively closely ✅
* Probably? Fixes all of the conhost font size roundtrip issues ✅
2026-10-30 00:45:03 +01:00
Dustin L. Howett
1046205b04 Rewrite HwndTerminal to build on ControlInteractivity and -Core (#20812)
This pull request replaces all of HwndTerminal, which used to be a thin
layer on top of TerminalCore.lib, with a new implementation that relies
on the Interactivity and Core layers in TerminalControl.lib.

We used to spend a lot of time reimplementing interactivity components
for HwndTerminal or--if I'm being honest--letting it rot and never
giving it the improvements the rest of the application got.

Among those improvements:

- Automatic scrolling finally works (as of #20710)
- Selection works the same way as it does in Terminal proper (starts on
  the half-cell, uses an exclusive range)
- Consistent double- and triple-click behavior without having to
  reimplement word- and line-wise expansion
- Scroll wheel behavior
- Shift+Click to suppress VT mouse mode
- Scrolling and focus handling move down into the Win32 message loop
  from WPF

This pull request seeks to get HwndTerminal back to where it was (plus
the things we naturally get from switching over). In the future, we can
more easily add:

- title reporting (surprised we didn't have this)
- clickable URLs
- automatic copy-to-clipboard
- right-click menu support
- DTTERM window manipulation
- shaders
- Ctrl+Scroll zoom

Implementation Details
----------------------

The WPF control is backed by a flat "C" API, which takes in a `void*`
and does some stuff to it. We call that a `PTERM`. References to "Flat
C" in this commit body describe the body of work below WPF.

X-macros are used to fill out the definintions of every C API and bridge
it to a properly typed C++ member function. Ugh. No more crap where we
split the implementation into half C export and half C++ member.

ControlCore and ControlInteractivity require something that looks like
TerminalSettings. The WPF control only supports the most basic settings,
in `struct TerminalTheme`, and so I've added a bridge WinRT type to
adapt TerminalTheme to
IXxxSettings. Most of the values it returns are our "defaults", and some
of them are overridden.

Core requires an `ITerminalConnection`, but the WPF API uses a pair of
"write output" and "send input" callbacks. Flat C provides an
ITerminalConnection that bridges those callbacks. It does not
communicate connection state or anything else. Resizing is probably
going to be a problem.

Core requires a dispatcher queue to ensure that some operations happen
on the UI thread. I have stubbed out an implementation of
`IDispatcherQueue` that calls a couple function pointers with a context
pointer; the WPF code hooks up to that and bridges it into the WPF
dispatcher. Yes, the Core's dispatcher queue _is_ the WPF main UI
thread. It has to be, otherwise we'll explode the first time we try to
update the scroll bar. Prep work was done in #20713.

To make the above easier, I removed all use of DispatcherTimer (see
#20711). Attempts to use it will almost certainly cause the WPF control
to implode.

Core needed to be taught a couple tricks to start up targeting an HWND
instead of a composition handle. See #20722 for more.

Refs #20710
Refs #20711
Refs #20713
Refs #20722

Required #20721
Refs #20745

Related to #6999
2026-10-20 18:53:23 -05:00
Dustin L. Howett
3ba2464e0c build: move code format to a GH workflow, emit rich errors (#20822)
This allows us to emit GitHub-native error messages which will appear in
the Files view. See screenshots below.
2026-10-19 16:44:45 -05:00
Leonard Hecker
5951f69654 Fix several ScrollConsoleScreenBuffer ConPTY issues (#20774)
- Fixed #20772 by fully committing to lazy DA1 capabilities path via
  `VtIo::SetDeviceAttributes`. It accidentally only did so with enabled
  cursor inheritance before.
- Fixed #20773 by fixing the source/destination rectangle alignment
  in the non-DECCRA path of `ScrollConsoleScreenBuffer`.

Also closes MSFT-64450466.

As a drive-by:
- Fixed the DECCRA path not restoring cursor attributes in conhost.
- Reduced memory use in the non-DECCRA path.
- Added a `IL/DL` sequence fast-pass for `ScrollConsoleScreenBuffer`.
- Fixed a broken bounds checks in `Read/WriteConsoleOutputWImplHelper`.
- Fixed the TraceLogging definition for `SMALL_RECT`.
2026-10-08 01:16:58 +02:00
盗天叔叔
f1ddcbe4df Fix broken links (#20699) 2026-09-29 14:43:13 +00:00
Leonard Hecker
0626dc1457 Fix 5s lags when using OSC 52 clipboard copy (#20728)
Hilarious repro: `printf "\e]0;A\a\e]52;c;Qg==\a"`

This issue is exactly what happens when you Ctrl+X in a clean file in
msedit and it freezes Windows Terminal. It's because it puts a "•" in
the title and copies the text.

It triggers a title and clipboard change in the same frame which causes
the UI and VT thread to deadlock trying to get the console lock.
2026-09-28 15:11:15 +00:00
Carlos Zamora
c0c72e95f3 Update profile subpages (#20336)
## Summary of the Pull Request
Updates the individual profile pages to include:
- icons + settings expanders/cards
- `SettingsResetButton`: a new "reset value" button
- a new "unfocused appearance" subpage with its own preview (similar to
default appearance)

## Detailed Description of the Pull Request / Additional comments
- `IInheritableViewModel`: interface exposing `HasSetting()`,
`ClearSetting()`, and `SettingOverrideSource()`
- To help ensure that these are updated properly, a static assert was
added that checks the number of profile settings. This is intended to be
a tripwire to ensure future changes also update the reset buttons.
- `Profiles_UnfocusedAppearance.h/cpp/idl/xaml`: the new unfocused
appearance page
- added helper functions `FormatAccessibleName()` and
`ColorToHexString()` to deduplicate code that creates accessible names
for SettingsExpanders across the entire SUI

## Validation Steps Performed
- [X] settings search + deep link navigation
- [X] "reset value" button
- [X] accessibility pass with Narrator

## PR Checklist
Related to #17000

---------

Co-authored-by: Dustin L. Howett <dustin@howett.net>
2026-09-15 17:55:42 -05:00
Leonard Hecker
d3b8ed33e6 Introduce an AI Usage Policy (#20654)
After quite a lot of deliberation today, I think this is how I would
personally define it. I tried to keep it short and open to AI-use,
but particularly restrictive to autonomous AI-use (= typically slop).
2026-09-11 02:24:53 +02:00
Dustin L. Howett
b9587a0510 Add a comment explaining the basics to preschoolers (#20632) 2026-09-02 00:07:10 +02:00
James Holderness
e9a72b69ce Preserve the DRCS font when performing a soft reset (#20607)
When the terminal performs a soft reset (`DECSTR`), we reinitialize the
`TerminalOutput` class to reset the character set mappings, but in the
process we lose the DRCS state that tracks whether there is a soft font
available. A similar problem occurs when restoring the cursor state with
the `DECRC` sequence. This PR updates the `TerminalOutput` class's soft
reset and restore implementations to fix these issues.

## References and Relevant Issues

The original DRCS support was added in PR #10011. The soft reset of the
character sets was changed in PR #16547, but as far as I can tell this
would have already been broken in the initial implementation.

## Detailed Description of the Pull Request / Additional comments

I realized I could simplify the issue, by first reimplementing the
`SoftReset` method as a call to `Restore` with a fresh instance of the
class (although initialized with the active GR translation state, since
we don't want to lose that either). It then becomes the responsibility
of the `Restore` method to preserve the DRCS state after it replaces
everything else.

We can't just preserve the `_drcsId` and `_drcsTranslationTable` fields
though. We also need to handle the case where the DRCS font is replacing
one of the restored G-sets. But this can be achieved just by calling one
of the `SetDrcsDesignation` methods, exactly as if the font was being
newly downloaded.

## Validation Steps Performed

I've manually verified that the test case in #20581 is now working as
expected in OpenConsole. I've also added unit tests that confirm that
`DECSTR` resets the character sets as expected, and `DECRC` restores the
character sets as expected, but they also both preserve the soft font if
one has been defined.

Closes #20581
2026-09-01 20:22:08 +00:00
Dan Fiedler
c7572cde0c Pin GitHub Actions to full-length commit SHAs (#20559) 2026-08-25 22:29:37 +00:00
Carlos Zamora
86d15aef08 Port SettingsCard/Expander from WCT and update SUI to use it (#20232)
## Summary of the Pull Request
Ports the `SettingsCard` and `SettingsExpander` from Windows Community
Toolkit to the TerminalSettingsEditor project:
- Windows Community Toolkit code:
https://github.com/CommunityToolkit/Windows/tree/main/components/SettingsControls/src
- `SettingsCard` and `SettingsExpander` were ported over and reuse our
macros to reduce boilerplate.
- A few deviations exist since WCT targets WinUI 3 but TSE uses WinUI 2
(i.e. chevron rendering)
- One deviation specific to TSE: `Description` is applied as
`AutomationProperties.FullDescription` for accessibility. This is for
accessibility compliance. Description text should be read out by the
screen reader (scan mode isn't enough). Prior to this change, we would
expose it as `HelpText`. This change exposes it as `FullDescription`
which is more fitting as it's generally an opt-in behavior for screen
reader users to hear. This prevents the user from being overwhelmed with
information.
- `SettingsControlsHelpers` is used to make this much easier to review.
Any converters, triggers, or other classes that are used for the
migration were added there.

Additionally, this PR performs the migration to use these new controls
and removes `SettingContainer` entirely. Associated changes:
- Resources: renamed keys `.HelpText` --> `.Description`
- Deleting `SettingContainerStyle.xaml` and moving anything that's still
used to `CommonResources.xaml`
- Appearances: `BackgroundImageSettingsVisible` -->
`BackgroundImageSettingsEnabled` to make use of the disabled styling
- GenerateSettingsIndex.ps1 was updated to target
SettingsCard/SettingsExpander for the search index

Other notable changes as a part of using the new controls:
- Navigators (i.e. "Advanced" button in Profiles page, Extensions page)
were also converted to use `SettingsCard`
- Utils.h/cpp includes a fix for deep link to work for nested settings
(i.e. "Foreground", "Columns")

Switching to use the WCT port directly allows us to iterate faster on
the settings UI and be more consistent with the Windows ecosystem.
However, this does mean that the "reset button" had to be removed from
the individual settings. This was already a weird pattern, so removing
it shouldn't be too much of an issue. However, there was value to being
able to reset settings. To provide this kind of functionality, a "reset"
button is being added to the profile pages. This clears all settings in
a profile so that they can apply their own customizations on top. It
sacrifices granularity for simplicity and is a better understood
concept.

## Validation Steps Performed
- [X] settings search should pick up and navigate to settings properly
- [X] accessibility audit

## PR Checklist
Related to #17000
2026-08-24 16:20:17 -07:00
Josh Soref
d185095a25 Work around check-spelling v0.0.26 bug (#20545)
In v0.0.26, check_extra_dictionaries isn't honored from config.json for
pull requests

Leave `cspell` with the value from v0.0.26, and use `cspell1` for the
active dictionaries.

## Detailed Description of the Pull Request / Additional comments

check-spelling v0.0.26 has a minor bug where it doesn't honor
check_extra_dictionaries from config.json in pull requests (it does for
pushes). I missed it in testing (it's fixed in prerelease).

The workaround is to use a different alias in config.json for the
check_extra_dictionaries and reserve `cspell` for the current version of
check-spelling (currently v0.0.26). When the repository updates to the
next version, that aliasing can be dropped (and at some point, once
people are all relying on config.json, I'll probably upgrade the
defaults, but until people are using a version of config.json that can
tolerate such jitter, I don't want to do that...).
2026-08-13 17:36:32 -05:00
Leonard Hecker
e907f9fb75 Fix visual artifacts when using QQ Wubi IME (#20542) 2026-08-13 22:13:27 +02:00
Dustin L. Howett
128bffd614 Canary: enable STL hardening and destructor tombstoning in all builds (#20544)
This may cause us some pain, but having a safer codebase is worth some
pain.

More info at https://github.com/microsoft/STL/wiki/STL-Hardening.
2026-08-12 23:15:54 +00:00
Leonard Hecker
a47fb5d070 Do not retry a DSR-CPR if the ConPTY host did not respond (#20510)
People sometimes use ConPTY just for console API translation and so the
host lacks any VT capabilities. This means DSR-CPR queries never get a
response. Previously we would never clear the dirty flag which would
result in a 500ms lag on each `GetConsoleScreenBufferInfo` call and
PowerShell calls that API _**on every single stdout print**_
(sometimes per character due to lack of any stdout buffering).

## Validation Steps Performed
* Lobotomize conhost's ability to respond to DSR-CPR
* Run OpenConsole --> VtPipeTerm --> pwsh
* Resize the window
* After this PR, stdio will not lag
2026-08-05 12:40:58 -05:00
Leonard Hecker
fbda436dc6 Fix various KKP encoding issues (#20052)
NOTE:
This commit changes our input model to treat all
Ctrl-Alt combinations as an AltGr modifier by default.
Ctrl+Alt+/ will not produce `"\x1b\x1f"` anymore.

This fixes the following issues:
* Base-key report of non-ASCII keys was broken
* AltGr on international keyboards would spam
  Ctrl/Alt up/down events repeatedly forever
* KKP doesn't report modifier key repeats
* AltGr+Key combinations were reported as Ctrl+Alt+key
  but should've been just plain Key-But-Modified

Closes #19977

## Validation Steps Performed
This cannot be easily tested in unit tests, due to
the dependence on international keyboard layouts.
It appears to work correctly from what I can tell.
2026-07-31 18:14:39 -05:00
Phil Scott
0c4881bc9c Fixes xbox controller crashing the Terminal (#20234)
## Summary of the Pull Request
Fixes a denial of service by a toddler with an Xbox controller wanting
to play Forza. They can impatiently press up and down and close out the
terminal window.

Issue is upstream in WinUI, but I think this gathers things into a state
where Terminal can at least recover by adding a `GettingFocus` handler
on the `TabViewItem` that cancels that gamepad focus move before it
reaches the framework handler.

## References and Relevant Issues
Issue #19671 and #20089

## Validation Steps Performed
Handed a controller to my toddler while working in terminal. I also
banged on the keys myself.

## PR Checklist
Closes #19671 
Closes #20089
2026-06-23 10:27:17 -07:00
Dustin L. Howett
05b613cf06 Pre-warm SHGetKnownFolder to avoid a deadlock in the nvidia driver (#20351)
The nvidia driver attempts to use SHGetKnownFolder (which has its own
lock!) under the loader lock, which occasionally triggers a deadlock
when we attempt to do the same thing during settings load.

Closes #20350 (superseded)
Closes #20348

Co-authored-by: gleb <46842077+groovg@users.noreply.github.com>
2026-06-22 18:09:00 -05:00
Carlos Zamora
93bdbfaa3d Add support for OSC777 (Send Notification) (#20012)
## Summary of the Pull Request
targets #20010

This adds support for the `OSC 777 ; notify ; title ; body ST` sequence.
This allows client applications to send a notification to the Terminal.
When this notification is clicked, it summons the terminal window that
sent it.

## Validation Steps Performed
```pwsh
# in PowerShell. Terminal should not be focused.
sleep 2; Write-Output "`e]777;notify;Hello;This is a notification`a"
```

## PR Checklist
- [X] Closes #7718
- [ ] Documentation updated
- [X] Schema updated (if necessary)

Heavily based on #19938
Co-authored by @zadjii-msft
2026-06-03 17:54:01 -07:00
Dustin L. Howett
8ef8e95eb5 meta: add a solution filter that only opens conhost components (#20271)
It loads faster, and a full "solution" build produces everything
required to run and test conhost.
2026-05-29 10:37:13 -07:00
aarushi singh
abeac1b135 Use PlaySoundW for profile bell sounds (#20031)
We believed that this would fix an issue on Windows 10, where the volume
mixer would forget Windows Terminal after every relaunch. It turns out
that it does not.

Still, this code is much more concise and doesn't require yet another
WinRT object. Story of our lives.

Refs #17733
2026-05-15 20:51:01 +02:00
Dustin L. Howett
dbc5177f7f Migrate some pull requests from OS (#20181)
Some work was required to ensure conhost builds.

---------

Co-authored-by: Dragos Sambotin <dragoss@microsoft.com>
Co-authored-by: Daniel Paoliello (HE HIM) <danpao@microsoft.com>
2026-05-05 00:34:13 +00:00
Carlos Zamora
e4e3f08efc Add toast notification infrastructure (#20010)
## Summary of the Pull Request
Adds the infrastructure for toast notifications. Breakdown:
- `DesktopNotification`:
- `DesktopNotificationArgs` includes the struct to group all
notification-related data together.
   - `SendNotification()` actually sends it
- `AppCommandlineArgs.cpp`: added a check for the `--from-toast` no-op
sentinel; ensures no new window is created
- Most of the other changes are just bubbling up the notification from
the `TerminalPaneContent` to `TerminalPage`
- `TabManagement.cpp`: `_SendDesktopNotification()` does the final
packaging of the notification before calling the `DesktopNotification`
API

This supports finding the right tab when it's been reordered or even
moved to a new window!
This also has expanded to support finding the right pane, which is
resilient to pane swaps/closing too. When the pane can't be found, we
just fallback to the tab.
If the pane is already focused, we don't send a notification.

This simply adds the infrastructure! Looks like nothing can actually
take advantage of it yet, but it's been tested with the changes in
#20011.

Heavily based on #19935
Co-authored by @zadjii-msft
2026-04-29 17:24:45 -07:00
Josh Soref
c17029a7e9 Update dictionaries (#20148)
Follow up to #20141
2026-04-26 20:43:00 -05:00
Josh Soref
c62bb193d3 Refresh check-spelling metadata for v0.0.26 (#20141)
This is a refresh of spell-check-this, more or less as of
e089393b4e.

## References and Relevant Issues

A number of changes take advantage of features from
http://github.com/check-spelling/check-spelling/releases/v0.0.26

1.
[`load-config-from`](https://docs.check-spelling.dev/Configuration#load-config-from)
will allow future PRs to switch cleanly w/o the mess that this PR has --
once this merges, the `config.json` file will be used for the three
dictionary configuration elements instead of the ones in the workflow.
2. `contents: read` is no longer needed by the comment jobs as the data
is provided by the main job

Contains fixes for the following specific issues:
`without`, `with`, `with the`, `with the window`, `will be`,
`whether or not`, `where the`, `using`, `uppercase or lowercase`,
`unit testing`, `to`, `to which...`, `to which`,
`to which the view refers`, `to which the pane was moved`,
`to run a command/switch to a tab/...`,
`to retrieve the user selected command`, `time,`, `the...that the`,
`the session's initial directory`, `that`, `that will ask`, `that the`,
`that opened the first flyout`, `same as terminal,`, `results,`,
`queue,`, `please`, `pane,`, `out-of-date`, `our`, `one`, `on-screen`,
`often`, `off-screen`, `of a`, `little-endian`, `left over`,
`includes, at a minimum,`, `know of`, `its`,
`if, after the calculation,`, `if`, `if we have an`, `if dragging`,
`if commands`, `guard,`, `given process information in a list`,
`from which`, `from creating`, `for which...`, `for the axis`,
`for initializing the buffer`, `containing the cursor`, `console-wait`,
`change`, `bytes`, `be`, `baseline,`, `aumid`, `at`, `ask me *again*`,
`an`, `also need to`, `again`, `add`, `add event`, `about spelunking`,
(rewrite `Appearances::_UpdateWithNewViewModel` comment), `'a'`, and ` (`

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2026-04-24 22:50:42 +00:00
Dustin L. Howett
0a6c3d71fb build: Add a 1ES Pipeline Templates version of Canary (#20127)
This pipeline runs on our agents, rather than OneBranch's, and doesn't
use all of the OneBranch machinery--which is only required for producing
a vpack that we check into Windows. Since Canary will never be a vpack,
we don't need to worry.

It runs at about twice the speed _and_ we control the build images!

This pull request also adds support for the "Terrapin Retrieval Tool,"
which will allow us to move away from having vcpkg contact remote
servers directly to download source code (and which may become mandatory
even in our OneBranch pipelines.)
2026-04-24 15:39:27 -05:00
Dustin L. Howett
17e6126597 spelling: move to v0.0.26 (#20099) 2026-04-23 19:37:41 +02:00
dagecko
a7a928cfc9 actions: pin the hash of the check-spelling action (#20022)
In theory, somebody could compromise jsoref and push a new `v0.0.25` tag. As if.
2026-03-26 15:53:26 +00:00
Dustin L. Howett
80e4b3c947 Only honor Ctrl+Z during ReadFile if the console is in PROCESSED mode (#19940)
This restores the behavior of ReadFile to that of Windows 7.

Closes #4958
2026-03-11 11:52:33 -05:00
Carlos Zamora
e2110e716c Fix memory leaks with UIA (#19950)
## Summary of the Pull Request
This includes the memory leak fixes that @lhecker and I investigated as
a part of #19710.

The `ITextRangeProvider`s (namely `UiaTextRange`s) weren't being
destroyed after they were done being used by the screen reader.

## Validation Steps Performed
In my own testing, I set a breakpoint on the destructor for
`UiaTextRangeBase`. Prior to this change, that destructor would mainly
be called when the terminal control was closed, which would result in us
leaking these objects. With this change, I've confirmed that these text
ranges are being destroyed immediately after they are done being used
(without needing to close the terminal control).

## PR Checklist
Closes #19710
2026-03-11 02:08:32 +01:00
Carlos Zamora
fbd48e7463 Polish GenerateSettingsIndex.ps1 and propagate changes (#19907)
## Summary of the Pull Request
Cleans up GenerateSettingsIndex.ps1 by addressing the feedback Dustin
left in #19519

## Validation Steps Performed
✅ SUI search works
2026-02-26 22:54:07 +00:00
Carlos Zamora
f20c549d15 Implement search in Settings UI (#19519)
## Summary of the Pull Request
Adds search functionality to the settings UI. This is added to an
`AutoSuggestBox` in the main `NavigationView`. Invoking a result
navigates to the proper location in the settings UI and focuses the
setting, when possible.

## References and Relevant Issues
Based on https://github.com/microsoft/PowerToys/pull/41285

## Detailed Description of the Pull Request / Additional comments
- tools/GenerateSettingsIndex.ps1: parses all the XAML files in the
settings UI for SettingsContainers and builds a search index from them
- XAML changes: ensures all SettingContainer objects have an `x:Name` so
that we can navigate to them and bring them into view.
- TerminalSettingsEditor/Utils.h: implements `BringIntoViewWhenLoaded()`
which navigates to the relevant part of the UI. This is called in
`OnNavigatedTo()` for each page.
- fzf was moved out of TerminalApp so that TerminalSettingsEditor can
access it
- There's a few main components to searching, all of it is in
`MainPage`:
- `MainPage::_UpdateSearchIndex()`|`SearchIndex::Reset()`: loads the
search index generated by `GenerateSettingsIndex.ps1`; provides
additional localization, if needed
   - `MainPage::SettingsSearchBox_TextChanged`:
      - detect that text changed in the search box
- perform the actual search in `SearchIndex::SearchAsync()`. This is a
HEFTY async function that can be cancelled. It needs a lot of context
passed in to expand the search index appropriately (i.e. build awareness
of "PowerShell" profile and generate results appropriately). This is
also where fzf is used to perform weighted matching.
- the weighted matching itself is pretty complicated, but all the
associated bonus weights are at the top of SearchIndex.cpp.
- `SettingsSearchBox_QuerySubmitted`: extract the search index metadata
and call the correct `_Navigate()` function

## Validation Steps Performed
Search for...
- settings that don't change at runtime:
   - [x] global settings
   - [x] settings in profile.defaults
   - [x] "add new profile" page
- settings that may change at runtime:
   - [x] settings in a profile
   - [x] individual color schemes
   - [x] actions (main actions page + edit action subpage)
   - [x] new tab menu folders
   - [x] extensions
- misc. corner cases:
- [x] terminal chat (blocked in indexing script; requires minor changes
in feature branch)
   - [x] settings in appearance objects

To test fzf matching and weighted results, I specifically tested these
scenarios:
- "PowerShell" --> prioritize the PowerShell profile page(s)
- "font size" --> prioritize profile defaults entry
- "font size powershell" --> prioritize PowerShell > font size

## PR Checklist
Closes #12949 

## Follow-ups
- search by JSON key: need a way to add JSON keys to index entries.
`GetSearchableFields()` should make the rest pretty easy.
- search by keywords: need to define keywords. `GetSearchableFields()`
should make the rest pretty easy.
2026-02-20 15:04:45 -08:00
Leonard Hecker
c81c66b406 Implement the Kitty Keyboard Protocol (#19817)
This essentially rewrites `TerminalInput` from scratch.
There's significant overlap between what kind of information
the Kitty protocol needs from the OS and our existing code.
The rewrite allows us to share large parts of the implementation.

Closes #11509

## Validation Steps Performed
* `kitten show-key -m kitty` ✅
* US Intern. " + ' produces `\'` ✅
* Hebrew base keys produce Unicode ✅
* Hebrew AltGr combinations produce Unicode ✅
* French AltGr+Space produces U+00A0 ✅
* German AltGr+Decimals produce []{}... ✅
2026-02-16 19:53:49 -06:00
Dustin L. Howett
bc4e6129ef Disable the creation of issues without using a template (#19808)
We've seen an uptick in "language model" "people" submitting issues
without using the template. Easy fix.
2026-02-13 14:01:31 -06:00
William Zhang
8d94edd7b0 Dim the caption buttons for unfocused windows (#19668)
This PR closes #12632 by dimming the caption controls in the titlebar
when unfocused. Leaves them intact when in high contrast mode. The color
used is borrowed from PowerToys' unfocused color.

## Validation Steps Performed
Tested by hovering and unhovering in focused and unfocused states, as
well as in high contrast mode. States are consistent and applied
correctly. I did notice that clicking on the titlebar wouldn't put it
into focus unless I also moved my mouse though, but that is also present
in the release branch.

Closes #12632
2026-01-20 20:18:07 +00:00
Leonard Hecker
e8971c80ae Prevent RPC_E_CANTCALLOUT_ININPUTSYNCCALL during WM_SETTINGCHANGE (#19755)
Closes #19505
2026-01-19 11:56:53 -06:00
Leonard Hecker
c0debf8e26 Improve sixel performance (#19639)
Together with #19640 this bumps the performance on my HW by around 60%.
You can now stream 4K images at >60 FPS on a high-end CPU.

## Validation Steps Performed
* Used imagemagick to dump large images ✅
2026-01-12 14:05:33 +01:00
Dustin L. Howett
7a7cdec91f Disallow fragments from containing UNC media paths (#19615)
Fragments are not allowed to declare web-source icons; this is equally
true for UNC paths in the local network (or WebDAV paths!)
2025-12-05 12:41:03 -08:00
Leonard Hecker
1ca0c76bc7 Fix a WPF<>TSF crash by avoiding TF_TMAE_CONSOLE (#19584)
As explained in detail in the diff.

Closes #19562
2025-11-24 12:01:21 -06:00
Leonard Hecker
81cdb07646 Separate pruning of elevated/unelevated session buffers (#19546)
Previously, launching an unelevated session after an elevated one would
delete the latter's persisted buffers, and vice versa of course. Also,
elevated buffers didn't have an ACL forbidding access to unelevated
users. That's also fixed now.

Closes #19526

## Validation Steps Performed
* Unelevated/elevated WT doesn't erase each other's buffers ✅
* Old buffers named `buffer_` are renamed to `elevated_` if needed ✅
2025-11-20 11:49:14 -08:00
Leonard Hecker
898b9e3cab Fetch the terminal cursor position after a resize (#19535)
Closes #18725

## Validation Steps Performed
Functionality was observed under a
debugger while using PowerShell 5.
2025-11-18 11:42:09 -08:00
Leonard Hecker
2e78665ee0 Move all blink handling into Renderer (#19330)
This PR moves the cursor blinker and VT blink rendition timer into
`Renderer`. To do so, this PR introduces a generic timer system with
which you can schedule arbitrary timer jobs. Thanks to this, this PR
removes a crapton of code, particularly throughout conhost.

## Validation Steps Performed
* Focus/unfocus starts/stops blinking ✅
* OS-wide blink settings apply on focus ✅
2025-11-11 15:29:48 +01:00
Piotr Szlazak
f5ddecd1d4 Fix the casing on an image URL in the FTCS marks spec (#19440) 2025-10-15 19:45:08 -05:00
Leonard Hecker
4600c4791b Rewrite the MSAA/UIA integration into conhost (#19344)
Goal: Remove `CursorBlinker`.
Problem: Spooky action at a distance via `Cursor::HasMoved`.
Solution: Moved all the a11y event raising into `_stream.cpp` and pray
for the best.

Goal: Prevent node.js from tanking conhost performance via MSAA (WHY).
Problem: `ServiceLocator`.
Solution: Unserviced the locator. Debounced event raising. Performance
increased by >10x.
Problem 2: Lots of files changed.

This PR is a prerequisite for #19330

## Validation Steps Performed
Ran NVDA with and without UIA enabled and with different delays. ✅
2025-09-22 22:53:52 +00:00
Dustin L. Howett
d6714f3ca9 Convert the solution file to the new SLNX format (#19328) 2025-09-09 15:01:03 -05:00
Dustin L. Howett
ad48162f02 Reflect inbox changes from RS (#19258)
Reflect inbox changes to `onecore/windows/core/console/open`.

* eed3a6fa5 Merged PR 13076689: Update managed TAEF tests that exist in
GE branches to use the new publishing locations of TAEF's managed
reference binaries.
* 718d7d02d Merged PR 12483430: build console* with clang

Somebody internal is trying to build the console with Clang (which is
cool).

---------

Co-authored-by: Dragos Sambotin <dragoss@microsoft.com>
Co-authored-by: Phil Deets <pdeets@microsoft.com>
2025-08-25 19:14:25 +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
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