Skip to content

Commit

Permalink
prevent submission of message if waiting on response
Browse files Browse the repository at this point in the history
  • Loading branch information
TerminalFi committed Jul 3, 2024
1 parent 491b24b commit 02835a2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
3 changes: 3 additions & 0 deletions plugin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ def on_server_notification_async(self, notification) -> None:
return

conversation_manager = WindowConversationManager(window)
if params.get("kind", None) == "end":
conversation_manager.is_waiting = False

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

Expand Down
7 changes: 6 additions & 1 deletion plugin/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def _on_prompt(self, plugin: CopilotPlugin, session: Session, msg: str):
import uuid

manager = WindowConversationManager(window)
if manager.is_waiting:
manager.prompt(callback=lambda x: self._on_prompt(plugin, session, x), initial_text=msg)
return

template = load_string_template(msg)
sel = []
if not (view := find_view_by_id(manager.last_active_view_id)):
Expand Down Expand Up @@ -288,7 +292,7 @@ def _on_prompt(self, plugin: CopilotPlugin, session: Session, msg: str):
{
"conversationId": manager.conversation_id,
"message": msg,
"workDoneToken": f"copilot_chat://{manager.window.id()}", # Not sure where this comes from
"workDoneToken": f"copilot_chat://{manager.window.id()}",
"doc": request["doc"],
"computeSuggestions": True,
"references": [],
Expand All @@ -297,6 +301,7 @@ def _on_prompt(self, plugin: CopilotPlugin, session: Session, msg: str):
),
manager.prompt(callback=lambda x: self._on_prompt(plugin, session, x)),
)
manager.is_waiting = True
manager.update()


Expand Down
11 changes: 0 additions & 11 deletions plugin/ui/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ class WindowConversationManager:
# window settings #
# ------------- #

@property
def is_visible(self) -> bool:
"""Whether the panel completions is visible."""
return get_copilot_setting(
self.window, COPILOT_WINDOW_CONVERSATION_SETTINGS_PREFIX, "is_visible_conversation", False
)

@is_visible.setter
def is_visible(self, value: bool) -> None:
set_copilot_setting(self.window, COPILOT_WINDOW_CONVERSATION_SETTINGS_PREFIX, "is_visible_conversation", value)

@property
def group_id(self) -> int:
"""The ID of the group which is used to show panel completions."""
Expand Down

0 comments on commit 02835a2

Please sign in to comment.