Skip to content

Commit

Permalink
refactor: tidy codes
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Aug 17, 2024
1 parent 6194c4b commit 412ba96
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions plugin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,26 +320,27 @@ def update_status_bar_text(self, extra_variables: dict[str, Any] | None = None)

def on_server_notification_async(self, notification: Notification) -> None:
if notification.method == "$/progress":
if (token := notification.params["token"]) and token.startswith("copilot_chat://"):
if params := notification.params["value"]:
if not (window := WindowConversationManager.find_window_by_token_id(token)):
return

wcm = WindowConversationManager(window)
if params.get("kind", None) == "end":
wcm.is_waiting = False
if (
(token := notification.params["token"])
and token.startswith("copilot_chat://")
and (params := notification.params["value"])
and (window := WindowConversationManager.find_window_by_token_id(token))
):
wcm = WindowConversationManager(window)
if params.get("kind", None) == "end":
wcm.is_waiting = False

if suggest_title := params.get("suggestedTitle", None):
wcm.suggested_title = suggest_title
if suggest_title := params.get("suggestedTitle", None):
wcm.suggested_title = suggest_title

if params.get("reply", None):
wcm.append_conversation_entry(params)
if params.get("reply", None):
wcm.append_conversation_entry(params)

if followup := params.get("followUp", None):
message = followup.get("message", "")
wcm.follow_up = message
if followup := params.get("followUp", None):
message = followup.get("message", "")
wcm.follow_up = message

wcm.update()
wcm.update()

@notification_handler(NTFY_FEATURE_FLAGS_NOTIFICATION)
def _handle_feature_flags_notification(self, payload: CopilotPayloadFeatureFlagsNotification) -> None:
Expand Down

0 comments on commit 412ba96

Please sign in to comment.