Refactor ToolCallStatus enum to flat variants (#36356)

Replace nested Allowed variant with distinct statuses for clearer status
handling.

Release Notes:

- N/A
This commit is contained in:
Ben Brandt 2025-08-17 15:05:23 +02:00 committed by GitHub
parent da8a692ec0
commit 5895fac377
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 72 additions and 70 deletions

View file

@ -1053,14 +1053,10 @@ impl AcpThreadView {
let card_header_id = SharedString::from("inner-tool-call-header");
let status_icon = match &tool_call.status {
ToolCallStatus::Allowed {
status: acp::ToolCallStatus::Pending,
}
| ToolCallStatus::WaitingForConfirmation { .. } => None,
ToolCallStatus::Allowed {
status: acp::ToolCallStatus::InProgress,
..
} => Some(
ToolCallStatus::Pending
| ToolCallStatus::WaitingForConfirmation { .. }
| ToolCallStatus::Completed => None,
ToolCallStatus::InProgress => Some(
Icon::new(IconName::ArrowCircle)
.color(Color::Accent)
.size(IconSize::Small)
@ -1071,16 +1067,7 @@ impl AcpThreadView {
)
.into_any(),
),
ToolCallStatus::Allowed {
status: acp::ToolCallStatus::Completed,
..
} => None,
ToolCallStatus::Rejected
| ToolCallStatus::Canceled
| ToolCallStatus::Allowed {
status: acp::ToolCallStatus::Failed,
..
} => Some(
ToolCallStatus::Rejected | ToolCallStatus::Canceled | ToolCallStatus::Failed => Some(
Icon::new(IconName::Close)
.color(Color::Error)
.size(IconSize::Small)
@ -1146,15 +1133,23 @@ impl AcpThreadView {
tool_call.content.is_empty(),
cx,
)),
ToolCallStatus::Allowed { .. } | ToolCallStatus::Canceled => v_flex()
.w_full()
.children(tool_call.content.iter().map(|content| {
div()
.child(
self.render_tool_call_content(entry_ix, content, tool_call, window, cx),
)
.into_any_element()
})),
ToolCallStatus::Pending
| ToolCallStatus::InProgress
| ToolCallStatus::Completed
| ToolCallStatus::Failed
| ToolCallStatus::Canceled => {
v_flex()
.w_full()
.children(tool_call.content.iter().map(|content| {
div()
.child(
self.render_tool_call_content(
entry_ix, content, tool_call, window, cx,
),
)
.into_any_element()
}))
}
ToolCallStatus::Rejected => v_flex().size_0(),
};
@ -1467,12 +1462,7 @@ impl AcpThreadView {
let tool_failed = matches!(
&tool_call.status,
ToolCallStatus::Rejected
| ToolCallStatus::Canceled
| ToolCallStatus::Allowed {
status: acp::ToolCallStatus::Failed,
..
}
ToolCallStatus::Rejected | ToolCallStatus::Canceled | ToolCallStatus::Failed
);
let output = terminal_data.output();