Skip to content

Commit

Permalink
Activate the sidepanel and the expected chat before focusing input
Browse files Browse the repository at this point in the history
  • Loading branch information
brichet committed Jan 7, 2025
1 parent f47ed40 commit 3a4e7da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/jupyterlab-chat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,17 @@ const chatCommands: JupyterFrontEndPlugin<void> = {
commands.addCommand(CommandIDs.focusInput, {
caption: 'Focus the input of the current chat widget',
isEnabled: () => tracker.currentWidget !== null,
execute: async () => {
execute: () => {
const widget = tracker.currentWidget;
if (widget) {
app.shell.activateById(widget.id);
if (widget instanceof ChatWidget && chatPanel) {
// The chat is the side panel.
app.shell.activateById(chatPanel.id);
chatPanel.openIfExists(widget.model.name);
} else {
// The chat is in the main area.
app.shell.activateById(widget.id);
}
widget.model.focusInput();
}
}
Expand Down

0 comments on commit 3a4e7da

Please sign in to comment.