-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Collaborative chat using jupyterlab_chat package #237
Closed
Closed
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
396784e
Uses the jupyterlab_chat package (back end and front end) to add a co…
brichet ffdd270
Format the message to retrieve the user avatar color
brichet 5409b9a
Change the chat repo from jupyterlab-chat to jupyter-chat
brichet 65d648b
First version of chat based on YDoc (CRDT)
brichet 44decfd
Use schema for global configuration of the chat
brichet b059b34
Remove server extension and handlers, not used anymore since the chat…
brichet 13a4b91
Automatic application of license header
github-actions[bot] 724a766
Allow creating and opening chats from the side panel, and display sev…
brichet 5a68cbe
Allow closing chat and improve chat creation
brichet 91688a8
Add tests on chat
brichet 7844308
Look for chat files using the drive instead of the filebrowser, and l…
brichet 6b86cd9
Use the temporary 'chat-jupyter' npm package
brichet a09b737
Linting
brichet 6a01b2a
WORKAROUND: avoid circular dependency between jupyter_collaboration a…
brichet acfec42
linting
brichet a40da5b
Fix YBaseDoc import
brichet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
export * from './factory'; | ||
export * from './model'; | ||
export * from './widget'; | ||
export * from './ychat'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) Jupyter Development Team. | ||
* Distributed under the terms of the Modified BSD License. | ||
*/ | ||
|
||
// TODO: remove this module in favor of the one in jupyter_ydoc when released. | ||
|
||
import { Delta, DocumentChange, MapChange, YDocument } from '@jupyter/ydoc'; | ||
import { JSONExt, JSONObject } from '@lumino/coreutils'; | ||
import * as Y from 'yjs'; | ||
|
||
/** | ||
* Definition of the shared Chat changes. | ||
*/ | ||
export type ChatChange = DocumentChange & { | ||
/** | ||
* Messages list change | ||
*/ | ||
messagesChange?: Delta<any>; | ||
/** | ||
* Content change | ||
*/ | ||
contentChange?: MapChange; | ||
}; | ||
|
||
interface IDict<T = any> { | ||
[key: string]: T; | ||
} | ||
|
||
/** | ||
* The collaborative chat shared document. | ||
*/ | ||
export class YChat extends YDocument<ChatChange> { | ||
/** | ||
* Create a new collaborative chat model. | ||
*/ | ||
constructor(options?: YDocument.IOptions) { | ||
super(options); | ||
this._content = this.ydoc.getMap<IDict>('content'); | ||
this._content.observe(this._contentObserver); | ||
|
||
this._messages = this.ydoc.getArray<IDict>('messages'); | ||
this._messages.observe(this._messagesObserver); | ||
} | ||
|
||
/** | ||
* Document version | ||
*/ | ||
readonly version: string = '1.0.0'; | ||
|
||
/** | ||
* Static method to create instances on the sharedModel | ||
* | ||
* @returns The sharedModel instance | ||
*/ | ||
static create(options?: YDocument.IOptions): YChat { | ||
return new YChat(options); | ||
} | ||
|
||
get content(): JSONObject { | ||
return JSONExt.deepCopy(this._content.toJSON()); | ||
} | ||
|
||
get messages(): string[] { | ||
return JSONExt.deepCopy(this._messages.toJSON()); | ||
} | ||
|
||
setMessage(value: IDict): void { | ||
this._messages.push([value]); | ||
} | ||
|
||
private _contentObserver = (event: Y.YMapEvent<IDict>): void => { | ||
this._changed.emit(this.content); | ||
}; | ||
|
||
private _messagesObserver = (event: Y.YArrayEvent<IDict>): void => { | ||
const changes: ChatChange = {}; | ||
changes.messagesChange = event.delta; | ||
this._changed.emit(changes); | ||
}; | ||
|
||
private _content: Y.Map<IDict>; | ||
private _messages: Y.Array<IDict>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how that can work, since
jupyter_ydoc
doesn't exportYBaseDoc
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me neither, but i fixed it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the
YBaseDoc
should be prefixed with an underscore, to specified that it should not be imported.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's fine to import it, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, I misunderstood your comment and thought you meant not to import it.