From 86135d0c1358e279b47381a342769bb125ad0146 Mon Sep 17 00:00:00 2001 From: Petr Mironychev <9195189+Palm1r@users.noreply.github.com> Date: Mon, 29 Jun 2026 15:11:40 +0200 Subject: [PATCH] fix: Remove files and folder watches --- settings/AgentsSettingsPage.cpp | 42 ------------------- settings/ProjectSettingsPanel.cpp | 6 ++- settings/ProvidersSettingsPage.cpp | 7 ++++ sources/agents/agents.qrc | 8 ++++ .../ProviderInstanceFactory.cpp | 31 +------------- .../ProviderInstanceFactory.hpp | 8 ---- sources/providersConfig/mistral.toml | 2 +- sources/skills/SkillsManager.cpp | 25 +---------- sources/skills/SkillsManager.hpp | 5 --- 9 files changed, 23 insertions(+), 111 deletions(-) diff --git a/settings/AgentsSettingsPage.cpp b/settings/AgentsSettingsPage.cpp index 326c7b1..a60a2f4 100644 --- a/settings/AgentsSettingsPage.cpp +++ b/settings/AgentsSettingsPage.cpp @@ -16,11 +16,9 @@ #include #include -#include #include #include #include -#include #include #include #include @@ -153,26 +151,6 @@ public: &AgentListPane::selectByName); } - m_reloadDebounce = new QTimer(this); - m_reloadDebounce->setSingleShot(true); - m_reloadDebounce->setInterval(300); - connect(m_reloadDebounce, &QTimer::timeout, this, [this] { - constexpr qint64 kSelfWriteIgnoreMs = 1500; - if (QDateTime::currentMSecsSinceEpoch() - m_lastSelfWriteMs < kSelfWriteIgnoreMs) { - armWatcher(); - return; - } - reloadFromDisk(); - }); - - m_watcher = new QFileSystemWatcher(this); - connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString &) { - m_reloadDebounce->start(); - }); - connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &) { - m_reloadDebounce->start(); - }); - reloadFromDisk(); if (m_navigator) { @@ -194,21 +172,6 @@ private: m_agentFactory->reload(); updateUserPathLabel(); m_listPane->refresh(); - armWatcher(); - } - - void armWatcher() - { - if (!m_watcher) - return; - const QStringList watched = m_watcher->files() + m_watcher->directories(); - if (!watched.isEmpty()) - m_watcher->removePaths(watched); - const QString dir = QodeAssist::AgentFactory::userAgentsDir(); - m_watcher->addPath(dir); - const QDir userDir(dir); - for (const QString &f : userDir.entryList({QStringLiteral("*.toml")}, QDir::Files)) - m_watcher->addPath(userDir.filePath(f)); } void updateUserPathLabel() @@ -246,7 +209,6 @@ private: void customizeAgent(const AgentConfig &parent) { - m_lastSelfWriteMs = QDateTime::currentMSecsSinceEpoch(); const AgentDuplicateResult res = duplicateAgentInUserDir(parent, *m_agentFactory); if (!res.ok) { QMessageBox::warning(this, tr("Duplicate"), res.error); @@ -272,7 +234,6 @@ private: QMessageBox::No) != QMessageBox::Yes) return; - m_lastSelfWriteMs = QDateTime::currentMSecsSinceEpoch(); if (!QFile::remove(sourcePath)) { QMessageBox::warning( this, @@ -296,9 +257,6 @@ private: AgentListPane *m_listPane = nullptr; QScrollArea *m_detailScroll = nullptr; AgentDetailPane *m_detail = nullptr; - QFileSystemWatcher *m_watcher = nullptr; - QTimer *m_reloadDebounce = nullptr; - qint64 m_lastSelfWriteMs = 0; }; class AgentsSettingsPage : public Core::IOptionsPage diff --git a/settings/ProjectSettingsPanel.cpp b/settings/ProjectSettingsPanel.cpp index 0f37f71..df1aa6a 100644 --- a/settings/ProjectSettingsPanel.cpp +++ b/settings/ProjectSettingsPanel.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "ProjectSettings.hpp" #include "SettingsConstants.hpp" @@ -90,6 +91,9 @@ static ProjectSettingsWidget *createProjectPanel(Project *project) QObject::connect( &settings->projectSkillDirs, &Utils::BaseAspect::changed, skillsList, refreshSkills); + auto *reloadSkillsButton = new QPushButton(Tr::tr("Reload")); + QObject::connect(reloadSkillsButton, &QPushButton::clicked, skillsList, refreshSkills); + Column{ generalWidget, Space{8}, @@ -97,7 +101,7 @@ static ProjectSettingsWidget *createProjectPanel(Project *project) title(Tr::tr("Skills")), Column{ settings->projectSkillDirs, - new QLabel(Tr::tr("Discovered project skills:")), + Row{new QLabel(Tr::tr("Discovered project skills:")), st, reloadSkillsButton}, skillsList, }, }, diff --git a/settings/ProvidersSettingsPage.cpp b/settings/ProvidersSettingsPage.cpp index c566008..1452306 100644 --- a/settings/ProvidersSettingsPage.cpp +++ b/settings/ProvidersSettingsPage.cpp @@ -86,6 +86,13 @@ public: headerRow->setSpacing(8); headerRow->addWidget(m_titleLabel, 1); + auto *reloadButton = new QPushButton(tr("Reload from disk"), this); + connect(reloadButton, &QPushButton::clicked, this, [this] { + if (m_factory) + m_factory->reload(); + }); + headerRow->addWidget(reloadButton); + auto *headerSep = new QFrame(this); headerSep->setFrameShape(QFrame::HLine); headerSep->setFrameShadow(QFrame::Sunken); diff --git a/sources/agents/agents.qrc b/sources/agents/agents.qrc index 7c6ab2f..7b8edc3 100644 --- a/sources/agents/agents.qrc +++ b/sources/agents/agents.qrc @@ -14,6 +14,14 @@ openai_chat_responses.toml google_base_chat.toml google_chat.toml + mistral_base_chat.toml + mistral_chat.toml + mistral_chat_reasoning.toml + mistral_compression.toml + mistral_quick_refactor.toml + codestral_base_fim.toml + codestral_completion_fim.toml + mistral_completion_codestral_fim.toml ollama_base_chat.toml ollama_chat_simple.toml ollama_chat_thinking.toml diff --git a/sources/providersConfig/ProviderInstanceFactory.cpp b/sources/providersConfig/ProviderInstanceFactory.cpp index daa924e..2296ce8 100644 --- a/sources/providersConfig/ProviderInstanceFactory.cpp +++ b/sources/providersConfig/ProviderInstanceFactory.cpp @@ -5,12 +5,9 @@ #include "ProviderInstanceFactory.hpp" #include -#include -#include #include #include #include -#include #include @@ -39,15 +36,6 @@ ProviderInstanceFactory::ProviderInstanceFactory(QObject *parent) { ::initProviderInstancesResource(); - m_watcher = new QFileSystemWatcher(this); - m_reloadDebounce = new QTimer(this); - m_reloadDebounce->setSingleShot(true); - m_reloadDebounce->setInterval(150); - connect(m_reloadDebounce, &QTimer::timeout, this, [this] { reload(); }); - auto kick = [this](const QString &) { m_reloadDebounce->start(); }; - connect(m_watcher, &QFileSystemWatcher::fileChanged, this, kick); - connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, kick); - reload(); } @@ -65,6 +53,7 @@ void ProviderInstanceFactory::reload() Q_FUNC_INFO, "ProviderInstanceFactory must be used from its owner thread"); clear(); + QDir().mkpath(userInstancesDir()); auto result = ProviderInstanceLoader::load(instanceQrcPrefix(), userInstancesDir()); for (const QString &err : result.errors) LOG_MESSAGE(QString("[ProviderInstances] error: %1").arg(err)); @@ -83,7 +72,6 @@ void ProviderInstanceFactory::reload() m_warnings = std::move(result.warnings); rebuildIndexes(); - rewatchUserDir(); emit instancesReloaded(); } @@ -113,23 +101,6 @@ void ProviderInstanceFactory::rebuildIndexes() }); } -void ProviderInstanceFactory::rewatchUserDir() -{ - if (!m_watcher) - return; - - const QStringList stale = m_watcher->files() + m_watcher->directories(); - if (!stale.isEmpty()) - m_watcher->removePaths(stale); - - const QString userDir = userInstancesDir(); - QDir().mkpath(userDir); - m_watcher->addPath(userDir); - QDir d(userDir); - for (const QFileInfo &fi : d.entryInfoList({"*.toml"}, QDir::Files)) - m_watcher->addPath(fi.absoluteFilePath()); -} - const ProviderInstance *ProviderInstanceFactory::instanceByName(const QString &name) const { const auto it = m_nameIndex.constFind(name.toCaseFolded()); diff --git a/sources/providersConfig/ProviderInstanceFactory.hpp b/sources/providersConfig/ProviderInstanceFactory.hpp index a22208b..dd3f0e7 100644 --- a/sources/providersConfig/ProviderInstanceFactory.hpp +++ b/sources/providersConfig/ProviderInstanceFactory.hpp @@ -13,9 +13,6 @@ #include "ProviderInstance.hpp" -class QFileSystemWatcher; -class QTimer; - namespace QodeAssist::Providers { class ProviderInstanceFactory : public QObject @@ -47,7 +44,6 @@ signals: void instancesReloaded(); private: - void rewatchUserDir(); void rebuildIndexes(); std::vector m_instances; @@ -55,10 +51,6 @@ private: QStringList m_knownClientApisCache; QStringList m_errors; QStringList m_warnings; - - - QFileSystemWatcher *m_watcher = nullptr; - QTimer *m_reloadDebounce = nullptr; }; } // namespace QodeAssist::Providers diff --git a/sources/providersConfig/mistral.toml b/sources/providersConfig/mistral.toml index 45f0a7b..4d3ae78 100644 --- a/sources/providersConfig/mistral.toml +++ b/sources/providersConfig/mistral.toml @@ -2,7 +2,7 @@ schema_version = 1 name = "Mistral AI" client_api = "Mistral AI" -description = "Cloud (Mistral). Mistral chat/instruct models, incl. the Magistral reasoning model. For Mistral's FIM code model, use Codestral." +description = "Cloud (Mistral). Mistral chat/instruct models, the Magistral reasoning model, and the Codestral code model — including native FIM via /v1/fim/completions. The dedicated Codestral provider (codestral.mistral.ai) has its own key and endpoint." url = "https://api.mistral.ai" api_key_ref = "qodeassist/providers/Mistral AI" diff --git a/sources/skills/SkillsManager.cpp b/sources/skills/SkillsManager.cpp index aef07e5..ddaf37f 100644 --- a/sources/skills/SkillsManager.cpp +++ b/sources/skills/SkillsManager.cpp @@ -5,7 +5,6 @@ #include "SkillsManager.hpp" #include -#include #include "SkillsLoader.hpp" @@ -13,10 +12,7 @@ namespace QodeAssist::Skills { SkillsManager::SkillsManager(QObject *parent) : QObject(parent) - , m_watcher(new QFileSystemWatcher(this)) -{ - connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, [this] { reload(); }); -} +{} void SkillsManager::configure( const QString &projectPath, @@ -61,28 +57,9 @@ void SkillsManager::reload() { const QStringList roots = resolveRoots(m_projectPath, m_globalRoots, m_projectSubdirs); m_skills = SkillsLoader::scan(roots); - updateWatcher(roots); emit skillsChanged(); } -void SkillsManager::updateWatcher(const QStringList &roots) -{ - const QStringList watched = m_watcher->directories(); - if (!watched.isEmpty()) - m_watcher->removePaths(watched); - - QStringList toWatch; - for (const QString &root : roots) { - if (QDir(root).exists()) - toWatch << root; - } - for (const AgentSkill &skill : m_skills) - toWatch << skill.skillDir; - - if (!toWatch.isEmpty()) - m_watcher->addPaths(toWatch); -} - QVector SkillsManager::skills() const { return m_skills; diff --git a/sources/skills/SkillsManager.hpp b/sources/skills/SkillsManager.hpp index 50a890f..b3e3d13 100644 --- a/sources/skills/SkillsManager.hpp +++ b/sources/skills/SkillsManager.hpp @@ -13,8 +13,6 @@ #include "AgentSkill.hpp" -class QFileSystemWatcher; - namespace QodeAssist::Skills { class SkillsManager : public QObject @@ -48,13 +46,10 @@ signals: void skillsChanged(); private: - void updateWatcher(const QStringList &roots); - QString m_projectPath; QStringList m_globalRoots; QStringList m_projectSubdirs; QVector m_skills; - QFileSystemWatcher *m_watcher = nullptr; }; } // namespace QodeAssist::Skills