mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
fix: Add ConfirmGroup to confirm URL addition
This commit is contained in:
parent
47294e7609
commit
b26550d93f
2 changed files with 10 additions and 4 deletions
|
@ -25,7 +25,7 @@ from rich.markdown import Markdown
|
|||
from aider import __version__, models, prompts, urls, utils
|
||||
from aider.commands import Commands
|
||||
from aider.history import ChatSummary
|
||||
from aider.io import InputOutput
|
||||
from aider.io import ConfirmGroup, InputOutput
|
||||
from aider.linter import Linter
|
||||
from aider.llm import litellm
|
||||
from aider.mdstream import MarkdownStream
|
||||
|
@ -771,9 +771,10 @@ class Coder:
|
|||
url_pattern = re.compile(r"(https?://[^\s/$.?#].[^\s]*[^\s,.])")
|
||||
urls = list(set(url_pattern.findall(inp))) # Use set to remove duplicates
|
||||
added_urls = []
|
||||
group = ConfirmGroup(urls)
|
||||
for url in urls:
|
||||
if url not in self.rejected_urls:
|
||||
if self.io.confirm_ask("Add URL to the chat?", subject=url):
|
||||
if self.io.confirm_ask("Add URL to the chat?", subject=url, group=group):
|
||||
inp += "\n\n"
|
||||
inp += self.commands.cmd_web(url, paginate=False)
|
||||
added_urls.append(url)
|
||||
|
|
|
@ -30,8 +30,9 @@ class ConfirmGroup:
|
|||
preference: str = None
|
||||
show_group: bool = True
|
||||
|
||||
def __init__(self, items):
|
||||
self.show_group = len(items) > 1
|
||||
def __init__(self, items=None):
|
||||
if items is not None:
|
||||
self.show_group = len(items) > 1
|
||||
|
||||
|
||||
class AutoCompleter(Completer):
|
||||
|
@ -383,6 +384,9 @@ class InputOutput:
|
|||
):
|
||||
self.num_user_asks += 1
|
||||
|
||||
if group and not group.show_group:
|
||||
group = None
|
||||
|
||||
valid_responses = "yn"
|
||||
options = " (Y)es/(N)o"
|
||||
if group:
|
||||
|
@ -427,6 +431,7 @@ class InputOutput:
|
|||
res = "n"
|
||||
elif group and group.preference:
|
||||
res = group.preference
|
||||
self.user_input(f"{question}{res}", log_only=False)
|
||||
else:
|
||||
res = prompt(
|
||||
question,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue