Debugger: Preserve variables panel contents when switching editor focus#17830
Conversation
|
Thanks for making a pull request to jupyterlab! |
| @@ -709,7 +709,6 @@ export class DebuggerService implements IDebugger, IDisposable { | |||
| */ | |||
| private _clearModel(): void { | |||
| this._model.callstack.frames = []; | |||
There was a problem hiding this comment.
Shouldn't we do the same for stack frames?
If this is the proper fix, then why is _clearModel there and in which other case is it useful?
There was a problem hiding this comment.
Shouldn't we do the same for stack frames?
I am not sure about stack frames but I tried removing that as well as while I tested it I didn't notice anything broken.
If this is the proper fix, then why is _clearModel there and in which other case is it useful?
_clearModel is used in several places in the same file (service.ts):
-
In the session setter, when
event.event === 'continued'line 117 -
When DebuggerService Continues the execution of the current thread line 219
-
When retrieving frames to get the latest state of variables line 263
-
When the
DebuggerServiceis started line 463
It seems useful to me but maybe @krassowski or @jtpio could give more insight. (sorry for the ping)
There was a problem hiding this comment.
It seems that callstack panel isn't cleared when switching focus on notebooks:
Screencast.From.2025-09-02.13-03-16.mp4
Is this code this._model.callstack.frames = []; even called? It should right, so why is the callstack panel not being empty?
|
What happens if I click on a file in |
Hi, I tried doing this (behaviour looks normal to me): Screen.Recording.2025-08-29.at.18.45.04.mp4 |
|
Thanks for more context @krassowski, I don't know if it works the way we expect it to but here it is - Screen.Recording.2025-08-29.at.19.43.49.mp4 |
|
Hi @krassowski, I'm wondering if the visual regression test failure is actually related to the change because when i inspect the test assets it doesn't look like they are related - would be glad to know what you think. Thanks |
|
No, the mermaid failures are known and tracked in #17820 |
martinRenou
left a comment
There was a problem hiding this comment.
That looks good to me! Thanks!

References
Potential fix for #17829
Code changes
Currently, when switching focus between editors, the debugger’s
_clearModel()method clears both the callstack and variables scopes:jupyterlab/packages/debugger/src/service.ts
Lines 710 to 713 in 11a9a7c
This causes the Variables panel to be emptied whenever focus changes, even if a debugging session is still active. In contrast, the Breakpoints panel correctly persists its state across focus changes.
This PR modifies
_clearModel()to only clear the callstack frames, allowing the Variables panel to preserve the last known state until updated by the active session.User-facing changes
Screen.Recording.2025-08-29.at.15.13.15.mp4
Backwards-incompatible changes