Delay rendering tool call diff editor until it has a revealed range (#35901)

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-08-11 12:49:46 -04:00 committed by GitHub
parent 7965052757
commit 42bf5a17b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 13 deletions

View file

@ -174,6 +174,10 @@ impl Diff {
buffer_text
)
}
pub fn has_revealed_range(&self, cx: &App) -> bool {
self.multibuffer().read(cx).excerpt_paths().next().is_some()
}
}
pub struct PendingDiff {

View file

@ -1153,16 +1153,25 @@ impl AcpThreadView {
),
};
let needs_confirmation = match &tool_call.status {
ToolCallStatus::WaitingForConfirmation { .. } => true,
_ => tool_call
.content
.iter()
.any(|content| matches!(content, ToolCallContent::Diff(_))),
};
let is_collapsible = !tool_call.content.is_empty() && !needs_confirmation;
let is_open = !is_collapsible || self.expanded_tool_calls.contains(&tool_call.id);
let needs_confirmation = matches!(
tool_call.status,
ToolCallStatus::WaitingForConfirmation { .. }
);
let is_edit = matches!(tool_call.kind, acp::ToolKind::Edit);
let has_diff = tool_call
.content
.iter()
.any(|content| matches!(content, ToolCallContent::Diff { .. }));
let has_nonempty_diff = tool_call.content.iter().any(|content| match content {
ToolCallContent::Diff(diff) => diff.read(cx).has_revealed_range(cx),
_ => false,
});
let is_collapsible =
!tool_call.content.is_empty() && !needs_confirmation && !is_edit && !has_diff;
let is_open = tool_call.content.is_empty()
|| needs_confirmation
|| has_nonempty_diff
|| self.expanded_tool_calls.contains(&tool_call.id);
let gradient_color = cx.theme().colors().panel_background;
let gradient_overlay = {
@ -1180,7 +1189,7 @@ impl AcpThreadView {
};
v_flex()
.when(needs_confirmation, |this| {
.when(needs_confirmation || is_edit || has_diff, |this| {
this.rounded_lg()
.border_1()
.border_color(self.tool_card_border_color(cx))
@ -1194,7 +1203,7 @@ impl AcpThreadView {
.gap_1()
.justify_between()
.map(|this| {
if needs_confirmation {
if needs_confirmation || is_edit || has_diff {
this.pl_2()
.pr_1()
.py_1()
@ -1271,7 +1280,7 @@ impl AcpThreadView {
.child(self.render_markdown(
tool_call.label.clone(),
default_markdown_style(
needs_confirmation,
needs_confirmation || is_edit || has_diff,
window,
cx,
),