Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wt.exe from command line with named console binary picks the wrong tab icon and wrong tab title #7552

Open
pstaag opened this issue Sep 7, 2020 · 11 comments
Labels
Area-Commandline wt.exe's commandline arguments Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Milestone

Comments

@pstaag
Copy link

pstaag commented Sep 7, 2020

Environment

Windows build number: Microsoft Windows [Version 10.0.19041.450]
Windows Terminal version (if applicable): 1.2.2381.0

Steps to reproduce

start Windows terminal from console or Run... with a chosen named .exe that produces console output.

eg. win+R wt thiscommandisjustanexample enter

(picking a binary that actually does exist is not making a difference for this bug)

Expected behavior

  • Tab gets it's title from the binary's name

  • Tab gets it's icon from the called binary / tab gets a generic console-binary icon, since the binary does not contain one

Actual behavior

The tab inherits several pieces of behaviour from the default profile.

This includes,

  • the icon that is defined for defaultProfile in settings.json
  • the tabTitle that is defined for defaultProfile in settings.json
  • the default profile's backgroundImage with it's settings for backgroundImageStretchMode and backgroundImageAlignment applied as defined in settings.json

Reflection

You are just applying the default profile to anything unknown that runs, don't you?

Awesome. In that case, I guess, Windows Terminal requires a hidden default profile that is invoked if nothing else applies. Instead of just picking the one that is opened as default on start.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Sep 7, 2020
@KalleOlaviNiemitalo
Copy link

It looks like Windows Terminal does not attempt to use the icon and title of the command at all. I have Git Bash as the default profile, and if I run wt cmd, then Windows Terminal starts cmd.exe in the Git Bash profile and gets the icon and title from that profile. I can override the title with a command like wt --profile "Command Prompt" --title "nslookup" nslookup but cannot get the command-specific icon.

In the console host (cmdhost.exe or openconsole.exe), SystemConfigurationProvider::GetSettingsFromLink tries to find an icon and a title for the console window. If it later becomes possible to set Windows Terminal as the default terminal in Windows (#492, #7414), then it would make sense for Windows Terminal to choose the icon and title in a similar way. (If a user just runs wt thiscommandisjustanexample, then there is no .lnk file involved, and many features of that function cannot be used.)

What is wrong with using the background image of the default profile?

@pstaag
Copy link
Author

pstaag commented Sep 8, 2020

@KalleOlaviNiemitalo I use profile specific backgrounds. One for Debian, one for PoweShell, and so on.

Calling wt.exe with a console binary in Windows and getting Debian's logo (because Debian is my default profile) on it...something does not sit right with me about that.

It's not the bug that will hinder Windows Terminal from shipping, but it's also Not Right^tm

@KalleOlaviNiemitalo
Copy link

Perhaps wt command and wt new-tab command should choose the profile this way:

  1. If the -p or --profile option is given, use that.
  2. Otherwise, if commandProfile is defined in settings.json, use that. This would be a new setting. It could refer to a hidden profile. The name of the commandProfile setting would not depend on command.
  3. Otherwise, if defaultProfile is defined in settings.json, use that.
  4. Otherwise, use the first profile.

commandProfile would not be used for plain wt or wt new-tab without command.

That would solve the background image issue but would still not use a command-specific icon and title.

@DHowett
Copy link
Member

DHowett commented Sep 9, 2020

So, this is going to become more important once we land #492. The solution we're going to go with in the interim is...

  • If there is a defaults block (profiles.defaults), apply that to any applications started up by the default terminal interface.

I don't think we can generally grab icons from whatever you launch (without grovelling in the process tree to figure out whose executable is on the hook for running a given commandline), but we can definitely fall back to a default icon. Perhaps we should do the process tree thing.

When we apply this change to commandline invocation (which I do think we should), there will be a split between -p x command and command invocation, just like there should have been.

After we land that, we can talk about process name matching. ConEmu supports taking over as the default terminal on Windows, and it lets you specify "when x.exe is running, my profile is y". We should absolutely have something similar.

After that, we can hook up default mappings (any cmd.exe => Command Prompt unless hidden, any pwsh.exe, powershell.exe => a powershell profile).

@DHowett DHowett added Area-Commandline wt.exe's commandline arguments Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Sep 9, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 9, 2020
@DHowett
Copy link
Member

DHowett commented Sep 9, 2020

As a workitem that's going to require nontrivial work and design discussion even though its outward appearance is that of a bug, this is going to be one of our rare "task-bugs".

@DHowett
Copy link
Member

DHowett commented Sep 9, 2020

/cc @miniksa this is topical for your recent defterm investiation

@DHowett DHowett added this to the Terminal v2.0 milestone Sep 9, 2020
@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Sep 10, 2020
@zadjii-msft zadjii-msft modified the milestones: Terminal v2.0, 22H2 Jan 4, 2022
@zadjii-msft
Copy link
Member

I may xlink this to #1504, #9458, #4768. This might just be a dup of that trio.

@zadjii-msft
Copy link
Member

Note
for discussion:

We probably want to document what we want to do here, since this isn't the defeterm scenario. We'll use #14372 for the "defterm" version. This thread might turn into something like:

wt --icon foo.exe -- foo.exe

or something like, "When icon is null for a profile, use the commandline's application's icon as the icon". That assumes that we can parse out the application from the commandline, but I think we already do that. Might need discussion.

@zadjii-msft zadjii-msft added the Needs-Discussion Something that requires a team discussion before we can proceed label Feb 7, 2023
@carlos-zamora carlos-zamora removed the Needs-Discussion Something that requires a team discussion before we can proceed label Feb 21, 2023
@zadjii-msft
Copy link
Member

Hmm. This is... trickier than it might seem on the surface. Cause here's the thing - we almost always get the tab icon from the profile directly. That's right. So in the profiles.defaults + commandline case, we don't really keep the original commandline around.

Goddard, options:

Okay so option 1 - put the icon in the pane. Follow-up problem: now, when the settings reload, we have to re-use that commandline to rebuild what the icon for the pane should be. Barf.

@zadjii-msft
Copy link
Member

I bet after #15843, if you set the icon of the profiles.defaults to null, then wt -- foo.exe might just auto pick the icon of foo.exe

Nope, no, it won't. It'll still try to pick the icon of the profile, because we still don't do the NewTerminalArgs propagation thing. We're literally asking for the Profile of the pane, and getting the icon from the profile. Not from the TerminalSettings or anything like that.

@NewtonChutney
Copy link

I hope we solve the issue of icon picking differences between conhost and wt!
conhost nu and wt nu
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

7 participants