History

acp: Allow permissions on existing terminal tool calls (#49270)

It is possible, when the agent is streaming the tool call, that we will get a permission request on an existing terminal and we need to render that. When Zed controls the terminal this won't happen, but when we are just rendering the output, it can happen and we need to show it. Release Notes: - agent: Fix permission options not rendering on terminal commands

Ben Brandt committed 9 months ago

Commit c5bfa931 parent 323b5791 file · +15 −1Browse files

Unified · Split

crates/agent_ui/src/acp/thread_view/active_thread.rs+15−1
@@ -4479,6 +4479,12 @@ impl AcpThreadView { · 4478 unmodified lines
44794479 ToolCallStatus::Rejected | ToolCallStatus::Canceled | ToolCallStatus::Failed
44804480 );
44814481
4482+ let confirmation_options = match &tool_call.status {
4483+ ToolCallStatus::WaitingForConfirmation { options, .. } => Some(options),
4484+ _ => None,
4485+ };
4486+ let needs_confirmation = confirmation_options.is_some();
4487+
44824488 let output = terminal_data.output();
44834489 let command_finished = output.is_some();
44844490 let truncated_output =
@@ -4547,7 +4553,7 @@ impl AcpThreadView { · 62 unmodified lines
45474553 .color(Color::Muted),
45484554 ),
45494555 )
4550− .when(!command_finished, |header| {
4556+ .when(!command_finished && !needs_confirmation, |header| {
45514557 header
45524558 .gap_1p5()
45534559 .child(
@@ -4725,6 +4731,14 @@ impl AcpThreadView { · 171 unmodified lines
47254731 })),
47264732 )
47274733 })
4734+ .when_some(confirmation_options, |this, options| {
4735+ this.child(self.render_permission_buttons(
4736+ options,
4737+ entry_ix,
4738+ tool_call.id.clone(),
4739+ cx,
4740+ ))
4741+ })
47284742 .into_any()
47294743 }
47304744