Skip to content

Commit 2b0132f

Browse files
authored
Merge pull request #203 from TerminalFi/impl/debugChatCommands
Impl/debug chat commands
2 parents a607739 + 5445a8f commit 2b0132f

File tree

4 files changed

+65
-26
lines changed

4 files changed

+65
-26
lines changed

Main.sublime-commands

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,9 @@
128128
{
129129
"caption": "Copilot: Send Any Request",
130130
"command": "copilot_send_any_request"
131+
},
132+
{
133+
"caption": "Copilot: Debug Chat Commands",
134+
"command": "copilot_conversation_debug"
131135
}
132136
]

plugin/__init__.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CopilotConversationChatShimCommand,
1515
CopilotConversationCloseCommand,
1616
CopilotConversationCopyCodeCommand,
17+
CopilotConversationDebugCommand,
1718
CopilotConversationDestroyCommand,
1819
CopilotConversationDestroyShimCommand,
1920
CopilotConversationInsertCodeCommand,
@@ -50,35 +51,36 @@
5051
"CopilotAcceptPanelCompletionCommand",
5152
"CopilotAcceptPanelCompletionShimCommand",
5253
"CopilotAskCompletionsCommand",
53-
"CopilotCheckStatusCommand",
5454
"CopilotCheckFileStatusCommand",
55+
"CopilotCheckStatusCommand",
5556
"CopilotClosePanelCompletionCommand",
57+
"CopilotConversationAgentsCommand",
58+
"CopilotConversationChatCommand",
59+
"CopilotConversationChatShimCommand",
60+
"CopilotConversationCloseCommand",
61+
"CopilotConversationCopyCodeCommand",
62+
"CopilotConversationDebugCommand",
63+
"CopilotConversationDestroyCommand",
64+
"CopilotConversationDestroyShimCommand",
65+
"CopilotConversationInsertCodeCommand",
66+
"CopilotConversationInsertCodeShimCommand",
67+
"CopilotConversationRatingCommand",
68+
"CopilotConversationRatingShimCommand",
69+
"CopilotConversationTemplatesCommand",
70+
"CopilotConversationToggleReferencesBlockCommand",
71+
"CopilotConversationTurnDeleteCommand",
72+
"CopilotConversationTurnDeleteShimCommand",
5673
"CopilotGetPanelCompletionsCommand",
57-
"CopilotGetVersionCommand",
5874
"CopilotGetPromptCommand",
75+
"CopilotGetVersionCommand",
5976
"CopilotNextCompletionCommand",
6077
"CopilotPreviousCompletionCommand",
6178
"CopilotRejectCompletionCommand",
79+
"CopilotSendAnyRequestCommand",
6280
"CopilotSignInCommand",
6381
"CopilotSignInWithGithubTokenCommand",
6482
"CopilotSignOutCommand",
65-
"CopilotConversationToggleReferencesBlockCommand",
6683
"CopilotToggleConversationChatCommand",
67-
"CopilotConversationChatShimCommand",
68-
"CopilotConversationChatCommand",
69-
"CopilotConversationCloseCommand",
70-
"CopilotConversationDestroyShimCommand",
71-
"CopilotConversationDestroyCommand",
72-
"CopilotConversationAgentsCommand",
73-
"CopilotConversationTemplatesCommand",
74-
"CopilotConversationTurnDeleteCommand",
75-
"CopilotConversationTurnDeleteShimCommand",
76-
"CopilotConversationRatingShimCommand",
77-
"CopilotConversationRatingCommand",
78-
"CopilotConversationCopyCodeCommand",
79-
"CopilotConversationInsertCodeShimCommand",
80-
"CopilotConversationInsertCodeCommand",
81-
"CopilotSendAnyRequestCommand",
8284
# ST: helper commands
8385
"CopilotPrepareAndEditSettingsCommand",
8486
# ST: event listeners

plugin/commands.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import Callable
88
from functools import partial, wraps
99
from pathlib import Path
10-
from typing import Any, Literal, cast
10+
from typing import Any, Literal, Sequence, cast
1111

1212
import sublime
1313
import sublime_plugin
@@ -49,6 +49,7 @@
4949
preprocess_message_for_html,
5050
)
5151
from .types import (
52+
CopilotConversationDebugTemplates,
5253
CopilotPayloadConversationCreate,
5354
CopilotPayloadConversationPreconditions,
5455
CopilotPayloadConversationTemplate,
@@ -866,6 +867,24 @@ def _on_result_sign_out(self, payload: CopilotPayloadSignOut) -> None:
866867
GithubInfo.clear_avatar()
867868

868869

870+
class CopilotConversationDebugCommand(CopilotTextCommand):
871+
@_provide_plugin_session()
872+
def run(self, plugin: CopilotPlugin, session: Session, _: sublime.Edit) -> None:
873+
if not (window := self.view.window()):
874+
return
875+
876+
templates = tuple(CopilotConversationDebugTemplates)
877+
window.show_quick_panel(
878+
[[template.name, template.value] for template in templates],
879+
lambda index: self._on_selected(index, templates),
880+
)
881+
882+
def _on_selected(self, index: int, templates: Sequence[CopilotConversationDebugTemplates]) -> None:
883+
if index == -1:
884+
return
885+
self.view.run_command("copilot_conversation_chat", {"message": f"{templates[index].value}"})
886+
887+
869888
class CopilotSendAnyRequestCommand(CopilotTextCommand):
870889
@_provide_plugin_session()
871890
def run(self, plugin: CopilotPlugin, session: Session, _: sublime.Edit, request_type: str, payload: str) -> None:

plugin/types.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,7 @@ class CopilotPayloadPanelCompletionSolutionCount(TypedDict, total=True):
162162
# --------------------- #
163163

164164

165-
class CopilotConversationTemplates(StrEnum):
166-
FIX = "/fix"
167-
TESTS = "/tests"
168-
DOC = "/doc"
169-
EXPLAIN = "/explain"
170-
SIMPLIFY = "/simplify"
171-
165+
class CopilotStrEnum(StrEnum):
172166
@classmethod
173167
def has_value(cls, value: str) -> bool:
174168
try:
@@ -178,6 +172,26 @@ def has_value(cls, value: str) -> bool:
178172
return False
179173

180174

175+
class CopilotConversationTemplates(CopilotStrEnum):
176+
FIX = "/fix"
177+
TESTS = "/tests"
178+
DOC = "/doc"
179+
EXPLAIN = "/explain"
180+
SIMPLIFY = "/simplify"
181+
182+
183+
class CopilotConversationDebugTemplates(CopilotStrEnum):
184+
FAIL = "/debug.fail"
185+
FILTER = "/debug.filter"
186+
DUMP = "/debug.dump"
187+
TREE = "/debug.tree"
188+
ECHO = "/debug.echo"
189+
PROMPT = "/debug.prompt"
190+
SKILLS = "/debug.skills"
191+
VULNERABILITY = "/debug.vulnerability"
192+
MARKDOWN = "/debug.markdown"
193+
194+
181195
class CopilotPayloadConversationEntry(TypedDict, total=True):
182196
kind: str
183197
conversationId: str

0 commit comments

Comments
 (0)