Compare commits

..

6 Commits

Author SHA1 Message Date
5969d530bd chore: Upgrade plugin to 0.6.2 2025-09-01 00:51:03 +02:00
809f1c6614 feat: Add support QtCreator 17.0.1 (#225)
Add support 17.0.1 instead 17.0.0
2025-09-01 00:49:52 +02:00
851e681cf5 feat: Add new http client 2025-08-30 18:34:10 +02:00
f2f3b7cce0 doc: Add hotkey to close chat view 2025-08-20 09:31:27 +02:00
5b7a9b681c doc: Update chat description in README.md 2025-08-19 11:41:20 +02:00
29af277139 doc: Added chat and hotkeys description 2025-08-18 12:29:03 +02:00
6 changed files with 240 additions and 5 deletions

View File

@ -46,8 +46,8 @@ jobs:
}
qt_config:
- {
qt_version: "6.9.1",
qt_creator_version: "17.0.0"
qt_version: "6.9.2",
qt_creator_version: "17.0.1"
}
- {
qt_version: "6.8.3",

View File

@ -1,7 +1,7 @@
{
"Id" : "qodeassist",
"Name" : "QodeAssist",
"Version" : "0.6.1",
"Version" : "0.6.2",
"CompatVersion" : "${IDE_VERSION}",
"Vendor" : "Petr Mironychev",
"VendorId" : "petrmironychev",

View File

@ -40,7 +40,8 @@
- Sharing IDE opened files with model context (disabled by default, need enable in settings)
- Quick refactor code via fast chat command and opened files
- Chat functionality:
- Side and Bottom panels
- Side and Bottom panels(enabling in chat settings due stability reason with QQuickWidget problem)
- Chat in additional popup window with pinning(recommended)
- Chat history autosave and restore
- Token usage monitoring and management
- Attach files for one-time code analysis
@ -85,6 +86,11 @@ Join our Discord Community: Have questions or want to discuss QodeAssist? Join o
<img width="326" alt="QodeAssistBottomPanel" src="https://github.com/user-attachments/assets/4cc64c23-a294-4df8-9153-39ad6fdab34b">
</details>
<details>
<summary>Chat in addtional window: (click to expand)</summary>
<img width="851" height="865" alt="image" src="https://github.com/user-attachments/assets/a68894b7-886e-4501-a61b-7161ae34b427" />
</details>
<details>
<summary>Automatic syncing with open editor files: (click to expand)</summary>
<img width="600" alt="OpenedDocumentsSync" src="https://github.com/user-attachments/assets/08efda2f-dc4d-44c3-927c-e6a975090d2f">
@ -271,7 +277,16 @@ Linked files provide persistent context throughout the conversation:
- [ ] Support MCP
## Hotkeys
All hotkeys available in QtCreator Settings
Also you can find default hotkeys here:
- To call chat with llm in separate window, you can use:
- on Mac: Option + Command + W
- on Windows: Ctrl + Alt + W
- on Linux: Ctrl + Alt + W
- To close chat with llm in separate window, you can use:
- on Mac: Option + Command + S
- on Windows: Ctrl + Alt + S
- on Linux: Ctrl + Alt + S
- To call manual request to suggestion, you can use or change it in settings
- on Mac: Option + Command + Q
- on Windows: Ctrl + Alt + Q

View File

@ -16,6 +16,7 @@ add_library(LLMCore STATIC
OpenAIMessage.hpp OpenAIMessage.cpp
ValidationUtils.hpp ValidationUtils.cpp
ProviderID.hpp
HttpClient.hpp HttpClient.cpp
)
target_link_libraries(LLMCore

150
llmcore/HttpClient.cpp Normal file
View File

@ -0,0 +1,150 @@
/*
* Copyright (C) 2025 Petr Mironychev
*
* This file is part of QodeAssist.
*
* QodeAssist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QodeAssist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
*/
#include "HttpClient.hpp"
#include <QJsonDocument>
#include <QMutexLocker>
#include <QUuid>
#include <Logger.hpp>
namespace QodeAssist::LLMCore {
HttpClient::HttpClient(QObject *parent)
: QObject(parent)
, m_manager(new QNetworkAccessManager(this))
{
connect(this, &HttpClient::sendRequest, this, &HttpClient::onSendRequest);
}
HttpClient::~HttpClient()
{
QMutexLocker locker(&m_mutex);
for (auto *reply : std::as_const(m_activeRequests)) {
reply->abort();
reply->deleteLater();
}
m_activeRequests.clear();
}
void HttpClient::onSendRequest(const HttpRequest &request)
{
QNetworkRequest networkRequest(request.url);
networkRequest.setTransferTimeout(300000);
networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
networkRequest.setRawHeader("Accept", "text/event-stream");
networkRequest.setRawHeader("Cache-Control", "no-cache");
networkRequest.setRawHeader("Connection", "keep-alive");
if (request.headers.has_value()) {
for (const auto &[headername, value] : request.headers->asKeyValueRange()) {
networkRequest.setRawHeader(headername.toUtf8(), value.toUtf8());
}
}
QJsonDocument doc(request.payload);
LOG_MESSAGE(QString("HttpClient: Sending POST to %1").arg(request.url.toString()));
LOG_MESSAGE(QString("HttpClient: data: %1").arg(doc.toJson(QJsonDocument::Indented)));
QNetworkReply *reply = m_manager->post(networkRequest, doc.toJson(QJsonDocument::Compact));
addActiveRequest(reply, request.requestId);
connect(reply, &QNetworkReply::readyRead, this, &HttpClient::onReadyRead);
connect(reply, &QNetworkReply::finished, this, &HttpClient::onFinished);
}
void HttpClient::onReadyRead()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (!reply)
return;
QString requestId;
{
QMutexLocker locker(&m_mutex);
for (auto it = m_activeRequests.begin(); it != m_activeRequests.end(); ++it) {
if (it.value() == reply) {
requestId = it.key();
break;
}
}
}
if (requestId.isEmpty())
return;
QByteArray data = reply->readAll();
if (!data.isEmpty()) {
emit dataReceived(requestId, data);
}
}
void HttpClient::onFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (!reply)
return;
QString requestId;
bool hasError = false;
QString errorMsg;
{
QMutexLocker locker(&m_mutex);
for (auto it = m_activeRequests.begin(); it != m_activeRequests.end(); ++it) {
if (it.value() == reply) {
requestId = it.key();
m_activeRequests.erase(it);
break;
}
}
if (reply->error() != QNetworkReply::NoError) {
hasError = true;
errorMsg = reply->errorString();
}
}
reply->deleteLater();
if (!requestId.isEmpty()) {
emit requestFinished(requestId, !hasError, errorMsg);
}
}
QString HttpClient::addActiveRequest(QNetworkReply *reply, const QString &requestId)
{
QMutexLocker locker(&m_mutex);
m_activeRequests[requestId] = reply;
LOG_MESSAGE(QString("HttpClient: Added active request: %1").arg(requestId));
return requestId;
}
void HttpClient::cancelRequest(const QString &requestId)
{
QMutexLocker locker(&m_mutex);
if (auto it = m_activeRequests.find(requestId); it != m_activeRequests.end()) {
it.value()->abort();
it.value()->deleteLater();
m_activeRequests.erase(it);
LOG_MESSAGE(QString("HttpClient: Cancelled request: %1").arg(requestId));
}
}
} // namespace QodeAssist::LLMCore

69
llmcore/HttpClient.hpp Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright (C) 2025 Petr Mironychev
*
* This file is part of QodeAssist.
*
* QodeAssist is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* QodeAssist is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <QHash>
#include <QJsonObject>
#include <QMap>
#include <QMutex>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QObject>
#include <QUrl>
namespace QodeAssist::LLMCore {
struct HttpRequest
{
QUrl url;
QString requestId;
QJsonObject payload;
std::optional<QMap<QString, QString>> headers;
};
class HttpClient : public QObject
{
Q_OBJECT
public:
HttpClient(QObject *parent = nullptr);
~HttpClient();
void cancelRequest(const QString &requestId);
signals:
void sendRequest(const QodeAssist::LLMCore::HttpRequest &request);
void dataReceived(const QString &requestId, const QByteArray &data);
void requestFinished(const QString &requestId, bool success, const QString &error);
private slots:
void onSendRequest(const QodeAssist::LLMCore::HttpRequest &request);
void onReadyRead();
void onFinished();
private:
QString addActiveRequest(QNetworkReply *reply, const QString &requestId);
QNetworkAccessManager *m_manager;
QHash<QString, QNetworkReply *> m_activeRequests;
mutable QMutex m_mutex;
};
} // namespace QodeAssist::LLMCore