|
9 | 9 | } from '@jupyter/chat';
|
10 | 10 | import {
|
11 | 11 | JupyterFrontEnd,
|
12 |
| - JupyterFrontEndPlugin |
| 12 | + JupyterFrontEndPlugin, |
| 13 | + ILayoutRestorer |
13 | 14 | } from '@jupyterlab/application';
|
14 | 15 | import { ReactWidget, IThemeManager } from '@jupyterlab/apputils';
|
15 | 16 | import { ICompletionProviderManager } from '@jupyterlab/completer';
|
@@ -45,15 +46,21 @@ const chatPlugin: JupyterFrontEndPlugin<void> = {
|
45 | 46 | description: 'LLM chat extension',
|
46 | 47 | autoStart: true,
|
47 | 48 | requires: [IAIProviderRegistry, IRenderMimeRegistry, IChatCommandRegistry],
|
48 |
| - optional: [INotebookTracker, ISettingRegistry, IThemeManager], |
| 49 | + optional: [ |
| 50 | + INotebookTracker, |
| 51 | + ISettingRegistry, |
| 52 | + IThemeManager, |
| 53 | + ILayoutRestorer |
| 54 | + ], |
49 | 55 | activate: async (
|
50 | 56 | app: JupyterFrontEnd,
|
51 | 57 | providerRegistry: IAIProviderRegistry,
|
52 | 58 | rmRegistry: IRenderMimeRegistry,
|
53 | 59 | chatCommandRegistry: IChatCommandRegistry,
|
54 | 60 | notebookTracker: INotebookTracker | null,
|
55 | 61 | settingsRegistry: ISettingRegistry | null,
|
56 |
| - themeManager: IThemeManager | null |
| 62 | + themeManager: IThemeManager | null, |
| 63 | + restorer: ILayoutRestorer | null |
57 | 64 | ) => {
|
58 | 65 | let activeCellManager: IActiveCellManager | null = null;
|
59 | 66 | if (notebookTracker) {
|
@@ -129,14 +136,18 @@ const chatPlugin: JupyterFrontEndPlugin<void> = {
|
129 | 136 | inputToolbarRegistry,
|
130 | 137 | welcomeMessage: welcomeMessage(providerRegistry.providers)
|
131 | 138 | });
|
132 |
| - chatWidget.title.caption = 'Jupyterlite AI Chat'; |
133 | 139 | } catch (e) {
|
134 | 140 | chatWidget = buildErrorWidget(themeManager);
|
135 | 141 | }
|
136 | 142 |
|
| 143 | + chatWidget.title.caption = 'Jupyterlite AI Chat'; |
| 144 | + chatWidget.id = '@jupyterlite/ai:chat-widget'; |
| 145 | + |
137 | 146 | app.shell.add(chatWidget as ReactWidget, 'left', { rank: 2000 });
|
138 | 147 |
|
139 |
| - console.log('Chat extension initialized'); |
| 148 | + if (restorer) { |
| 149 | + restorer.add(chatWidget, chatWidget.id); |
| 150 | + } |
140 | 151 | }
|
141 | 152 | };
|
142 | 153 |
|
|
0 commit comments