diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index 6ed08a8f1..00d15bdb1 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -363,7 +363,7 @@ export class Compiler extends MonacoPane { diff --git a/static/panes/executor.ts b/static/panes/executor.ts index 9208f0152..fdc8d969a 100644 --- a/static/panes/executor.ts +++ b/static/panes/executor.ts @@ -186,7 +186,7 @@ export class Executor extends Pane { this.compilerIsVisible, ); - this.initLibraries(state); + await this.initLibraries(state); this.updateCompilerInfo(); this.updateState(); @@ -906,6 +906,8 @@ export class Executor extends Pane { this.compiler?.remote ?? undefined, ), ); + // Wait for the lazily-loaded libraries to be selected before compiling or persisting state. + await this.libsWidget.stateLoaded; } onFontScale(): void { diff --git a/static/widgets/libs-widget.ts b/static/widgets/libs-widget.ts index dcbbb4ebe..4ac24aac8 100644 --- a/static/widgets/libs-widget.ts +++ b/static/widgets/libs-widget.ts @@ -139,6 +139,9 @@ export class LibsWidget { private readonly onChangeCallback: () => void; + // Resolves once the saved state has been applied to the lazily-loaded library list. + public readonly stateLoaded: Promise; + private readonly availableLibs: AvailableLibs; private readonly filters: PopupAlertFilter[] = [ (compilerId, langId) => { @@ -176,9 +179,10 @@ export class LibsWidget { this.initButtons(); this.onChangeCallback = onChangeCallback; this.availableLibs = {}; - this.updateAvailableLibs(possibleLibs, true).then(() => { + this.stateLoaded = this.updateAvailableLibs(possibleLibs, true).then(() => { this.loadState(state); this.fullRefresh(); + this.updateButton(); }); const searchInput = this.domRoot.find('.lib-search-input');