@@ -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| {
@@ -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 {