async parsing + tex caching

This commit is contained in:
2026-08-26 02:06:10 +02:00
parent e18875a752
commit 3946541f87
32 changed files with 2730 additions and 489 deletions
+32 -4
View File
@@ -94,8 +94,8 @@ LlmClient* ChatSession::client() const {
}
void ChatSession::ensureLoaded() {
if (m_loaded) return;
m_loaded = true;
if (m_loadRequested) return;
m_loadRequested = true;
if (auto* store = qobject_cast<ChatStore*>(parent()))
store->loadMessagesInto(this);
}
@@ -105,6 +105,18 @@ ChatMessageModel* ChatSession::messagesModel() {
return m_model;
}
void ChatSession::markLoaded() {
if (m_loaded) return;
m_loaded = true;
Q_EMIT loaded();
}
bool ChatSession::takeClearPending() {
const bool pending = m_clearPending;
m_clearPending = false;
return pending;
}
void ChatSession::adoptMessages(QList<ChatMessage*> messages) {
m_model->loadMessages(std::move(messages));
}
@@ -127,9 +139,20 @@ void ChatSession::clearMessages() {
}
void ChatSession::startGeneration(ChatMessage* target) {
if (auto* generation = target->activeGeneration()) {
if (auto* clientObject = client())
auto* generation = target->activeGeneration();
auto* clientObject = client();
if (generation && clientObject) {
if (isLoaded()) {
clientObject->startGeneration(this, generation);
} else {
// The store load is still in flight; the request needs the
// full history, so start once it lands.
connect(
this, &ChatSession::loaded, clientObject,
[this, generation, clientObject]() {
clientObject->startGeneration(this, generation);
});
}
}
persist();
}
@@ -209,6 +232,11 @@ void ChatSession::clear() {
return;
}
}
if (!isLoaded()) {
// The load lands shortly; drop everything once it does.
m_clearPending = true;
return;
}
m_model->clear();
persist();
}