Skip to content

Commit 6acd0be

Browse files
dbg
1 parent 822dfa6 commit 6acd0be

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

kernel/src/components/Dialog.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { ConnectCard } from './ConnectCard';
22
import { ServiceContainer } from '../services/ServiceContainer';
33
import { Card } from './Card';
4+
import { JupyterLiteServer } from '@jupyterlite/server';
45
// import { NotebookPanel } from '@jupyterlab/notebook';
56
// import { INotebookTracker} from '@jupyterlab/notebook';
67

78
export interface DialogProps {
89
closeDialog: () => void;
910
serviceContainer: ServiceContainer;
11+
app: JupyterLiteServer;
1012
}
1113

1214
export class Dialog {
@@ -47,7 +49,14 @@ export class Dialog {
4749
// create an arrow function that calls the save method on the serviceContainer but first iterates over all cells and gathers their code content if they are code cells
4850
async () => {
4951
// TODO: current widget might not be correct at this level, need to check and possibly change how we're getting this
50-
// console.log("[Dialog] saveCard: props.app =", props.app);
52+
console.log("[Dialog] saveCard: props.app =", props.app);
53+
54+
// Wait for the app to not be null
55+
if (!props.app) {
56+
console.error("[Dialog] saveCard: props.app is null, cannot save notebook.");
57+
return;
58+
}
59+
5160
// const notebook = (props.app.shell as any).currentWidget as NotebookPanel | null;
5261
// console.log("[Dialog] saveCard: notebook =", notebook);
5362
// const notebook = props.nTracker.currentWidget as NotebookPanel | null;

kernel/src/index.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
1717
activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs) => {
1818
const activeKernels = new Map<string, EmbeddedKernel>();
1919

20-
// print the app to console
21-
console.log("JupyterLite Embedded Kernel Plugin Activated. App:", app);
22-
// Get the current NotebookPanel instance if available
23-
// @ts-ignore: JupyterLite may expose notebook panel via global or app context
24-
const notebookPanel = (window as any).notebookPanel || app.notebookPanel || null;
25-
console.log("Notebook Panel:", notebookPanel);
26-
2720
app.router.post('/api/kernels/(.*)/interrupt', async (req, kernelId: string) => {
2821
const kernel = activeKernels.get(kernelId);
2922
if (kernel) {
@@ -59,7 +52,8 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
5952
devService = serviceContainer.deviceService;
6053

6154
const welcomePanel = new WelcomePanel(
62-
serviceContainer
55+
serviceContainer,
56+
app
6357
);
6458
document.body.appendChild(welcomePanel.getElement());
6559
const kernel = new EmbeddedKernel(options, serviceContainer);
@@ -76,14 +70,6 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
7670

7771
activeKernels.set(kernel.id, kernel);
7872

79-
// print the app to console
80-
console.log("JupyterLite Embedded Kernel Plugin Later app show:", app);
81-
82-
// Get the current NotebookPanel instance if available
83-
// @ts-ignore: JupyterLite may expose notebook panel via global or app context
84-
const notebookPanel = (window as any).notebookPanel || app.notebookPanel || null;
85-
console.log("Notebook Panel Later:", notebookPanel);
86-
8773
return kernel;
8874
}
8975
});

kernel/src/panel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { MinimizedButton } from './components/MinimizedButton';
33
import { Dialog } from './components/Dialog';
44
import { ServiceContainer } from './services/ServiceContainer';
55
// import { INotebookTracker} from '@jupyterlab/notebook';
6+
import { JupyterLiteServer } from '@jupyterlite/server';
67

78
class DialogPanel {
89
private element: HTMLDivElement;
@@ -94,6 +95,7 @@ export default class WelcomePanel {
9495

9596
constructor(
9697
private serviceContainer: ServiceContainer,
98+
private app: JupyterLiteServer
9799
) {
98100

99101
this.element = document.createElement('div');
@@ -118,6 +120,7 @@ export default class WelcomePanel {
118120
const dialog = new Dialog({
119121
closeDialog: () => this.hide(),
120122
serviceContainer: this.serviceContainer,
123+
app: this.app
121124
});
122125
this.dialogPanel = new DialogPanel(dialog);
123126

0 commit comments

Comments
 (0)