microsoft / vscode

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

Restart button is often not visible #200896

Open RossBencina opened 1 year ago

RossBencina commented 1 year ago

Applies To

What happened?

Often, the "Restart" button is not visible in the toolbar. For example, right now I see:

image

It was there 10 minutes ago:

image

It seems to disappear after restarting the kernel. I can't predict when it reappears.

VS Code Version

1.78.0 (user setup)

Jupyter Extension Version

v2023.4.1011241018

Jupyter logs

No response

Coding Language and Runtime Version

Python 3.10.7

Language Extension Version (if applicable)

Python Extension v2023.8.0

Anaconda Version (if applicable)

(not using Anaconda)

Running Jupyter locally or remotely?

None

rebornix commented 1 year ago

Relevant issue https://github.com/microsoft/vscode/issues/184194

jdegenstein commented 1 year ago

Hopefully I am not hijacking this issue, but I often see "Restart" (kernel) grayed out on a fully working interactive console.

image

hzphzp commented 1 year ago

same problem

kdgutier commented 1 year ago

Hey @hzphzp, I found that the restart button reappears when you click a cell in the notebook.

awf commented 11 months ago

same problem, does not ungray/reappear on clicking

DonJayamanne commented 10 months ago

@awf @hzphzp @kdgutier are you still running into this issyue?

VSCodeTriageBot commented 9 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

dderiso commented 6 months ago

this is still an issue

dderiso commented 6 months ago

On my machine, the current workaround is to click on the code cell, then click on the output, then click on the code cell again. The restart button then appears. Hope that helps uncover the cause.

epicwhale commented 6 months ago

Any luck with this issue? This issue is plaguing my workflow way too frequently now...

rqueraud commented 6 months ago

I started to have a lot of weird things happening recently (No more "Restart button", cells hanging forever, ...). I found out that I was using the "pre-release" version of the extension. So, going into "Extensions" -> "Jupyter" and switching to release version seemed to solve my issues.

Edit : Ok, unfortunately the restart button still disappear...

epicwhale commented 6 months ago

Unfortunately, I'm facing this issue (of restart button disappearing) quite severely in both the release version and pre-release version!

christian-kento-rasmussen commented 5 months ago

Any update it is still an issue on VS Code version:

Version: 1.88.1 (Universal) Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:42:52.765Z (1 wk ago) Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.2.0

romach6 commented 4 months ago

I'm having this same issue. I don't have a solution, but a decent work around is to assign a keyboard shortcut for the 'restart kernel' and the 'restart and run all' commands. Here are the steps to do so:

  1. With VSCode open. Press 'command + shift + p' to bring up the command bar.
  2. Enter 'Open Keyboard Shortcuts' Screenshot 2024-05-02 at 9 48 00 AM
  3. Type 'kernel' in the search bar.
  4. Hover your mouse over the 'Jupyter Restart Kernel and Run All Cells' or 'Jupyter: Restart Kernel' command, depending on which one you would like to assign a keyboard shortcut for.
  5. Click the '+' sign that appears at the far left of the row. Screenshot 2024-05-02 at 9 50 12 AM
  6. Follow the instructions that appear to enter the desired key combo and press 'Enter'
  7. Now you should be good to go to restart the kernel with just a few key strokes for whenever the button disappears. Screenshot 2024-05-02 at 9 57 37 AM
epicwhale commented 4 months ago

@romach6 I don't think your workaround would work when the Restart button is NOT visible in the Notebook - which is the root of this problem. I have this shortcut configured for ages, but I can only fire it from my keyboard when the Notebook shows the button. Or does it work for you irrespective of the button's visibility?

dderiso commented 4 months ago

The workaround I use is to click on results and then back on code. That seems to make it reappear.

This obviously needs to be fixed. It should never disappear since reset is stateless.

romach6 commented 4 months ago

@epicwhale When I experienced this issue, I could use the keyboard shortcut irrespective of the button's visibility.

If this is not working for you, another work-around is to put the magic command %reset -f at the start of your notebook before any actual code. This command will remove all variables from memory, except for those that are defined by the user in the configuration file. The -f parameter ensures that the command is executed without confirmation.

Despite the availability of work arounds, I agree that this issue should be addressed.

For the sake of further documenting this issue, here are my settings/versions:

VS Code Version

Version: 1.89.0 (Universal) Commit: b58957e67ee1e712cebf466b995adf4c5307b2bd Date: 2024-05-01T02:10:10.196Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0

Jupyter Extension Version

v2024.4.0

Coding Language and Runtime Version

Python 3.10.7

Language Extension Version (if applicable)

Python Extension v2024.6.0

Anaconda Version (if applicable)

(not using Anaconda)

Running Jupyter locally or remotely?

Locally

epicwhale commented 4 months ago

@DonJayamanne hey - just checking any luck with this one? I've now chanced upon quite a few folks on the internet and around me who face this issue... what would it take to get some traction within the team? anything more we can help in terms of debug reports?

Yoyokrazy commented 4 months ago

