From 3a4e7da41b5a37557b6f22d274f81f805dc12334 Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Tue, 7 Jan 2025 16:36:22 +0100 Subject: [PATCH] Activate the sidepanel and the expected chat before focusing input --- python/jupyterlab-chat/src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/python/jupyterlab-chat/src/index.ts b/python/jupyterlab-chat/src/index.ts index bc2feed..1b01ed9 100644 --- a/python/jupyterlab-chat/src/index.ts +++ b/python/jupyterlab-chat/src/index.ts @@ -607,10 +607,17 @@ const chatCommands: JupyterFrontEndPlugin = { 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(); } }