Skip to content

Commit 2230aee

Browse files
committed
Fix ChatEditor message refresh logic
- Removed duplicate call to `ChatManager::instance().getViewingChat()`. - Updated logic so that `refreshMessages()` is only invoked when the loaded conversation contains more than one message (a new conversation has a single root node). - Simplified the `convId` handling; the empty‑check was unnecessary because the editor is only opened with a valid ID. - Added a comment explaining the one‑root‑message rule for new conversations.
1 parent b156b0d commit 2230aee

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

llamachateditor.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,17 @@ ChatEditor::ChatEditor()
143143
[this](Core::IEditor *editor) {
144144
if (editor == this) {
145145
const QString convId = QString::fromUtf8(m_document->contents());
146-
if (!convId.isEmpty()) {
147-
auto chat = ChatManager::instance().getViewingChat(convId);
146+
ViewingChat chat = ChatManager::instance().getViewingChat(convId);
147+
148+
// A new conversation has one root message
149+
if (chat.messages.size() > 1) {
148150
refreshMessages(chat.messages, chat.conv.currNode);
149151
} else {
150152
ChatManager::instance().refreshServerProps();
151153
}
152-
ChatManager::instance().setCurrentConversation(convId);
153154

154-
ViewingChat chat = ChatManager::instance().getViewingChat(convId);
155-
if (chat.conv.name.isEmpty())
156-
m_document->setPreferredDisplayName(Tr::tr("llama.cpp coversation"));
157-
else
158-
m_document->setPreferredDisplayName(chat.conv.name);
155+
ChatManager::instance().setCurrentConversation(convId);
156+
m_document->setPreferredDisplayName(chat.conv.name);
159157

160158
EditorManager::instance()->updateWindowTitles();
161159

0 commit comments

Comments
 (0)