mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-08 05:34:59 +00:00
better live output of multi file edits
This commit is contained in:
parent
f187cf0346
commit
f9086e66d3
3 changed files with 27 additions and 14 deletions
|
@ -527,19 +527,23 @@ class Coder:
|
|||
continue
|
||||
|
||||
if self.pretty:
|
||||
show_resp = self.modify_incremental_response()
|
||||
if show_resp:
|
||||
md = Markdown(
|
||||
show_resp, style=self.assistant_output_color, code_theme="default"
|
||||
)
|
||||
live.update(md)
|
||||
self.live_incremental_response(live, False)
|
||||
else:
|
||||
sys.stdout.write(text)
|
||||
sys.stdout.flush()
|
||||
finally:
|
||||
self.live_incremental_response(live, True)
|
||||
if live:
|
||||
live.stop()
|
||||
|
||||
def live_incremental_response(self, live, final):
|
||||
show_resp = self.modify_incremental_response(final)
|
||||
if not show_resp:
|
||||
return
|
||||
|
||||
md = Markdown(show_resp, style=self.assistant_output_color, code_theme="default")
|
||||
live.update(md)
|
||||
|
||||
def modify_incremental_response(self):
|
||||
return self.partial_response_content
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class FunctionCoder(Coder):
|
|||
else:
|
||||
self.cur_messages += [dict(role="assistant", content=content)]
|
||||
|
||||
def modify_incremental_response(self):
|
||||
def modify_incremental_response(self, final=False):
|
||||
args = self.parse_partial_args()
|
||||
|
||||
if not args:
|
||||
|
@ -70,7 +70,7 @@ class FunctionCoder(Coder):
|
|||
if explanation:
|
||||
res += f"{explanation}\n\n"
|
||||
|
||||
for file_upd in files:
|
||||
for i, file_upd in enumerate(files):
|
||||
path = file_upd.get("path")
|
||||
if not path:
|
||||
continue
|
||||
|
@ -79,11 +79,13 @@ class FunctionCoder(Coder):
|
|||
continue
|
||||
|
||||
res += path + ":\n"
|
||||
res += self.live_diffs(path, content)
|
||||
|
||||
this_final = (i < len(files) - 1) or final
|
||||
res += self.live_diffs(path, content, this_final)
|
||||
|
||||
return res
|
||||
|
||||
def live_diffs(self, fname, content):
|
||||
def live_diffs(self, fname, content, final):
|
||||
lines = content.splitlines(keepends=True)
|
||||
|
||||
# ending an existing block
|
||||
|
@ -95,7 +97,7 @@ class FunctionCoder(Coder):
|
|||
show_diff = diffs.diff_partial_update(
|
||||
orig_lines,
|
||||
lines,
|
||||
final=True,
|
||||
final,
|
||||
).splitlines()
|
||||
|
||||
return "\n".join(show_diff)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue