Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notebook variables pane sync #5583

Merged
merged 13 commits into from
Dec 11, 2024
Merged

Notebook variables pane sync #5583

merged 13 commits into from
Dec 11, 2024

Conversation

nstrayer
Copy link
Contributor

@nstrayer nstrayer commented Dec 3, 2024

Addresses #2452

This PR adds the ability for the variables pane to "follow" the user around as they work across different sessions (particularly useful for notebooks that have their own sessions.)

It works by automatically switching the variables pane in the following circumstances

  • If the active editor tab is changed
    • If changed to a notebook, will switch variables to that notesbook session's variables
    • If changed to a non-notebook file such as a script, will switch the variables to the last-active console session.
  • If code is run in the console the session backing the console's variables will be focused.
variables-follow-mode.mov

All of this behavior can be turned off by setting the positron.variables.followMode setting to false. (src/vs/workbench/services/positronVariables/common/positronVariables.contribution.ts)

Annoyances

  • Currently there's no real way to correlate a script like a .R or .py script with a session. In this case we go back to the most recent console session, but that could be confusing if you clicked onto an R session and your most recent console was a python session. I left this behavior as is because it's what currently happens and it feels like the upcoming multi-session work will formalize behavior around this.

Code Refactoring:

  • Renamed the method setActivePositronVariablesInstance to _setActivePositronVariablesInstance for consistency with other private methods. (src/vs/workbench/services/positronVariables/common/positronVariablesService.ts)

QA notes:

Should be able to fiddle between different notebooks and consoles and the variables pane should go to where you expect it to.

@nstrayer nstrayer force-pushed the notebook-variables-pane-sync branch from 846302b to faeb9b3 Compare December 4, 2024 20:32
seeM
seeM previously approved these changes Dec 6, 2024
Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

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

Code changes LGTM and confirmed the expected behavior locally. A few thoughts below:

Should variables also select the correct runtime on Positron startup? For example, I had a notebook opened from a previous session, and when I started Positron it wasn't selected. We might just need to check the active editor etc when we also register the event listeners.

Also, should variables switch to the notebook runtime when a notebook cell is executed?

@nstrayer nstrayer force-pushed the notebook-variables-pane-sync branch from faeb9b3 to fb8d591 Compare December 6, 2024 20:03
…ing last console instance in favor of the foreground instance property on the session service.
seeM
seeM previously approved these changes Dec 11, 2024
Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for laying the groundwork for unit testing the variables service!

@nstrayer nstrayer merged commit 1015d73 into main Dec 11, 2024
5 checks passed
@nstrayer nstrayer deleted the notebook-variables-pane-sync branch December 11, 2024 16:53
@github-actions github-actions bot locked and limited conversation to collaborators Dec 11, 2024
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.

2 participants