Prevent sending slash commands in CC threads (#36453)

Highlight them as errors in the editor, and add a leading space when
sending them so users don't hit the odd behavior when sending these
commands to the SDK.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-08-19 02:00:41 -04:00 committed by GitHub
parent 7bcea7dc2c
commit d30b017d1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 263 additions and 16 deletions

View file

@ -7,7 +7,7 @@ use acp_thread::{AgentConnection, Plan};
use action_log::ActionLog;
use agent::{TextThreadStore, ThreadStore};
use agent_client_protocol::{self as acp};
use agent_servers::AgentServer;
use agent_servers::{AgentServer, ClaudeCode};
use agent_settings::{AgentProfileId, AgentSettings, CompletionMode, NotifyWhenAgentWaiting};
use anyhow::bail;
use audio::{Audio, Sound};
@ -160,6 +160,7 @@ impl AcpThreadView {
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
let prevent_slash_commands = agent.clone().downcast::<ClaudeCode>().is_some();
let message_editor = cx.new(|cx| {
MessageEditor::new(
workspace.clone(),
@ -167,6 +168,7 @@ impl AcpThreadView {
thread_store.clone(),
text_thread_store.clone(),
"Message the agent @ to include context",
prevent_slash_commands,
editor::EditorMode::AutoHeight {
min_lines: MIN_EDITOR_LINES,
max_lines: Some(MAX_EDITOR_LINES),
@ -184,6 +186,7 @@ impl AcpThreadView {
project.clone(),
thread_store.clone(),
text_thread_store.clone(),
prevent_slash_commands,
)
});
@ -3925,6 +3928,10 @@ pub(crate) mod tests {
) -> Task<gpui::Result<Rc<dyn AgentConnection>>> {
Task::ready(Ok(Rc::new(self.connection.clone())))
}
fn into_any(self: Rc<Self>) -> Rc<dyn Any> {
self
}
}
#[derive(Clone)]