Skip to content

Commit 982721a

Browse files
dbg
1 parent d4f82de commit 982721a

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

kernel/src/components/Dialog.ts

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { ConnectCard } from './ConnectCard';
22
import { ServiceContainer } from '../services/ServiceContainer';
33
import { Card } from './Card';
4-
import { NotebookPanel } from '@jupyterlab/notebook';
5-
import { INotebookTracker} from '@jupyterlab/notebook';
4+
// import { NotebookPanel } from '@jupyterlab/notebook';
5+
// import { INotebookTracker} from '@jupyterlab/notebook';
66

77
export interface DialogProps {
88
closeDialog: () => void;
99
serviceContainer: ServiceContainer;
10-
nTracker: INotebookTracker;
1110
}
1211

1312
export class Dialog {
@@ -51,29 +50,29 @@ export class Dialog {
5150
// console.log("[Dialog] saveCard: props.app =", props.app);
5251
// const notebook = (props.app.shell as any).currentWidget as NotebookPanel | null;
5352
// console.log("[Dialog] saveCard: notebook =", notebook);
54-
const notebook = props.nTracker.currentWidget as NotebookPanel | null;
55-
var allCellContent : string = '';
53+
// const notebook = props.nTracker.currentWidget as NotebookPanel | null;
54+
// var allCellContent : string = '';
5655

5756
console.log("[Dialog] saveCard: Saving notebook content...");
5857

59-
if (notebook) {
60-
console.log("[Dialog] saveCard: Found notebook:", notebook.title.label);
61-
notebook.revealed.then(() => {
58+
// if (notebook) {
59+
// console.log("[Dialog] saveCard: Found notebook:", notebook.title.label);
60+
// notebook.revealed.then(() => {
6261

63-
if (notebook.content.model) {
64-
for (const cell of notebook.content.model.cells) {
65-
const shared_cell_mapping = cell.sharedModel;
66-
if (shared_cell_mapping.cell_type === 'code') {
67-
allCellContent += shared_cell_mapping.getSource() + '\n\n';
68-
}
69-
}
70-
}
71-
72-
console.log("[Dialog] saveCard: Cells to save:", allCellContent);
73-
});
74-
}
75-
76-
return props.serviceContainer.saveCodeToDevice(allCellContent);
62+
// if (notebook.content.model) {
63+
// for (const cell of notebook.content.model.cells) {
64+
// const shared_cell_mapping = cell.sharedModel;
65+
// if (shared_cell_mapping.cell_type === 'code') {
66+
// allCellContent += shared_cell_mapping.getSource() + '\n\n';
67+
// }
68+
// }
69+
// }
70+
71+
// console.log("[Dialog] saveCard: Cells to save:", allCellContent);
72+
// });
73+
// }
74+
75+
// return props.serviceContainer.saveCodeToDevice(allCellContent);
7776
});
7877

7978
optionsContainer.appendChild(this.connectCard.getElement());

kernel/src/index.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
// Removed Widget import as we're no longer using @lumino/widgets
12
import { JupyterLiteServer, JupyterLiteServerPlugin } from '@jupyterlite/server';
23
import { IKernel, IKernelSpecs } from '@jupyterlite/kernel';
3-
import { INotebookTracker } from '@jupyterlab/notebook';
44
import { EmbeddedKernel } from './kernel';
55
import WelcomePanel from './panel';
66
import { ServiceContainer } from './services/ServiceContainer';
77
import { DeviceService } from './services/DeviceService';
88

9+
// Variable for saving the DeviceService instance so we can restore it if kernel is restarted
910
var devService: DeviceService | null = null;
1011

12+
// Kernel plugin for the embedded kernel
1113
const kernelPlugin: JupyterLiteServerPlugin<void> = {
1214
id: 'jupyterlite-embedded-kernel:kernel',
1315
autoStart: true,
14-
requires: [IKernelSpecs, INotebookTracker], // Add INotebookTracker here
15-
activate: (
16-
app: JupyterLiteServer,
17-
kernelspecs: IKernelSpecs,
18-
notebookTracker: INotebookTracker // Add notebookTracker parameter
19-
) => {
16+
requires: [IKernelSpecs],
17+
activate: (app: JupyterLiteServer, kernelspecs: IKernelSpecs) => {
2018
const activeKernels = new Map<string, EmbeddedKernel>();
2119

20+
// print the app to console
21+
console.log("JupyterLite Embedded Kernel Plugin Activated. App:", app);
22+
2223
app.router.post('/api/kernels/(.*)/interrupt', async (req, kernelId: string) => {
2324
const kernel = activeKernels.get(kernelId);
2425
if (kernel) {
@@ -50,17 +51,19 @@ const kernelPlugin: JupyterLiteServerPlugin<void> = {
5051
const serviceContainer = new ServiceContainer(devService);
5152
await serviceContainer.init();
5253

54+
// Save the DeviceService instance so we can restore it if kernel is restarted
5355
devService = serviceContainer.deviceService;
5456

5557
const welcomePanel = new WelcomePanel(
56-
serviceContainer,
57-
notebookTracker // Pass notebookTracker here
58+
serviceContainer
5859
);
5960
document.body.appendChild(welcomePanel.getElement());
6061
const kernel = new EmbeddedKernel(options, serviceContainer);
6162

63+
// welcomePanel.show();
6264
welcomePanel.initialShow();
6365

66+
// If the deivce is already connected, update the welcome panel
6467
if (serviceContainer.deviceService.isConnected()) {
6568
welcomePanel.updateOnConnection("Connected");
6669
}

kernel/src/panel.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { globalStyles, animations, overlayStyles, dialogStyles, minimizedStyles,
22
import { MinimizedButton } from './components/MinimizedButton';
33
import { Dialog } from './components/Dialog';
44
import { ServiceContainer } from './services/ServiceContainer';
5-
import { INotebookTracker} from '@jupyterlab/notebook';
5+
// import { INotebookTracker} from '@jupyterlab/notebook';
66

77
class DialogPanel {
88
private element: HTMLDivElement;
@@ -94,7 +94,6 @@ export default class WelcomePanel {
9494

9595
constructor(
9696
private serviceContainer: ServiceContainer,
97-
private nTracker: INotebookTracker
9897
) {
9998

10099
this.element = document.createElement('div');
@@ -119,7 +118,6 @@ export default class WelcomePanel {
119118
const dialog = new Dialog({
120119
closeDialog: () => this.hide(),
121120
serviceContainer: this.serviceContainer,
122-
nTracker: this.nTracker,
123121
});
124122
this.dialogPanel = new DialogPanel(dialog);
125123

0 commit comments

Comments
 (0)