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

ssh <start typing hostname> --- the hostname is invisible. No matter what color scheme I select. #14242

Closed
mgarrett69 opened this issue Oct 17, 2022 · 13 comments
Assignees
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Question For questions or discussion Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Answered Related to questions that have been answered

Comments

@mgarrett69
Copy link

Windows Terminal version

1.16.2642.0

Windows build number

10.0.22621.0

Other Software

No response

Steps to reproduce

Just open a windows terminal and issue a ssh command.

(also seen when I ran [environment]::OsVersion -- the [environment] part of the string is invisible)

Expected Behavior

Here is the copy/paste of what I typed into the terminal (and what came back when I hit enter)

PS C:\Users\migarret\Work Folders\Downloads> ssh imola1
Warning: Permanently added 'xx.xx.xx.xx' (ED25519) to the list of known hosts.
Last login: Mon Oct 17 15:20:33 2022 from xx.xx.xx.xx
AvereOS_2022.08.0

[root@imola1 ~]#

Actual Behavior

image

@mgarrett69 mgarrett69 added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Oct 17, 2022
@DHowett
Copy link
Member

DHowett commented Oct 17, 2022

Huh. This might be an alternate reality version of this note, which applies to background colors (they're handled by the same code.)

All the same, can you share your settings.json?

@DHowett DHowett added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Oct 17, 2022
@DHowett
Copy link
Member

DHowett commented Oct 17, 2022

(And, perhaps, would you grab the following powershell output?

$PSVersionTable

Get-Module PSReadline | Format-List *

@237dmitry
Copy link

The main trouble is in the PSReadline options and $PSStyle parameters that know nothing about colorschemes. Everything requires configuration.

(also seen when I ran [environment]::OsVersion -- the [environment] part of the string is invisible)

Select with the mouse or set it to the clipboard:

$PSversionTable | Out-String | Set-Clipboard

You can change default foreground color of PSReadline:

Set-PSReadLineOption -Color @{'Default' = "`e[38;5;16m"}

Screenshot 2022-10-18 000646

@DHowett
Copy link
Member

DHowett commented Oct 17, 2022

@237dmitry you're right that it's configurable, but also... this text should be showing up in the "default foreground" color. I marked your original comments as off-topic since they may confuse users into thinking that to see text by default they would need to do some configuring. Still, I appreciate you adding additional info to this bug report!

The default foreground and background in every color scheme should absolutely be readable and require no Terminal or shell configuration. 🙂

@237dmitry
Copy link

this text should be showing up in the "default foreground"

I think, PSReadline Team does not think about it. If you launch pwsh without profile pwsh -NoProfile and see output of Get-PSReadlineOptions there is:

DefaultTokenColor                      : "`e[37m"    # White! 

I do not know this parameter changes depend on base 16 colors or not. Rather not. This is static value -- user knows better how to tune host.

@DHowett
Copy link
Member

DHowett commented Oct 17, 2022

Ah, that's a very good point! The default configuration of PowerShell does display white-on-default-bg. Bah. Thank you!

@mgarrett69
Copy link
Author

Name                           Value                                                                                                                                         
----                           -----                                                                                                                                         
PSVersion                      5.1.22621.608                                                                                                                                 
PSEdition                      Desktop                                                                                                                                       
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                       
BuildVersion                   10.0.22621.608                                                                                                                                
CLRVersion                     4.0.30319.42000                                                                                                                               
WSManStackVersion              3.0                                                                                                                                           
PSRemotingProtocolVersion      2.3                                                                                                                                           
SerializationVersion           1.1.0.1                       
PS C:\Users\migarret\Work Folders\Downloads> Get-Module PSReadline | Format-List *


LogPipelineExecutionDetails : False
Name                        : PSReadLine
Path                        : C:\Program Files\WindowsPowerShell\Modules\PSReadLine\2.0.0\PSReadLine.psm1
ImplementingAssembly        :
Definition                  : function PSConsoleHostReadLine
                              {
                                  Microsoft.PowerShell.Core\Set-StrictMode -Off
                                  [Microsoft.PowerShell.PSConsoleReadLine]::ReadLine($host.Runspace, $ExecutionContext)
                              }

Description                 : Great command line editing in the PowerShell console host
Guid                        : 5714753b-2afd-4492-a5fd-01d9e2cff8b5
HelpInfoUri                 : https://aka.ms/powershell51-help
ModuleBase                  : C:\Program Files\WindowsPowerShell\Modules\PSReadLine\2.0.0
PrivateData                 :
Tags                        : {}
ProjectUri                  :
IconUri                     :
LicenseUri                  :
ReleaseNotes                :
RepositorySourceLocation    :
Version                     : 2.0.0
ModuleType                  : Script
Author                      : Microsoft Corporation
AccessMode                  : ReadWrite
ClrVersion                  : 4.0.0
CompanyName                 : Microsoft Corporation
Copyright                   : (c) Microsoft Corporation. All rights reserved.
DotNetFrameworkVersion      : 4.6.1
ExportedFunctions           : {[PSConsoleHostReadLine, PSConsoleHostReadLine]}
Prefix                      :
ExportedCmdlets             : {[Get-PSReadLineKeyHandler, Get-PSReadLineKeyHandler], [Get-PSReadLineOption, Get-PSReadLineOption], [Remove-PSReadLineKeyHandler,
                              Remove-PSReadLineKeyHandler], [Set-PSReadLineKeyHandler, Set-PSReadLineKeyHandler]...}
ExportedCommands            : {[Get-PSReadLineKeyHandler, Get-PSReadLineKeyHandler], [Get-PSReadLineOption, Get-PSReadLineOption], [Remove-PSReadLineKeyHandler,
                              Remove-PSReadLineKeyHandler], [Set-PSReadLineKeyHandler, Set-PSReadLineKeyHandler]...}
FileList                    : {}
CompatiblePSEditions        : {}
ModuleList                  : {}
NestedModules               : {Microsoft.PowerShell.PSReadLine}
PowerShellHostName          :
PowerShellHostVersion       :
PowerShellVersion           : 5.0
ProcessorArchitecture       : None
Scripts                     : {}
RequiredAssemblies          : {}
RequiredModules             : {}
RootModule                  : PSReadLine.psm1
ExportedVariables           : {}
ExportedAliases             : {}
ExportedWorkflows           : {}
ExportedDscResources        : {}
SessionState                : System.Management.Automation.SessionState
OnRemove                    :
ExportedFormatFiles         : {C:\Program Files\WindowsPowerShell\Modules\PSReadLine\2.0.0\PSReadLine.format.ps1xml}
ExportedTypeFiles           : {}

settings.zip

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Oct 18, 2022
@mgarrett69
Copy link
Author

PS C:\Users\migarret\Work Folders\Downloads> Get-PSReadlineOptions
Get-PSReadlineOptions : The term 'Get-PSReadlineOptions' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-PSReadlineOptions
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-PSReadlineOptions:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\migarret\Work Folders\Downloads> Set-PSReadLineOption -Color @{'Default' = "`e[38;5;16m"}
Set-PSReadLineOption : 'e[38;5;16m' is not a valid color value.  It must be a ConsoleColor, ANSI escape sequence, or RGB value with optional leading '#'.
At line:1 char:1
+ Set-PSReadLineOption -Color @{'Default' = "`e[38;5;16m"}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-PSReadLineOption], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.SetPSReadLineOption

@mgarrett69
Copy link
Author

Let me know if I missed any of the output you wanted. As you can see, I caught errors when trying a few of the suggestions above.

And, for what it's worth, my background is grey, so even white lettering should not be invisible,,, I think.

@elsaco
Copy link

elsaco commented Oct 19, 2022

@mgarrett69 it's Get-PSReadLineOption not Get-PSReadLineOptions

@mgarrett69
Copy link
Author

Thanks elsaco

PS C:\Users\migarret\Work Folders\Downloads> Get-PSReadLineOption

EditMode : Windows
AddToHistoryHandler : System.Func`2[System.String,System.Object]
HistoryNoDuplicates : True
HistorySavePath : C:\Users\migarret\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
HistorySaveStyle : SaveIncrementally
HistorySearchCaseSensitive : False
HistorySearchCursorMovesToEnd : False
MaximumHistoryCount : 4096
ContinuationPrompt : >>
ExtraPromptLineCount : 0
PromptText : {> }
BellStyle : Audible
DingDuration : 50
DingTone : 1221
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...}
CommandValidationHandler :
CompletionQueryItems : 100
MaximumKillRingCount : 10
ShowToolTips : True
ViModeIndicator : None
WordDelimiters : ;:,.[]{}()/|^&*-=+'"–—―
AnsiEscapeTimeout : 100
CommandColor : "$([char]0x1b)[93m"
CommentColor : "$([char]0x1b)[32m"
ContinuationPromptColor : "$([char]0x1b)[37m"
DefaultTokenColor : "$([char]0x1b)[37m"
EmphasisColor : "$([char]0x1b)[96m"
ErrorColor : "$([char]0x1b)[91m"
KeywordColor : "$([char]0x1b)[92m"
MemberColor : "$([char]0x1b)[97m"
NumberColor : "$([char]0x1b)[97m"
OperatorColor : "$([char]0x1b)[90m"
ParameterColor : "$([char]0x1b)[90m"
SelectionColor : "$([char]0x1b)[30;47m"
StringColor : "$([char]0x1b)[36m"
TypeColor : "$([char]0x1b)[37m"
VariableColor : "$([char]0x1b)[92m"

@carlos-zamora carlos-zamora added the Needs-Discussion Something that requires a team discussion before we can proceed label Oct 20, 2022
@DHowett
Copy link
Member

DHowett commented Oct 20, 2022

Alright, so the root cause for this one is that the white color¹ in your default color scheme, Campbell, is set to the same color as the background. Now, you told me that this worked before Terminal 1.15 . . . and I'll get to that.

Anyway, PowerShell is explicitly requesting white and it doesn't know that your background is also white. Crap.

We've got a couple ways around this.

One is this feature that's currently available in preview builds that automatically detects when two colors have poor (or even catastrophic!) contrast and darkens or lightens the foreground color as appropriate to make it visible. Eventually, we'll enable it by default. That re-landed in #13343 and was enhanced in #13512.

The other is for you to change the white color (and bright white) to be dark; effectively, make a flipped version of the Campbell scheme where white and black are actually swapped.

¹ that is, color 37. you can see in your PSReadlineOptions that DefaultTokenColor is (blah blah blah) **37** m 

² why it's asking for 37 is... a long and ultimately disappointing story. The console only used to support 16 colors but all terminals since, say, 1981 have supported 18. PowerShell used the tools available to them and declared the "default" token color to be "white" (rather than "let the terminal decide what is best for visibility")


Now for the kicker. This worked in Terminal 1.14 (actually, this worked in all versions of Terminal between 0.1 (inclusive) and 1.15 (exclusive)!) In 1.15, however, we tore off in PR #13352 a band-aid that we had previously applied to PowerShell (originally applied in #6810).

Well, that band-aid was fixing two problems. One, the actual problem. Two, this.

We expressly ignored any requests for CSI 40 (black background) and CSI 37 (white foreground) from PowerShell... because they used it erroneously all the time.

In so doing, we hid this issue where their default token color is, in fact, 37. It should be 39.

Now that we're respecting PowerShell's color choices again, we're bound to run into more cases like this.


@mgarrett69 realized that he never tested other color schemes because of our poor and confusing UI for selecting/editing them. 1.16 didn't do so much to help, because the buttons that make it clear that there's actions to take are "below the fold." We should keep ideating there.


Tagged for team discussion so we can assess:

  • reintroducing the color quirk
  • enabling "color nudging" by default again
  • what to do about the color schemes UI

@zadjii-msft
Copy link
Member

We talked more with the PsReadline folks today. overall, we felt like the best option wasn't to keep patching an edge case with more heuristics. That would just shift the dissatisfaction around to different users in an elaborate game of wack-a-mole. They acknowledged that yea, the default PsReadline settings aren't configured for a light scheme, they're set up for a dark scheme (for more historical context: PowerShell/PSReadLine#464). They're gonna go ahead and update their docs to better clarify that users who prefer a light scheme should change their PsReadLine settings to match. That's tracked in: MicrosoftDocs/PowerShell-Docs#9358

As an immediate workaround, you should be able to set "adjustIndistinguishableColors": "indexed" to force the Terminal to manually adjust the text colors to ensure there's enough contrast in this use case.

@zadjii-msft zadjii-msft added Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered and removed Needs-Attention The core contributors need to come back around and look at this ASAP. labels Oct 25, 2022
@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2022
@zadjii-msft zadjii-msft removed the Needs-Discussion Something that requires a team discussion before we can proceed label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Issue-Question For questions or discussion Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

6 participants