Skip to content

Commit

Permalink
fix(vcs): fix CommitMessageSuggestionAction not updating editorField …
Browse files Browse the repository at this point in the history
…text

The CommitMessageSuggestionAction was not updating the editorField text when receiving new messages. This was fixed by using the invokeLater function to run the stream collection in the UI thread.
  • Loading branch information
phodal committed Jan 9, 2024
1 parent 8d6932e commit ef6c680
Showing 1 changed file with 6 additions and 3 deletions.
Expand Up @@ -5,6 +5,7 @@ import cc.unitmesh.devti.gui.chat.ChatActionType
import cc.unitmesh.devti.llms.LlmFactory
import cc.unitmesh.devti.prompting.VcsPrompting
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.components.service
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.vcs.VcsDataKeys
Expand Down Expand Up @@ -48,9 +49,11 @@ class CommitMessageSuggestionAction : ChatBaseAction() {

val stream = LlmFactory().create(project).stream(prompt, "", false)

runBlocking {
stream.cancellable().collect {
commitMessageUi.editorField.text += it
invokeLater {
runBlocking {
stream.cancellable().collect {
commitMessageUi.editorField.text += it
}
}
}
}
Expand Down

0 comments on commit ef6c680

Please sign in to comment.