Skip to content

Commit d36f37b

Browse files
Violinealexander.korovin
and
alexander.korovin
authored
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>
1 parent 3983b39 commit d36f37b

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ee.carlrobert.codegpt.actions.toolwindow
2+
3+
import com.intellij.openapi.actionSystem.AnAction
4+
import com.intellij.openapi.actionSystem.AnActionEvent
5+
import com.intellij.openapi.project.Project
6+
import ee.carlrobert.codegpt.toolwindow.chat.ChatToolWindowContentManager
7+
8+
class ClearChatTagsAction : AnAction() {
9+
10+
override fun actionPerformed(event: AnActionEvent) {
11+
val project: Project = event.project ?: return
12+
project.getService(ChatToolWindowContentManager::class.java).clearAllTags()
13+
}
14+
}

src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ChatToolWindowContentManager.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,8 @@ private Optional<Content> tryFindFirstChatTabContent() {
138138
.filter(content -> "Chat".equals(content.getTabName()))
139139
.findFirst();
140140
}
141-
}
141+
142+
public void clearAllTags() {
143+
tryFindActiveChatTabPanel().ifPresent(ChatToolWindowTabPanel::clearAllTags);
144+
}
145+
}

src/main/java/ee/carlrobert/codegpt/toolwindow/chat/ChatToolWindowTabPanel.java

+4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ public void sendMessage(
244244
});
245245
}
246246

247+
public void clearAllTags() {
248+
tagManager.clear();
249+
}
250+
247251
public void includeFiles(List<VirtualFile> referencedFiles) {
248252
userInputPanel.includeFiles(referencedFiles);
249253
totalTokensPanel.updateReferencedFilesTokens(

src/main/kotlin/ee/carlrobert/codegpt/util/coroutines/DisposableCoroutineScope.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import kotlinx.coroutines.*
55
import kotlin.coroutines.CoroutineContext
66

77
internal class DisposableCoroutineScope(
8-
scopeDispatcher: CoroutineDispatcher = Dispatchers.Main.immediate
8+
scopeDispatcher: CoroutineDispatcher = EdtDispatchers.Default
99
) : Disposable, CoroutineScope {
1010

1111
private val coroutineScope = CoroutineScope(SupervisorJob() + scopeDispatcher)

src/main/resources/META-INF/plugin.xml

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@
141141
description="Creates a new chat session">
142142
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt shift N" replace-all="true"/>
143143
</action>
144+
<action
145+
id="CodeGPT.ClearTags"
146+
class="ee.carlrobert.codegpt.actions.toolwindow.ClearChatTagsAction"
147+
text="Clear Tags"
148+
description="Clear all files tags in active chat">
149+
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt shift T" replace-all="true"/>
150+
</action>
144151
<action
145152
id="CodeGPT.ContextMenuEditCodeAction"
146153
text="Edit Code"

0 commit comments

Comments
 (0)