Skip to content

Commit

Permalink
sys info cell order
Browse files Browse the repository at this point in the history
  • Loading branch information
amunger committed Oct 2, 2024
1 parent 92a16fd commit 9f97edb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/interactive-window/InteractiveWindowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export class InteractiveWindowController {
throw new Error('Interactive Window kernel not selected');
}

await this.setInfoMessage(this.metadata, SysInfoReason.Start);
this.setInfoMessage(this.metadata, SysInfoReason.Start);
try {
const kernel = await this.createKernel();
const kernelEventHookForRestart = async () => {
if (this.interactiveWindow.notebookDocument && this.metadata) {
this.systemInfoCell = undefined;
// If we're about to restart, insert a 'restarting' message as it happens
await this.setInfoMessage(this.metadata, SysInfoReason.Restart);
this.setInfoMessage(this.metadata, SysInfoReason.Restart);
}
};
// Hook pre interrupt so we can stick in a message
Expand Down Expand Up @@ -220,9 +220,13 @@ export class InteractiveWindowController {
}
}

public async resolveSysInfoCell(){
await this.systemInfoCell?.resolveCell();
}

private setInfoMessage(metadata: KernelConnectionMetadata, reason: SysInfoReason) {
const message = getStartConnectMessage(metadata, reason);
return this.setInfoMessageCell(message);
this.setInfoMessageCell(message);
}

private finishSysInfoMessage(kernel: IKernel, reason: SysInfoReason) {
Expand Down
3 changes: 2 additions & 1 deletion src/interactive-window/interactiveWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export class InteractiveWindow implements IInteractiveWindow {
}

if (this.controller.controller) {
this.controller.startKernel().catch(noop);
await this.controller.startKernel();
await this.controller.resolveSysInfoCell();
} else {
logger.info('No controller selected for Interactive Window initialization');
this.controller.setInfoMessageCell(DataScience.selectKernelForEditor);
Expand Down
4 changes: 4 additions & 0 deletions src/interactive-window/systemInfoCell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export class SystemInfoCell {
this.sysInfoCellPromise = this.getOrUpdate(message);
}

public async resolveCell() {
return await this.sysInfoCellPromise;
}

private async getOrUpdate(message: string) {
const lastCellIndex = (await this.interactiveWindow.getAppendIndex()) - 1;
if (lastCellIndex >= 0) {
Expand Down

0 comments on commit 9f97edb

Please sign in to comment.