Skip to content
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

Update to jupyter collaboration 3 #94

Open
wants to merge 1 commit 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
4 changes: 2 additions & 2 deletions packages/jupyterlab-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
},
"dependencies": {
"@jupyter/chat": "^0.5.0",
"@jupyter/docprovider": "^2.1.4",
"@jupyter/ydoc": "^1.1.1",
"@jupyter/collaborative-drive": "^3.0.0",
"@jupyter/ydoc": "^2.0.0 || ^3.0.0",
"@jupyterlab/application": "^4.2.0",
"@jupyterlab/apputils": "^4.3.0",
"@jupyterlab/coreutils": "^6.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/jupyterlab-chat/src/widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
IChatModel,
readIcon
} from '@jupyter/chat';
import { ICollaborativeDrive } from '@jupyter/docprovider';
import { ICollaborativeDrive } from '@jupyter/collaborative-drive';
import { IThemeManager } from '@jupyterlab/apputils';
import { PathExt } from '@jupyterlab/coreutils';
import { DocumentWidget } from '@jupyterlab/docregistry';
Expand Down
31 changes: 31 additions & 0 deletions packages/jupyterlab-chat/src/ychat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,37 @@ export class YChat extends YDocument<IChatChanges> {
return JSONExt.deepCopy(this._messages.toJSON());
}

getSource(): JSONObject {
const users = this._users.toJSON();
const messages = this._messages.toJSON();
const metadata = this._metadata.toJSON();

return { users, messages, metadata };
}

setSource(value: JSONObject): void {
if (!value) {
return;
}

this.transact(() => {
const messages = (value['messages'] as unknown as Array<IYmessage>) ?? [];
messages.forEach(message => {
this._messages.push([message]);
});

const users = value['users'] ?? {};
Object.entries(users).forEach(([key, val]) =>
this._users.set(key, val as IUser)
);

const metadata = value['metadata'] ?? {};
Object.entries(metadata).forEach(([key, val]) =>
this._metadata.set(key, val as any)
);
});
}

getUser(username: string | undefined): IUser | undefined {
if (!username) {
return undefined;
Expand Down
8 changes: 4 additions & 4 deletions python/jupyterlab-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyter/docprovider": "^2.1.4",
"@jupyter/ydoc": "^1.1.1",
"@jupyter/collaborative-drive": "^3.0.0",
"@jupyter/ydoc": "^2.0.0 || ^3.0.0",
"@jupyterlab/application": "^4.2.0",
"@jupyterlab/apputils": "^4.3.0",
"@jupyterlab/coreutils": "^6.2.0",
Expand Down Expand Up @@ -131,8 +131,8 @@
"bundled": true,
"singleton": true
},
"@jupyter/docprovider": {
"bundled": true,
"@jupyter/collaborative-drive": {
"bundled": false,
"singleton": true
},
"jupyterlab-chat": {
Expand Down
2 changes: 1 addition & 1 deletion python/jupyterlab-chat/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ classifiers = [
]
dependencies = [
"jupyterlab~=4.0",
"jupyter_collaboration>=2.1.4,<3",
"jupyter_collaboration>=3,<4",
"jupyter_server>=2.0.1,<3",
"jupyter_ydoc",
"pycrdt"
Expand Down
2 changes: 1 addition & 1 deletion python/jupyterlab-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import {
ICollaborativeDrive,
SharedDocumentFactory
} from '@jupyter/docprovider';
} from '@jupyter/collaborative-drive';
import {
ILayoutRestorer,
JupyterFrontEnd,
Expand Down
Loading
Loading