From 168a1d070dd5b8d2a6a61cf75fd7decda50d58f8 Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Mon, 5 Aug 2024 17:44:30 -0300 Subject: [PATCH] feat: add delay before showing spinner and text --- aider/io.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/aider/io.py b/aider/io.py index a6ad16a07..5d656bccb 100644 --- a/aider/io.py +++ b/aider/io.py @@ -27,21 +27,26 @@ class Spinner: def __init__(self, io, text): self.io = io self.text = text + self.start_time = time.time() self.last_update = 0 - self._step() + self.visible = False def step(self): current_time = time.time() - if current_time - self.last_update >= 0.1: + if not self.visible and current_time - self.start_time >= 0.5: + self.visible = True self._step() - self.last_update = current_time + elif self.visible and current_time - self.last_update >= 0.1: + self._step() + self.last_update = current_time def _step(self): - print(f" {self.text} {next(self.io.spinner_chars)}", end="\r", flush=True) + if self.visible: + print(f" {self.text} {next(self.io.spinner_chars)}", end="\r", flush=True) def end(self): - # traceback.print_stack() - print(" " * (len(self.text) + 3)) + if self.visible: + print(" " * (len(self.text) + 3)) class AutoCompleter(Completer):