agent_ui: Refactor in preparation for subagent permission work (#47874)

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: MrSubidubi <dev@bahn.sh>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-01-29 10:53:53 +00:00
1 parent b7e11b38f4
commit 4c8b699f03
8 files changed
+2476 -1412

No files matched your search

+14
View File
@@ -302,6 +302,20 @@ impl MessageEditor {
}
}
pub fn set_command_state(
&mut self,
prompt_capabilities: Rc<RefCell<acp::PromptCapabilities>>,
available_commands: Rc<RefCell<Vec<acp::AvailableCommand>>>,
cached_user_commands: Rc<RefCell<collections::HashMap<String, UserSlashCommand>>>,
cached_user_command_errors: Rc<RefCell<Vec<CommandLoadError>>>,
_cx: &mut Context<Self>,
) {
self.prompt_capabilities = prompt_capabilities;
self.available_commands = available_commands;
self.cached_user_commands = cached_user_commands;
self.cached_user_command_errors = cached_user_command_errors;
}
fn command_hint(&self, snapshot: &MultiBufferSnapshot) -> Option<Inlay> {
let available_commands = self.available_commands.borrow();
if available_commands.is_empty() {
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+15 -5
View File
@@ -149,7 +149,12 @@ pub fn init(cx: &mut App) {
let thread = workspace
.panel::<AgentPanel>(cx)
.and_then(|panel| panel.read(cx).active_thread_view().cloned())
.and_then(|thread_view| thread_view.read(cx).thread().cloned());
.and_then(|thread_view| {
thread_view
.read(cx)
.as_active_thread()
.map(|r| r.thread.clone())
});
if let Some(thread) = thread {
AgentDiffPane::deploy_in_workspace(thread, workspace, window, cx);
@@ -1221,9 +1226,10 @@ impl AgentPanel {
pub(crate) fn active_agent_thread(&self, cx: &App) -> Option<Entity<AcpThread>> {
match &self.active_view {
ActiveView::ExternalAgentThread { thread_view, .. } => {
thread_view.read(cx).thread().cloned()
}
ActiveView::ExternalAgentThread { thread_view, .. } => thread_view
.read(cx)
.as_active_thread()
.map(|r| r.thread.clone()),
_ => None,
}
}
@@ -1638,7 +1644,11 @@ impl AgentPanel {
.as_native_thread(cx)
.map_or(false, |t| t.read(cx).is_generating_title());
if let Some(title_editor) = thread_view.read(cx).title_editor() {
if let Some(title_editor) = thread_view
.read(cx)
.as_active_thread()
.and_then(|ready| ready.title_editor.clone())
{
let container = div()
.w_full()
.on_action({
+1 -1
View File
@@ -237,7 +237,7 @@ enum ProfilePickerEntry {
Profile(ProfileMatchEntry),
}
pub(crate) struct ProfilePickerDelegate {
pub struct ProfilePickerDelegate {
fs: Arc<dyn Fs>,
provider: Arc<dyn ProfileProvider>,
foreground: ForegroundExecutor,
+2 -2
View File
@@ -142,8 +142,8 @@ impl AgentThreadPane {
fn title(&self, cx: &App) -> SharedString {
if let Some(active_thread_view) = &self.thread_view {
let thread_view = active_thread_view.view.read(cx);
if let Some(thread) = thread_view.thread() {
let title = thread.read(cx).title();
if let Some(ready) = thread_view.as_active_thread() {
let title = ready.thread.read(cx).title();
if !title.is_empty() {
return title;
}
+4 -5
View File
@@ -2011,7 +2011,7 @@ impl Interactivity {
origin: hitbox.origin,
size: text.size(FONT_SIZE),
};
if self.source_location.is_some()
if let Some(source_location) = self.source_location
&& text_bounds.contains(&window.mouse_position())
&& window.modifiers().secondary()
{
@@ -2042,7 +2042,6 @@ impl Interactivity {
window.on_mouse_event({
let hitbox = hitbox.clone();
let location = self.source_location.unwrap();
move |e: &crate::MouseDownEvent, phase, window, cx| {
if text_bounds.contains(&e.position)
&& phase.capture()
@@ -2055,9 +2054,9 @@ impl Interactivity {
eprintln!(
"This element was created at:\n{}:{}:{}",
dir.join(location.file()).to_string_lossy(),
location.line(),
location.column()
dir.join(source_location.file()).to_string_lossy(),
source_location.line(),
source_location.column()
);
}
}
+12 -2
View File
@@ -1806,7 +1806,12 @@ fn run_subagent_visual_tests(
.ok_or_else(|| anyhow::anyhow!("No active thread view"))?;
let thread = cx
.read(|cx| thread_view.read(cx).thread().cloned())
.read(|cx| {
thread_view
.read(cx)
.as_active_thread()
.map(|active| active.thread.clone())
})
.ok_or_else(|| anyhow::anyhow!("Thread not available"))?;
// Send the message to trigger the subagent response
@@ -2211,7 +2216,12 @@ fn run_agent_thread_view_test(
.ok_or_else(|| anyhow::anyhow!("No active thread view"))?;
let thread = cx
.read(|cx| thread_view.read(cx).thread().cloned())
.read(|cx| {
thread_view
.read(cx)
.as_active_thread()
.map(|active| active.thread.clone())
})
.ok_or_else(|| anyhow::anyhow!("Thread not available"))?;
// Send the message to trigger the image response