Skip to content

Commit 7b6a512

Browse files
authored
Chat panel tweaks (#92)
* Center welcome message * restore chat panel * style .jp-chat-welcome-message
1 parent c519df6 commit 7b6a512

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/index.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {
99
} from '@jupyter/chat';
1010
import {
1111
JupyterFrontEnd,
12-
JupyterFrontEndPlugin
12+
JupyterFrontEndPlugin,
13+
ILayoutRestorer
1314
} from '@jupyterlab/application';
1415
import { ReactWidget, IThemeManager } from '@jupyterlab/apputils';
1516
import { ICompletionProviderManager } from '@jupyterlab/completer';
@@ -45,15 +46,21 @@ const chatPlugin: JupyterFrontEndPlugin<void> = {
4546
description: 'LLM chat extension',
4647
autoStart: true,
4748
requires: [IAIProviderRegistry, IRenderMimeRegistry, IChatCommandRegistry],
48-
optional: [INotebookTracker, ISettingRegistry, IThemeManager],
49+
optional: [
50+
INotebookTracker,
51+
ISettingRegistry,
52+
IThemeManager,
53+
ILayoutRestorer
54+
],
4955
activate: async (
5056
app: JupyterFrontEnd,
5157
providerRegistry: IAIProviderRegistry,
5258
rmRegistry: IRenderMimeRegistry,
5359
chatCommandRegistry: IChatCommandRegistry,
5460
notebookTracker: INotebookTracker | null,
5561
settingsRegistry: ISettingRegistry | null,
56-
themeManager: IThemeManager | null
62+
themeManager: IThemeManager | null,
63+
restorer: ILayoutRestorer | null
5764
) => {
5865
let activeCellManager: IActiveCellManager | null = null;
5966
if (notebookTracker) {
@@ -129,14 +136,18 @@ const chatPlugin: JupyterFrontEndPlugin<void> = {
129136
inputToolbarRegistry,
130137
welcomeMessage: welcomeMessage(providerRegistry.providers)
131138
});
132-
chatWidget.title.caption = 'Jupyterlite AI Chat';
133139
} catch (e) {
134140
chatWidget = buildErrorWidget(themeManager);
135141
}
136142

143+
chatWidget.title.caption = 'Jupyterlite AI Chat';
144+
chatWidget.id = '@jupyterlite/ai:chat-widget';
145+
137146
app.shell.add(chatWidget as ReactWidget, 'left', { rank: 2000 });
138147

139-
console.log('Chat extension initialized');
148+
if (restorer) {
149+
restorer.add(chatWidget, chatWidget.id);
150+
}
140151
}
141152
};
142153

style/base.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
color: var(--jp-error-color1);
1515
font-size: var(--jp-content-font-size1);
1616
}
17+
18+
.jp-chat-welcome-message {
19+
text-align: center;
20+
max-width: 350px;
21+
margin: 0 auto;
22+
}

0 commit comments

Comments
 (0)