Skip to content

Commit

Permalink
Add the toolbar to websocket chat
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Jul 18, 2024
1 parent b1d557b commit 5bee9f2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/jupyterlab-ws-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@jupyter/chat": "^0.2.0",
"@jupyterlab/apputils": "^4.3.0",
"@jupyterlab/coreutils": "^6.2.0",
"@jupyterlab/notebook": "^4.2.0",
"@jupyterlab/rendermime": "^4.2.0",
"@jupyterlab/services": "^7.2.0",
"@jupyterlab/settingregistry": "^4.2.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/jupyterlab-ws-chat/schema/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
"type": "boolean",
"default": true,
"readOnly": false
},
"enableCodeToolbar": {
"description": "Whether to enable or not the code toolbar.",
"type": "boolean",
"default": true,
"readOnly": false
}
},
"additionalProperties": false
Expand Down
20 changes: 18 additions & 2 deletions packages/jupyterlab-ws-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import {
ActiveCellManager,
AutocompletionRegistry,
IAutocompletionRegistry,
buildChatSidebar,
Expand All @@ -15,6 +16,7 @@ import {
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { ReactWidget, IThemeManager } from '@jupyterlab/apputils';
import { INotebookTracker } from '@jupyterlab/notebook';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import { ISettingRegistry } from '@jupyterlab/settingregistry';

Expand Down Expand Up @@ -49,6 +51,7 @@ const chat: JupyterFrontEndPlugin<void> = {
optional: [
IAutocompletionRegistry,
ILayoutRestorer,
INotebookTracker,
ISettingRegistry,
IThemeManager
],
Expand All @@ -57,31 +60,44 @@ const chat: JupyterFrontEndPlugin<void> = {
rmRegistry: IRenderMimeRegistry,
autocompletionRegistry: IAutocompletionRegistry,
restorer: ILayoutRestorer | null,
notebookTracker: INotebookTracker,
settingsRegistry: ISettingRegistry | null,
themeManager: IThemeManager | null
) => {
// Create an active cell manager for code toolbar.
const activeCellManager = new ActiveCellManager({
tracker: notebookTracker,
shell: app.shell
});

/**
* Initialize chat handler, open WS connection
*/
const chatHandler = new WebSocketHandler({ commands: app.commands });
const chatHandler = new WebSocketHandler({
commands: app.commands,
activeCellManager
});

/**
* Load the settings.
*/
let sendWithShiftEnter = false;
let stackMessages = true;
let unreadNotifications = true;
let enableCodeToolbar = true;
function loadSetting(setting: ISettingRegistry.ISettings): void {
// Read the settings and convert to the correct type
sendWithShiftEnter = setting.get('sendWithShiftEnter')
.composite as boolean;
stackMessages = setting.get('stackMessages').composite as boolean;
unreadNotifications = setting.get('unreadNotifications')
.composite as boolean;
enableCodeToolbar = setting.get('enableCodeToolbar').composite as boolean;
chatHandler.config = {
sendWithShiftEnter,
stackMessages,
unreadNotifications
unreadNotifications,
enableCodeToolbar
};
}

Expand Down

0 comments on commit 5bee9f2

Please sign in to comment.