Skip to content

Adding multi chats panel in @jupyter/chat package #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/jupyter-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export * from './registers';
export * from './selection-watcher';
export * from './types';
export * from './widgets';
export * from './multiChatPanel';
export * from './token';
22 changes: 22 additions & 0 deletions packages/jupyter-chat/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
IUser
} from './types';
import { replaceMentionToSpan } from './utils';
import { PromiseDelegate } from '@lumino/coreutils';

/**
* The chat model interface.
Expand All @@ -40,6 +41,11 @@ export interface IChatModel extends IDisposable {
*/
unreadMessages: number[];

/**
* The promise resolving when the model is ready.
*/
readonly ready: Promise<void>;

/**
* The indexes list of the messages currently in the viewport.
*/
Expand Down Expand Up @@ -241,6 +247,9 @@ export abstract class AbstractChatModel implements IChatModel {
this._activeCellManager = options.activeCellManager ?? null;
this._selectionWatcher = options.selectionWatcher ?? null;
this._documentManager = options.documentManager ?? null;

this._readyDelegate = new PromiseDelegate<void>();
this.ready = this._readyDelegate.promise;
}

/**
Expand Down Expand Up @@ -328,6 +337,18 @@ export abstract class AbstractChatModel implements IChatModel {
localStorage.setItem(`@jupyter/chat:${this._id}`, JSON.stringify(storage));
}

/**
* Promise that resolves when the model is ready.
*/
readonly ready: Promise<void>;

/**
* Mark the model as ready.
*/
protected markReady(): void {
this._readyDelegate.resolve();
}

/**
* The chat settings.
*/
Expand Down Expand Up @@ -677,6 +698,7 @@ export abstract class AbstractChatModel implements IChatModel {
private _id: string | undefined;
private _name: string = '';
private _config: IConfig;
private _readyDelegate: PromiseDelegate<void>;
private _inputModel: IInputModel;
private _isDisposed = false;
private _commands?: CommandRegistry;
Expand Down
Loading