Skip to content

Notebook scroll position affects correctness of anywidget client code #17132

@ntjess

Description

@ntjess

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

If an anywidget.AnyWidget is not in view when its cell is being rendered, the frontend never executes its render code. A reproducibility nightmare 😅. In standard jupyter, the code always executes if the widget is in a cell's output, even if the cell is not in view

main.ipynb

To reproduce:

  1. Run the notebook with the scroll position at the top of the document
  2. Observe the widget content changes successfully
  3. Restart and clear outputs
  4. Scroll to the bottom of the document and
  5. Run all cells again without scrolling
  6. Wait 1 second, and scroll up
  7. Observe the timeout error is raised and the widget contents never change

Bonus steps:

  1. Clear all outputs and scroll to the bottom again
  2. From command palette, toggle developer tools
  3. Run all cells and wait
  4. As you scroll up, you will see the console log statement from the anywidget hits the dev console generally as the widget comes into view(!!)

VS Code Version

Version: 1.105.1 (Universal) Commit: 7d842fb85a0275a4a8e4d7e040d2625abbf7f084 Date: 2025-10-14T22:33:36.618Z Electron: 37.6.0 ElectronBuildId: 12502201 Chromium: 138.0.7204.251 Node.js: 22.19.0 V8: 13.8.258.32-electron.0 OS: Darwin arm64 25.0.0

Jupyter Extension Version

2025.10.2025101001

Jupyter logs

No log messages shown during execution

Coding Language and Runtime Version

python 3.13.7

Language Extension Version (if applicable)

2025.16.0

Anaconda Version (if applicable)

N/A, using uv

Running Jupyter locally or remotely?

Local

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugtriage-neededIssue needs to be triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions