Skip to content

Commit

Permalink
Merge pull request #173 from pieces-app/fix-ask
Browse files Browse the repository at this point in the history
fix ask issue where ask does not have context pipeline #172
  • Loading branch information
bishoy-at-pieces authored Sep 18, 2024
2 parents 9d1a44f + 6ba980b commit 2c19bb8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
16 changes: 9 additions & 7 deletions ask/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ def run_async(self):


def on_done(self,description):
self.description = description
if not self.description:
self.description = "No description provided"
self._description = description
if not description:
description = "No description provided"
sublime.set_timeout_async(self.on_done_async,0)

def on_done_async(self):
if self.task == "fix":
pipeline = QGPTTaskPipeline(code_fix=QGPTTaskPipelineForCodeFix(error=self.description))
task = QGPTTaskPipeline(code_fix=QGPTTaskPipelineForCodeFix(error=self._description))
elif self.task == "modify":
pipeline = QGPTTaskPipeline(code_modification=QGPTTaskPipelineForCodeModification(instruction=self.description))
elif self.task == "comment":
pipeline = QGPTTaskPipeline(code_commentation=QGPTTaskPipelineForCodeCommentation())
task = QGPTTaskPipeline(code_modification=QGPTTaskPipelineForCodeModification(instruction=self._description))
else: # comment
task = QGPTTaskPipeline(code_commentation=QGPTTaskPipelineForCodeCommentation())

self.view.set_status('Pieces Refactoring', 'Copilot is thinking...')

Expand All @@ -105,6 +105,7 @@ def on_done_async(self):
)
]
)
pipeline = QGPTPromptPipeline(task=task)
try:
res = PiecesSettings.api_client.copilot.question(" ",relevant,pipeline)
except:
Expand Down Expand Up @@ -153,6 +154,7 @@ def run(self, edit, code, selection):
use_spaces = settings.get('translate_tabs_to_spaces')
tab_size = settings.get('tab_size', 4)


# Get the current indentation level of the selected region
current_line_region = self.view.line(region.begin())
current_line_text = self.view.substr(current_line_region)
Expand Down
33 changes: 17 additions & 16 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ._pieces_lib.pieces_os_client import SeededConnectorConnection,SeededTrackedApplication
from ._pieces_lib.pieces_os_client.wrapper.websockets.base_websocket import BaseWebsocket
from ._pieces_lib.pieces_os_client.wrapper import PiecesClient
from ._pieces_lib import notify
from ._pieces_lib import notify as notification
from multiprocessing.pool import ThreadPool
import sublime
import os
Expand Down Expand Up @@ -114,23 +114,24 @@ def pool(cls):
def notify(title,message,level="info"):
try:
if level == "error":
notify.error(title, message, False)
notification.error(title, message, False)
elif level == "warning":
notify.warning(title, message, False)
notification.warning(title, message, False)
else:
notify.info(title, message, False)
notify.destroy()
notification.info(title, message, False)
notification.destroy()
except:
pass
if PiecesSettings.api_client.local_os == "MACOS":
os_icon = "pieces_server.icns"
elif PiecesSettings.api_client.local_os == "WINDOWS":
os_icon = "pieces_server.ico"
else:
os_icon = "pieces_server.png"

package_path = os.path.join(sublime.packages_path(),"Pieces") if debug else os.path.join(sublime.installed_packages_path(),"Pieces.sublime-package")
path = os.path.join(package_path,"icons", os_icon) if os_icon else None
os_icon = path
notify.setup_notifications("Pieces for Sublime Text",os_icon,sender=None)

if api_client.local_os == "MACOS":
os_icon = "pieces_server.icns"
elif api_client.local_os == "WINDOWS":
os_icon = "pieces_server.ico"
else:
os_icon = "pieces_server.png"

package_path = os.path.join(sublime.packages_path(),"Pieces") if debug else os.path.join(sublime.installed_packages_path(),"Pieces.sublime-package")
path = os.path.join(package_path,"icons", os_icon) if os_icon else None
os_icon = path
notification.setup_notifications("Pieces for Sublime Text",os_icon,sender=None)

0 comments on commit 2c19bb8

Please sign in to comment.