From a1d9262dd11bffd4a12b62ba6e8171d7ca75728a Mon Sep 17 00:00:00 2001 From: Jakub Blach Date: Thu, 1 Feb 2024 14:09:46 +0100 Subject: [PATCH] Fix `TreeUI should be accessed only from EDT` exception --- .../sourcegraph/cody/commands/ui/CommandsContextMenu.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/sourcegraph/cody/commands/ui/CommandsContextMenu.kt b/src/main/kotlin/com/sourcegraph/cody/commands/ui/CommandsContextMenu.kt index a0b657a6d8..06d8bf5f1b 100644 --- a/src/main/kotlin/com/sourcegraph/cody/commands/ui/CommandsContextMenu.kt +++ b/src/main/kotlin/com/sourcegraph/cody/commands/ui/CommandsContextMenu.kt @@ -3,6 +3,7 @@ package com.sourcegraph.cody.commands.ui import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.DefaultActionGroup +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.DumbAwareAction import com.intellij.openapi.project.Project @@ -33,8 +34,10 @@ class CommandsContextMenu { CodyEditorFactoryListener.Util.informAgentAboutEditorChange( it, hasFileChanged = false) { CodyToolWindowContent.executeOnInstanceIfNotDisposed(project) { - switchToChatSession( - AgentChatSession.createFromCommand(project, commandId)) + ApplicationManager.getApplication().invokeLater { + switchToChatSession( + AgentChatSession.createFromCommand(project, commandId)) + } } } }