Skip to content

Conversation

@dlqqq
Copy link
Collaborator

@dlqqq dlqqq commented Oct 17, 2025

Description

This PR introduces UI handling for document resets occurring on *.chat files provided by jupyterlab_chat. This may occur when an out-of-band change is made to a *.chat file or when the YDoc history is squashed to preserve server memory (a planned feature).

Demo

Screen.Recording.2025-10-16.at.5.02.09.PM.mov

Technical details

  • The document reset handling is implemented entirely in a single ychat plugin. This provides a custom YChat that provides a reset() method & resetSignal property for the Yjs Websocket provider to call & emit to when receiving a document reset close code (4xxx). This follows the strategy applied to our custom YFile and YNotebook classes.

  • The ychat plugin listens to resetSignal on each YChat instance. When a reset is detected, the plugin finds the correct ChatWidget document widget containing the YChat instance which was reset, then clears its UI state before the subsequent SS1 + SS2 handshake is completed. This provides handling of chat document resets in the UI, without the need to fork the plugin providing the ChatWidget class.

  • This PR adds NPM dependencies on @jupyter/chat and jupyterlab-chat. It also adds the correct JupyterLab module federation configuration to ensure that tokens and classes imported are the same instances as the ones provided with the jupyterlab_chat package.

    • This does NOT add jupyterlab_chat as a required dependency. The custom ychat plugin is only loaded if jupyterlab_chat is installed.

@dlqqq dlqqq added the enhancement New feature or request label Oct 17, 2025
Copy link
Collaborator

@ellisonbg ellisonbg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done local testing and everything worked as is. I left some relative minor comments for changes and follow up issues. Marking as changes needed, but they should be relatively minor.

@dlqqq
Copy link
Collaborator Author

dlqqq commented Oct 20, 2025

Implemented requested changes & verified that the branch still works as expected in handling document resets on chat files. 👍

Copy link
Collaborator

@Zsailer Zsailer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, @dlqqq!

Looks like you addressed all of @ellisonbg's comments. Approving to unblock merge.

@dlqqq dlqqq merged commit d397f76 into jupyter-ai-contrib:main Oct 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle reset of ychat documents in the frontend Implement out of band logic for chat documents

3 participants