1+ import { INotebookShell } from '@jupyter-notebook/application' ;
12import {
23 JupyterFrontEnd ,
34 JupyterFrontEndPlugin
@@ -11,6 +12,7 @@ import {
1112} from '@jupyterlab/apputils' ;
1213import { IDocumentWidget } from '@jupyterlab/docregistry' ;
1314import { IRenderMimeRegistry } from '@jupyterlab/rendermime' ;
15+ import { SingletonLayout , Widget } from '@lumino/widgets' ;
1416
1517import { chatCommandPlugins } from './chat-commands' ;
1618import { completionPlugin } from './completions' ;
@@ -35,13 +37,19 @@ const plugin: JupyterFrontEndPlugin<void> = {
3537 id : '@jupyter-ai/core:plugin' ,
3638 autoStart : true ,
3739 requires : [ IRenderMimeRegistry ] ,
38- optional : [ ICommandPalette , IThemeManager , IJaiCompletionProvider ] ,
40+ optional : [
41+ ICommandPalette ,
42+ IThemeManager ,
43+ IJaiCompletionProvider ,
44+ INotebookShell
45+ ] ,
3946 activate : async (
4047 app : JupyterFrontEnd ,
4148 rmRegistry : IRenderMimeRegistry ,
4249 palette : ICommandPalette | null ,
4350 themeManager : IThemeManager | null ,
44- completionProvider : IJaiCompletionProvider | null
51+ completionProvider : IJaiCompletionProvider | null ,
52+ notebookShell : INotebookShell | null
4553 ) => {
4654 const openInlineCompleterSettings = ( ) => {
4755 app . commands . execute ( 'settingeditor:open' , {
@@ -50,7 +58,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
5058 } ;
5159
5260 // Create a AI settings widget.
53- let aiSettings : MainAreaWidget < ReactWidget > ;
61+ let aiSettings : Widget ;
5462 let settingsWidget : ReactWidget ;
5563 try {
5664 settingsWidget = buildAiSettings (
@@ -67,13 +75,20 @@ const plugin: JupyterFrontEndPlugin<void> = {
6775 app . commands . addCommand ( CommandIDs . openAiSettings , {
6876 execute : ( ) => {
6977 if ( ! aiSettings || aiSettings . isDisposed ) {
70- aiSettings = new MainAreaWidget ( { content : settingsWidget } ) ;
78+ if ( notebookShell ) {
79+ aiSettings = new Widget ( ) ;
80+ const layout = new SingletonLayout ( ) ;
81+ aiSettings . layout = layout ;
82+ layout . widget = settingsWidget ;
83+ } else {
84+ aiSettings = new MainAreaWidget ( { content : settingsWidget } ) ;
85+ }
7186 aiSettings . id = 'jupyter-ai-settings' ;
7287 aiSettings . title . label = 'AI settings' ;
7388 aiSettings . title . closable = true ;
7489 }
7590 if ( ! aiSettings . isAttached ) {
76- app ?. shell . add ( aiSettings , 'main' ) ;
91+ app ?. shell . add ( aiSettings , notebookShell ? 'left' : 'main' ) ;
7792 }
7893 app . shell . activateById ( aiSettings . id ) ;
7994 } ,
0 commit comments