Skip to content

Commit 2dc6a78

Browse files
committed
Manage history message cache
1 parent 4af88a2 commit 2dc6a78

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/main/kotlin/ai/devchat/devchat/handler/SendMessageRequestHandler.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import ai.devchat.cli.DevChatResponse
44
import ai.devchat.common.Log
55
import ai.devchat.devchat.BaseActionHandler
66
import ai.devchat.devchat.DevChatActions
7+
import ai.devchat.idea.storage.ActiveConversation
78
import com.alibaba.fastjson.JSONObject
89
import java.io.File
910
import java.io.FileWriter
@@ -53,6 +54,14 @@ class SendMessageRequestHandler(metadata: JSONObject?, payload: JSONObject?) : B
5354
response.update(line)
5455
promptCallback(response)
5556
}
57+
val currentTopic = ActiveConversation.topic ?: response.promptHash!!
58+
val newMessage = wrapper.logTopic(currentTopic, 1).getJSONObject(0)
59+
60+
if (currentTopic == ActiveConversation.topic) {
61+
ActiveConversation.addMessage(newMessage)
62+
} else {
63+
ActiveConversation.reset(currentTopic, listOf(newMessage))
64+
}
5665
}
5766

5867
override fun except(exception: Exception) {

0 commit comments

Comments
 (0)