Improve commit message display for /undo command

This commit is contained in:
Paul Gauthier 2024-07-29 10:55:42 -03:00 committed by Paul Gauthier (aider)
parent 93a48e5a4c
commit 8543a97e76

View file

@ -1264,7 +1264,7 @@ class Coder:
if self.main_model.info.get("output_cost_per_token"): if self.main_model.info.get("output_cost_per_token"):
cost += completion_tokens * self.main_model.info.get("output_cost_per_token") cost += completion_tokens * self.main_model.info.get("output_cost_per_token")
self.total_cost += cost self.total_cost += cost
def format_cost(value): def format_cost(value):
if value == 0: if value == 0:
return "0.00" return "0.00"
@ -1273,7 +1273,7 @@ class Coder:
return f"{value:.2f}" return f"{value:.2f}"
else: else:
return f"{value:.{max(2, 2 - int(math.log10(magnitude)))}f}" return f"{value:.{max(2, 2 - int(math.log10(magnitude)))}f}"
self.usage_report += f" Cost: ${format_cost(cost)} request, ${format_cost(self.total_cost)} session." self.usage_report += f" Cost: ${format_cost(cost)} request, ${format_cost(self.total_cost)} session."
def get_multi_response_content(self, final=False): def get_multi_response_content(self, final=False):
@ -1520,7 +1520,7 @@ class Coder:
if self.show_diffs: if self.show_diffs:
self.commands.cmd_diff() self.commands.cmd_diff()
self.io.tool_output("You can use /undo to revert and discard the committed changes.") self.io.tool_output(f"You can use /undo to revert and discard commit {commit_hash}.")
return self.gpt_prompts.files_content_gpt_edits.format( return self.gpt_prompts.files_content_gpt_edits.format(
hash=commit_hash, hash=commit_hash,
message=commit_message, message=commit_message,