microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.81k stars 131 forks source link

Send custom message to Python extension in VS Code for justMyCode #170

Closed Anapo14 closed 2 years ago

Anapo14 commented 4 years ago

We are learning that most users are struggling to discover the justMyCode warning message we print in the debugger console when they attempt to step into library and have the toggle set to 'true'. It would be great if we could send a custom message to the python extension and let the extension-side handle the action of pulling focus to the console,better alerting users about the justMyCode warning. We could even have a pop-up that allows the user to disable the setting as well as a 'learn more' link included in the notification that leads to a screenshot/example in the docs displaying the behavior.

int19h commented 4 years ago

A popup is probably a better idea here.

Do we want this to be a specific message for JMC specifically, or a more generic one that'll allow us to do other popup notifications in the future?

karthiknadig commented 4 years ago

We need a generic mechanism for this. We really need a API in VSCode to handle custom reverse requests. Until that point this should be an event.

Anapo14 commented 4 years ago

A more generic one @int19h. +1 to Karthik.

fabioz commented 3 years ago

I think we may also want to show a message in case a breakpoint is disabled due to justMyCode (i.e.: the VSCode UI isn't great at the moment: https://github.com/microsoft/debugpy/issues/572).

int19h commented 2 years ago

@fabioz, since you're already touching the relevant code in https://github.com/microsoft/debugpy/pull/766, do you want to add the custom message, as well?

fabioz commented 2 years ago

Sure... this will also need something in the VSCode Python side (which is probably most of the work to have this implemented), so, it'd be nice to have the format which would be expected in the client defined to implement this feature.

I think that a straightforward way could be just adding some json data to the existing output event and then have the UI act on it.

int19h commented 2 years ago

Since the ask was for a generic mechanism, I think re-using "output" makes a lot of sense. But I don't think we can use "data" alone, since the spec says it will be pretty-printed out.

Now, in the DAP spec for "output", the "category" property allows for arbitrary strings. So we can add a new category - say, "warning"? And then the message goes into "output" - and I don't think we need "data" then.

@karthiknadig, what do you think?

int19h commented 2 years ago

DAP now has the "important" category that is exactly this: https://github.com/microsoft/debug-adapter-protocol/issues/218

It's not implemented in the VSCode client just yet, but it's already scheduled: https://github.com/microsoft/vscode/issues/138091

Note that existing clients are already required by the spec to implement any unknown value as "console", so we can switch right away without having to wait for VSCode.

karthiknadig commented 2 years ago

DAP now has the "important" category that is exactly this: microsoft/debug-adapter-protocol#218

This is fantastic.