From e478fc2d1f0e4f9fd5cb3d88a2b0efe0b8c04bd8 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Tue, 20 Jun 2023 21:51:38 -0700
Subject: function calling! many changes here

---
 extension/react-app/src/tabs/gui.tsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index f0e3ffd4..24529967 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -426,9 +426,9 @@ function GUI(props: GUIProps) {
         }}
         hidden={!showDataSharingInfo}
       >
-        By turning on this switch, you signal that you would 
-        contribute this software development data to a publicly 
-        accessible, open-source dataset in the future.
+        By turning on this switch, you signal that you would contribute this
+        software development data to a publicly accessible, open-source dataset
+        in the future.
         <br />
         <br />
         <b>
@@ -485,6 +485,8 @@ function GUI(props: GUIProps) {
         <HeaderButtonWithText
           onClick={() => {
             client?.sendClear();
+            // Reload the window to get completely fresh session
+            window.location.reload();
           }}
           text="Clear All"
         >
-- 
cgit v1.2.3-70-g09d2


From 2dd87605a05236c1dd10389883766f4c51207d56 Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Wed, 21 Jun 2023 15:25:49 -0700
Subject: initial ideas

---
 continuedev/src/continuedev/core/autopilot.py           | 4 ++++
 continuedev/src/continuedev/server/gui.py               | 3 +++
 continuedev/src/continuedev/server/gui_protocol.py      | 4 ++++
 extension/react-app/src/hooks/useContinueGUIProtocol.ts | 4 ++++
 extension/react-app/src/tabs/gui.tsx                    | 4 ++--
 5 files changed, 17 insertions(+), 2 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index a6e688ae..2ed77e4d 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -45,6 +45,10 @@ class Autopilot(ContinueBaseModel):
     async def get_available_slash_commands(self) -> List[Dict]:
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
+    async def change_default_model(self):
+        # TODO: Implement this
+        temp = self.continue_sdk.config.slash_commands
+
     async def clear_history(self):
         self.history = History.from_empty()
         self._main_user_input_queue = []
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index cf046734..53a5f16b 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -116,6 +116,9 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
         asyncio.create_task(
             self.session.autopilot.retry_at_index(index))
 
+    def on_change_default_model(self):
+        asyncio.create_task(self.session.autopilot.change_default_model())
+
     def on_clear_history(self):
         asyncio.create_task(self.session.autopilot.clear_history())
 
diff --git a/continuedev/src/continuedev/server/gui_protocol.py b/continuedev/src/continuedev/server/gui_protocol.py
index d9506c6f..66839d9b 100644
--- a/continuedev/src/continuedev/server/gui_protocol.py
+++ b/continuedev/src/continuedev/server/gui_protocol.py
@@ -35,6 +35,10 @@ class AbstractGUIProtocolServer(ABC):
     def on_retry_at_index(self, index: int):
         """Called when the user requests a retry at a previous index"""
 
+    @abstractmethod
+    def on_change_default_model(self):
+        """Called when the user requests to change the default model"""
+
     @abstractmethod
     def on_clear_history(self):
         """Called when the user requests to clear the history"""
diff --git a/extension/react-app/src/hooks/useContinueGUIProtocol.ts b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
index 59397742..4eb68046 100644
--- a/extension/react-app/src/hooks/useContinueGUIProtocol.ts
+++ b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
@@ -55,6 +55,10 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
     });
   }
 
+  changeDefaultModel() {
+    this.messenger.send("change_default_model", {});
+  }
+
   sendClear() {
     this.messenger.send("clear_history", {});
   }
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index f0e3ffd4..15260e0c 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -470,7 +470,7 @@ function GUI(props: GUIProps) {
             Contribute Data
           </span>
         </div>
-        {/* <HeaderButtonWithText
+        { <HeaderButtonWithText
           onClick={() => {
             setUsingFastModel((prev) => !prev);
           }}
@@ -481,7 +481,7 @@ function GUI(props: GUIProps) {
           >
             {usingFastModel ? "⚡" : "🧠"}
           </div>
-        </HeaderButtonWithText> */}
+        </HeaderButtonWithText>}
         <HeaderButtonWithText
           onClick={() => {
             client?.sendClear();
-- 
cgit v1.2.3-70-g09d2


From 0eceef43ae9d0e0e195a9dbbe1e038b4e02ea61b Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Wed, 21 Jun 2023 15:28:37 -0700
Subject: Revert "initial ideas"

This reverts commit 2dd87605a05236c1dd10389883766f4c51207d56.
---
 continuedev/src/continuedev/core/autopilot.py           | 4 ----
 continuedev/src/continuedev/server/gui.py               | 3 ---
 continuedev/src/continuedev/server/gui_protocol.py      | 4 ----
 extension/react-app/src/hooks/useContinueGUIProtocol.ts | 4 ----
 extension/react-app/src/tabs/gui.tsx                    | 4 ++--
 5 files changed, 2 insertions(+), 17 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index 2ed77e4d..a6e688ae 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -45,10 +45,6 @@ class Autopilot(ContinueBaseModel):
     async def get_available_slash_commands(self) -> List[Dict]:
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
-    async def change_default_model(self):
-        # TODO: Implement this
-        temp = self.continue_sdk.config.slash_commands
-
     async def clear_history(self):
         self.history = History.from_empty()
         self._main_user_input_queue = []
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index 53a5f16b..cf046734 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -116,9 +116,6 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
         asyncio.create_task(
             self.session.autopilot.retry_at_index(index))
 
-    def on_change_default_model(self):
-        asyncio.create_task(self.session.autopilot.change_default_model())
-
     def on_clear_history(self):
         asyncio.create_task(self.session.autopilot.clear_history())
 
diff --git a/continuedev/src/continuedev/server/gui_protocol.py b/continuedev/src/continuedev/server/gui_protocol.py
index 66839d9b..d9506c6f 100644
--- a/continuedev/src/continuedev/server/gui_protocol.py
+++ b/continuedev/src/continuedev/server/gui_protocol.py
@@ -35,10 +35,6 @@ class AbstractGUIProtocolServer(ABC):
     def on_retry_at_index(self, index: int):
         """Called when the user requests a retry at a previous index"""
 
-    @abstractmethod
-    def on_change_default_model(self):
-        """Called when the user requests to change the default model"""
-
     @abstractmethod
     def on_clear_history(self):
         """Called when the user requests to clear the history"""
diff --git a/extension/react-app/src/hooks/useContinueGUIProtocol.ts b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
index 4eb68046..59397742 100644
--- a/extension/react-app/src/hooks/useContinueGUIProtocol.ts
+++ b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
@@ -55,10 +55,6 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
     });
   }
 
