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

Auto scroll outputs #11760

Open
jtpio opened this issue Dec 29, 2021 · 13 comments
Open

Auto scroll outputs #11760

jtpio opened this issue Dec 29, 2021 · 13 comments

Comments

@jtpio
Copy link
Member

jtpio commented Dec 29, 2021

Problem

The classic notebook has some logic to auto scroll outputs when they become too long:

https://github.com/jupyter/notebook/blob/a9a31c096eeffe1bff4e9164c6a0442e0e13cdb3/notebook/static/notebook/less/outputarea.less#L12

This is useful becomes it saves screen real estate and doesn't confuse users when outputs are really long and take a lot of space.

For example:

classic-autoscroll-outputs.mp4

Proposed Solution

There is an effort to mimic that behavior in RetroLab: jupyterlab/retrolab#288

If the result ends up being useful and working, we should consider moving it to JupyterLab so it's available by default in the notebook. And fixes parity with the classic notebook.

Additional context

This was also reported in berkeley-dsep-infra/datahub#2992 and berkeley-dsep-infra/datahub#2994

auto is also specified in the nbformat spec: https://nbformat.readthedocs.io/en/latest/format_description.html#code-cells

Also linking to #5897 as related.

@PAGWatson
Copy link

I thought I'd ask has the retrolab solution been tested with code that gives a mix of warnings from modules and output from print statements? This is because I found that a workaround for jupyterlab using the Stylus browser extension did not work in this case (mentioned at #5897 (comment)). In that case, warnings produced by modules seem to be treated as distinct from script output, so sections of script output divided by warning messages can become very long without being scrolled. So it would seem good to include this as a test case.

@jtpio
Copy link
Member Author

jtpio commented Jan 13, 2023

Thanks @PAGWatson for the suggestion.

Would you be able to try with the latest Notebook 7 pre-release?

You can install it with pip install --pre notebook. Notebook 7 is based on RetroLab and has support for auto scrolled outputs.

@PAGWatson
Copy link

Thanks for responding quickly. Not right at the minute. But it works fine in Notebook 6, so if the function isn't very different to that then I guess it's probably fine.

@jtpio
Copy link
Member Author

jtpio commented Jan 13, 2023

It's also possible to try the Notebook 7 pre-release more easily on Binder: https://mybinder.org/v2/gist/jtpio/d368ab89cee5123ecee60683115e15f3/master?urlpath=/tree

@PAGWatson
Copy link

I tested it and it seemed to work for my case.

Is there a way to set the default height of the scroll window? I use a large screen and would like to be able to set the scroll window so it takes up all of the available height, in order to view large figures. I see there is a grab thing that lets the window be resized with the mouse, but it would be better not to have to do this each time. In notebook 6, I used commands like

from IPython.display import display, HTML
display(HTML("<style>div.output_scroll { height: 55em; }</style>"))

at the top of my notebooks, but now this does not seem to have an effect.

@jtpio
Copy link
Member Author

jtpio commented Jan 16, 2023

Thanks @PAGWatson for testing.

Is there a way to set the default height of the scroll window?

Not at the moment but maybe this could be made possible via the settings? Currently there is a threshold hardcoded here.

at the top of my notebooks, but now this does not seem to have an effect.

The class name is different in Notebook 7. Maybe using jp-mod-outputsScrolled would work.

@krassowski
Copy link
Member

Not at the moment but maybe this could be made possible via the settings? Currently there is a threshold hardcoded here.

+1. Shall we track this in an older issue, #7567?

@PAGWatson
Copy link

Thanks.

I didn't manage to set the scroll window height with a command - doing e.g.
display(HTML("<style>div.jp-mod-outputsScrolled { height: 100em; }</style>"))
seems to increase the spacing underneath scroll windows, but not actually make the windows taller to fill the space.

@JasonWeill JasonWeill modified the milestones: 4.0.0, 4.1.0 Feb 1, 2023
@fcollonval fcollonval modified the milestones: 4.1.0, 4.0.0 Feb 2, 2023
@krassowski
Copy link
Member

A relevant piece in JupyterLab code:

// We don't have the notion of 'auto' scrolled, so we make it false.
if (this.model.getMetadata('scrolled') === 'auto') {
this.outputsScrolled = false;
} else {

@jtpio
Copy link
Member Author

jtpio commented Mar 1, 2023

Bumping to 4.1.0 as this could likely be added without introducing breaking changes.

@burnpanck
Copy link

Not sure if this is this is the right place - let me try anyway: I just upgraded to jupyter notebook 7.0, thus migrating from the "classic" experience to the "jupyterlab" based version. With that migration, my user-experience has degraded significantly. I have a notebook that hosts a number of weakly related interactive tasks that I run sporadically while exploring a problem. The output from some of these cells can sometimes be 100s of lines long. In general, that output being collapsed is great, but while a specific task is running, I want to be able to use the full screen real-estate to monitor the (long-running) task as it goes. Previously, I would un-collapse the output after it started, and then be able to just follow the output, as it is generated. Now, if I attempt to do that, after a several seconds and potentially hundreds of lines of output later, it auto-collapses again. All of a sudden, this leaves me (who followed the output in the uncollapsed state) in the middle of nowhere far away in that document. It appears, previously, it would only auto-collapse once per execution, but now it does it repeatedly. Where is the right place to discuss this issue?

@jtpio
Copy link
Member Author

jtpio commented Aug 1, 2023

@burnpanck would it be possible to provide a screencast to highlight the issue you are experiencing?

Auto scrolling outputs in currently only implemented in Notebook 7 at the moment. So we could track that specific issue in the notebook repo if you would like to open one there: https://github.com/jupyter/notebook

@burnpanck
Copy link

Ping me again in a week, I have an urgent deadline that I need to make. I have downgraded to notebook 6.5 in the meanwhile so I can work.

@krassowski krassowski added this to the 4.3.0 milestone May 7, 2024
@krassowski krassowski modified the milestones: 4.3.0, 4.4.0 Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants