microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.29k stars 29.31k forks source link

Notebook connected to remote kernel and conflict between remote and local color-theme. #214069

Closed Mr-Ruben closed 5 months ago

Mr-Ruben commented 5 months ago

Does this issue occur when all extensions are disabled?: Difficult, because without extension I cannot reach the point.

Version: 1.89.1 Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:16:23.416Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 4.19.0-24-amd64

Steps to Reproduce:

  1. Using a dark theme (I tried multiple, all have the same issue). Open a notebook and create an array
  2. display the content of the var just by using its name
  3. Connect to an existing remote kernel (jupyterlab)
  4. display the content of the var just by using its name The numbers are not visible, but the ", [ ]" are.

Findings: This does not happen with non-dark themes. This does not happen when not connecting to existing remote kernels. The data is there, but the numbers have the same color than the background. If I select the output, I can see it. There seems to be an extra line in the output when connecting to existing kernel. No problem with strings, just numbers.

You could say that this is not a bug, I am fine with that. But at least if someone finds the same problem doesn't go nuts figuring out why.

image

image

image

image

In Jupyterlab

image

As you can see, the numbers in Jupyterlab seem to be black (in this specific theme), and that color seems to be passed to vscode.

From gpt

The issue you're experiencing seems related to how VS Code and the Jupyter extension render the output when displaying a variable directly versus when using print(). When you display a variable directly (e.g., data), Jupyter typically uses rich representation methods, which may involve HTML or other formatted outputs. These outputs can be styled differently than plain text printed using print().

To be extra verbose (increase find-ability)

I am using vscode on linux. Vscode runs notebooks connected to remote kernels from jupyterlab.

If the kernel is created for the notebook in vscode, all is fine.

But If I connect one notebook to an existing kernel of another notebook, the output numbers have the same color than the background, which doesn't make sense to me.

amunger commented 5 months ago

Is this from the built-in renderer? (is there an option to "change presentation type" in the output menu on the left) What is the mime type of the output? If you don't have the option to change the presentation, just reopen the file in a text editor and look for the output property in there. Either the output_type, or the key in the data object. For me, connecting to a server that I created by running jupyter lab, it's just a plain text output (same as a local kernel) that renders as expected:

"data": {
  "text/plain": [
       "[1, 2, 3, 4, 5]"
   ]

But I would assume you're getting something different back as output.

Mr-Ruben commented 5 months ago

Is this from the built-in renderer? (is there an option to "change presentation type" in the output menu on the left) What is the mime type of the output?

Sorry, but I don't understand where is that (a photo helps).

In any case,

I got this (in VScode) https://i.imgur.com/rW5l3F5.png

when I click on 'open in a text editor'

I think that answers your question.

In any case, for me it is not a bug. As I said, I just wanted to document what I found out, which is that the theme style used in Jupyter is passed down to VScode with its output through the kernel. (I hope it is well phrased).

amunger commented 5 months ago
image

"change presentation" would be in that menu if there is more than one mime type. Also, try the copy output command - that would likely have html, whereas I just get plaintext in the output

Mr-Ruben commented 5 months ago

Is this from the built-in renderer? (is there an option to "change presentation type" in the output menu on the left) What is the mime type of the output?

Clicking on ... > change presentation I got here

I tried the 2 options. If the theme is dark, I get the same results

If I click on ... > copy cell output I get

[1, 2, 'kjkj ', 888822982]

Important (maybe). I got these "Interactive window" or "Notebook" connected to jupyter_kernel using the "jupyter power toys" extension.

amunger commented 5 months ago

interesting, it looks like the kernel running on that jupyter lab server is adding ansi color codes to the output, though I'm not sure why, and I couldn't find any way to configure that to always happen. But I agree, not really something we want to try and fix on our end since someone could be purposefully trying to use text color.

Thanks for helping investigate!

vscodenpa commented 5 months ago

The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our issue reporting guidelines.

Happy Coding!