Hey everyone, just want to update that I'll be looking into this as part of the next development cycle. If the repro is inconsistent or requires a more niche setup, I'll likely reach out towards the beginning of the new month. Thanks for the patience, will be addressing this soon.

jvprimakipr commented 3 months ago

It's June, and this is still an issue.

epicwhale commented 2 months ago

Eagerly waiting for this fix too!

@Yoyokrazy I can't emphasize enough how much this bug has plagued my productivity (and other folks I know) the past few months. I would be using VS Code so much more once this is fixed :) thanks in advance!

Gavin-OP commented 2 months ago

I have the same issue. Waiting for this fix!!!!

Yoyokrazy commented 2 months ago

@epicwhale + other people with consistent repro's

I've looked into this a bit and can't seem to reproduce this reliably, I think there is likely a kernel related context key issue causing this. To control the visibility/enablement of the Restart button in the notebook toolbar I've broken it down to be as follows:

simplified in plaintext (FOR GLOBAL TOOLBAR):
    is workspace trusted
    AND
    is notebook type of jupyter (ipynb)
    AND
    kernel id contains `ms-toolsai.jupyter`
    AND
    kernel is able to restart
    AND
    kernel "is jupyter"

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
notes:
    - `notebookKernel` is just the kernel id
    - able to restart/canrestartNotebookkernel represents the following condition
        - `kernel.status !== 'unknown' || executionService.executionCount > 0 || kernel.startedAtLeastOnce`
    - kernel is jupyter/jupyter.kernel.isjupyter represents the following condition
        - `document && isJupyterNotebook(document) && this.controllers.getSelected(document)`

Right now, my thought is that the bug lies at 🐛 kernel is able to restart, so I think the best thing to do would be to collect some context keys and general logs from you the next time you see this. To do this, follow these steps:

For those of you seeing the restart button greyed out in interactive windows, the same process will apply but you will look for: "jupyter.interactive.canRestartNotebookKernel"

sglbl commented 2 months ago

In my case, it only happens when I have second monitor attached and using 2 windows of vscode. Maybe this would help about finding the bug

epicwhale commented 2 months ago

@Yoyokrazy thanks for investigating. So I stopped using VS Code two weeks ago due to this bug. So I'll try my best if I can get back to it to repro it in the coming days. But here are two things that should help repro this consistently:

  1. what @sglbl mentioned above, using dual monitors + having a 2nd window of VS Code. Moreso, I think if you keep a jupyter notebook in the second window, the repro chance would be very high.

  2. using devcontainers (the project I faced this every few mins on was using a vs code dev container) - I wonder if there's anything to do with that exacerbates this.

Have you tried (1) dual monitor ?

Let me know if you are still stuck with it, and I'll try to repro this weekend if you still are.

Yoyokrazy commented 2 months ago

@epicwhale + @sglbl , thank you so much for that! The dual windows of vscode, with a notebook in each, repro'd right away.

The problem is indeed a context key bug, with two of the keys:

This gives me a good spot to dig into, will keep the issue up to date with findings.

epicwhale commented 1 month ago

@Yoyokrazy while you look closer at this one, could it be possible it's a very similar issue causing the 'Debug Cell' option to disappear arbitrarily too? there's dozens of users facing it here, including me: https://github.com/microsoft/vscode/issues/150219 - if so, you might be able to kill two birds with one! 🙏

Yoyokrazy commented 1 month ago

Yep, taking a look at a handful of potential context issues atm, with that one on the list 👍 thanks for the shout!

Yoyokrazy commented 1 month ago

So update on my end, the repro is highly inconsistent (though when it does appear, it is quite breaking as described). Been working in devcontainers + dual instances of VS Code so my theory is that there could be a race condition making this tricky to diagnose.

I've gone ahead and added logging statements in the PR linked above this, so the next time you see this, attaching logs (found in output view -> Jupyter) would be appreciated and will help diagnose the issue. Thanks!

epicwhale commented 1 month ago

@Yoyokrazy sure, if you can let me know when your PR makes it into the extension update (for Insider edition), I can keep it on and collect a log when it happens.

Is this all I have to set to debug to turn it on?

image
Yoyokrazy commented 1 month ago

@epicwhale, I went ahead and built a vsix that you can install locally, trying to avoid flooding standard jupyter users with logging. Otherwise, yep that is all you would need to do, logs would appear in the standard output channel that you've attached from before.

(this is just an artifact built from this PR: vscode-jupyter#15916) ms-toolsai-jupyter-insiders.vsix.zip

epicwhale commented 1 month ago

@Yoyokrazy Oddly I am not able to install this vsix file.. it does not appear in the install from vsix file picker even though I have unzipped it? do you have a better set of instructions to use your artifact? (on Mac here)

image

vsix file not appearing

image

even though it's clearly unzipped in my downloads folder?

image
Yoyokrazy commented 1 month ago

Sorry bout the delay, I'll whip up a new vsix in the evening and test it against my personal machine and see if I can get you a better set of steps. Not immediately sure why that vsix wouldn't work, but perhaps I can get you a platform specific vsix rather than a universal. 🏃