Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,18 @@ const myChatExtension: JupyterFrontEndPlugin<void> = {
}
};
```

## Make the chats discoverable for third party extensions

The `jupyter/chat` package provides an `IChatTracker` token. This token is a generic
token that can be exposed by any extension providing a chat. It is designed to expose
an `IWidgetTracker` tracking either `ChatWidget` or `MainAreaWidget<ChatWidget>`, in
order to allow tracking both chats in main area chats and those in side panel.
To be available for others extensions, this token must be exposed by the developers
of the extension providing the chat(s), with a dedicated plugin.

```{note}
Since the token is generic, a configuration with multiple extensions providing chat(s)
will create a conflict. One of the plugins exposing the `IChatTracker` token will have
to be disabled (and the chats from that extension will no longer be tracked).
```
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ This token is composed of:
- `tracker`, a widget tracker that allows to track all the opened chats, and to
retrieve the current one.

```{caution}
Currently the widget tracker only tracks the main area widgets, not the ones opened in
the side panel.
```

### IChatPanel

This token is a pointer to the left panel containing chats.\
Expand Down
1 change: 1 addition & 0 deletions packages/jupyter-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export * from './markdown-renderer';
export * from './model';
export * from './registers';
export * from './selection-watcher';
export * from './tokens';
export * from './types';
export * from './widgets';
24 changes: 24 additions & 0 deletions packages/jupyter-chat/src/tokens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) Jupyter Development Team.
* Distributed under the terms of the Modified BSD License.
*/

import { IWidgetTracker, MainAreaWidget } from '@jupyterlab/apputils';
import { Token } from '@lumino/coreutils';

import { ChatWidget } from './widgets';

/**
* the chat tracker type.
*/
export type IChatTracker = IWidgetTracker<
ChatWidget | MainAreaWidget<ChatWidget>
>;

/**
* A chat tracker token.
*/
export const IChatTracker = new Token<IChatTracker>(
'@jupyter/chat:IChatTracker',
'The chat widget tracker'
);
8 changes: 8 additions & 0 deletions packages/jupyter-chat/src/widgets/chat-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Chat, IInputToolbarRegistry, MESSAGE_CLASS } from '../components';
import { chatIcon } from '../icons';
import { IChatModel } from '../model';
import {
ChatArea,
IFileAttachment,
INotebookAttachment,
INotebookAttachmentCell
Expand Down Expand Up @@ -71,6 +72,13 @@ export class ChatWidget extends ReactWidget {
return this._chatOptions.model;
}

/**
* The area where the chat is opened.
*/
get area(): ChatArea | undefined {
return this._chatOptions.area;
}

/**
* Get the input toolbar registry (if it has been provided when creating the widget).
*/
Expand Down
Loading
Loading