Skip to content

Commit db38ea2

Browse files
committed
Close editor when a conversation is deleted
Added a connection to ChatManager::conversationDeleted in ChatEditor. When a conversation is deleted, the handler opens a temporary editor for the conversation ID (using EditorManager::openEditorWithContents with flags that keep it hidden) and immediately closes it with EditorManager::closeEditors. This forces the editor manager to clean up any open editors that were referencing the deleted conversation.
1 parent a9c716f commit db38ea2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llamachateditor.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ ChatEditor::ChatEditor()
126126
m_document->setPreferredDisplayName(chat.conv.name);
127127
EditorManager::instance()->updateWindowTitles();
128128
});
129+
connect(&ChatManager::instance(),
130+
&ChatManager::conversationDeleted,
131+
this,
132+
[this](const QString &convId) {
133+
QString name;
134+
IEditor *ed = EditorManager::openEditorWithContents(
135+
Constants::LLAMACPP_VIEWER_ID,
136+
&name,
137+
convId.toUtf8(),
138+
convId,
139+
EditorManager::DoNotMakeVisible | EditorManager::DoNotSwitchToEditMode
140+
| EditorManager::DoNotChangeCurrentEditor);
141+
142+
EditorManager::closeEditors({ed}, false);
143+
});
129144
connect(&ChatManager::instance(),
130145
&ChatManager::followUpQuestionsReceived,
131146
this,

0 commit comments

Comments
 (0)