Skip to content

Commit

Permalink
Update to jupyter collaboration 3
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Dec 9, 2024
1 parent e8aa316 commit f8b51be
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 286 deletions.
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.6.2",
"@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 @@ -58,8 +58,8 @@
},
"dependencies": {
"@jupyter-notebook/application": "^7.2.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 Expand Up @@ -132,8 +132,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 @@ -17,7 +17,7 @@ import {
import {
ICollaborativeDrive,
SharedDocumentFactory
} from '@jupyter/docprovider';
} from '@jupyter/collaborative-drive';
import {
ILayoutRestorer,
JupyterFrontEnd,
Expand Down
Loading

0 comments on commit f8b51be

Please sign in to comment.