diff --git a/ChatView/ClientInterface.cpp b/ChatView/ClientInterface.cpp index 477aee1..2924c52 100644 --- a/ChatView/ClientInterface.cpp +++ b/ChatView/ClientInterface.cpp @@ -289,14 +289,14 @@ void ClientInterface::sendMessage( connect( provider, &LLMCore::Provider::toolExecutionStarted, - m_chatModel, - &ChatModel::addToolExecutionStatus, + this, + &ClientInterface::handleToolExecutionStarted, Qt::UniqueConnection); connect( provider, &LLMCore::Provider::toolExecutionCompleted, - m_chatModel, - &ChatModel::updateToolResult, + this, + &ClientInterface::handleToolExecutionCompleted, Qt::UniqueConnection); connect( provider, @@ -498,6 +498,31 @@ void ClientInterface::handleRedactedThinkingBlockReceived( m_chatModel->addRedactedThinkingBlock(requestId, signature); } +void ClientInterface::handleToolExecutionStarted( + const QString &requestId, const QString &toolId, const QString &toolName) +{ + if (!m_activeRequests.contains(requestId)) { + LOG_MESSAGE(QString("Ignoring tool execution start for non-chat request: %1").arg(requestId)); + return; + } + + m_chatModel->addToolExecutionStatus(requestId, toolId, toolName); +} + +void ClientInterface::handleToolExecutionCompleted( + const QString &requestId, + const QString &toolId, + const QString &toolName, + const QString &toolOutput) +{ + if (!m_activeRequests.contains(requestId)) { + LOG_MESSAGE(QString("Ignoring tool execution result for non-chat request: %1").arg(requestId)); + return; + } + + m_chatModel->updateToolResult(requestId, toolId, toolName, toolOutput); +} + bool ClientInterface::isImageFile(const QString &filePath) const { static const QSet imageExtensions = {"png", "jpg", "jpeg", "gif", "webp", "bmp", "svg"}; diff --git a/ChatView/ClientInterface.hpp b/ChatView/ClientInterface.hpp index 0fd895c..5155b36 100644 --- a/ChatView/ClientInterface.hpp +++ b/ChatView/ClientInterface.hpp @@ -66,6 +66,13 @@ private slots: void handleThinkingBlockReceived( const QString &requestId, const QString &thinking, const QString &signature); void handleRedactedThinkingBlockReceived(const QString &requestId, const QString &signature); + void handleToolExecutionStarted( + const QString &requestId, const QString &toolId, const QString &toolName); + void handleToolExecutionCompleted( + const QString &requestId, + const QString &toolId, + const QString &toolName, + const QString &toolOutput); private: void handleLLMResponse(const QString &response, const QJsonObject &request);