@jupyter/chat 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/input/chat-input.js +18 -14
- package/lib/components/input/toolbar-registry.d.ts +16 -1
- package/lib/components/input/toolbar-registry.js +10 -1
- package/lib/components/messages/messages.d.ts +1 -0
- package/lib/components/messages/messages.js +1 -1
- package/lib/input-model.d.ts +7 -6
- package/lib/input-model.js +3 -0
- package/lib/model.d.ts +15 -0
- package/lib/model.js +23 -1
- package/lib/widgets/chat-widget.js +17 -2
- package/lib/widgets/index.d.ts +1 -0
- package/lib/widgets/index.js +1 -0
- package/lib/widgets/multichat-panel.d.ts +212 -0
- package/lib/widgets/multichat-panel.js +368 -0
- package/package.json +4 -3
- package/src/components/input/chat-input.tsx +27 -26
- package/src/components/input/toolbar-registry.tsx +21 -1
- package/src/components/messages/messages.tsx +1 -1
- package/src/input-model.ts +10 -6
- package/src/model.ts +33 -1
- package/src/widgets/chat-widget.tsx +22 -2
- package/src/widgets/index.ts +1 -0
- package/src/widgets/multichat-panel.tsx +575 -0
- package/style/chat.css +2 -7
- package/style/input.css +66 -35
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
* Copyright (c) Jupyter Development Team.
|
|
3
3
|
* Distributed under the terms of the Modified BSD License.
|
|
4
4
|
*/
|
|
5
|
-
import { Autocomplete, Box,
|
|
5
|
+
import { Autocomplete, Box, TextField, Toolbar } from '@mui/material';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
7
|
import React, { useEffect, useRef, useState } from 'react';
|
|
8
8
|
import { AttachmentPreviewList } from '../attachments';
|
|
9
9
|
import { useChatCommands } from '.';
|
|
10
10
|
const INPUT_BOX_CLASS = 'jp-chat-input-container';
|
|
11
|
+
const INPUT_TEXTFIELD_CLASS = 'jp-chat-input-textfield';
|
|
12
|
+
const INPUT_COMPONENT_CLASS = 'jp-chat-input-component';
|
|
11
13
|
const INPUT_TOOLBAR_CLASS = 'jp-chat-input-toolbar';
|
|
12
14
|
export function ChatInput(props) {
|
|
13
15
|
var _a;
|
|
@@ -139,7 +141,7 @@ export function ChatInput(props) {
|
|
|
139
141
|
React.createElement(AttachmentPreviewList, { attachments: attachments, onRemove: model.removeAttachment }),
|
|
140
142
|
React.createElement(Autocomplete, { ...chatCommands.autocompleteProps,
|
|
141
143
|
// ensure the autocomplete popup always renders on top
|
|
142
|
-
|
|
144
|
+
slotProps: {
|
|
143
145
|
popper: {
|
|
144
146
|
placement: 'top'
|
|
145
147
|
},
|
|
@@ -147,24 +149,26 @@ export function ChatInput(props) {
|
|
|
147
149
|
sx: {
|
|
148
150
|
border: '1px solid lightgray'
|
|
149
151
|
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
},
|
|
153
|
+
listbox: {
|
|
154
|
+
sx: {
|
|
155
|
+
'& .MuiAutocomplete-option': {
|
|
156
|
+
padding: 2
|
|
157
|
+
}
|
|
155
158
|
}
|
|
156
159
|
}
|
|
157
|
-
}, renderInput: params => (React.createElement(TextField, { ...params, fullWidth: true, variant: "
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
160
|
+
}, renderInput: params => (React.createElement(TextField, { ...params, fullWidth: true, variant: "filled", className: INPUT_TEXTFIELD_CLASS, multiline: true, onKeyDown: handleKeyDown, placeholder: "Start chatting", inputRef: inputRef, sx: { marginTop: '1px' }, onSelect: () => { var _a, _b; return (model.cursorIndex = (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.selectionStart) !== null && _b !== void 0 ? _b : null); }, slotProps: {
|
|
161
|
+
input: {
|
|
162
|
+
...params.InputProps,
|
|
163
|
+
className: INPUT_COMPONENT_CLASS
|
|
164
|
+
}
|
|
165
|
+
}, label: input.length > 2 ? helperText : ' ' })), inputValue: input, onInputChange: (_, newValue, reason) => {
|
|
163
166
|
// Do not update the value if the reason is 'reset', which should occur only
|
|
164
167
|
// if an autocompletion command has been selected. In this case, the value is
|
|
165
168
|
// set in the 'onChange()' callback of the autocompletion (to avoid conflicts).
|
|
166
169
|
if (reason !== 'reset') {
|
|
167
170
|
model.value = newValue;
|
|
168
171
|
}
|
|
169
|
-
} })
|
|
172
|
+
} }),
|
|
173
|
+
React.createElement(Toolbar, { className: INPUT_TOOLBAR_CLASS }, toolbarElements.map(item => (React.createElement(item.element, { model: model, chatCommandRegistry: props.chatCommandRegistry }))))));
|
|
170
174
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Token } from '@lumino/coreutils';
|
|
2
|
+
import { ISignal } from '@lumino/signaling';
|
|
1
3
|
import * as React from 'react';
|
|
2
4
|
import { IInputModel } from '../../input-model';
|
|
3
|
-
import { ISignal } from '@lumino/signaling';
|
|
4
5
|
import { IChatCommandRegistry } from '../../registers';
|
|
5
6
|
/**
|
|
6
7
|
* The toolbar registry interface.
|
|
@@ -102,3 +103,17 @@ export declare namespace InputToolbarRegistry {
|
|
|
102
103
|
*/
|
|
103
104
|
function defaultToolbarRegistry(): InputToolbarRegistry;
|
|
104
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* A factory interface for creating a new Input Toolbar Registry
|
|
108
|
+
* for each Chat Panel.
|
|
109
|
+
*/
|
|
110
|
+
export interface IInputToolbarRegistryFactory {
|
|
111
|
+
/**
|
|
112
|
+
* Create a new input toolbar registry instance.
|
|
113
|
+
*/
|
|
114
|
+
create: () => IInputToolbarRegistry;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The token of the factory to create an input toolbar registry.
|
|
118
|
+
*/
|
|
119
|
+
export declare const IInputToolbarRegistryFactory: Token<IInputToolbarRegistryFactory>;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Jupyter Development Team.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
import { Token } from '@lumino/coreutils';
|
|
2
6
|
import { Signal } from '@lumino/signaling';
|
|
7
|
+
import { AttachButton, CancelButton, SendButton } from './buttons';
|
|
3
8
|
/**
|
|
4
9
|
* The toolbar registry implementation.
|
|
5
10
|
*/
|
|
@@ -83,3 +88,7 @@ export class InputToolbarRegistry {
|
|
|
83
88
|
}
|
|
84
89
|
InputToolbarRegistry.defaultToolbarRegistry = defaultToolbarRegistry;
|
|
85
90
|
})(InputToolbarRegistry || (InputToolbarRegistry = {}));
|
|
91
|
+
/**
|
|
92
|
+
* The token of the factory to create an input toolbar registry.
|
|
93
|
+
*/
|
|
94
|
+
export const IInputToolbarRegistryFactory = new Token('@jupyter/chat:IInputToolbarRegistryFactory');
|
|
@@ -3,6 +3,7 @@ import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
|
3
3
|
import { IInputToolbarRegistry } from '../input';
|
|
4
4
|
import { IChatCommandRegistry, IMessageFooterRegistry } from '../../registers';
|
|
5
5
|
import { IChatModel } from '../../model';
|
|
6
|
+
export declare const MESSAGE_CLASS = "jp-chat-message";
|
|
6
7
|
/**
|
|
7
8
|
* The base components props.
|
|
8
9
|
*/
|
|
@@ -13,8 +13,8 @@ import { Navigation } from './navigation';
|
|
|
13
13
|
import { WelcomeMessage } from './welcome';
|
|
14
14
|
import { WritingUsersList } from './writers';
|
|
15
15
|
import { ScrollContainer } from '../scroll-container';
|
|
16
|
+
export const MESSAGE_CLASS = 'jp-chat-message';
|
|
16
17
|
const MESSAGES_BOX_CLASS = 'jp-chat-messages-container';
|
|
17
|
-
const MESSAGE_CLASS = 'jp-chat-message';
|
|
18
18
|
const MESSAGE_STACKED_CLASS = 'jp-chat-message-stacked';
|
|
19
19
|
/**
|
|
20
20
|
* The messages list component.
|
package/lib/input-model.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ import { IAttachment, IUser } from './types';
|
|
|
10
10
|
*/
|
|
11
11
|
export interface IInputModel extends IDisposable {
|
|
12
12
|
/**
|
|
13
|
-
* The chat context (a
|
|
13
|
+
* The chat context (a subset of the chat model).
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
chatContext?: IChatContext;
|
|
16
16
|
/**
|
|
17
17
|
* Function to send a message.
|
|
18
18
|
*/
|
|
@@ -127,7 +127,8 @@ export declare class InputModel implements IInputModel {
|
|
|
127
127
|
/**
|
|
128
128
|
* The chat context (a readonly subset of the chat model);
|
|
129
129
|
*/
|
|
130
|
-
get chatContext(): IChatContext;
|
|
130
|
+
get chatContext(): IChatContext | undefined;
|
|
131
|
+
set chatContext(value: IChatContext | undefined);
|
|
131
132
|
/**
|
|
132
133
|
* Function to send a message.
|
|
133
134
|
*/
|
|
@@ -244,7 +245,7 @@ export declare class InputModel implements IInputModel {
|
|
|
244
245
|
*/
|
|
245
246
|
get isDisposed(): boolean;
|
|
246
247
|
private _onSend;
|
|
247
|
-
private _chatContext
|
|
248
|
+
private _chatContext?;
|
|
248
249
|
private _value;
|
|
249
250
|
private _cursorIndex;
|
|
250
251
|
private _currentWord;
|
|
@@ -266,9 +267,9 @@ export declare class InputModel implements IInputModel {
|
|
|
266
267
|
export declare namespace InputModel {
|
|
267
268
|
interface IOptions {
|
|
268
269
|
/**
|
|
269
|
-
* The chat context (a
|
|
270
|
+
* The chat context (a subset of the chat model).
|
|
270
271
|
*/
|
|
271
|
-
chatContext
|
|
272
|
+
chatContext?: IChatContext;
|
|
272
273
|
/**
|
|
273
274
|
* The function that should send the message.
|
|
274
275
|
* @param content - the content of the message.
|
package/lib/input-model.js
CHANGED
package/lib/model.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export interface IChatModel extends IDisposable {
|
|
|
22
22
|
* The indexes list of the unread messages.
|
|
23
23
|
*/
|
|
24
24
|
unreadMessages: number[];
|
|
25
|
+
/**
|
|
26
|
+
* The promise resolving when the model is ready.
|
|
27
|
+
*/
|
|
28
|
+
readonly ready: Promise<void>;
|
|
25
29
|
/**
|
|
26
30
|
* The indexes list of the messages currently in the viewport.
|
|
27
31
|
*/
|
|
@@ -173,6 +177,7 @@ export declare abstract class AbstractChatModel implements IChatModel {
|
|
|
173
177
|
*/
|
|
174
178
|
get name(): string;
|
|
175
179
|
set name(value: string);
|
|
180
|
+
get disposed(): ISignal<AbstractChatModel, void>;
|
|
176
181
|
/**
|
|
177
182
|
* The chat messages list.
|
|
178
183
|
*/
|
|
@@ -202,6 +207,14 @@ export declare abstract class AbstractChatModel implements IChatModel {
|
|
|
202
207
|
*/
|
|
203
208
|
get lastRead(): number;
|
|
204
209
|
set lastRead(value: number);
|
|
210
|
+
/**
|
|
211
|
+
* Promise that resolves when the model is ready.
|
|
212
|
+
*/
|
|
213
|
+
get ready(): Promise<void>;
|
|
214
|
+
/**
|
|
215
|
+
* Set the model as ready.
|
|
216
|
+
*/
|
|
217
|
+
protected setReady(): void;
|
|
205
218
|
/**
|
|
206
219
|
* The chat settings.
|
|
207
220
|
*/
|
|
@@ -324,7 +337,9 @@ export declare abstract class AbstractChatModel implements IChatModel {
|
|
|
324
337
|
private _id;
|
|
325
338
|
private _name;
|
|
326
339
|
private _config;
|
|
340
|
+
private _readyDelegate;
|
|
327
341
|
private _inputModel;
|
|
342
|
+
private _disposed;
|
|
328
343
|
private _isDisposed;
|
|
329
344
|
private _commands?;
|
|
330
345
|
private _activeCellManager;
|
package/lib/model.js
CHANGED
|
@@ -6,6 +6,7 @@ import { ArrayExt } from '@lumino/algorithm';
|
|
|
6
6
|
import { Signal } from '@lumino/signaling';
|
|
7
7
|
import { InputModel } from './input-model';
|
|
8
8
|
import { replaceMentionToSpan } from './utils';
|
|
9
|
+
import { PromiseDelegate } from '@lumino/coreutils';
|
|
9
10
|
/**
|
|
10
11
|
* An abstract implementation of IChatModel.
|
|
11
12
|
*
|
|
@@ -22,6 +23,8 @@ export class AbstractChatModel {
|
|
|
22
23
|
this._unreadMessages = [];
|
|
23
24
|
this._messagesInViewport = [];
|
|
24
25
|
this._name = '';
|
|
26
|
+
this._readyDelegate = new PromiseDelegate();
|
|
27
|
+
this._disposed = new Signal(this);
|
|
25
28
|
this._isDisposed = false;
|
|
26
29
|
this._notificationId = null;
|
|
27
30
|
this._writers = [];
|
|
@@ -43,7 +46,6 @@ export class AbstractChatModel {
|
|
|
43
46
|
...config
|
|
44
47
|
};
|
|
45
48
|
this._inputModel = new InputModel({
|
|
46
|
-
chatContext: this.createChatContext(),
|
|
47
49
|
activeCellManager: options.activeCellManager,
|
|
48
50
|
selectionWatcher: options.selectionWatcher,
|
|
49
51
|
documentManager: options.documentManager,
|
|
@@ -56,6 +58,10 @@ export class AbstractChatModel {
|
|
|
56
58
|
this._activeCellManager = (_b = options.activeCellManager) !== null && _b !== void 0 ? _b : null;
|
|
57
59
|
this._selectionWatcher = (_c = options.selectionWatcher) !== null && _c !== void 0 ? _c : null;
|
|
58
60
|
this._documentManager = (_d = options.documentManager) !== null && _d !== void 0 ? _d : null;
|
|
61
|
+
this._readyDelegate = new PromiseDelegate();
|
|
62
|
+
this.ready.then(() => {
|
|
63
|
+
this._inputModel.chatContext = this.createChatContext();
|
|
64
|
+
});
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
67
|
* The chat model id.
|
|
@@ -75,6 +81,9 @@ export class AbstractChatModel {
|
|
|
75
81
|
set name(value) {
|
|
76
82
|
this._name = value;
|
|
77
83
|
}
|
|
84
|
+
get disposed() {
|
|
85
|
+
return this._disposed;
|
|
86
|
+
}
|
|
78
87
|
/**
|
|
79
88
|
* The chat messages list.
|
|
80
89
|
*/
|
|
@@ -130,6 +139,18 @@ export class AbstractChatModel {
|
|
|
130
139
|
storage.lastRead = value;
|
|
131
140
|
localStorage.setItem(`@jupyter/chat:${this._id}`, JSON.stringify(storage));
|
|
132
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Promise that resolves when the model is ready.
|
|
144
|
+
*/
|
|
145
|
+
get ready() {
|
|
146
|
+
return this._readyDelegate.promise;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Set the model as ready.
|
|
150
|
+
*/
|
|
151
|
+
setReady() {
|
|
152
|
+
this._readyDelegate.resolve();
|
|
153
|
+
}
|
|
133
154
|
/**
|
|
134
155
|
* The chat settings.
|
|
135
156
|
*/
|
|
@@ -254,6 +275,7 @@ export class AbstractChatModel {
|
|
|
254
275
|
return;
|
|
255
276
|
}
|
|
256
277
|
this._isDisposed = true;
|
|
278
|
+
this._disposed.emit();
|
|
257
279
|
}
|
|
258
280
|
/**
|
|
259
281
|
* Whether the chat handler is disposed.
|
|
@@ -6,7 +6,7 @@ import { ReactWidget } from '@jupyterlab/apputils';
|
|
|
6
6
|
import { isCode, isMarkdown, isRaw } from '@jupyterlab/nbformat';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Drag } from '@lumino/dragdrop';
|
|
9
|
-
import { Chat } from '../components';
|
|
9
|
+
import { Chat, MESSAGE_CLASS } from '../components';
|
|
10
10
|
import { chatIcon } from '../icons';
|
|
11
11
|
// MIME type constant for file browser drag events
|
|
12
12
|
const FILE_BROWSER_MIME = 'application/x-jupyter-icontentsrich';
|
|
@@ -23,7 +23,22 @@ export class ChatWidget extends ReactWidget {
|
|
|
23
23
|
this.title.caption = 'Jupyter Chat'; // TODO: i18n
|
|
24
24
|
this._chatOptions = options;
|
|
25
25
|
this.id = `jupyter-chat::widget::${options.model.name}`;
|
|
26
|
-
this.node.
|
|
26
|
+
this.node.addEventListener('click', (event) => {
|
|
27
|
+
const target = event.target;
|
|
28
|
+
if (this.node.contains(document.activeElement)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const message = target.closest(`.${MESSAGE_CLASS}`);
|
|
32
|
+
if (message) {
|
|
33
|
+
const selection = window.getSelection();
|
|
34
|
+
if (selection &&
|
|
35
|
+
selection.toString().trim() !== '' &&
|
|
36
|
+
message.contains(selection.anchorNode)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
this.model.input.focus();
|
|
41
|
+
});
|
|
27
42
|
}
|
|
28
43
|
/**
|
|
29
44
|
* Get the model of the widget.
|
package/lib/widgets/index.d.ts
CHANGED
package/lib/widgets/index.js
CHANGED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { PanelWithToolbar, SidePanel } from '@jupyterlab/ui-components';
|
|
2
|
+
import { ISignal } from '@lumino/signaling';
|
|
3
|
+
import { Panel } from '@lumino/widgets';
|
|
4
|
+
import { ChatWidget } from './chat-widget';
|
|
5
|
+
import { Chat, IInputToolbarRegistryFactory } from '../components';
|
|
6
|
+
import { IChatModel } from '../model';
|
|
7
|
+
/**
|
|
8
|
+
* Generic sidepanel widget including multiple chats and the add chat button.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MultiChatPanel extends SidePanel {
|
|
11
|
+
constructor(options: MultiChatPanel.IOptions);
|
|
12
|
+
/**
|
|
13
|
+
* The sections of the side panel.
|
|
14
|
+
*/
|
|
15
|
+
get sections(): ChatSection[];
|
|
16
|
+
/**
|
|
17
|
+
* A signal emitting when a section is added to the panel.
|
|
18
|
+
*/
|
|
19
|
+
get sectionAdded(): ISignal<MultiChatPanel, ChatSection>;
|
|
20
|
+
/**
|
|
21
|
+
* Add a new widget to the chat panel.
|
|
22
|
+
*
|
|
23
|
+
* @param model - the model of the chat widget
|
|
24
|
+
* @param displayName - the name of the chat.
|
|
25
|
+
*/
|
|
26
|
+
addChat(args: MultiChatPanel.IAddChatArgs): ChatWidget | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Invoke the update of the list of available chats.
|
|
29
|
+
*/
|
|
30
|
+
updateChatList(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Update the list of available chats.
|
|
33
|
+
*/
|
|
34
|
+
private _updateChatList;
|
|
35
|
+
/**
|
|
36
|
+
* Open a chat if it exists in the side panel.
|
|
37
|
+
*
|
|
38
|
+
* @param name - the name of the chat.
|
|
39
|
+
* @returns a boolean, whether the chat existed in the side panel or not.
|
|
40
|
+
*/
|
|
41
|
+
openIfExists(name: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* A message handler invoked on an `'after-attach'` message.
|
|
44
|
+
*/
|
|
45
|
+
protected onAfterAttach(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Return the index of the chat in the list (-1 if not opened).
|
|
48
|
+
*
|
|
49
|
+
* @param name - the chat name.
|
|
50
|
+
*/
|
|
51
|
+
private _getChatIndex;
|
|
52
|
+
/**
|
|
53
|
+
* Expand the chat from its index.
|
|
54
|
+
*/
|
|
55
|
+
private _expandChat;
|
|
56
|
+
/**
|
|
57
|
+
* Handle `change` events for the HTMLSelect component.
|
|
58
|
+
*/
|
|
59
|
+
private _chatSelected;
|
|
60
|
+
/**
|
|
61
|
+
* Triggered when a section is toggled. If the section is opened, all others
|
|
62
|
+
* sections are closed.
|
|
63
|
+
*/
|
|
64
|
+
private _onExpansionToggled;
|
|
65
|
+
private _chatNamesChanged;
|
|
66
|
+
private _sectionAdded;
|
|
67
|
+
private _rmRegistry;
|
|
68
|
+
private _themeManager?;
|
|
69
|
+
private _chatCommandRegistry?;
|
|
70
|
+
private _attachmentOpenerRegistry?;
|
|
71
|
+
private _inputToolbarFactory?;
|
|
72
|
+
private _messageFooterRegistry?;
|
|
73
|
+
private _welcomeMessage?;
|
|
74
|
+
private _updateChatListDebouncer;
|
|
75
|
+
private _createModel?;
|
|
76
|
+
private _getChatNames?;
|
|
77
|
+
private _openInMain?;
|
|
78
|
+
private _renameChat?;
|
|
79
|
+
private _openChatWidget?;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The chat panel namespace.
|
|
83
|
+
*/
|
|
84
|
+
export declare namespace MultiChatPanel {
|
|
85
|
+
/**
|
|
86
|
+
* Options of the constructor of the chat panel.
|
|
87
|
+
*/
|
|
88
|
+
interface IOptions extends SidePanel.IOptions, Omit<Chat.IOptions, 'model' | 'inputToolbarRegistry'> {
|
|
89
|
+
/**
|
|
90
|
+
* The input toolbar factory;
|
|
91
|
+
*/
|
|
92
|
+
inputToolbarFactory?: IInputToolbarRegistryFactory;
|
|
93
|
+
/**
|
|
94
|
+
* An optional callback to create a chat model.
|
|
95
|
+
*
|
|
96
|
+
* @param name - the name of the chat, optional.
|
|
97
|
+
* @return an object that can be passed to add a chat section.
|
|
98
|
+
*/
|
|
99
|
+
createModel?: (name?: string) => Promise<IAddChatArgs>;
|
|
100
|
+
/**
|
|
101
|
+
* An optional callback to get the list of existing chats.
|
|
102
|
+
*
|
|
103
|
+
* @returns an object with display name as key and the "full" name as value.
|
|
104
|
+
*/
|
|
105
|
+
getChatNames?: () => Promise<{
|
|
106
|
+
[name: string]: string;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* An optional callback to open the chat in the main area.
|
|
110
|
+
*
|
|
111
|
+
* @param name - the name of the chat to move.
|
|
112
|
+
*/
|
|
113
|
+
openInMain?: (name: string) => void;
|
|
114
|
+
/**
|
|
115
|
+
* An optional callback to rename a chat.
|
|
116
|
+
*
|
|
117
|
+
* @param oldName - the old name of the chat.
|
|
118
|
+
* @param newName - the new name of the chat.
|
|
119
|
+
* @returns - a boolean, whether the chat has been renamed or not.
|
|
120
|
+
*/
|
|
121
|
+
renameChat?: (oldName: string, newName: string) => Promise<boolean>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The options for the add chat method.
|
|
125
|
+
*/
|
|
126
|
+
interface IAddChatArgs {
|
|
127
|
+
/**
|
|
128
|
+
* The model of the chat.
|
|
129
|
+
* No-op id undefined.
|
|
130
|
+
*/
|
|
131
|
+
model?: IChatModel;
|
|
132
|
+
/**
|
|
133
|
+
* The display name of the chat in the section title.
|
|
134
|
+
*/
|
|
135
|
+
displayName?: string;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The chat section containing a chat widget.
|
|
140
|
+
*/
|
|
141
|
+
export declare class ChatSection extends PanelWithToolbar {
|
|
142
|
+
/**
|
|
143
|
+
* Constructor of the chat section.
|
|
144
|
+
*/
|
|
145
|
+
constructor(options: ChatSection.IOptions);
|
|
146
|
+
/**
|
|
147
|
+
* The display name.
|
|
148
|
+
*/
|
|
149
|
+
get displayName(): string;
|
|
150
|
+
set displayName(value: string);
|
|
151
|
+
/**
|
|
152
|
+
* The chat widget of the section.
|
|
153
|
+
*/
|
|
154
|
+
get widget(): ChatWidget;
|
|
155
|
+
/**
|
|
156
|
+
* The model of the widget.
|
|
157
|
+
*/
|
|
158
|
+
get model(): IChatModel;
|
|
159
|
+
/**
|
|
160
|
+
* Dispose of the resources held by the widget.
|
|
161
|
+
*/
|
|
162
|
+
dispose(): void;
|
|
163
|
+
/**
|
|
164
|
+
* * Update the section’s title based on the chat name.
|
|
165
|
+
* */
|
|
166
|
+
private _updateTitle;
|
|
167
|
+
/**
|
|
168
|
+
* Change the title when messages are unread.
|
|
169
|
+
*
|
|
170
|
+
* TODO: fix it upstream in @jupyterlab/ui-components.
|
|
171
|
+
* Updating the title create a new Title widget, but does not attach again the
|
|
172
|
+
* toolbar. The toolbar is attached only when the title widget is attached the first
|
|
173
|
+
* time.
|
|
174
|
+
*/
|
|
175
|
+
private _unreadChanged;
|
|
176
|
+
private _chatWidget;
|
|
177
|
+
private _markAsRead;
|
|
178
|
+
private _spinner;
|
|
179
|
+
private _displayName;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The chat section namespace.
|
|
183
|
+
*/
|
|
184
|
+
export declare namespace ChatSection {
|
|
185
|
+
/**
|
|
186
|
+
* Options to build a chat section.
|
|
187
|
+
*/
|
|
188
|
+
interface IOptions extends Panel.IOptions {
|
|
189
|
+
/**
|
|
190
|
+
* The widget to display in the section.
|
|
191
|
+
*/
|
|
192
|
+
widget: ChatWidget;
|
|
193
|
+
/**
|
|
194
|
+
* An optional callback to open the chat in the main area.
|
|
195
|
+
*
|
|
196
|
+
* @param name - the name of the chat to move.
|
|
197
|
+
*/
|
|
198
|
+
openInMain?: (name: string) => void;
|
|
199
|
+
/**
|
|
200
|
+
* An optional callback to rename a chat.
|
|
201
|
+
*
|
|
202
|
+
* @param oldName - the old name of the chat.
|
|
203
|
+
* @param newName - the new name of the chat.
|
|
204
|
+
* @returns - a boolean, whether the chat has been renamed or not.
|
|
205
|
+
*/
|
|
206
|
+
renameChat?: (oldName: string, newName: string) => Promise<boolean>;
|
|
207
|
+
/**
|
|
208
|
+
* The name to display in the section title.
|
|
209
|
+
*/
|
|
210
|
+
displayName?: string;
|
|
211
|
+
}
|
|
212
|
+
}
|