Skip to content

Commit 006af2f

Browse files
committed
#126: A more rigorous way to prevent confirmations from being recorded in the prompt history
1 parent 89d9169 commit 006af2f

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

aider/io.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def without_input_history(func):
9494
"""Decorator to temporarily disable history saving for the prompt session buffer."""
9595

9696
@functools.wraps(func)
97-
def wrapper(self, *args, **kwargs):
97+
async def wrapper(self, *args, **kwargs):
9898
orig_buf_append = None
9999
try:
100100
orig_buf_append = self.prompt_session.default_buffer.append_to_history
@@ -105,7 +105,7 @@ def wrapper(self, *args, **kwargs):
105105
pass
106106

107107
try:
108-
return func(self, *args, **kwargs)
108+
return await func(self, *args, **kwargs)
109109
except Exception:
110110
raise
111111
finally:
@@ -413,7 +413,6 @@ def __init__(
413413
self.dry_run = dry_run
414414

415415
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
416-
self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
417416

418417
self.is_dumb_terminal = is_dumb_terminal()
419418
self.is_tty = sys.stdout.isatty()
@@ -478,6 +477,7 @@ def __init__(
478477

479478
# Validate color settings after console is initialized
480479
self._validate_color_settings()
480+
self.append_chat_history(f"\n# aider chat started at {current_time}\n\n")
481481

482482
def _spinner_supports_unicode(self) -> bool:
483483
if not self.is_tty:
@@ -1012,6 +1012,13 @@ def user_input(self, inp, log_only=True):
10121012
if not log_only:
10131013
self.display_user_input(inp)
10141014

1015+
if (
1016+
len(inp) <= 1
1017+
or self.confirmation_in_progress
1018+
or self.get_confirmation_acknowledgement()
1019+
):
1020+
return
1021+
10151022
prefix = "####"
10161023
if inp:
10171024
hist = inp.splitlines()
@@ -1055,6 +1062,7 @@ def acknowledge_confirmation(self):
10551062
return outstanding_confirmation
10561063

10571064
@restore_multiline_async
1065+
@without_input_history
10581066
async def confirm_ask(
10591067
self,
10601068
*args,
@@ -1482,6 +1490,9 @@ def toggle_multiline_mode(self):
14821490
)
14831491

14841492
def append_chat_history(self, text, linebreak=False, blockquote=False, strip=True):
1493+
if self.confirmation_in_progress or self.get_confirmation_acknowledgement():
1494+
return
1495+
14851496
if blockquote:
14861497
if strip:
14871498
text = text.strip()

0 commit comments

Comments
 (0)