Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Handle debugger lifecycle #290

Merged
merged 16 commits into from
Dec 17, 2019
Merged

Handle debugger lifecycle #290

merged 16 commits into from
Dec 17, 2019

Conversation

jtpio
Copy link
Member

@jtpio jtpio commented Dec 16, 2019

Fixes #292.

A couple of fixes as a follow-up to #239.

To try it out:

Binder

TODO

  • Turn debugging off when the sidebar is closed
  • Notebook and console handlers lifecycle should follow the toggle button
  • Create the sidebar when enabling debugging via the button if it does not exist yet. Otherwise: do not show the switch button if there is no sidebar? (Can be handled separately)

Keep last debug session

toggle-last-session

Handle widgets with the same session

toggle-sync-sessions

Restore the state from the kernel

Remove the recently added debuggedClients to stay stateless

toggle-restore-state-from-kernel

@jtpio jtpio added this to the 0.1.0 milestone Dec 16, 2019
@jtpio
Copy link
Member Author

jtpio commented Dec 16, 2019

To make the experience less confusing and to avoid starting and stopping the debugger, we should tie the handlers lifecycle to the toggle button, and whether debugging is enabled for a given session path:

toggle-dispose-handlers

@jtpio jtpio mentioned this pull request Dec 17, 2019
@jtpio jtpio marked this pull request as ready for review December 17, 2019 08:53
@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

It turns out that the toggle button logic needed quite some refactoring. The main takeaway is that toggling the button should also create and dispose the debug handlers properly.

This change also removes the debuggedClient state that was introduced in #239, so the debugger still stays stateless.

To try it out:

Binder

As an improvement, we could consider adding a signal to the debug session, so the UI can update itself when the state of the session changes (started or stopped). For now we have to focus back on the widget to have the UI changes propagated.

@afshin afshin requested a review from KsavinN December 17, 2019 09:13
@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

The second main change is that we now don't create a DebugSession anymore for a client that doesn't support debugging.

This allows the debugger to keep "focus" on the previous client that supports debugging. As a side-effect we can inspect variables for a notebook being debugged, while working on a notebook that doesn't have support for debugging:

toggle-last-session

src/index.ts Outdated Show resolved Hide resolved
src/session.ts Outdated Show resolved Hide resolved
Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So good, negative delta pull request!

👍

@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

Will do a quick update to:

  • move DebugSession#requestDebuggingEnabled to IDebugger#isAvailable
  • guarantee IDebugger#isAvailable returns a boolean

@KsavinN
Copy link
Collaborator

KsavinN commented Dec 17, 2019

Locally it works well :)

Don't know why but I see that button changed shape to a circle. (That bug was only in Binder)
dotNotToggle

@afshin
Copy link
Member

afshin commented Dec 17, 2019

Hm, @KsavinN, try running a git clean -fdx before rebuilding, maybe? I see the correct toggle when I build it.

@KsavinN
Copy link
Collaborator

KsavinN commented Dec 17, 2019

Hm, @KsavinN, try running a git clean -fdx before rebuilding, maybe? I see the correct toggle when I build it.

I did it locally. It's work properly. That bug appears during using a binder.

@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

Also seeing that on Binder, but not locally.

@afshin
Copy link
Member

afshin commented Dec 17, 2019

@jtpio I guess it should just be a method on DebugService that is exposed on the IDebugger interface.

@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

That sounds like the best option indeed.

@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

For Binder and the toggle button, it looks like an issue with JupyterLab 1.1.4 (which is used on Binder for now). Or maybe just the 1.1 series.

This can be reproduced locally in a fresh environment:

conda create -n debugger-test -c conda-forge jupyterlab=1.1.4 xeus-python ptvsd
jupyter labextension install @jupyterlab/debugger --debug
jupyter lab xpython_example.ipynb

We are probably all using 1.2+ locally.

@jtpio jtpio changed the title Handle debugger and sidebar lifecycle Handle debugger lifecycle Dec 17, 2019
@jtpio
Copy link
Member Author

jtpio commented Dec 17, 2019

This should be ready to go now, cc @afshin @KsavinN if you want to have another look.

Copy link
Member

@afshin afshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@afshin afshin merged commit 27c0061 into jupyterlab:master Dec 17, 2019
@jtpio jtpio deleted the button-sidebar branch December 18, 2019 09:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Debugger automatically starts then stops when new notebook is opened.
3 participants