fix: Remove files and folder watches

This commit is contained in:
Petr Mironychev
2026-06-29 15:11:40 +02:00
parent d66c714a28
commit 86135d0c13
9 changed files with 23 additions and 111 deletions

View File

@@ -14,6 +14,14 @@
<file>openai_chat_responses.toml</file>
<file>google_base_chat.toml</file>
<file>google_chat.toml</file>
<file>mistral_base_chat.toml</file>
<file>mistral_chat.toml</file>
<file>mistral_chat_reasoning.toml</file>
<file>mistral_compression.toml</file>
<file>mistral_quick_refactor.toml</file>
<file>codestral_base_fim.toml</file>
<file>codestral_completion_fim.toml</file>
<file>mistral_completion_codestral_fim.toml</file>
<file>ollama_base_chat.toml</file>
<file>ollama_chat_simple.toml</file>
<file>ollama_chat_thinking.toml</file>

View File

@@ -5,12 +5,9 @@
#include "ProviderInstanceFactory.hpp"
#include <QDir>
#include <QFileInfo>
#include <QFileSystemWatcher>
#include <QLoggingCategory>
#include <QSet>
#include <QThread>
#include <QTimer>
#include <coreplugin/icore.h>
@@ -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());

View File

@@ -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<ProviderInstance> 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

View File

@@ -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"

View File

@@ -5,7 +5,6 @@
#include "SkillsManager.hpp"
#include <QDir>
#include <QFileSystemWatcher>
#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<AgentSkill> SkillsManager::skills() const
{
return m_skills;

View File

@@ -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<AgentSkill> m_skills;
QFileSystemWatcher *m_watcher = nullptr;
};
} // namespace QodeAssist::Skills