-  changeDefaultModel() {
-    this.messenger.send("change_default_model", {});
-  }
-
   sendClear() {
     this.messenger.send("clear_history", {});
   }
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 15260e0c..f0e3ffd4 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -470,7 +470,7 @@ function GUI(props: GUIProps) {
             Contribute Data
           </span>
         </div>
-        { <HeaderButtonWithText
+        {/* <HeaderButtonWithText
           onClick={() => {
             setUsingFastModel((prev) => !prev);
           }}
@@ -481,7 +481,7 @@ function GUI(props: GUIProps) {
           >
             {usingFastModel ? "⚡" : "🧠"}
           </div>
-        </HeaderButtonWithText>}
+        </HeaderButtonWithText> */}
         <HeaderButtonWithText
           onClick={() => {
             client?.sendClear();
-- 
cgit v1.2.3-70-g09d2


From 6cedd587c6c62bf33349e374aafa83fdc78da510 Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Wed, 21 Jun 2023 15:36:12 -0700
Subject: initial ideas

---
 continuedev/src/continuedev/core/autopilot.py           | 4 ++++
 continuedev/src/continuedev/server/gui.py               | 3 +++
 continuedev/src/continuedev/server/gui_protocol.py      | 4 ++++
 extension/react-app/src/hooks/useContinueGUIProtocol.ts | 4 ++++
 extension/react-app/src/tabs/gui.tsx                    | 4 ++--
 5 files changed, 17 insertions(+), 2 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index a6e688ae..2ed77e4d 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -45,6 +45,10 @@ class Autopilot(ContinueBaseModel):
     async def get_available_slash_commands(self) -> List[Dict]:
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
+    async def change_default_model(self):
+        # TODO: Implement this
+        temp = self.continue_sdk.config.slash_commands
+
     async def clear_history(self):
         self.history = History.from_empty()
         self._main_user_input_queue = []
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index cf046734..53a5f16b 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -116,6 +116,9 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
         asyncio.create_task(
             self.session.autopilot.retry_at_index(index))
 
+    def on_change_default_model(self):
+        asyncio.create_task(self.session.autopilot.change_default_model())
+
     def on_clear_history(self):
         asyncio.create_task(self.session.autopilot.clear_history())
 
diff --git a/continuedev/src/continuedev/server/gui_protocol.py b/continuedev/src/continuedev/server/gui_protocol.py
index d9506c6f..66839d9b 100644
--- a/continuedev/src/continuedev/server/gui_protocol.py
+++ b/continuedev/src/continuedev/server/gui_protocol.py
@@ -35,6 +35,10 @@ class AbstractGUIProtocolServer(ABC):
     def on_retry_at_index(self, index: int):
         """Called when the user requests a retry at a previous index"""
 
+    @abstractmethod
+    def on_change_default_model(self):
+        """Called when the user requests to change the default model"""
+
     @abstractmethod
     def on_clear_history(self):
         """Called when the user requests to clear the history"""
diff --git a/extension/react-app/src/hooks/useContinueGUIProtocol.ts b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
index 59397742..4eb68046 100644
--- a/extension/react-app/src/hooks/useContinueGUIProtocol.ts
+++ b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
@@ -55,6 +55,10 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
     });
   }
 
+  changeDefaultModel() {
+    this.messenger.send("change_default_model", {});
+  }
+
   sendClear() {
     this.messenger.send("clear_history", {});
   }
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index f0e3ffd4..cbc0e8af 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -470,7 +470,7 @@ function GUI(props: GUIProps) {
             Contribute Data
           </span>
         </div>
-        {/* <HeaderButtonWithText
+        <HeaderButtonWithText
           onClick={() => {
             setUsingFastModel((prev) => !prev);
           }}
@@ -481,7 +481,7 @@ function GUI(props: GUIProps) {
           >
             {usingFastModel ? "⚡" : "🧠"}
           </div>
-        </HeaderButtonWithText> */}
+        </HeaderButtonWithText>
         <HeaderButtonWithText
           onClick={() => {
             client?.sendClear();
-- 
cgit v1.2.3-70-g09d2


From 8c8e65f552d35679e2d5feb142f01f8a97801d20 Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Wed, 21 Jun 2023 21:33:24 -0700
Subject: more progress

---
 continuedev/src/continuedev/core/autopilot.py              | 7 +++++--
 continuedev/src/continuedev/server/gui.py                  | 2 ++
 extension/react-app/src/hooks/ContinueGUIClientProtocol.ts | 2 ++
 extension/react-app/src/tabs/gui.tsx                       | 1 +
 4 files changed, 10 insertions(+), 2 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index 2ed77e4d..0b4b9b12 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -46,8 +46,11 @@ class Autopilot(ContinueBaseModel):
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
     async def change_default_model(self):
-        # TODO: Implement this
-        temp = self.continue_sdk.config.slash_commands
+        print("Changing default model")
+        if self.continue_sdk.config.default_model == "gpt-4":
+            self.continue_sdk.config.default_model == "gpt-3.5-turbo" # not quite correct
+        else:
+            self.continue_sdk.config.default_model == "gpt-4" # not quite correct
 
     async def clear_history(self):
         self.history = History.from_empty()
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index 53a5f16b..9b36c704 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -77,6 +77,8 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
                 self.on_reverse_to_index(data["index"])
             elif message_type == "retry_at_index":
                 self.on_retry_at_index(data["index"])
+            elif message_type == "change_default_model":
+                self.on_change_default_model()
             elif message_type == "clear_history":
                 self.on_clear_history()
             elif message_type == "delete_at_index":
diff --git a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
index 824bb086..6d9d1fdd 100644
--- a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
+++ b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
@@ -13,6 +13,8 @@ abstract class AbstractContinueGUIClientProtocol {
     callback: (commands: { name: string; description: string }[]) => void
   ): void;
 
+  abstract changeDefaultModel(): void;
+
   abstract sendClear(): void;
 
   abstract retryAtIndex(index: number): void;
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index cbc0e8af..15121010 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -473,6 +473,7 @@ function GUI(props: GUIProps) {
         <HeaderButtonWithText
           onClick={() => {
             setUsingFastModel((prev) => !prev);
+            client?.changeDefaultModel();
           }}
           text={usingFastModel ? "gpt-3.5-turbo" : "gpt-4"}
         >
-- 
cgit v1.2.3-70-g09d2


From 8bc0c8d23469c1d1e7e20114f27dca876a3b0383 Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Thu, 22 Jun 2023 12:39:01 -0700
Subject: start of syncing back

---
 continuedev/src/continuedev/core/autopilot.py |  8 ++----
 continuedev/src/continuedev/core/config.py    | 35 +++++++++++++++++++++++++++
 continuedev/src/continuedev/core/main.py      |  1 +
 continuedev/src/continuedev/core/sdk.py       | 11 ++++++++-
 extension/react-app/src/tabs/gui.tsx          |  1 +
 5 files changed, 49 insertions(+), 7 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index 0b4b9b12..ab7f4747 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -40,17 +40,13 @@ class Autopilot(ContinueBaseModel):
         keep_untouched = (cached_property,)
 
     def get_full_state(self) -> FullState:
-        return FullState(history=self.history, active=self._active, user_input_queue=self._main_user_input_queue)
+        return FullState(history=self.history, active=self._active, user_input_queue=self._main_user_input_queue, default_model=self.continue_sdk.config.default_model)
 
     async def get_available_slash_commands(self) -> List[Dict]:
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
     async def change_default_model(self):
-        print("Changing default model")
-        if self.continue_sdk.config.default_model == "gpt-4":
-            self.continue_sdk.config.default_model == "gpt-3.5-turbo" # not quite correct
-        else:
-            self.continue_sdk.config.default_model == "gpt-4" # not quite correct
+        self.continue_sdk.update_default_model()
 
     async def clear_history(self):
         self.history = History.from_empty()
diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py
index 652320fb..21d21879 100644
--- a/continuedev/src/continuedev/core/config.py
+++ b/continuedev/src/continuedev/core/config.py
@@ -86,3 +86,38 @@ def load_config(config_file: str) -> ContinueConfig:
     else:
         raise ValueError(f'Unknown config file extension: {ext}')
     return ContinueConfig(**config_dict)
+
+def update_config(config_file: str):
+    """
+    Update the config file with the current ContinueConfig object.
+    """
+    if not os.path.exists(config_file):
+        with open(config_file, 'w') as f:
+            config_dict = { "default_model": "gpt-3.5-turbo" }
+            json.dump(config_dict, f, indent=4)
+
+    _, ext = os.path.splitext(config_file)
+    if ext == '.yaml':
+
+        with open(config_file, 'w') as f:
+            config_dict = yaml.safe_load(f)
+
+            if config_dict["default_model"] == "gpt-4":
+                config_dict["default_model"] = "gpt-3.5-turbo"
+            else:
+                config_dict["default_model"] = "gpt-4"
+            
+            with open(config_file, 'w') as f:
+                json.dump(config_dict, f, indent=4)
+
+    elif ext == '.json':
+        with open(config_file, 'r') as f:
+            config_dict = json.load(f)
+
+        if config_dict["default_model"] == "gpt-4":
+            config_dict["default_model"] = "gpt-3.5-turbo"
+        else:
+            config_dict["default_model"] = "gpt-4"
+        
+        with open(config_file, 'w') as f:
+            json.dump(config_dict, f, indent=4)
\ No newline at end of file
diff --git a/continuedev/src/continuedev/core/main.py b/continuedev/src/continuedev/core/main.py
index efb91488..d6412ece 100644
--- a/continuedev/src/continuedev/core/main.py
+++ b/continuedev/src/continuedev/core/main.py
@@ -114,6 +114,7 @@ class FullState(ContinueBaseModel):
     history: History
     active: bool
     user_input_queue: List[str]
+    default_model: str
 
 
 class ContinueSDK:
diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py
index d6acc404..5652ec39 100644
--- a/continuedev/src/continuedev/core/sdk.py
+++ b/continuedev/src/continuedev/core/sdk.py
@@ -6,7 +6,7 @@ import os
 from ..steps.core.core import DefaultModelEditCodeStep
 from ..models.main import Range
 from .abstract_sdk import AbstractContinueSDK
-from .config import ContinueConfig, load_config
+from .config import ContinueConfig, load_config, update_config
 from ..models.filesystem_edit import FileEdit, FileSystemEdit, AddFile, DeleteFile, AddDirectory, DeleteDirectory
 from ..models.filesystem import RangeInFile
 from ..libs.llm.hf_inference_api import HuggingFaceInferenceAPI
@@ -170,6 +170,15 @@ class ContinueSDK(AbstractContinueSDK):
         else:
             return ContinueConfig()
 
+    def update_default_model(self):
+        dir = self.ide.workspace_directory
+        yaml_path = os.path.join(dir, '.continue', 'config.yaml')
+        json_path = os.path.join(dir, '.continue', 'config.json')
+        if os.path.exists(yaml_path):
+            update_config(yaml_path)
+        else:
+            update_config(json_path)
+
     def set_loading_message(self, message: str):
         # self.__autopilot.set_loading_message(message)
         raise NotImplementedError()
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 15121010..0dd7e3ec 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -230,6 +230,7 @@ function GUI(props: GUIProps) {
     console.log("CLIENT ON STATE UPDATE: ", client, client?.onStateUpdate);
     client?.onStateUpdate((state) => {
       // Scroll only if user is at very bottom of the window.
+      setUsingFastModel(state.using_fast_model);
       const shouldScrollToBottom =
         topGuiDivRef.current &&
         topGuiDivRef.current?.offsetHeight - window.scrollY < 100;
-- 
cgit v1.2.3-70-g09d2


From 71f8e361117ea5b4d88cc5c94e2e54a8ac5f2bf8 Mon Sep 17 00:00:00 2001
From: Ty Dunn <ty@tydunn.com>
Date: Thu, 22 Jun 2023 13:04:04 -0700
Subject: adding default model

---
 extension/react-app/src/tabs/gui.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 0dd7e3ec..16c950ef 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -230,7 +230,7 @@ function GUI(props: GUIProps) {
     console.log("CLIENT ON STATE UPDATE: ", client, client?.onStateUpdate);
     client?.onStateUpdate((state) => {
       // Scroll only if user is at very bottom of the window.
-      setUsingFastModel(state.using_fast_model);
+      setUsingFastModel(state.default_model === "gpt-3.5-turbo");
       const shouldScrollToBottom =
         topGuiDivRef.current &&
         topGuiDivRef.current?.offsetHeight - window.scrollY < 100;
-- 
cgit v1.2.3-70-g09d2


From d1d0e3d6ed02512489b42fa4a8a2176df7187207 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Thu, 22 Jun 2023 13:56:48 -0700
Subject: update global config with default model toggle

---
 continuedev/src/continuedev/core/autopilot.py      |  4 +-
 continuedev/src/continuedev/core/config.py         | 64 ++++++++++++----------
 continuedev/src/continuedev/core/sdk.py            | 18 +++---
 continuedev/src/continuedev/server/gui.py          |  6 +-
 .../src/hooks/ContinueGUIClientProtocol.ts         |  2 +-
 .../react-app/src/hooks/useContinueGUIProtocol.ts  |  4 +-
 extension/react-app/src/tabs/gui.tsx               | 10 ++--
 7 files changed, 57 insertions(+), 51 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index ab7f4747..f14a4127 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -45,8 +45,8 @@ class Autopilot(ContinueBaseModel):
     async def get_available_slash_commands(self) -> List[Dict]:
         return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
 
-    async def change_default_model(self):
-        self.continue_sdk.update_default_model()
+    async def change_default_model(self, model: str):
+        self.continue_sdk.update_default_model(model)
 
     async def clear_history(self):
         self.history = History.from_empty()
diff --git a/continuedev/src/continuedev/core/config.py b/continuedev/src/continuedev/core/config.py
index 21d21879..01316f1b 100644
--- a/continuedev/src/continuedev/core/config.py
+++ b/continuedev/src/continuedev/core/config.py
@@ -87,37 +87,45 @@ def load_config(config_file: str) -> ContinueConfig:
         raise ValueError(f'Unknown config file extension: {ext}')
     return ContinueConfig(**config_dict)
 
-def update_config(config_file: str):
+
+def load_global_config() -> ContinueConfig:
     """
-    Update the config file with the current ContinueConfig object.
+    Load the global config file and return a ContinueConfig object.
     """
-    if not os.path.exists(config_file):
-        with open(config_file, 'w') as f:
-            config_dict = { "default_model": "gpt-3.5-turbo" }
-            json.dump(config_dict, f, indent=4)
-
-    _, ext = os.path.splitext(config_file)
-    if ext == '.yaml':
+    global_dir = os.path.expanduser('~/.continue')
+    if not os.path.exists(global_dir):
+        os.mkdir(global_dir)
 
-        with open(config_file, 'w') as f:
-            config_dict = yaml.safe_load(f)
+    yaml_path = os.path.join(global_dir, 'config.yaml')
+    if os.path.exists(yaml_path):
+        with open(config_path, 'r') as f:
+            try:
+                config_dict = yaml.safe_load(f)
+            except:
+                return ContinueConfig()
+    else:
+        config_path = os.path.join(global_dir, 'config.json')
+        with open(config_path, 'r') as f:
+            try:
+                config_dict = json.load(f)
+            except:
+                return ContinueConfig()
+    return ContinueConfig(**config_dict)
 
-            if config_dict["default_model"] == "gpt-4":
-                config_dict["default_model"] = "gpt-3.5-turbo"
-            else:
-                config_dict["default_model"] = "gpt-4"
-            
-            with open(config_file, 'w') as f:
-                json.dump(config_dict, f, indent=4)
 
-    elif ext == '.json':
-        with open(config_file, 'r') as f:
-            config_dict = json.load(f)
+def update_global_config(config: ContinueConfig):
+    """
+    Update the config file with the given ContinueConfig object.
+    """
+    global_dir = os.path.expanduser('~/.continue')
+    if not os.path.exists(global_dir):
+        os.mkdir(global_dir)
 
-        if config_dict["default_model"] == "gpt-4":
-            config_dict["default_model"] = "gpt-3.5-turbo"
-        else:
-            config_dict["default_model"] = "gpt-4"
-        
-        with open(config_file, 'w') as f:
-            json.dump(config_dict, f, indent=4)
\ No newline at end of file
+    yaml_path = os.path.join(global_dir, 'config.yaml')
+    if os.path.exists(yaml_path):
+        with open(config_path, 'w') as f:
+            yaml.dump(config.dict(), f)
+    else:
+        config_path = os.path.join(global_dir, 'config.json')
+        with open(config_path, 'w') as f:
+            json.dump(config.dict(), f)
diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py
index 5652ec39..192552e7 100644
--- a/continuedev/src/continuedev/core/sdk.py
+++ b/continuedev/src/continuedev/core/sdk.py
@@ -6,7 +6,7 @@ import os
 from ..steps.core.core import DefaultModelEditCodeStep
 from ..models.main import Range
 from .abstract_sdk import AbstractContinueSDK
-from .config import ContinueConfig, load_config, update_config
+from .config import ContinueConfig, load_config, load_global_config, update_global_config
 from ..models.filesystem_edit import FileEdit, FileSystemEdit, AddFile, DeleteFile, AddDirectory, DeleteDirectory
 from ..models.filesystem import RangeInFile
 from ..libs.llm.hf_inference_api import HuggingFaceInferenceAPI
@@ -76,7 +76,7 @@ class Models:
         else:
             raise Exception(f"Unknown model {model_name}")
 
-    @cached_property
+    @property
     def default(self):
         default_model = self.sdk.config.default_model
         return self.__model_from_name(default_model) if default_model is not None else self.gpt35
@@ -168,16 +168,12 @@ class ContinueSDK(AbstractContinueSDK):
         elif os.path.exists(json_path):
             return load_config(json_path)
         else:
-            return ContinueConfig()
+            return load_global_config()
 
-    def update_default_model(self):
-        dir = self.ide.workspace_directory
-        yaml_path = os.path.join(dir, '.continue', 'config.yaml')
-        json_path = os.path.join(dir, '.continue', 'config.json')
-        if os.path.exists(yaml_path):
-            update_config(yaml_path)
-        else:
-            update_config(json_path)
+    def update_default_model(self, model: str):
+        config = self.config
+        config.default_model = model
+        update_global_config(config)
 
     def set_loading_message(self, message: str):
         # self.__autopilot.set_loading_message(message)
diff --git a/continuedev/src/continuedev/server/gui.py b/continuedev/src/continuedev/server/gui.py
index 9b36c704..cc6235e9 100644
--- a/continuedev/src/continuedev/server/gui.py
+++ b/continuedev/src/continuedev/server/gui.py
@@ -78,7 +78,7 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
             elif message_type == "retry_at_index":
                 self.on_retry_at_index(data["index"])
             elif message_type == "change_default_model":
-                self.on_change_default_model()
+                self.on_change_default_model(data["model"])
             elif message_type == "clear_history":
                 self.on_clear_history()
             elif message_type == "delete_at_index":
@@ -118,8 +118,8 @@ class GUIProtocolServer(AbstractGUIProtocolServer):
         asyncio.create_task(
             self.session.autopilot.retry_at_index(index))
 
-    def on_change_default_model(self):
-        asyncio.create_task(self.session.autopilot.change_default_model())
+    def on_change_default_model(self, model: str):
+        asyncio.create_task(self.session.autopilot.change_default_model(model))
 
     def on_clear_history(self):
         asyncio.create_task(self.session.autopilot.clear_history())
diff --git a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
index 6d9d1fdd..3d8e0a38 100644
--- a/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
+++ b/extension/react-app/src/hooks/ContinueGUIClientProtocol.ts
@@ -13,7 +13,7 @@ abstract class AbstractContinueGUIClientProtocol {
     callback: (commands: { name: string; description: string }[]) => void
   ): void;
 
-  abstract changeDefaultModel(): void;
+  abstract changeDefaultModel(model: string): void;
 
   abstract sendClear(): void;
 
diff --git a/extension/react-app/src/hooks/useContinueGUIProtocol.ts b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
index 4eb68046..f43a66ff 100644
--- a/extension/react-app/src/hooks/useContinueGUIProtocol.ts
+++ b/extension/react-app/src/hooks/useContinueGUIProtocol.ts
@@ -55,8 +55,8 @@ class ContinueGUIClientProtocol extends AbstractContinueGUIClientProtocol {
     });
   }
 
-  changeDefaultModel() {
-    this.messenger.send("change_default_model", {});
+  changeDefaultModel(model: string) {
+    this.messenger.send("change_default_model", { model });
   }
 
   sendClear() {
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 16c950ef..f47371ee 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -427,9 +427,9 @@ function GUI(props: GUIProps) {
         }}
         hidden={!showDataSharingInfo}
       >
-        By turning on this switch, you signal that you would 
-        contribute this software development data to a publicly 
-        accessible, open-source dataset in the future.
+        By turning on this switch, you signal that you would contribute this
+        software development data to a publicly accessible, open-source dataset
+        in the future.
         <br />
         <br />
         <b>
@@ -473,8 +473,10 @@ function GUI(props: GUIProps) {
         </div>
         <HeaderButtonWithText
           onClick={() => {
+            client?.changeDefaultModel(
+              usingFastModel ? "gpt-4" : "gpt-3.5-turbo"
+            );
             setUsingFastModel((prev) => !prev);
-            client?.changeDefaultModel();
           }}
           text={usingFastModel ? "gpt-3.5-turbo" : "gpt-4"}
         >
-- 
cgit v1.2.3-70-g09d2


From ad462728afc4e6a9e1402aff295010ced9cf2f7a Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Sun, 25 Jun 2023 08:22:37 -0700
Subject: Diff kb shortcut, fix bug

---
 extension/react-app/src/tabs/gui.tsx | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index f47371ee..a457382d 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -215,7 +215,7 @@ function GUI(props: GUIProps) {
   useEffect(() => {
     const listener = (e: any) => {
       // Cmd + J to toggle fast model
-      if (e.key === "j" && e.metaKey) {
+      if (e.key === "i" && e.metaKey && e.shiftKey) {
         setUsingFastModel((prev) => !prev);
       }
     };
@@ -237,15 +237,17 @@ function GUI(props: GUIProps) {
       setWaitingForSteps(state.active);
       setHistory(state.history);
       setUserInputQueue(state.user_input_queue);
-      const nextStepsOpen = [...stepsOpen];
-      for (
-        let i = nextStepsOpen.length;
-        i < state.history.timeline.length;
-        i++
-      ) {
-        nextStepsOpen.push(true);
-      }
-      setStepsOpen(nextStepsOpen);
+      setStepsOpen((prev) => {
+        const nextStepsOpen = [...prev];
+        for (
+          let i = nextStepsOpen.length;
+          i < state.history.timeline.length;
+          i++
+        ) {
+          nextStepsOpen.push(true);
+        }
+        return nextStepsOpen;
+      });
 
       if (shouldScrollToBottom) {
         scrollToBottom();
-- 
cgit v1.2.3-70-g09d2


From d3554d1cd7e24cabcfc8835140fcb0f7fa746061 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Sun, 25 Jun 2023 12:12:11 -0700
Subject: tweaks

---
 continuedev/src/continuedev/steps/chat.py | 17 +++++++++++++----
 extension/react-app/src/tabs/gui.tsx      |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py
index fee8f40e..a29f7f2f 100644
--- a/continuedev/src/continuedev/steps/chat.py
+++ b/continuedev/src/continuedev/steps/chat.py
@@ -88,7 +88,7 @@ class RunTerminalCommandStep(Step):
         return f"Ran the terminal command {self.command}."
 
     async def run(self, sdk: ContinueSDK):
-        await sdk.wait_for_user_confirmation(f"Run the terminal command {self.command}?")
+        await sdk.wait_for_user_confirmation(f"Run the following terminal command?\n\n```bash\n{self.command}\n```")
         await sdk.run(self.command)
 
 
@@ -201,7 +201,16 @@ class ChatWithFunctions(Step):
                     summary=f"Ran function {func_name}"
                 ))
                 last_function_called_index_in_history = sdk.history.current_index + 1
-                await sdk.run_step(step_name_step_class_map[func_name](
-                    **fn_call_params))
-                self.description += f"`Running function {func_name}`\n\n"
+                step_to_run = step_name_step_class_map[func_name](
+                    **fn_call_params)
+
+                if func_name == "AddFileStep":
+                    step_to_run.hide = True
+                    self.description += f"\nAdded file `{func_args['filename']}`"
+                elif func_name == "AddDirectoryStep":
+                    step_to_run.hide = True
+                    self.description += f"\nAdded directory `{func_args['directory_name']}`"
+                else:
+                    self.description += f"\n`Running function {func_name}`\n\n"
+                await sdk.run_step(step_to_run)
                 await sdk.update_ui()
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 24529967..d6131174 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -388,7 +388,7 @@ function GUI(props: GUIProps) {
             />
           );
         })}
-        {/* {waitingForSteps && <Loader></Loader>} */}
+        {waitingForSteps && <Loader></Loader>}
 
         <div>
           {userInputQueue.map((input) => {
-- 
cgit v1.2.3-70-g09d2


From 3fa2220379f07b162b9c72d1e0d6c13e0d59b8d9 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Sun, 25 Jun 2023 15:14:56 -0700
Subject: shipped function calling

---
 continuedev/src/continuedev/core/autopilot.py      |  14 ++++++++-
 continuedev/src/continuedev/steps/chat.py          |  33 +++++++++++----------
 extension/package-lock.json                        |   4 +--
 extension/package.json                             |   2 +-
 .../src/components/HeaderButtonWithText.tsx        |   6 +++-
 extension/react-app/src/tabs/gui.tsx               |   2 --
 .../scripts/continuedev-0.1.1-py3-none-any.whl     | Bin 86716 -> 89177 bytes
 7 files changed, 39 insertions(+), 22 deletions(-)

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/continuedev/src/continuedev/core/autopilot.py b/continuedev/src/continuedev/core/autopilot.py
index f14a4127..04f64ed8 100644
--- a/continuedev/src/continuedev/core/autopilot.py
+++ b/continuedev/src/continuedev/core/autopilot.py
@@ -15,6 +15,17 @@ from .sdk import ContinueSDK
 import asyncio
 from ..libs.util.step_name_to_steps import get_step_from_name
 from ..libs.util.traceback_parsers import get_python_traceback, get_javascript_traceback
+from openai import error as openai_errors
+
+
+def get_error_title(e: Exception) -> str:
+    if isinstance(e, openai_errors.APIError):
+        return "OpenAI is overloaded with requests. Please try again."
+    elif isinstance(e, openai_errors.RateLimitError):
+        return "This OpenAI API key has been rate limited. Please try again."
+    elif isinstance(e, openai_errors.Timeout):
+        return "OpenAI timed out. Please try again."
+    return e.__repr__()
 
 
 class Autopilot(ContinueBaseModel):
@@ -166,7 +177,8 @@ class Autopilot(ContinueBaseModel):
 
             error_string = e.message if is_continue_custom_exception else '\n\n'.join(
                 traceback.format_tb(e.__traceback__)) + f"\n\n{e.__repr__()}"
-            error_title = e.title if is_continue_custom_exception else e.__repr__()
+            error_title = e.title if is_continue_custom_exception else get_error_title(
+                e)
 
             # Attach an InternalErrorObservation to the step and unhide it.
             print(f"Error while running step: \n{error_string}\n{error_title}")
diff --git a/continuedev/src/continuedev/steps/chat.py b/continuedev/src/continuedev/steps/chat.py
index a940c3ba..2a8ae2da 100644
--- a/continuedev/src/continuedev/steps/chat.py
+++ b/continuedev/src/continuedev/steps/chat.py
@@ -182,21 +182,24 @@ class ChatWithFunctions(Step):
             else:
                 if func_name == "python" and "python" not in step_name_step_class_map:
                     # GPT must be fine-tuned to believe this exists, but it doesn't always
-                    self.chat_context.append(ChatMessage(
-                        role="assistant",
-                        content=None,
-                        function_call=FunctionCall(
-                            name=func_name,
-                            arguments=func_args
-                        ),
-                        summary=f"Ran function {func_name}"
-                    ))
-                    self.chat_context.append(ChatMessage(
-                        role="user",
-                        content="The 'python' function does not exist. Don't call it.",
-                        summary="'python' function does not exist."
-                    ))
-                    continue
+                    func_name = "EditHighlightedCodeStep"
+                    func_args = json.dumps({"user_input": self.user_input})
+                    # self.chat_context.append(ChatMessage(
+                    #     role="assistant",
+                    #     content=None,
+                    #     function_call=FunctionCall(
+                    #         name=func_name,
+                    #         arguments=func_args
+                    #     ),
+                    #     summary=f"Ran function {func_name}"
+                    # ))
+                    # self.chat_context.append(ChatMessage(
+                    #     role="user",
+                    #     content="The 'python' function does not exist. Don't call it. Try again to call another function.",
+                    #     summary="'python' function does not exist."
+                    # ))
+                    # msg_step.hide = True
+                    # continue
                 # Call the function, then continue to chat
                 func_args = "{}" if func_args == "" else func_args
                 fn_call_params = json.loads(func_args)
diff --git a/extension/package-lock.json b/extension/package-lock.json
index 12b2fe13..71edfe8c 100644
--- a/extension/package-lock.json
+++ b/extension/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "continue",
-  "version": "0.0.61",
+  "version": "0.0.62",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "continue",
-      "version": "0.0.61",
+      "version": "0.0.62",
       "license": "Apache-2.0",
       "dependencies": {
         "@electron/rebuild": "^3.2.10",
diff --git a/extension/package.json b/extension/package.json
index 9fd1d7a6..9679b159 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -14,7 +14,7 @@
   "displayName": "Continue",
   "pricing": "Free",
   "description": "Accelerating software development with language models",
-  "version": "0.0.61",
+  "version": "0.0.62",
   "publisher": "Continue",
   "engines": {
     "vscode": "^1.74.0"
diff --git a/extension/react-app/src/components/HeaderButtonWithText.tsx b/extension/react-app/src/components/HeaderButtonWithText.tsx
index 5901c5d8..30931f86 100644
--- a/extension/react-app/src/components/HeaderButtonWithText.tsx
+++ b/extension/react-app/src/components/HeaderButtonWithText.tsx
@@ -15,7 +15,11 @@ const HeaderButtonWithText = (props: HeaderButtonWithTextProps) => {
     <HeaderButton
       disabled={props.disabled}
       style={{ padding: "1px", paddingLeft: hover ? "4px" : "1px" }}
-      onMouseEnter={() => setHover(true)}
+      onMouseEnter={() => {
+        if (!props.disabled) {
+          setHover(true);
+        }
+      }}
       onMouseLeave={() => {
         setHover(false);
       }}
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 5001fe4b..4886bfad 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -491,8 +491,6 @@ function GUI(props: GUIProps) {
         <HeaderButtonWithText
           onClick={() => {
             client?.sendClear();
-            // Reload the window to get completely fresh session
-            window.location.reload();
           }}
           text="Clear All"
         >
diff --git a/extension/scripts/continuedev-0.1.1-py3-none-any.whl b/extension/scripts/continuedev-0.1.1-py3-none-any.whl
index 29e41d3c..692bdfb7 100644
Binary files a/extension/scripts/continuedev-0.1.1-py3-none-any.whl and b/extension/scripts/continuedev-0.1.1-py3-none-any.whl differ
-- 
cgit v1.2.3-70-g09d2


From 25eded3e2bb67bac3f05ed8fd724359b20e3d81b Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Sun, 25 Jun 2023 21:35:53 -0700
Subject: loading cover page (hidden)

---
 extension/react-app/public/continue.gif            | Bin 0 -> 5242 bytes
 .../react-app/src/components/LoadingCover.tsx      |  50 +++++++++++++++++++++
 extension/react-app/src/tabs/gui.tsx               |   2 +
 3 files changed, 52 insertions(+)
 create mode 100644 extension/react-app/public/continue.gif
 create mode 100644 extension/react-app/src/components/LoadingCover.tsx

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/react-app/public/continue.gif b/extension/react-app/public/continue.gif
new file mode 100644
index 00000000..daed6663
Binary files /dev/null and b/extension/react-app/public/continue.gif differ
diff --git a/extension/react-app/src/components/LoadingCover.tsx b/extension/react-app/src/components/LoadingCover.tsx
new file mode 100644
index 00000000..a0f8f7a2
--- /dev/null
+++ b/extension/react-app/src/components/LoadingCover.tsx
@@ -0,0 +1,50 @@
+import React from "react";
+import styled from "styled-components";
+
+const StyledDiv = styled.div`
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100vh;
+  background: linear-gradient(
+    101.79deg,
+    #12887a 0%,
+    #87245c 32%,
+    #e12637 63%,
+    #ffb215 100%
+  );
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  flex-direction: column;
+  z-index: 10;
+`;
+
+const StyledImg = styled.img`
+  /* add your styles here */
+`;
+
+const StyledDiv2 = styled.div`
+  width: 50%;
+  height: 5px;
+  background: white;
+  margin-top: 20px;
+`;
+
+interface LoadingCoverProps {
+  message: string;
+  hidden?: boolean;
+}
+
+const LoadingCover = (props: LoadingCoverProps) => {
+  return (
+    <StyledDiv style={{ display: props.hidden ? "none" : "inherit" }}>
+      <StyledImg src="continue.gif" alt="centered image" width="50%" />
+      <StyledDiv2></StyledDiv2>
+      <p>{props.message}</p>
+    </StyledDiv>
+  );
+};
+
+export default LoadingCover;
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 4886bfad..445d5700 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -18,6 +18,7 @@ import ReactSwitch from "react-switch";
 import { usePostHog } from "posthog-js/react";
 import { useSelector } from "react-redux";
 import { RootStore } from "../redux/store";
+import LoadingCover from "../components/LoadingCover";
 
 const TopGUIDiv = styled.div`
   overflow: hidden;
@@ -328,6 +329,7 @@ function GUI(props: GUIProps) {
   // const iterations = useSelector(selectIterations);
   return (
     <>
+      <LoadingCover hidden={true} message="Downloading local model..." />
       <TextDialog
         showDialog={showFeedbackDialog}
         onEnter={(text) => {
-- 
cgit v1.2.3-70-g09d2


From 0862b388dc0f07e45b6daeaec1f8c05925623692 Mon Sep 17 00:00:00 2001
From: Nate Sesti <sestinj@gmail.com>
Date: Mon, 26 Jun 2023 14:50:04 -0700
Subject: retry setup patch

---
 extension/package-lock.json                        |   4 +-
 extension/package.json                             |   2 +-
 extension/react-app/src/tabs/gui.tsx               |   4 +-
 extension/scripts/.continue_env_installed          |   0
 extension/scripts/.gitignore                       |   4 +-
 .../scripts/continuedev-0.1.1-py3-none-any.whl     | Bin 89627 -> 0 bytes
 extension/src/activation/environmentSetup.ts       | 108 +++++++++++++--------
 7 files changed, 73 insertions(+), 49 deletions(-)
 delete mode 100644 extension/scripts/.continue_env_installed
 delete mode 100644 extension/scripts/continuedev-0.1.1-py3-none-any.whl

(limited to 'extension/react-app/src/tabs/gui.tsx')

diff --git a/extension/package-lock.json b/extension/package-lock.json
index 98dfc223..fcd4c755 100644
--- a/extension/package-lock.json
+++ b/extension/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "continue",
-  "version": "0.0.67",
+  "version": "0.0.70",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "continue",
-      "version": "0.0.67",
+      "version": "0.0.70",
       "license": "Apache-2.0",
       "dependencies": {
         "@electron/rebuild": "^3.2.10",
diff --git a/extension/package.json b/extension/package.json
index a51bb6d0..b56c60f4 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -14,7 +14,7 @@
   "displayName": "Continue",
   "pricing": "Free",
   "description": "Accelerating software development with language models",
-  "version": "0.0.67",
+  "version": "0.0.70",
   "publisher": "Continue",
   "engines": {
     "vscode": "^1.74.0"
diff --git a/extension/react-app/src/tabs/gui.tsx b/extension/react-app/src/tabs/gui.tsx
index 445d5700..13b74423 100644
--- a/extension/react-app/src/tabs/gui.tsx
+++ b/extension/react-app/src/tabs/gui.tsx
@@ -352,9 +352,7 @@ function GUI(props: GUIProps) {
         {typeof client === "undefined" && (
           <>
             <Loader></Loader>
-            <p style={{ textAlign: "center" }}>
-              Trying to reconnect with server...
-            </p>
+            <p style={{ textAlign: "center" }}>Loading Continue server...</p>
           </>
         )}
         {history?.timeline.map((node: HistoryNode, index: number) => {
diff --git a/extension/scripts/.continue_env_installed b/extension/scripts/.continue_env_installed
deleted file mode 100644
index e69de29b..00000000
diff --git a/extension/scripts/.gitignore b/extension/scripts/.gitignore
index 7af27c08..fbb3bf9f 100644
--- a/extension/scripts/.gitignore
+++ b/extension/scripts/.gitignore
@@ -1,3 +1,5 @@
 testdb
 env
-stdout.txt
\ No newline at end of file
+stdout.txt
+.continue_env_installed
+**.whl
\ No newline at end of file
diff --git a/extension/scripts/continuedev-0.1.1-py3-none-any.whl b/extension/scripts/continuedev-0.1.1-py3-none-any.whl
deleted file mode 100644
index 4d1c8fb2..00000000
Binary files a/extension/scripts/continuedev-0.1.1-py3-none-any.whl and /dev/null differ
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 364b6af2..25b6f643 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -7,6 +7,25 @@ import * as fs from "fs";
 import rebuild from "@electron/rebuild";
 import { getContinueServerUrl } from "../bridge";
 import fetch from "node-fetch";
+import * as vscode from "vscode";
+
+const MAX_RETRIES = 5;
+async function retryThenFail(
+  fn: () => Promise<any>,
+  retries: number = MAX_RETRIES
+): Promise<any> {
+  try {
+    return await fn();
+  } catch (e) {
+    if (retries > 0) {
+      return await retryThenFail(fn, retries - 1);
+    }
+    vscode.window.showErrorMessage(
+      "Failed to set up Continue extension. Please email nate@continue.dev and we'll get this fixed ASAP!"
+    );
+    throw e;
+  }
+}
 
 async function runCommand(cmd: string): Promise<[string, string | undefined]> {
   console.log("Running command: ", cmd);
@@ -91,6 +110,7 @@ async function setupPythonEnv() {
     pythonCmd,
     pipCmd
   );
+
   if (checkEnvExists()) {
     console.log("Python env already exists, skipping...");
   } else {
@@ -124,21 +144,23 @@ async function setupPythonEnv() {
     );
   }
 
-  if (checkRequirementsInstalled()) {
-    console.log("Python requirements already installed, skipping...");
-  } else {
-    const installRequirementsCommand = [
-      `cd ${path.join(getExtensionUri().fsPath, "scripts")}`,
-      activateCmd,
-      pipUpgradeCmd,
-      `${pipCmd} install -r requirements.txt`,
-      "touch .continue_env_installed",
-    ].join(" ; ");
-    const [, stderr] = await runCommand(installRequirementsCommand);
-    if (stderr) {
-      throw new Error(stderr);
+  await retryThenFail(async () => {
+    if (checkRequirementsInstalled()) {
+      console.log("Python requirements already installed, skipping...");
+    } else {
+      const installRequirementsCommand = [
+        `cd ${path.join(getExtensionUri().fsPath, "scripts")}`,
+        activateCmd,
+        pipUpgradeCmd,
+        `${pipCmd} install -r requirements.txt`,
+        "touch .continue_env_installed",
+      ].join(" ; ");
+      const [, stderr] = await runCommand(installRequirementsCommand);
+      if (stderr) {
+        throw new Error(stderr);
+      }
     }
-  }
+  });
 }
 
 function readEnvFile(path: string) {
@@ -198,10 +220,6 @@ export async function startContinuePythonServer() {
     return;
   }
 
-  console.log("Starting Continue python server...");
-
-  if (await checkServerRunning(serverUrl)) return;
-
   let activateCmd = ". env/bin/activate";
   let pythonCmd = "python3";
   if (process.platform == "win32") {
@@ -214,33 +232,39 @@ export async function startContinuePythonServer() {
     "scripts"
   )} ; ${activateCmd} ; cd .. ; ${pythonCmd} -m scripts.run_continue_server`;
 
-  return new Promise(async (resolve, reject) => {
-    try {
-      const child = spawn(command, {
-        shell: true,
-      });
-      child.stdout.on("data", (data: any) => {
-        console.log(`stdout: ${data}`);
-      });
-      child.stderr.on("data", (data: any) => {
-        console.log(`stderr: ${data}`);
-        if (data.includes("Uvicorn running on")) {
-          console.log("Successfully started Continue python server");
+  return await retryThenFail(async () => {
+    console.log("Starting Continue python server...");
+
+    if (await checkServerRunning(serverUrl)) return;
+
+    return new Promise(async (resolve, reject) => {
+      try {
+        const child = spawn(command, {
+          shell: true,
+        });
+        child.stdout.on("data", (data: any) => {
+          console.log(`stdout: ${data}`);
+        });
+        child.stderr.on("data", (data: any) => {
+          console.log(`stderr: ${data}`);
+          if (data.includes("Uvicorn running on")) {
+            console.log("Successfully started Continue python server");
+            resolve(null);
+          }
+        });
+        child.on("error", (error: any) => {
+          console.log(`error: ${error.message}`);
+        });
+      } catch (e) {
+        console.log("Failed to start Continue python server", e);
+        // If failed, check if it's because the server is already running (might have happened just after we checked above)
+        if (await checkServerRunning(serverUrl)) {
           resolve(null);
+        } else {
+          reject();
         }
-      });
-      child.on("error", (error: any) => {
-        console.log(`error: ${error.message}`);
-      });
-    } catch (e) {
-      console.log("Failed to start Continue python server", e);
-      // If failed, check if it's because the server is already running (might have happened just after we checked above)
-      if (await checkServerRunning(serverUrl)) {
-        resolve(null);
-      } else {
-        reject();
       }
-    }
+    });
   });
 }
 
-- 
cgit v1.2.3-70-g09d2

