fix: Improve confirm dialog messages

This commit is contained in:
Paul Gauthier 2024-08-21 05:38:13 -07:00 committed by Paul Gauthier (aider)
parent 72ebc7868a
commit ba746dd211
5 changed files with 14 additions and 20 deletions

View file

@ -826,7 +826,7 @@ class Coder:
added_urls = []
for url in urls:
if url not in self.rejected_urls:
if self.io.confirm_ask(f"Add {url} to the chat?"):
if self.io.confirm_ask(f"Add URL to the chat?", subject=url):
inp += "\n\n"
inp += self.commands.cmd_web(url, paginate=False)
added_urls.append(url)
@ -1315,10 +1315,8 @@ class Coder:
if not mentioned_rel_fnames:
return
for rel_fname in mentioned_rel_fnames:
self.io.tool_output(rel_fname)
if not self.io.confirm_ask("Add these files to the chat?"):
add_files = "\n".join(mentioned_rel_fnames) + "\n"
if not self.io.confirm_ask("Add these files to the chat?", subject=add_files):
return
for rel_fname in mentioned_rel_fnames:
@ -1663,7 +1661,7 @@ class Coder:
return True
if not Path(full_path).exists():
if not self.io.confirm_ask(f"Allow creation of new file {path}?"):
if not self.io.confirm_ask(f"Allow creation of new file?", subject=path):
self.io.tool_error(f"Skipping edits to {path}")
return
@ -1682,7 +1680,8 @@ class Coder:
return True
if not self.io.confirm_ask(
f"Allow edits to {path} which was not previously added to chat?"
"Allow edits to file that has not been added to the chat?",
subject=path,
):
self.io.tool_error(f"Skipping edits to {path}")
return

View file

@ -46,9 +46,8 @@ class EditBlockCoder(Coder):
if edit[0] is None:
edit = edit[1]
# This is a shell command
self.io.tool_output()
self.io.tool_output(f"{edit.strip()}", bold=True)
if self.io.confirm_ask("Do you want to run this suggested shell command?"):
if self.io.confirm_ask("Run this shell command?", subject=edit.strip()):
self.io.tool_output()
try:
# Add the command to input history
self.io.add_to_input_history(f"/run {edit.strip()}")

View file

@ -357,6 +357,7 @@ class InputOutput:
self.num_user_asks += 1
if subject:
self.tool_output()
self.tool_output(subject, bold=True)
if self.yes is True:
@ -378,6 +379,7 @@ class InputOutput:
self.num_user_asks += 1
if subject:
self.tool_output()
self.tool_output(subject, bold=True)
if self.yes is True:

View file

@ -281,10 +281,8 @@ def check_pip_install_extra(io, module, prompt, pip_install_cmd):
cmd = get_pip_install(pip_install_cmd)
text = f"{prompt}:\n\n{' '.join(cmd)}\n"
io.tool_error(text)
if not io.confirm_ask("Run pip install?", default="y"):
io.tool_error(prompt)
if not io.confirm_ask("Run pip install?", default="y", subject=' '.join(cmd)):
return
success, output = run_install(cmd)

View file

@ -68,14 +68,10 @@ Newer aider version v{latest_version} is available. To upgrade, run:
cmd = utils.get_pip_install(["--upgrade", "aider-chat"])
text = f"""
Newer aider version v{latest_version} is available. To upgrade, run:
text = f"Newer aider version v{latest_version} is available. To upgrade, run:"
{' '.join(cmd)}
"""
io.tool_error(text)
if io.confirm_ask("Run pip install?"):
if io.confirm_ask("Run pip install?", subject=' '.join(cmd)):
success, output = utils.run_install(cmd)
if success:
io.tool_output("Re-run aider to use new version.")