Skip to content

Commit 247a8ad

Browse files
committed
feat(chat): add removeLastMessage function to clear chat history #51
This commit introduces a new function `removeLastMessage` to the `ChatCodingPanel` class, which allows clearing the chat history by removing the last message from the component list. The function is guarded by a condition to ensure that the list is not empty before attempting to remove the last message. After removal, the UI is updated to reflect the change.
1 parent ddaa4e2 commit 247a8ad

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main/kotlin/cc/unitmesh/devti/counit/CustomAgentChatProcessor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class CustomAgentChatProcessor(val project: Project) {
5959
sb.append(it)
6060
}
6161
}
62+
ui.removeLastMessage()
6263
ui.setInput(sb.toString())
6364
ui.hiddenProgressBar()
6465
}

src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,12 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
254254
fun hiddenProgressBar() {
255255
progressBar.isVisible = false
256256
}
257+
258+
fun removeLastMessage() {
259+
if (myList.componentCount > 0) {
260+
myList.remove(myList.componentCount - 1)
261+
}
262+
263+
updateUI()
264+
}
257265
}

0 commit comments

Comments
 (0)