better chat list view + anchor to bottom. sqlite db for chats + LIFO-ordered

This commit is contained in:
2026-08-23 16:37:11 +02:00
parent 37c6a9986e
commit aae3757daf
36 changed files with 2653 additions and 1459 deletions
+11 -8
View File
@@ -7,9 +7,9 @@
#include <QString>
#include <QVariantList>
namespace ZShell {
namespace ZShell::llm {
class Chat;
class LlmClient;
class ChatStore : public QObject {
Q_OBJECT
@@ -20,19 +20,22 @@ class ChatStore : public QObject {
public:
explicit ChatStore(QObject* parent = nullptr);
~ChatStore();
~ChatStore() override;
[[nodiscard]] int count() const;
[[nodiscard]] QVariantList values() const;
[[nodiscard]] ChatSession* at(int index) const;
Q_INVOKABLE ChatSession* insert(int index = -1);
Q_INVOKABLE ZShell::llm::ChatSession* insert(int index = -1);
Q_INVOKABLE void remove(int index);
Q_INVOKABLE void remove(ChatSession* chat);
Q_INVOKABLE void remove(ZShell::llm::ChatSession* chat);
Q_INVOKABLE void move(int from, int to);
Q_INVOKABLE void clear();
[[nodiscard]] ChatSession* sessionById(const QString& id);
[[nodiscard]] LlmClient* llmClient() const { return m_llmClient; }
void setLlmClient(LlmClient* client);
void persist(ChatSession* session);
void saveMeta(ChatSession* session);
void loadMessagesInto(ChatSession* session);
@@ -40,6 +43,7 @@ class ChatStore : public QObject {
Q_SIGNALS:
void countChanged();
void valuesChanged();
void sessionRemoved(ZShell::llm::ChatSession* session);
private:
void openDb();
@@ -50,11 +54,10 @@ class ChatStore : public QObject {
void notify(const QList<ChatSession*>& before);
QList<ChatSession*> m_sessions;
LlmClient* m_llmClient = nullptr;
QString m_connectionName;
[[nodiscard]] QSqlDatabase db() const;
friend class Chat;
};
} // namespace ZShell
} // namespace ZShell::llm