Skip to content
Open
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
22 changes: 14 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,27 @@ const plugin: JupyterFrontEndPlugin<void> = {
inputToolbarFactory,
attachmentOpenerRegistry,
createModel: async (name?: string) => {
const model = modelRegistry.createModel(name);
let model = name ? modelRegistry.get(name) : undefined;
if (!model) {
model = modelRegistry.createModel(name);
}
chatPanel.updateChatList();
return { model };
},
getChatNames: async () => {
const names = modelRegistry.getAll().map(model => model.name);
const arr: { [key: string]: string } = {};
for (const name of names) {
arr[name] = name;
}
return arr;
},
renameChat: async (oldName: string, newName: string) => {
const model = modelRegistry.get(oldName);
const concurrencyModel = modelRegistry.get(newName);
if (model && !concurrencyModel) {
model.name = newName;
chatPanel.updateChatList();
return true;
}
return false;
Expand Down Expand Up @@ -371,8 +384,6 @@ const plugin: JupyterFrontEndPlugin<void> = {
widget.disposed.connect(() => {
// Dispose of the approval buttons widget when the chat is disposed.
approvalButton.dispose();
// Remove the model from the registry when the widget is disposed.
modelRegistry.remove(model.name);
});
});

Expand Down Expand Up @@ -515,11 +526,6 @@ function registerCommands(
model.agentManager.activeProviderChanged.connect(() =>
tracker.save(widget)
);

// Remove the model from the registry when the widget is disposed.
widget.disposed.connect(() => {
modelRegistry.remove(model.name);
});
};

commands.addCommand(CommandIds.openChat, {
Expand Down
Loading