mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-05 04:29:12 -04:00
fix: Found and fix review mistakes
This commit is contained in:
@@ -9,11 +9,9 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QSaveFile>
|
||||
#include <QTimer>
|
||||
|
||||
#include <LLMQore/ToolsManager.hpp>
|
||||
#include <logger/Logger.hpp>
|
||||
@@ -86,7 +84,6 @@ void McpClientsManager::init()
|
||||
m_initialized = true;
|
||||
|
||||
ensureFileExists();
|
||||
setupWatcher();
|
||||
|
||||
connect(
|
||||
&Settings::mcpSettings().enableMcpClients,
|
||||
@@ -128,48 +125,6 @@ void McpClientsManager::ensureFileExists()
|
||||
}
|
||||
}
|
||||
|
||||
void McpClientsManager::setupWatcher()
|
||||
{
|
||||
m_watcher = new QFileSystemWatcher(this);
|
||||
m_reloadDebounce = new QTimer(this);
|
||||
m_reloadDebounce->setSingleShot(true);
|
||||
m_reloadDebounce->setInterval(300);
|
||||
|
||||
connect(m_reloadDebounce.data(), &QTimer::timeout, this, [this]() {
|
||||
const bool suppress = m_suppressNextWatcherReload;
|
||||
m_suppressNextWatcherReload = false;
|
||||
if (!suppress)
|
||||
loadFromDisk();
|
||||
updateWatchedPaths();
|
||||
});
|
||||
connect(m_watcher.data(), &QFileSystemWatcher::fileChanged, this, [this]() {
|
||||
m_reloadDebounce->start();
|
||||
});
|
||||
connect(m_watcher.data(), &QFileSystemWatcher::directoryChanged, this, [this]() {
|
||||
m_reloadDebounce->start();
|
||||
});
|
||||
|
||||
updateWatchedPaths();
|
||||
}
|
||||
|
||||
void McpClientsManager::updateWatchedPaths()
|
||||
{
|
||||
if (!m_watcher)
|
||||
return;
|
||||
if (!m_watcher->files().isEmpty())
|
||||
m_watcher->removePaths(m_watcher->files());
|
||||
if (!m_watcher->directories().isEmpty())
|
||||
m_watcher->removePaths(m_watcher->directories());
|
||||
|
||||
const QString path = configFilePath();
|
||||
const QFileInfo info(path);
|
||||
if (info.exists())
|
||||
m_watcher->addPath(path);
|
||||
const QString dir = info.absolutePath();
|
||||
if (QFileInfo::exists(dir))
|
||||
m_watcher->addPath(dir);
|
||||
}
|
||||
|
||||
QList<McpServerConnection *> McpClientsManager::connections() const
|
||||
{
|
||||
return m_connections;
|
||||
@@ -242,14 +197,12 @@ bool McpClientsManager::writeRoot(const QJsonObject &root)
|
||||
emit writeFailed(reason);
|
||||
return false;
|
||||
}
|
||||
m_suppressNextWatcherReload = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void McpClientsManager::reload()
|
||||
{
|
||||
loadFromDisk();
|
||||
updateWatchedPaths();
|
||||
}
|
||||
|
||||
bool McpClientsManager::setServerEnabled(const QString &name, bool enabled)
|
||||
|
||||
@@ -7,14 +7,10 @@
|
||||
#include <QJsonObject>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
#include "McpServerConnection.hpp"
|
||||
|
||||
class QFileSystemWatcher;
|
||||
class QTimer;
|
||||
|
||||
namespace QodeAssist::Mcp {
|
||||
|
||||
class McpClientsManager : public QObject
|
||||
@@ -49,18 +45,13 @@ private:
|
||||
|
||||
void loadFromDisk();
|
||||
void ensureFileExists();
|
||||
void setupWatcher();
|
||||
void updateWatchedPaths();
|
||||
|
||||
static QJsonObject builtinServers();
|
||||
QJsonObject readRoot() const;
|
||||
bool writeRoot(const QJsonObject &root);
|
||||
|
||||
bool m_initialized = false;
|
||||
bool m_suppressNextWatcherReload = false;
|
||||
QList<McpServerConnection *> m_connections;
|
||||
QPointer<QFileSystemWatcher> m_watcher;
|
||||
QPointer<QTimer> m_reloadDebounce;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Mcp
|
||||
|
||||
Reference in New Issue
Block a user