diff --git a/assets/settings/default.json b/assets/settings/default.json index 924b97008482e7f739b642b1730beaa9a60e6e22..203c90f8ff46410366fee07bde8c0e04cec4a290 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -857,7 +857,11 @@ // its response, or needs user input. // Default: false - "play_sound_when_agent_done": false + "play_sound_when_agent_done": false, + /// Whether to have edit cards in the agent panel expanded, showing a preview of the full diff. + /// + /// Default: true + "expand_edit_card": true }, // The settings for slash commands. "slash_commands": { diff --git a/crates/agent_settings/src/agent_settings.rs b/crates/agent_settings/src/agent_settings.rs index f3087765de072f2043fb7f87fd8369a2eab39d25..30cd2552efb1db06d3d990913a743429f4a95864 100644 --- a/crates/agent_settings/src/agent_settings.rs +++ b/crates/agent_settings/src/agent_settings.rs @@ -67,6 +67,7 @@ pub struct AgentSettings { pub model_parameters: Vec, pub preferred_completion_mode: CompletionMode, pub enable_feedback: bool, + pub expand_edit_card: bool, } impl AgentSettings { @@ -291,6 +292,10 @@ pub struct AgentSettingsContent { /// /// Default: true enable_feedback: Option, + /// Whether to have edit cards in the agent panel expanded, showing a preview of the full diff. + /// + /// Default: true + expand_edit_card: Option, } #[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Default)] @@ -441,6 +446,7 @@ impl Settings for AgentSettings { value.preferred_completion_mode, ); merge(&mut settings.enable_feedback, value.enable_feedback); + merge(&mut settings.expand_edit_card, value.expand_edit_card); settings .model_parameters diff --git a/crates/assistant_tools/src/edit_file_tool.rs b/crates/assistant_tools/src/edit_file_tool.rs index 8c7728b4b72c9aa52c717e58fbdd63591dd88f0f..baf62c11f26cbefd0fcaecc6c99b0ebb71e42c93 100644 --- a/crates/assistant_tools/src/edit_file_tool.rs +++ b/crates/assistant_tools/src/edit_file_tool.rs @@ -4,6 +4,7 @@ use crate::{ schema::json_schema_for, ui::{COLLAPSED_LINES, ToolOutputPreview}, }; +use agent_settings; use anyhow::{Context as _, Result, anyhow}; use assistant_tool::{ ActionLog, AnyToolCard, Tool, ToolCard, ToolResult, ToolResultContent, ToolResultOutput, @@ -14,7 +15,7 @@ use editor::{Editor, EditorMode, MinimapVisibility, MultiBuffer, PathKey}; use futures::StreamExt; use gpui::{ Animation, AnimationExt, AnyWindowHandle, App, AppContext, AsyncApp, Entity, Task, - TextStyleRefinement, WeakEntity, pulsating_between, px, + TextStyleRefinement, Transformation, WeakEntity, percentage, pulsating_between, px, }; use indoc::formatdoc; use language::{ @@ -515,7 +516,9 @@ pub struct EditFileToolCard { impl EditFileToolCard { pub fn new(path: PathBuf, project: Entity, window: &mut Window, cx: &mut App) -> Self { + let expand_edit_card = agent_settings::AgentSettings::get_global(cx).expand_edit_card; let multibuffer = cx.new(|_| MultiBuffer::without_headers(Capability::ReadOnly)); + let editor = cx.new(|cx| { let mut editor = Editor::new( EditorMode::Full { @@ -556,7 +559,7 @@ impl EditFileToolCard { diff_task: None, preview_expanded: true, error_expanded: None, - full_height_expanded: true, + full_height_expanded: expand_edit_card, total_lines: None, } } @@ -755,6 +758,13 @@ impl ToolCard for EditFileToolCard { _ => None, }; + let running_or_pending = match status { + ToolUseStatus::Running | ToolUseStatus::Pending => Some(()), + _ => None, + }; + + let should_show_loading = running_or_pending.is_some() && !self.full_height_expanded; + let path_label_button = h_flex() .id(("edit-tool-path-label-button", self.editor.entity_id())) .w_full() @@ -863,6 +873,18 @@ impl ToolCard for EditFileToolCard { header.bg(codeblock_header_bg) }) .child(path_label_button) + .when(should_show_loading, |header| { + header.pr_1p5().child( + Icon::new(IconName::ArrowCircle) + .size(IconSize::XSmall) + .color(Color::Info) + .with_animation( + "arrow-circle", + Animation::new(Duration::from_secs(2)).repeat(), + |icon, delta| icon.transform(Transformation::rotate(percentage(delta))), + ), + ) + }) .when_some(error_message, |header, error_message| { header.child( h_flex() diff --git a/docs/src/ai/configuration.md b/docs/src/ai/configuration.md index 5c49cde598a71a3592bf96c2660dc4b31dfa8c30..e65433afe5420aa4dc2abf18d87cb7a3b991e0c6 100644 --- a/docs/src/ai/configuration.md +++ b/docs/src/ai/configuration.md @@ -646,3 +646,19 @@ You can choose between `thread` (the default) and `text_thread`: } } ``` + +### Edit Card + +Use the `expand_edit_card` setting to control whether edit cards show the full diff in the Agent Panel. +It is set to `true` by default, but if set to false, the card's height is capped to a certain number of lines, requiring a click to be expanded. + +```json +{ + "agent": { + "expand_edit_card": "false" + } +} +``` + +This setting is currently only available in Preview. +It should be up in Stable by the next release.