chore: restructure llm plugin to be more coherent & fix various bugs in llm ui
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
C++ / fmt (pull_request) Failing after 6s
C++ / build (pull_request) Failing after 10s
C++ / clang-tidy (pull_request) Failing after 9s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 49s
Python / verify (pull_request) Successful in 1m35s
Rust / fmt (pull_request) Successful in 36s
Rust / clippy (pull_request) Successful in 54s
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "messagemodel.hpp"
|
||||
#include "message.hpp"
|
||||
#include "messagemodel.hpp"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
@@ -12,30 +12,32 @@
|
||||
|
||||
namespace ZShell::llm {
|
||||
|
||||
class ChatStore;
|
||||
class LlmClient;
|
||||
class Workspace;
|
||||
|
||||
class ChatSession : public QObject {
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_UNCREATABLE("Chat sessions are managed by Chat.chats")
|
||||
QML_UNCREATABLE("Chat sessions are owned by the LlmClient singleton")
|
||||
|
||||
Q_PROPERTY(QString id READ id CONSTANT)
|
||||
Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
|
||||
Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
|
||||
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconChanged)
|
||||
Q_PROPERTY(QDateTime createdAt READ createdAt CONSTANT)
|
||||
Q_PROPERTY(QDateTime updatedAt READ updatedAt NOTIFY updatedAtChanged)
|
||||
Q_PROPERTY(bool pinned READ pinned NOTIFY pinnedChanged)
|
||||
Q_PROPERTY(bool pinned READ pinned WRITE setPinned NOTIFY pinnedChanged)
|
||||
Q_PROPERTY(bool loaded READ isLoaded NOTIFY loaded)
|
||||
Q_PROPERTY(int messageCount READ messageCount NOTIFY messageCountChanged)
|
||||
Q_PROPERTY(int usageTokens READ usageTokens NOTIFY usageTokensChanged)
|
||||
Q_PROPERTY(
|
||||
ZShell::llm::ChatMessageModel* messagesModel READ messagesModel CONSTANT)
|
||||
Q_PROPERTY(QString workspace READ workspacePath CONSTANT)
|
||||
Q_PROPERTY(
|
||||
QString attachmentError READ attachmentError NOTIFY
|
||||
attachmentErrorChanged)
|
||||
|
||||
public:
|
||||
explicit ChatSession(const QString& id, QObject* parent = nullptr);
|
||||
ChatSession(ChatStore* store, const QString& id, QObject* parent = nullptr);
|
||||
|
||||
[[nodiscard]] QString id() const { return m_id; }
|
||||
[[nodiscard]] QString title() const { return m_title; }
|
||||
@@ -50,34 +52,33 @@ class ChatSession : public QObject {
|
||||
[[nodiscard]] qint64 updatedAtMs() const { return m_updatedAt; }
|
||||
[[nodiscard]] bool pinned() const { return m_pinned; }
|
||||
[[nodiscard]] int messageCount() const { return m_messageCount; }
|
||||
[[nodiscard]] int usageTokens() const { return m_usageTokens; }
|
||||
[[nodiscard]] ChatMessageModel* messagesModel();
|
||||
void ensureLoaded();
|
||||
[[nodiscard]] bool isLoaded() const { return m_loaded; }
|
||||
[[nodiscard]] ChatMessageModel* model() const { return m_model; }
|
||||
void markLoaded();
|
||||
[[nodiscard]] bool takeClearPending();
|
||||
|
||||
[[nodiscard]] LlmClient* client() const;
|
||||
[[nodiscard]] int lastTokenCount() const { return m_lastTokenCount; }
|
||||
void setLastTokenCount(int value);
|
||||
|
||||
[[nodiscard]] QString workspacePath() const { return m_workspace; }
|
||||
[[nodiscard]] QString attachmentError() const { return m_attachmentError; }
|
||||
void setAttachmentError(const QString& value);
|
||||
|
||||
static QString sandboxDirFor(const QString& sessionId);
|
||||
void ensureWorkspace();
|
||||
[[nodiscard]] ChatStore* store() const { return m_store; }
|
||||
[[nodiscard]] LlmClient* client() const;
|
||||
[[nodiscard]] Workspace* workspace() const { return m_workspace; }
|
||||
|
||||
void setTitle(const QString& value);
|
||||
void setIcon(const QString& value);
|
||||
void setUpdatedAt(qint64 value);
|
||||
void setPinned(bool value);
|
||||
void setUsageTokens(int value);
|
||||
|
||||
void setMeta(
|
||||
void hydrate(
|
||||
const QString& title,
|
||||
const QString& icon,
|
||||
qint64 createdAt,
|
||||
qint64 updatedAt,
|
||||
int messageCount);
|
||||
int messageCount,
|
||||
bool pinned);
|
||||
|
||||
[[nodiscard]] bool isCommitted() const { return m_committed; }
|
||||
void setCommitted(bool value) { m_committed = value; }
|
||||
|
||||
void adoptMessages(QList<ChatMessage*> messages);
|
||||
void persist();
|
||||
@@ -101,6 +102,7 @@ class ChatSession : public QObject {
|
||||
void pinnedChanged();
|
||||
void messageCountChanged();
|
||||
void loaded();
|
||||
void usageTokensChanged();
|
||||
void attachmentErrorChanged();
|
||||
|
||||
private:
|
||||
@@ -109,20 +111,22 @@ class ChatSession : public QObject {
|
||||
ChatMessage::Role role, const QString& content, qint64 timestamp);
|
||||
void startGeneration(ChatMessage* target);
|
||||
void setCount(int value);
|
||||
void setAttachmentError(const QString& value);
|
||||
|
||||
ChatStore* m_store;
|
||||
QString m_id;
|
||||
bool m_committed = false;
|
||||
QString m_title;
|
||||
QString m_icon;
|
||||
qint64 m_createdAt = 0;
|
||||
qint64 m_updatedAt = 0;
|
||||
bool m_pinned = false;
|
||||
int m_messageCount = 0;
|
||||
int m_usageTokens = 0;
|
||||
ChatMessageModel* m_model = nullptr;
|
||||
Workspace* m_workspace = nullptr;
|
||||
bool m_loadRequested = false;
|
||||
bool m_loaded = false;
|
||||
bool m_clearPending = false;
|
||||
int m_lastTokenCount = 0;
|
||||
QString m_workspace;
|
||||
QString m_attachmentError;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user