microsoft / vscode

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

Multiple terminal devMode status bar entries can show up #211859

Open Tyriar opened 5 months ago

Tyriar commented 5 months ago

It's only meant to show for focused one:

Screenshot 2024-05-02 at 10 52 55 AM
Tyriar commented 5 months ago

Repro:

  1. Create several terminals
  2. Create this keybinding { "key": "ctrl+shift+k", "command": "workbench.action.terminal.focusPrevious" }
  3. ctrl+shift+k several times
Tyriar commented 5 months ago

@bpasero there seems to be a race condition here around StatusBarModel.onDidStorageValueChange. The above repro is very reliable after ~5 ctrl+shift+k's, but it will go away completely if I comment out the StatusBarModel.onDidStorageValueChange implementation.

bpasero commented 5 months ago

Works fine for me:

Recording 2024-05-03 at 08 45 56

vscodenpa commented 5 months ago

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

Tyriar commented 5 months ago

@bpasero oh sorry you need to set "terminal.integrated.developer.devMode": true and recreate the terminals

Recording 2024-05-03 at 05 14 43

bpasero commented 5 months ago

I can reproduce but I do not have a good idea how to fix this. I think the challenge is that we get an event to the process that actually changed the storage and then see a mismatch between the storage value we receive and the latest in-memory state:

https://github.com/microsoft/vscode/blob/75a7755c6599627089de4c8355f05b8a708ddcda/src/vs/workbench/browser/parts/statusbar/statusbarModel.ts#L58

I know we added a external property to the storage change event to distinguish this:

https://github.com/microsoft/vscode/blob/75a7755c6599627089de4c8355f05b8a708ddcda/src/vs/platform/storage/common/storage.ts#L274-L281

But it sometimes wrongly reports external: true even when the value changed from within the renderer where I am listening. I think this is maybe because the in-memory state changed before the event returned and then maybe we think its an external change?