File tree Expand file tree Collapse file tree
src/main/kotlin/ai/devchat/devchat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ class ActionHandlerFactory {
1313 put(DevChatActions .SET_OR_UPDATE_KEY_REQUEST , SetOrUpdateKeyRequestHandler ::class )
1414 put(DevChatActions .LIST_COMMANDS_REQUEST , ListCommandsRequestHandler ::class )
1515 put(DevChatActions .LOAD_CONVERSATIONS_REQUEST , LoadConversationRequestHandler ::class )
16+ put(DevChatActions .LOAD_HISTORY_MESSAGES_REQUEST , LoadHistoryMessagesRequestHandler ::class )
1617 put(DevChatActions .LIST_TOPICS_REQUEST , ListTopicsRequestHandler ::class )
1718 put(DevChatActions .INSERT_CODE_REQUEST , InsertCodeRequestHandler ::class )
1819 put(DevChatActions .REPLACE_FILE_CONTENT_REQUEST , ReplaceFileContentHandler ::class )
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ object DevChatActions {
1414 const val LOAD_CONVERSATIONS_RESPONSE = " loadConversations/response"
1515 const val LOAD_HISTORY_MESSAGES_REQUEST = " loadHistoryMessages/request"
1616 const val LOAD_HISTORY_MESSAGES_RESPONSE = " loadHistoryMessages/response"
17- const val LIST_CONVERSATIONS_RESPONSE = " listConversations/response"
1817 const val LIST_TOPICS_REQUEST = " listTopics/request"
1918 const val LIST_TOPICS_RESPONSE = " listTopics/response"
2019 const val INSERT_CODE_REQUEST = " insertCode/request"
Original file line number Diff line number Diff line change 1+ package ai.devchat.devchat.handler
2+
3+ import ai.devchat.common.Log
4+ import ai.devchat.devchat.ActionHandler
5+ import ai.devchat.devchat.DevChatActionHandler
6+ import ai.devchat.devchat.DevChatActions
7+ import ai.devchat.idea.setting.DevChatSettingsState
8+ import ai.devchat.idea.storage.ActiveConversation
9+ import com.alibaba.fastjson.JSONObject
10+
11+ class LoadHistoryMessagesRequestHandler (private val handler : DevChatActionHandler ) : ActionHandler {
12+ private var metadata: JSONObject ? = null
13+ private var payload: JSONObject ? = null
14+
15+ private fun action (res : JSONObject ) {
16+ val pageSize = DevChatSettingsState .instance.maxLogCount
17+ val pageIndex = metadata!! .getInteger(" pageIndex" ) ? : 1
18+ res[" messages" ] = ActiveConversation .getMessages(pageIndex, pageSize)
19+ }
20+
21+ override fun executeAction () {
22+ handler.handle(
23+ DevChatActions .LOAD_HISTORY_MESSAGES_RESPONSE ,
24+ metadata!! .getString(" callback" ),
25+ ::action
26+ )
27+ }
28+
29+ override fun setMetadata (metadata : JSONObject ) {
30+ this .metadata = metadata
31+ }
32+
33+ override fun setPayload (payload : JSONObject ) {
34+ this .payload = payload
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments