Skip to content

Commit bf25ca2

Browse files
committed
Restore logic around restoring widgets when the kernel connection goes to connected.
In particular, there was a subtle piece of logic for not restoring notebook widgets when a kernel reconnected.
1 parent 73e4166 commit bf25ca2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

packages/jupyterlab-manager/src/manager.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,10 @@ export class WidgetManager extends LabWidgetManager {
588588
// Only restore if our initial restore at construction is finished
589589
if (this._initialRestoredStatus) {
590590
// We only want to restore widgets from the kernel, not ones saved in the notebook.
591-
this.restoreWidgets(this._context!.model);
591+
this.restoreWidgets(this._context!.model, {
592+
loadKernel: true,
593+
loadNotebook: false
594+
});
592595
}
593596
}
594597
}
@@ -602,9 +605,16 @@ export class WidgetManager extends LabWidgetManager {
602605
/**
603606
* Restore widgets from kernel and saved state.
604607
*/
605-
async restoreWidgets(notebook: INotebookModel): Promise<void> {
606-
await this._loadFromKernel();
607-
await this._loadFromNotebook(notebook);
608+
async restoreWidgets(
609+
notebook: INotebookModel,
610+
{ loadKernel, loadNotebook } = { loadKernel: true, loadNotebook: true }
611+
): Promise<void> {
612+
if (loadKernel) {
613+
await this._loadFromKernel();
614+
}
615+
if (loadNotebook) {
616+
await this._loadFromNotebook(notebook);
617+
}
608618
this._restoredStatus = true;
609619
this._initialRestoredStatus = true;
610620
this._restored.emit();

0 commit comments

Comments
 (0)