Skip to content

Commit

Permalink
feat(chat): add removeLastMessage function to clear chat history #51
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phodal committed Mar 6, 2024
1 parent ddaa4e2 commit 247a8ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -59,6 +59,7 @@ class CustomAgentChatProcessor(val project: Project) {
sb.append(it)
}
}
ui.removeLastMessage()
ui.setInput(sb.toString())
ui.hiddenProgressBar()
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt
Expand Up @@ -254,4 +254,12 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
fun hiddenProgressBar() {
progressBar.isVisible = false
}

fun removeLastMessage() {
if (myList.componentCount > 0) {
myList.remove(myList.componentCount - 1)
}

updateUI()
}
}

0 comments on commit 247a8ad

Please sign in to comment.