diff --git a/src/main/kotlin/ai/devchat/devchat/handler/SendMessageRequestHandler.kt b/src/main/kotlin/ai/devchat/devchat/handler/SendMessageRequestHandler.kt index 39d7938..a40ce23 100644 --- a/src/main/kotlin/ai/devchat/devchat/handler/SendMessageRequestHandler.kt +++ b/src/main/kotlin/ai/devchat/devchat/handler/SendMessageRequestHandler.kt @@ -4,6 +4,7 @@ import ai.devchat.cli.DevChatResponse import ai.devchat.common.Log import ai.devchat.devchat.BaseActionHandler import ai.devchat.devchat.DevChatActions +import ai.devchat.idea.storage.ActiveConversation import com.alibaba.fastjson.JSONObject import java.io.File import java.io.FileWriter @@ -53,6 +54,14 @@ class SendMessageRequestHandler(metadata: JSONObject?, payload: JSONObject?) : B response.update(line) promptCallback(response) } + val currentTopic = ActiveConversation.topic ?: response.promptHash!! + val newMessage = wrapper.logTopic(currentTopic, 1).getJSONObject(0) + + if (currentTopic == ActiveConversation.topic) { + ActiveConversation.addMessage(newMessage) + } else { + ActiveConversation.reset(currentTopic, listOf(newMessage)) + } } override fun except(exception: Exception) {