Title propagation issues (empty app title, title doesn't update when unfocused, etc.) #11958

Closed
opened 2026-01-31 03:02:26 +00:00 by claunia · 12 comments
Owner

Originally created by @giggio on GitHub (Jan 4, 2021).

Environment

Windows build number: Microsoft Windows [Version 10.0.19042.685]
Windows Terminal version (if applicable): latest on main branch but it also happens
on the preview version from the store

Steps to reproduce

Open Windows terminal and Alt+Tab.

Expected behavior

Shows Application title.

Actual behavior

App title is empty.

Context

These are my settings: https://gist.github.com/giggio/d4cf676d93b89a2f78cb7f25c01fdcda

You can see that there is no title in Alt+Tab:
image

It is also empty on the task bar:
image

And when using Win+Tab:
image

I'd like it to simply read "Windows Terminal", always.

Originally created by @giggio on GitHub (Jan 4, 2021). # Environment ```none Windows build number: Microsoft Windows [Version 10.0.19042.685] Windows Terminal version (if applicable): latest on main branch but it also happens on the preview version from the store ``` # Steps to reproduce Open Windows terminal and <kbd>Alt</kbd>+<kbd>Tab</kbd>. # Expected behavior Shows Application title. # Actual behavior App title is empty. # Context These are my settings: https://gist.github.com/giggio/d4cf676d93b89a2f78cb7f25c01fdcda You can see that there is no title in <kbd>Alt</kbd>+<kbd>Tab</kbd>: ![image](https://user-images.githubusercontent.com/334958/103588380-ec867980-4e9d-11eb-85af-08abb308a153.png) It is also empty on the task bar: ![image](https://user-images.githubusercontent.com/334958/103588395-f3ad8780-4e9d-11eb-8fc6-8bf36e63ed6d.png) And when using <kbd>Win</kbd>+<kbd>Tab</kbd>: ![image](https://user-images.githubusercontent.com/334958/103588284-b943ea80-4e9d-11eb-888f-b1c2efe9e62a.png) I'd like it to simply read "Windows Terminal", always.
Author
Owner

@zadjii-msft commented on GitHub (Jan 5, 2021):

Hmm. I'd bet that somewhere along the line, we made it so "showTerminalTitleInTitlebar": false would propagate a Windows Terminal to the actual window title. Whoops!

@zadjii-msft commented on GitHub (Jan 5, 2021): Hmm. I'd bet that somewhere along the line, we made it so `"showTerminalTitleInTitlebar": false` would propagate a `Windows Terminal` to the actual window title. Whoops!
Author
Owner

@giggio commented on GitHub (Jan 5, 2021):

When you first open it, it is empty. After you create another tab, it is still empty. After you switch between the second tab and the first, then the tab title shows up as the app title:

image

The same thing shows on the taskbar.

Still, I'd like it to just read "Windows Terminal".

@giggio commented on GitHub (Jan 5, 2021): When you first open it, it is empty. After you create another tab, it is still empty. After you switch between the second tab and the first, then the tab title shows up as the app title: ![image](https://user-images.githubusercontent.com/334958/103654394-ad4a3e00-4f1a-11eb-8cb5-250a33cd58d9.png) The same thing shows on the taskbar. Still, I'd like it to just read "Windows Terminal".
Author
Owner

@DHowett commented on GitHub (Feb 4, 2021):

From #9007

Environment

Windows build number: Version 10.0.19042.746
Windows Terminal version (if applicable):   Windows Terminal Preview Version: 1.6.10272.0

Steps to reproduce

can be reproduced in both wsl or in powershell.

  1. run this and then switch to another application
    sleep 5; cd .\Documents\
    
  2. after 5 secs, tab title will be updated, but title in taskbar won't.

Expected behavior

title in taskbar updates properly even when terminal is not in focus.

Here's two screenshot:
image
image

Actual behavior

title in taskbar stays old value when terrminal is not in focus.

@DHowett commented on GitHub (Feb 4, 2021): From #9007 > # Environment > ``` > Windows build number: Version 10.0.19042.746 > Windows Terminal version (if applicable): Windows Terminal Preview Version: 1.6.10272.0 > ``` > > # Steps to reproduce > can be reproduced in both wsl or in powershell. > > 1. run this and then switch to another application > ``` > sleep 5; cd .\Documents\ > ``` > 2. after 5 secs, tab title will be updated, but title in taskbar won't. > > # Expected behavior > title in taskbar updates properly even when terminal is not in focus. > > Here's two screenshot: > ![image](https://user-images.githubusercontent.com/1235888/106647066-aade1100-65b8-11eb-9215-e555fdafc6b1.png) > ![image](https://user-images.githubusercontent.com/1235888/106647083-b03b5b80-65b8-11eb-83bb-dc3716701022.png) > > # Actual behavior > title in taskbar stays old value when terrminal is not in focus.
Author
Owner

@sarim commented on GitHub (Feb 4, 2021):

Can you point to where ESC]0 (and 1,2) is being handled in the codebase?

@sarim commented on GitHub (Feb 4, 2021): Can you point to where `ESC]0` (and 1,2) is being handled in the codebase?
Author
Owner

@zadjii-msft commented on GitHub (Feb 4, 2021):

@sarim Sure!

  • At the lower levels it's handled by Terminal::SetWindowTitle
  • That bubbles to TermControl::_TerminalTitleChanged
  • That bubbles to an event handlers in TerminalTab::_AttachEventHandlersToControl (in the lambda passed to control.TitleChanged)
  • That handler calls TerminalTab::UpdateTitle
  • That method also raises a PropertyChanged event for the Title property of the tab, which is handled in event handler in TerminalPage::_RegisterTerminalEvents
  • That calls TerminalPage::_UpdateTitle
  • That raises an event handled in AppHost::AppTitleChanged

I think that's it?

@zadjii-msft commented on GitHub (Feb 4, 2021): @sarim Sure! * At the lower levels it's handled by `Terminal::SetWindowTitle` * That bubbles to `TermControl::_TerminalTitleChanged` * That bubbles to an event handlers in `TerminalTab::_AttachEventHandlersToControl` (in the lambda passed to `control.TitleChanged`) * That handler calls `TerminalTab::UpdateTitle` * That method also raises a `PropertyChanged` event for the `Title` property of the tab, which is handled in event handler in `TerminalPage::_RegisterTerminalEvents` * That calls `TerminalPage::_UpdateTitle` * That raises an event handled in `AppHost::AppTitleChanged` I think that's it?
Author
Owner

@sarim commented on GitHub (Feb 4, 2021):

Thanks a lot. I think you already did most of the work listing all those methods. I just managed to set up vs and terminal. I think I found the problem too. Code is checking tab.FocusState() != FocusState::Unfocused , but when the whole terminal window is not in focus, the active tab is also in Unfocused state.
I'll investigate further and see If I can come up with a solution.

@sarim commented on GitHub (Feb 4, 2021): Thanks a lot. I think you already did most of the work listing all those methods. I just managed to set up vs and terminal. I think I found the problem too. Code is checking `tab.FocusState() != FocusState::Unfocused` , but when the whole terminal window is not in focus, the active tab is also in Unfocused state. I'll investigate further and see If I can come up with a solution.
Author
Owner

@zadjii-msft commented on GitHub (Feb 4, 2021):

Oh good catch! Thanks for looking into this!

@zadjii-msft commented on GitHub (Feb 4, 2021): Oh good catch! Thanks for looking into this!
Author
Owner

@sarim commented on GitHub (Feb 4, 2021):

So I solved the issues.

first issue: empty title

There were a missing _settings.GlobalSettings().ShowTitleInTitlebar() check. Because of this Title update event was being fired even when showTerminalTitleInTitlebar is false.

This explains this behavior

After you switch between the second tab and the first, then the tab title shows up as the app title

I fixed this in fece4c9919

Now showTerminalTitleInTitlebar is false:

  • Window title is correctly shown as "Windows Terminal", not empty.
  • After switching between tabs, Tab title doesn't propagate to window title.

Second issue: title doesn't propagate when unfocused

Reason explained above, I fixed it in b0fb2c77d2

https://github.com/sarim/terminal/tree/sarim/title-propagation

@zadjii-msft please check if the code is acceptable. should I send a PR?

@sarim commented on GitHub (Feb 4, 2021): So I solved the issues. ## first issue: empty title There were a missing `_settings.GlobalSettings().ShowTitleInTitlebar()` check. Because of this Title update event was being fired even when `showTerminalTitleInTitlebar` is false. This explains this behavior > After you switch between the second tab and the first, then the tab title shows up as the app title I fixed this in https://github.com/sarim/terminal/commit/fece4c9919cbf020f0c8121a2499c232f18ff761 Now `showTerminalTitleInTitlebar` is false: - Window title is correctly shown as "Windows Terminal", not empty. - After switching between tabs, Tab title doesn't propagate to window title. ## Second issue: title doesn't propagate when unfocused Reason explained above, I fixed it in https://github.com/sarim/terminal/commit/b0fb2c77d255c0211d811aeb4d26740dfc592fb5 https://github.com/sarim/terminal/tree/sarim/title-propagation @zadjii-msft please check if the code is acceptable. should I send a PR?
Author
Owner

@Don-Vito commented on GitHub (Feb 4, 2021):

@sarim - Not an expert, but I believe you definitely need to issue a PR - IMHO the solution looks good. 😊 I left a comment for some improvements to consider.

@Don-Vito commented on GitHub (Feb 4, 2021): @sarim - Not an expert, but I believe you definitely need to issue a PR - IMHO the solution looks good. :blush: I left a comment for some improvements to consider.
Author
Owner

@giggio commented on GitHub (Feb 7, 2021):

Awesome, I just built it from main it is working perfectly. Tks! :shipit:

@giggio commented on GitHub (Feb 7, 2021): Awesome, I just built it from `main` it is working perfectly. Tks! :shipit:
Author
Owner

@ghost commented on GitHub (Feb 11, 2021):

:tada:This issue was addressed in #9054, which has now been successfully released as Windows Terminal v1.5.10411.0.🎉

Handy links:

@ghost commented on GitHub (Feb 11, 2021): :tada:This issue was addressed in #9054, which has now been successfully released as `Windows Terminal v1.5.10411.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.5.10411.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Feb 11, 2021):

:tada:This issue was addressed in #9054, which has now been successfully released as Windows Terminal Preview v1.6.10412.0.🎉

Handy links:

@ghost commented on GitHub (Feb 11, 2021): :tada:This issue was addressed in #9054, which has now been successfully released as `Windows Terminal Preview v1.6.10412.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.6.10412.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11958