From 550dcdda711ad3020ed426fba7ca69b000845b93 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 5 Oct 2026 19:11:47 +1300 Subject: [PATCH 1/3] Live mode: remember the start warning and "always" across restarts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Live mode asked at every start (the "Mode direct" warning) and forgot "always" for scripts when QElectroTech closed, so a user who works with an assistant every day re-enabled it every day. Both are now opt-in and remembered: the warning has a "Ne plus demander au démarrage" checkbox (scripting/live_skip_warning), and the ask-first choice is saved (scripting/live_ask_first; the Assistant panel's checkbox and "Toujours" in the script window). The status bar still shows live mode whenever it is open. Switching live mode off in the settings clears "don't ask again", so turning it back on warns again. Co-Authored-By: Claude Opus 5.5 --- sources/qetdiagrameditor.cpp | 2 +- sources/scripting/liveserver.cpp | 19 +++++++++++++--- sources/scripting/liveserver.h | 5 +++-- sources/utils/qetsettings.cpp | 38 ++++++++++++++++++++++++++++++++ sources/utils/qetsettings.h | 4 ++++ 5 files changed, 62 insertions(+), 6 deletions(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index 41c8e82e5..fa6f73447 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -4086,7 +4086,7 @@ void QETDiagramEditor::setUpLiveIndicator() auto *dock_layout = new QVBoxLayout(content); auto *ask = new QCheckBox(tr("Demander avant d'exécuter un script écrit par l'assistant"), content); ask->setChecked(LiveServer::instance().askFirst()); - ask->setToolTip(tr("Pour cette session seulement : chaque démarrage redemande")); + ask->setToolTip(tr("Retenu après un redémarrage")); auto *log = new QListWidget(content); log->setWordWrap(true); dock_layout->addWidget(ask); diff --git a/sources/scripting/liveserver.cpp b/sources/scripting/liveserver.cpp index 6eb679c18..a892a9f5f 100644 --- a/sources/scripting/liveserver.cpp +++ b/sources/scripting/liveserver.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,8 @@ LiveServer &LiveServer::instance() return server; } -LiveServer::LiveServer() +LiveServer::LiveServer() : + m_ask_first(QetSettings::liveAskFirst()) { connect(qApp, &QCoreApplication::aboutToQuit, this, &LiveServer::stop); } @@ -104,6 +106,10 @@ void LiveServer::askAndStart(QWidget *parent) return; } m_asked = true; + if (QetSettings::liveSkipStartWarning()) { + start(); + return; + } QMessageBox box(QMessageBox::Warning, tr("Mode direct"), tr("Le mode direct est activé : un assistant IA connecté " @@ -117,11 +123,17 @@ void LiveServer::askAndStart(QWidget *parent) box.addButton(tr("&Pas pour cette session"), QMessageBox::RejectRole); QPushButton *off = box.addButton(tr("&Désactiver"), QMessageBox::DestructiveRole); box.setDefaultButton(go); + auto *remember = new QCheckBox(tr("Ne plus demander au démarrage"), &box); + remember->setToolTip(tr("Le mode direct s'ouvrira à chaque démarrage. Pour être " + "de nouveau averti, désactivez-le puis réactivez-le dans " + "Configurer QElectroTech > Général > Projets.")); + box.setCheckBox(remember); box.exec(); if (box.clickedButton() == off) { QetSettings::setLiveAssistantEnabled(false); } else if (box.clickedButton() == go) { + if (remember->isChecked()) QetSettings::setLiveSkipStartWarning(true); start(); } } @@ -241,7 +253,7 @@ void LiveServer::handle(const QJsonObject &request) const QString name = request.value(QStringLiteral("name")).toString(); const QString source = request.value(QStringLiteral("source")).toString(); //A script the assistant just wrote: the user sees it first, - //unless they said "always" this session. A stored script + //unless they chose "always" (remembered). A stored script //is one the user already has, so it runs as a click would. if (m_ask_first && !confirm(name, source)) answer = failure(QStringLiteral("refused by the user")); @@ -380,6 +392,7 @@ void LiveServer::setAskFirst(bool ask) { if (ask == m_ask_first) return; m_ask_first = ask; + QetSettings::setLiveAskFirst(ask); emit askFirstChanged(ask); } @@ -514,7 +527,7 @@ bool LiveServer::confirm(const QString &name, const QString &source) auto *buttons = new QDialogButtonBox(&dialog); QPushButton *run = buttons->addButton(tr("&Exécuter"), QDialogButtonBox::AcceptRole); buttons->addButton(tr("&Refuser"), QDialogButtonBox::RejectRole); - QPushButton *always = buttons->addButton(tr("&Toujours pour cette session"), + QPushButton *always = buttons->addButton(tr("&Toujours"), QDialogButtonBox::AcceptRole); layout->addWidget(buttons); QPushButton *clicked = nullptr; diff --git a/sources/scripting/liveserver.h b/sources/scripting/liveserver.h index 2a8726a88..6cb06cd9a 100644 --- a/sources/scripting/liveserver.h +++ b/sources/scripting/liveserver.h @@ -34,7 +34,8 @@ class QWidget; Three things must all be true before anything can connect: scripting is allowed, the "mode direct" setting is on (off by default), and the user - accepted the warning shown at this start. With the setting off this + accepted the warning shown at this start (or once ticked "don't ask + again", which lasts until the setting is switched off). With the setting off this class opens nothing and QElectroTech behaves as if it did not exist. The channel is a QLocalServer only the user's own account can open, @@ -96,7 +97,7 @@ class LiveServer : public QObject State m_state = Off; bool m_asked = false; bool m_busy = false; - bool m_ask_first = true; ///< per session, never saved: every start asks again + bool m_ask_first = true; ///< saved: QetSettings::liveAskFirst() }; #endif // LIVESERVER_H diff --git a/sources/utils/qetsettings.cpp b/sources/utils/qetsettings.cpp index 43adb2ce4..507ba928b 100644 --- a/sources/utils/qetsettings.cpp +++ b/sources/utils/qetsettings.cpp @@ -171,6 +171,44 @@ namespace QetSettings { QSettings settings; settings.setValue("scripting/live_assistant", enabled); + //Turned off and on again: the start warning comes back, so + //"don't ask again" never outlives the choice it was made for + if (!enabled) settings.remove("scripting/live_skip_warning"); + } + + /** + * @brief liveSkipStartWarning + * @return true when the user ticked "don't ask again" in live mode's + * start warning: live mode then opens at every start without asking, + * until it is switched off in the settings. False unless they did. + */ + bool liveSkipStartWarning() + { + QSettings settings; + return settings.value("scripting/live_skip_warning", false).toBool(); + } + + void setLiveSkipStartWarning(bool skip) + { + QSettings settings; + settings.setValue("scripting/live_skip_warning", skip); + } + + /** + * @brief liveAskFirst + * @return whether live mode shows each script the assistant wrote and + * asks before running it. On unless the user chose "always". + */ + bool liveAskFirst() + { + QSettings settings; + return settings.value("scripting/live_ask_first", true).toBool(); + } + + void setLiveAskFirst(bool ask) + { + QSettings settings; + settings.setValue("scripting/live_ask_first", ask); } /** diff --git a/sources/utils/qetsettings.h b/sources/utils/qetsettings.h index 64bf4b615..1aad738e8 100644 --- a/sources/utils/qetsettings.h +++ b/sources/utils/qetsettings.h @@ -40,6 +40,10 @@ namespace QetSettings bool scriptingForcedByEnvironment(); bool liveAssistantEnabled(); void setLiveAssistantEnabled(bool enabled); + bool liveSkipStartWarning(); + void setLiveSkipStartWarning(bool skip); + bool liveAskFirst(); + void setLiveAskFirst(bool ask); /** @brief The sheet (folio) background the diagram editors draw. From 85492c8f754f51025f4705d89b9aac6583673572 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 5 Oct 2026 20:22:38 +1300 Subject: [PATCH 2/3] Live mode: English for the remembered-choice texts Co-Authored-By: Claude Opus 5.5 --- lang/qet_en.ts | 84 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/lang/qet_en.ts b/lang/qet_en.ts index 55b13f184..b59c89883 100644 --- a/lang/qet_en.ts +++ b/lang/qet_en.ts @@ -7185,12 +7185,12 @@ Please use the advanced editor for this. LiveServer - + Mode direct Live mode - + Le mode direct est activé : un assistant IA connecté pourra exécuter des scripts sur le projet ouvert. Chaque action s'annule d'un Ctrl+Z, et le bouton « Arrêter » de la barre d'état coupe la connexion. @@ -7203,55 +7203,69 @@ Each action is undone with one Ctrl+Z, and the “Stop” button in the status b This setting is in Configure QElectroTech > General > Projects. - + &Continuer &Continue - + &Pas pour cette session &Not this session - + &Désactiver &Turn off - - + + Ne plus demander au démarrage + Don't ask again at start + + + + Le mode direct s'ouvrira à chaque démarrage. Pour être de nouveau averti, désactivez-le puis réactivez-le dans Configurer QElectroTech > Général > Projets. + Live mode will open at every start. To be warned again, turn it off and back on in Configure QElectroTech > General > Projects. + + + + script script - + Assistant : %1 Assistant: %1 - + L'assistant veut exécuter un script The assistant wants to run a script - + « %1 » sur le projet ouvert. Une fois exécuté, Ctrl+Z l'annule. “%1” on the open project. Once it has run, Ctrl+Z undoes it. - + &Exécuter &Run - + &Refuser &Decline - + + &Toujours + &Always + + &Toujours pour cette session - &Always this session + &Always this session @@ -7765,90 +7779,90 @@ Do you still want to link this slave contact? NewElementWizard - + Vous n'êtes pas obligé de préciser l'extension *.elmt. Elle sera ajoutée automatiquement. You don't have to specify the *.elmt extension. It will be added automatically. - + nouvel_element new_element - + &Suivant > &Next > - + Créer un nouvel élément : Assistant window title Create a new element: wizard - + Étape 1/3 : Catégorie parente wizard page title Step 1 of 3: Parent category - + Sélectionnez une catégorie dans laquelle enregistrer le nouvel élément. wizard page subtitle Select a category which to save the new element in. - + Étape 2/3 : Nom du fichier wizard page title Step 2 of 3: Filename - + Indiquez le nom du fichier dans lequel enregistrer le nouvel élément. wizard page subtitle Enter the name of the file for the new element. - + Étape 3/3 : Noms de l'élément wizard page title Step 3 of 3: Element names - + Indiquez le ou les noms de l'élément. wizard page subtitle Enter one or more names for the element. - + Nom du nouvel élément default name when creating a new element New element name - - - + + + Erreur message box title Error - + Vous devez sélectionner une catégorie. message box content You must select a category. - + Vous devez entrer un nom de fichier message box content You must enter a filename - + Un élément portant le même nom existe déjà An element with the same name already exists @@ -11296,6 +11310,11 @@ A script runs with your permissions: it can read and modify the open project and Enable scripts? This setting can be changed in Configure QElectroTech > General > Projects. + + + Retenu après un redémarrage + Remembered after a restart + Scripts JavaScript (*.js);;Tous les fichiers (*) @@ -11386,9 +11405,8 @@ To make a script of it, ask your AI assistant: the button below copies the reque Ask before running a script the assistant wrote - Pour cette session seulement : chaque démarrage redemande - For this session only: every start asks again + For this session only: every start asks again From 193d177d95ac04df880ca28c5bde2f79e7046cc4 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Mon, 5 Oct 2026 20:34:44 +1300 Subject: [PATCH 3/3] qet-mcp README: remembered live-mode choices Co-Authored-By: Claude Opus 5.5 --- misc/qet-mcp/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/qet-mcp/README.md b/misc/qet-mcp/README.md index 0852d13a4..f32e37762 100644 --- a/misc/qet-mcp/README.md +++ b/misc/qet-mcp/README.md @@ -338,7 +338,8 @@ QElectroTech, in front of you, so you can watch, stop or undo: | `qet_live_screenshot` | a picture of the folio on screen, as an MCP image, cropped to the folio | A script the assistant writes on the spot is shown to you first, with -*Run*, *Decline* or *Always this session*; the Assistant +*Run*, *Decline* or *Always* (remembered after a restart; untick "Ask +before running" in the Assistant panel to be asked again); the Assistant panel lists everything it did. QElectroTech only listens when three things are true: @@ -349,7 +350,8 @@ QElectroTech only listens when three things are true: mode)" is ticked (off by default; in French, Configurer QElectroTech > Général > Projets); 3. at this start, you answered *Continue* to the warning QElectroTech shows - every time it starts with that setting on. + when it starts with that setting on -- or, once, ticked "Don't ask again + at start" in it, which lasts until the setting is switched off. While it listens, the status bar says so and shows the assistant's last action, with a *Stop* button that closes the channel for the rest of