Skip to content

Commit 53c737e

Browse files
committed
Use the 'inputChange' signal in the jupyterlab-chat model
1 parent 5b56bbd commit 53c737e

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

packages/jupyter-chat/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export * from './active-cell-manager';
77
export * from './components';
88
export * from './icons';
9+
export * from './input-model';
910
export * from './model';
1011
export * from './registry';
1112
export * from './selection-watcher';

packages/jupyter-chat/src/model.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,6 @@ export interface IChatModel extends IDisposable {
161161
* Update the current writers list.
162162
*/
163163
updateWriters(writers: IUser[]): void;
164-
165-
/**
166-
* Function called by the input on key pressed.
167-
*/
168-
inputChanged?(input?: string): void;
169164
}
170165

171166
/**
@@ -514,11 +509,6 @@ export class ChatModel implements IChatModel {
514509
this._writersChanged.emit(writers);
515510
}
516511

517-
/**
518-
* Function called by the input on key pressed.
519-
*/
520-
inputChanged?(input?: string): void {}
521-
522512
/**
523513
* Add unread messages to the list.
524514
* @param indexes - list of new indexes.

packages/jupyterlab-chat/src/model.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ChatModel,
88
IAttachment,
99
IChatMessage,
10+
IInputModel,
1011
INewMessage,
1112
IUser
1213
} from '@jupyter/chat';
@@ -59,6 +60,8 @@ export class LabChatModel extends ChatModel implements DocumentRegistry.IModel {
5960
});
6061

6162
this.sharedModel.awareness.on('change', this.onAwarenessChange);
63+
64+
this.input.valueChanged.connect(this.onInputChanged);
6265
}
6366

6467
readonly collaborative = true;
@@ -209,8 +212,8 @@ export class LabChatModel extends ChatModel implements DocumentRegistry.IModel {
209212
/**
210213
* Function called by the input on key pressed.
211214
*/
212-
inputChanged(input?: string): void {
213-
if (!input || !this.config.sendTypingNotification) {
215+
onInputChanged = (_: IInputModel, value: string): void => {
216+
if (!value || !this.config.sendTypingNotification) {
214217
return;
215218
}
216219
const awareness = this.sharedModel.awareness;
@@ -221,7 +224,7 @@ export class LabChatModel extends ChatModel implements DocumentRegistry.IModel {
221224
this._timeoutWriting = window.setTimeout(() => {
222225
this._resetWritingStatus();
223226
}, WRITING_DELAY);
224-
}
227+
};
225228

226229
/**
227230
* Triggered when an awareness state changes.

0 commit comments

Comments
 (0)