-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d13b02a
commit 82301b5
Showing
8 changed files
with
150 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from __future__ import annotations | ||
|
||
from .chat import ViewConversationManager | ||
from .completion import ViewCompletionManager | ||
from .panel_completion import ViewPanelCompletionManager | ||
|
||
__all__ = ( | ||
"ViewCompletionManager", | ||
"ViewConversationManager", | ||
"ViewPanelCompletionManager", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
from __future__ import annotations | ||
|
||
import sublime | ||
|
||
from ..types import CopilotPayloadConversationEntry | ||
from ..utils import ( | ||
get_copilot_view_setting, | ||
set_copilot_view_setting, | ||
) | ||
|
||
|
||
class ViewConversationManager: | ||
# ------------- # | ||
# view settings # | ||
# ------------- # | ||
|
||
@property | ||
def is_visible(self) -> bool: | ||
"""Whether the panel completions is visible.""" | ||
return get_copilot_view_setting(self.view, "is_visible_conversation", False) | ||
|
||
@is_visible.setter | ||
def is_visible(self, value: bool) -> None: | ||
set_copilot_view_setting(self.view, "is_visible_conversation", value) | ||
|
||
@property | ||
def conversation_id(self) -> str: | ||
"""Whether the panel completions is visible.""" | ||
return get_copilot_view_setting(self.view, "conversation_id", "") | ||
|
||
@conversation_id.setter | ||
def conversation_id(self, value: str) -> None: | ||
set_copilot_view_setting(self.view, "conversation_id", value) | ||
|
||
@property | ||
def is_waiting(self) -> bool: | ||
"""Whether the converation completions is streaming.""" | ||
return get_copilot_view_setting(self.view, "is_waiting_conversation", False) | ||
|
||
@is_waiting.setter | ||
def is_waiting(self, value: bool) -> None: | ||
set_copilot_view_setting(self.view, "is_waiting_conversation", value) | ||
|
||
@property | ||
def completions(self) -> list[CopilotPayloadConversationEntry]: | ||
"""All `completions` in the view. Note that this is a copy.""" | ||
return get_copilot_view_setting(self.view, "conversation_entries", []) | ||
|
||
@completions.setter | ||
def completions(self, value: list[CopilotPayloadConversationEntry]) -> None: | ||
set_copilot_view_setting(self.view, "conversation_entries", value) | ||
|
||
# -------------- # | ||
# normal methods # | ||
# -------------- # | ||
|
||
def __init__(self, view: sublime.View) -> None: | ||
self.view = view | ||
self.conversation_history = [] | ||
|
||
def reset(self) -> None: | ||
self.is_waiting = False | ||
self.is_visible = False | ||
|
||
def append_conversation_entry(self, entry: CopilotPayloadConversationEntry) -> None: | ||
conversation_history = self.conversation_history | ||
conversation_history.append(entry) | ||
self.conversation_history = conversation_history |