From 7d91e8fdf19ea32c1d0e7dcb1d6a9db6d2019467 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 2 Oct 2026 11:57:53 +1300 Subject: [PATCH] Live mode: find the open project while QElectroTech is not the active window While the user types to the assistant, QElectroTech is not the active application, and QMdiArea then reports no active sub-window: status said no project was open and every run was refused. Make the sub-window it remembers active again before handling a request; the focus stays where the user put it. Found with the Windows package under Wine; reproduced on Linux with another window focused. Co-Authored-By: Claude Opus 5.5 (1M context) --- sources/scripting/liveserver.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sources/scripting/liveserver.cpp b/sources/scripting/liveserver.cpp index c7806fd3d..1b9ab2995 100644 --- a/sources/scripting/liveserver.cpp +++ b/sources/scripting/liveserver.cpp @@ -273,12 +273,23 @@ void LiveServer::handle(const QJsonObject &request) */ QETDiagramEditor *LiveServer::editor() const { - QETDiagramEditor *shown = nullptr; + QETDiagramEditor *chosen = nullptr; for (QETDiagramEditor *e : QETApp::diagramEditors()) { - if (e->isActiveWindow()) return e; - if (!shown && e->isVisible()) shown = e; + if (e->isActiveWindow()) { + chosen = e; + break; + } + if (!chosen && e->isVisible()) chosen = e; } - return shown; + //While the user is typing to the assistant, QElectroTech is not + //the active application, and QMdiArea then has no active + //sub-window: every "current project" in the editor reads as none. + //The one it remembers is the project the user was looking at. + if (chosen && !chosen->m_workspace.activeSubWindow() + && chosen->m_workspace.currentSubWindow()) { + chosen->m_workspace.setActiveSubWindow(chosen->m_workspace.currentSubWindow()); + } + return chosen; } QJsonObject LiveServer::status()