Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Notebook editor contributions are instantiated before the _list (NotebookCellList) is created, causing cryptic "Cannot read property of undefined" errors when calling viewzone or overlay APIs in contribution constructors.

Changes

Added guard checks to three methods in NotebookEditorWidget:

  • changeViewZones() - Throws clear error if _list is not initialized
  • getViewZoneLayoutInfo() - Throws clear error if _list is not initialized
  • changeCellOverlays() - Throws clear error if _list is not initialized

Error messages now explain the problem and suggest deferring calls until after the notebook editor is fully initialized (e.g., after view model attachment).

Example

Before: Calling from a contribution constructor resulted in:

TypeError: Cannot read property 'changeViewZones' of undefined

After: Clear, actionable error:

Error: Cannot change notebook viewzones before the list view is initialized. 
Consider deferring the viewzone changes until after the notebook editor is 
fully initialized (e.g., after the view model is attached).
Original prompt

This section details on the original issue you should resolve

<issue_title>Unable to create Notebook viewzones before the ViewModel is attached (i.e. before notebook list view is setup)</issue_title>
<issue_description>* When trying to add viewzones to notebooks in notebook editor contribution, the list view may not have been initialized yet.

  • However the viewzone API requires the list view to be initialized, as we might be passing the index position for viewzones.
    As a result things fall over.

</issue_description>

Comments on the Issue (you are @copilot in this section)

@DonJayamanne I think we should at a minimum throw a meaningful error message. This should make it simpler to debug and understand whats going on, note, this is not a solution but would have definitely saved time and will save others time when using this internal API.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix error handling for notebook viewzones initialization Add meaningful error messages when calling notebook APIs before list view initialization Dec 10, 2025
Copilot AI requested a review from DonJayamanne December 10, 2025 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to create Notebook viewzones before the ViewModel is attached (i.e. before notebook list view is setup)

2 participants