How to we know when the Shell of the JupyterFrontEnd instance is ready to have Widgets added to it?

If I try to .add a widget to the Shell immediately after my extension starts, it doesn’t seem to work. However, if I wait some time (about 5 seconds) and then add it, the Widget displays.
How do we know when the Shell is ready for Widgets to be added? I’ve looked for Promises and Signals, but I haven’t been able to find it.

It looks like when this promise resolves the Shell is ready to have Widgets added to it: jupyterFrontEnd.restored.then

It will be interesting to take a closer look at it.

Yes, add it after the restored promise fulfills. That restored promise fulfills when the ux has restored all the documents that were open in the workspace, so you want to add new things after that.

1 Like