feat: replace synchronous HTTP calls with async client and add background task tracking

This commit is contained in:
2025-11-06 15:44:41 +00:00
parent 99d7ec53d5
commit e018cff131
19 changed files with 531 additions and 1771 deletions
+2 -1
View File
@@ -1,9 +1,10 @@
from pr.ui.colors import Colors
from pr.ui.colors import Colors, Spinner
from pr.ui.display import display_tool_call, print_autonomous_header
from pr.ui.rendering import highlight_code, render_markdown
__all__ = [
"Colors",
"Spinner",
"highlight_code",
"render_markdown",
"display_tool_call",
+30
View File
@@ -1,3 +1,6 @@
import asyncio
class Colors:
RESET = "\033[0m"
BOLD = "\033[1m"
@@ -12,3 +15,30 @@ class Colors:
BG_BLUE = "\033[44m"
BG_GREEN = "\033[42m"
BG_RED = "\033[41m"
class Spinner:
def __init__(self, message="Processing...", spinner_chars="|/-\\"):
self.message = message
self.spinner_chars = spinner_chars
self.running = False
self.task = None
async def start(self):
self.running = True
self.task = asyncio.create_task(self._spin())
async def stop(self):
self.running = False
if self.task:
await self.task
# Clear the line
print("\r" + " " * (len(self.message) + 2) + "\r", end="", flush=True)
async def _spin(self):
i = 0
while self.running:
char = self.spinner_chars[i % len(self.spinner_chars)]
print(f"\r{Colors.CYAN}{char}{Colors.RESET} {self.message}", end="", flush=True)
i += 1
await asyncio.sleep(0.1)