Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent_ui: Ensure message editor placeholder text is accurate (#42375)
Danilo Leal2c375e2e0a31
diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/acp/message_editor.rsindex 7789564d3b8..4f919a6c042 100644--- a/crates/agent_ui/src/acp/message_editor.rs+++ b/crates/agent_ui/src/acp/message_editor.rs@@ -1195,6 +1195,17 @@ impl MessageEditor {self.editor.read(cx).text(cx)}+ pub fn set_placeholder_text(+ &mut self,+ placeholder: &str,+ window: &mut Window,+ cx: &mut Context<Self>,+ ) {+ self.editor.update(cx, |editor, cx| {+ editor.set_placeholder_text(placeholder, window, cx);+ });+ }+#[cfg(test)]pub fn set_text(&mut self, text: &str, window: &mut Window, cx: &mut Context<Self>) {self.editor.update(cx, |editor, cx| {diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rsindex 306976473d7..17daf5a18e9 100644--- a/crates/agent_ui/src/acp/thread_view.rs+++ b/crates/agent_ui/src/acp/thread_view.rs@@ -337,19 +337,7 @@ impl AcpThreadView {let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default()));let available_commands = Rc::new(RefCell::new(vec![]));- let placeholder = if agent.name() == "Zed Agent" {- format!("Message the {} — @ to include context", agent.name())- } else if agent.name() == "Claude Code"- || agent.name() == "Codex"- || !available_commands.borrow().is_empty()- {- format!(- "Message {} — @ to include context, / for commands",- agent.name()- )- } else {- format!("Message {} — @ to include context", agent.name())- };+ let placeholder = placeholder_text(agent.name().as_ref(), false);let message_editor = cx.new(|cx| {let mut editor = MessageEditor::new(@@ -1456,7 +1444,14 @@ impl AcpThreadView {});}+ let has_commands = !available_commands.is_empty();self.available_commands.replace(available_commands);++ let new_placeholder = placeholder_text(self.agent.name().as_ref(), has_commands);++ self.message_editor.update(cx, |editor, cx| {+ editor.set_placeholder_text(&new_placeholder, window, cx);+ });}AcpThreadEvent::ModeUpdated(_mode) => {// The connection keeps track of the mode@@ -5708,6 +5703,19 @@ fn loading_contents_spinner(size: IconSize) -> AnyElement {.into_any_element()}+fn placeholder_text(agent_name: &str, has_commands: bool) -> String {+ if agent_name == "Zed Agent" {+ format!("Message the {} — @ to include context", agent_name)+ } else if has_commands {+ format!(+ "Message {} — @ to include context, / for commands",+ agent_name+ )+ } else {+ format!("Message {} — @ to include context", agent_name)+ }+}+impl Focusable for AcpThreadView {fn focus_handle(&self, cx: &App) -> FocusHandle {match self.thread_state {