Skip to content
Merged
673 changes: 458 additions & 215 deletions crates/agent_ui/src/agent_panel.rs

Large diffs are not rendered by default.

37 changes: 33 additions & 4 deletions crates/agent_ui/src/agent_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ mod terminal_codegen;
mod terminal_inline_assistant;
#[cfg(any(test, feature = "test-support"))]
pub mod test_support;
mod thread_branch_picker;
mod thread_history;
mod thread_history_view;
mod thread_import;
pub mod thread_metadata_store;
mod thread_worktree_picker;
pub mod threads_archive_view;
mod ui;

use std::path::PathBuf;
use std::rc::Rc;
use std::sync::Arc;

Expand Down Expand Up @@ -314,16 +317,42 @@ impl Agent {
}
}

/// Describes which branch to use when creating a new git worktree.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case", tag = "kind")]
pub enum NewWorktreeBranchTarget {
/// Create a new randomly named branch from the current HEAD.
/// Will match worktree name if the newly created worktree was also randomly named.
#[default]
CurrentBranch,
/// Check out an existing branch, or create a new branch from it if it's
/// already occupied by another worktree.
ExistingBranch { name: String },
/// Create a new branch with an explicit name, optionally from a specific ref.
CreateBranch {
name: String,
#[serde(default)]
from_ref: Option<String>,
},
}

/// Sets where new threads will run.
#[derive(
Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Action,
)]
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Action)]
#[action(namespace = agent)]
#[serde(rename_all = "snake_case", tag = "kind")]
pub enum StartThreadIn {
#[default]
LocalProject,
NewWorktree,
NewWorktree {
/// When this is None, Zed will randomly generate a worktree name
/// otherwise, the provided name will be used.
#[serde(default)]
worktree_name: Option<String>,
#[serde(default)]
branch_target: NewWorktreeBranchTarget,
},
/// A linked worktree that already exists on disk.
LinkedWorktree { path: PathBuf, display_name: String },
}

/// Content to initialize new external agent with.
Expand Down
5 changes: 4 additions & 1 deletion crates/agent_ui/src/conversation_view/thread_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,10 @@ impl ThreadView {
.upgrade()
.and_then(|workspace| workspace.read(cx).panel::<AgentPanel>(cx))
.is_some_and(|panel| {
panel.read(cx).start_thread_in() == &StartThreadIn::NewWorktree
!matches!(
panel.read(cx).start_thread_in(),
StartThreadIn::LocalProject
)
});

if intercept_first_send {
Expand Down
Loading
Loading