Skip to content

Commit

Permalink
Handle the case where the command to open chat has not been loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed May 13, 2024
1 parent 6e457c8 commit 8f9ef11
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/jupyterlab-collaborative-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,17 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
filepath = model.path;
}

return commands.execute(CommandIDs.openChat, {
filepath,
inSidePanel
});
if (commands.hasCommand(CommandIDs.openChat)) {
return commands.execute(CommandIDs.openChat, {
filepath,
inSidePanel
});
} else {
commands.execute('docmanager:open', {
path: `RTC:${filepath}`,
factory: FACTORY
});
}
}
});

Expand Down Expand Up @@ -410,7 +417,7 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
}
})
.catch(e =>
console.error('The command to open a chat is not initialized', e)
console.error('The command to open a chat is not initialized\n', e)
);
}
};
Expand Down Expand Up @@ -476,6 +483,7 @@ const chatPanel: JupyterFrontEndPlugin<ChatPanel> = {
label: 'Move the chat to the side panel',
caption: 'Move the chat to the side panel',
icon: launchIcon,
isEnabled: () => commands.hasCommand(CommandIDs.openChat),
execute: async () => {
const widget = app.shell.currentWidget;
// Ensure widget is a CollaborativeChatWidget and is in main area
Expand Down

0 comments on commit 8f9ef11

Please sign in to comment.