feat: clear chat tag by keyboard shortcut (#946)

* Added a keyboard shortcut to remove tags from an active chat

* Replace Main.immediate dispatcher to EdtDispatcher

---------

Co-authored-by: alexander.korovin <alexander.korovin@vk.team>
This commit is contained in:
Violine 2025-03-27 14:13:17 +03:00 committed by Carl-Robert Linnupuu
parent c7308a4512
commit c41f2fd2e9
5 changed files with 31 additions and 2 deletions

View file

@ -0,0 +1,14 @@
package ee.carlrobert.codegpt.actions.toolwindow
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowContentManager
class ClearChatTagsAction : AnAction() {
override fun actionPerformed(event: AnActionEvent) {
val project: Project = event.project ?: return
project.getService(ChatToolWindowContentManager::class.java).clearAllTags()
}
}

View file

@ -138,4 +138,8 @@ public final class ChatToolWindowContentManager {
.filter(content -> "Chat".equals(content.getTabName()))
.findFirst();
}
}
public void clearAllTags() {
tryFindActiveChatTabPanel().ifPresent(ChatToolWindowTabPanel::clearAllTags);
}
}

View file

@ -244,6 +244,10 @@ public class ChatToolWindowTabPanel implements Disposable {
});
}
public void clearAllTags() {
tagManager.clear();
}
public void includeFiles(List<VirtualFile> referencedFiles) {
userInputPanel.includeFiles(referencedFiles);
totalTokensPanel.updateReferencedFilesTokens(

View file

@ -5,7 +5,7 @@ import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
internal class DisposableCoroutineScope(
scopeDispatcher: CoroutineDispatcher = Dispatchers.Main.immediate
scopeDispatcher: CoroutineDispatcher = EdtDispatchers.Default
) : Disposable, CoroutineScope {
private val coroutineScope = CoroutineScope(SupervisorJob() + scopeDispatcher)

View file

@ -129,6 +129,13 @@
description="Creates a new chat session">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt shift N" replace-all="true"/>
</action>
<action
id="CodeGPT.ClearTags"
class="ee.carlrobert.codegpt.actions.toolwindow.ClearChatTagsAction"
text="Clear Tags"
description="Clear all files tags in active chat">
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt shift T" replace-all="true"/>
</action>
<action
id="CodeGPT.ContextMenuEditCodeAction"
text="Edit Code"