Skip to content

Commit 721606f

Browse files
committed
refactor: tidy codes
Signed-off-by: Jack Cherng <[email protected]>
1 parent f8a6f21 commit 721606f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

plugin/commands.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
REQ_CONVERSATION_TURN,
3131
REQ_CONVERSATION_TURN_DELETE,
3232
REQ_COPILOT_MODELS,
33+
REQ_COPILOT_SET_MODEL_POLICY,
3334
REQ_FILE_CHECK_STATUS,
3435
REQ_GET_PANEL_COMPLETIONS,
3536
REQ_GET_PROMPT,
3637
REQ_GET_VERSION,
3738
REQ_NOTIFY_ACCEPTED,
3839
REQ_NOTIFY_REJECTED,
39-
REQ_SET_MODEL_POLICY,
4040
REQ_SIGN_IN_CONFIRM,
4141
REQ_SIGN_IN_INITIATE,
4242
REQ_SIGN_IN_WITH_GITHUB_TOKEN,
@@ -600,15 +600,23 @@ def _on_result_copilot_models(self, payload: list[CopilotModel]) -> None:
600600
if not (window := self.view.window()):
601601
return
602602
window.show_quick_panel(
603-
[[item["modelFamily"], item["modelName"], ", ".join(item["scopes"])] for item in payload], lambda _: None
603+
[
604+
sublime.QuickPanelItem(
605+
trigger=item["modelFamily"],
606+
details=item["modelName"],
607+
annotation=", ".join(item["scopes"]),
608+
)
609+
for item in payload
610+
],
611+
lambda _: None, # @todo implement model switching callback
604612
)
605613

606614

607615
class CopilotSetModelPolicyCommand(CopilotTextCommand):
608616
@_provide_plugin_session()
609617
def run(self, plugin: CopilotPlugin, session: Session, _: sublime.Edit, model_name: str, enabled: str) -> None:
610618
session.send_request(
611-
Request(REQ_SET_MODEL_POLICY, {"modelFamily": model_name, "enabled": enabled}),
619+
Request(REQ_COPILOT_SET_MODEL_POLICY, {"modelFamily": model_name, "enabled": enabled}),
612620
lambda _: None,
613621
)
614622

plugin/constants.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
# ---------------- #
1919

2020
REQ_CHECK_STATUS = "checkStatus"
21+
REQ_COPILOT_MODELS = "copilot/models"
22+
REQ_COPILOT_SET_MODEL_POLICY = "copilot/setModelPolicy"
2123
REQ_FILE_CHECK_STATUS = "checkFileStatus"
2224
REQ_GET_COMPLETIONS = "getCompletions"
2325
REQ_GET_COMPLETIONS_CYCLING = "getCompletionsCycling"
24-
REQ_GET_PROMPT = "getPrompt"
2526
REQ_GET_PANEL_COMPLETIONS = "getPanelCompletions"
27+
REQ_GET_PROMPT = "getPrompt"
2628
REQ_GET_VERSION = "getVersion"
29+
REQ_GIT_COMMIT_GENERATE = "git/commitGenerate"
2730
REQ_NOTIFY_ACCEPTED = "notifyAccepted"
2831
REQ_NOTIFY_REJECTED = "notifyRejected"
2932
REQ_NOTIFY_SHOWN = "notifyShown"
@@ -33,9 +36,6 @@
3336
REQ_SIGN_IN_INITIATE = "signInInitiate"
3437
REQ_SIGN_IN_WITH_GITHUB_TOKEN = "signInWithGithubToken"
3538
REQ_SIGN_OUT = "signOut"
36-
REQ_COPILOT_MODELS = "copilot/models"
37-
REQ_SET_MODEL_POLICY = "copilot/setModelPolicy"
38-
REQ_GIT_COMMIT_GENERATE = "git/commitGenerate"
3939

4040
# --------------------- #
4141
# Copilot chat requests #

0 commit comments

Comments
 (0)