Update agent-client-protocol to 3.6.0 (schema 1.13) (#66245)

Updates `agent-client-protocol` to 3.6.0 (schema 1.13) and adopts the
protocol clarifications made since schema 1.12. Each commit stands
alone:

1. **Update agent-client-protocol to 3.6.0 (schema 1.13)**
- Adapts to the new types: tagged `AvailableCommand`,
`CancelledPermissionOutcome`, `ClientAuthCapabilities`, 1-based
`NonZeroU32` tool call lines, signed terminal exit codes, unsigned
`ResourceLink.size`, and v2 `RequestId` (no `null`).
- Terminal exit codes keep the platform's signed value instead of `c as
u32`; v1 Agents still receive the same 32-bit pattern as before.
- Session message participants follow the new patch rules: omitted
keeps, `null` clears, a value replaces.
   - An unknown tool status shows as in progress.
   - Unknown command kinds are offered as plain commands.
   - v1 `terminal/*` calls for an unknown terminal return `-32002`.
- A `terminal_update` with an invalid `output` snapshot still applies
its other fields (agentclientprotocol/agent-client-protocol#2577).
2. **Reject elicitation forms Zed can't render**: `-32602` for a
required property of an unknown type, a dangling `required` name, or
`enum` with `oneOf`. Optional unknown properties are left out, and
defaults that don't match their schema are ignored.
3. **Show streamed tool text as continuous text**: adjacent plain text
in `tool_call_content_chunk` extends the previous text block, like
message chunks.
4. **Apply tool call permission subjects to the transcript**: a
`tool_call` subject is applied like a `tool_call_update` before the
prompt is shown, so the permission card attaches to its tool call.

Related SDK and spec PRs: agentclientprotocol/rust-sdk#450,
agentclientprotocol/rust-sdk#451,
agentclientprotocol/agent-client-protocol#2578.

Release Notes:

- N/A
This commit is contained in:
Ben Brandt authored and GitHub committed 2026-10-28 12:48:20 +00:00
1 parent 37faef81f7
commit 5e8998a2a7
20 files changed
+864 -365

No files matched your search

Generated
+23 -23
View File
@@ -328,9 +328,9 @@ dependencies = [
[[package]]
name = "agent-client-protocol"
version = "3.5.0"
version = "3.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bbe69c878aef64a3d92041e256e75acdb1bf2ea8e55ef3313e69dbb2f5bd75a"
checksum = "89b41f18aeb4a6d1a463b994cb880cc562cdea7d616ea3e22f9c6f2a438fc4f6"
dependencies = [
"agent-client-protocol-derive",
"agent-client-protocol-schema",
@@ -346,9 +346,9 @@ dependencies = [
[[package]]
name = "agent-client-protocol-derive"
version = "3.5.0"
version = "3.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25b7ae92f0d1ba46ca61e7e03d4a9758e877d100b783aa1c62b140d5a9d59fb2"
checksum = "5d2d255cb5d3afa4760084fbcaf87c7d214d316328546cd777d8736a8af6e368"
dependencies = [
"quote",
"syn 3.0.3",
@@ -356,9 +356,9 @@ dependencies = [
[[package]]
name = "agent-client-protocol-schema"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "430e900fdb40a811c1a3e0d85b1134e485d96699f8b90889a15c1da6a0b26c3f"
checksum = "c7c7cee33b16d162a617d5ea7292471c542ab31b416a2c089228aa8a6d4d18fe"
dependencies = [
"anyhow",
"derive_more",
@@ -2737,7 +2737,7 @@ dependencies = [
"maybe-owned",
"rustix",
"rustix-linux-procfs",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
"winx",
]
@@ -5009,7 +5009,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -5795,7 +5795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -6855,7 +6855,7 @@ dependencies = [
"libc",
"log",
"rustversion",
"windows-link 0.1.3",
"windows-link 0.2.1",
"windows-result 0.4.1",
]
@@ -6987,7 +6987,7 @@ dependencies = [
"gobject-sys",
"libc",
"system-deps",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -10999,7 +10999,7 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -11377,7 +11377,7 @@ version = "0.50.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
dependencies = [
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -14110,8 +14110,8 @@ version = "0.14.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042"
dependencies = [
"heck 0.4.1",
"itertools 0.10.5",
"heck 0.5.0",
"itertools 0.14.0",
"log",
"multimap",
"petgraph",
@@ -14130,7 +14130,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf"
dependencies = [
"anyhow",
"itertools 0.10.5",
"itertools 0.14.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -15511,7 +15511,7 @@ dependencies = [
"errno 0.3.14",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -15609,7 +15609,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -16803,7 +16803,7 @@ version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451"
dependencies = [
"heck 0.4.1",
"heck 0.5.0",
"proc-macro2",
"quote",
"syn 2.0.117",
@@ -16872,7 +16872,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -17186,7 +17186,7 @@ dependencies = [
"cfg-if",
"libc",
"psm",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]
[[package]]
@@ -17903,7 +17903,7 @@ dependencies = [
"getrandom 0.4.1",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -20725,7 +20725,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.61.2",
]
[[package]]
+1 -1
View File
@@ -530,7 +530,7 @@ accesskit = { version = "0.24.0", features = ["enumn"] }
accesskit_macos = "0.26.0"
accesskit_unix = "0.22"
accesskit_windows = "0.34"
agent-client-protocol = { version = "=3.5.0", features = ["schemars", "unstable", "unstable_protocol_v2"] }
agent-client-protocol = { version = "=3.6.0", features = ["schemars", "unstable", "unstable_protocol_v2"] }
aho-corasick = "1.1"
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "4c129667ce56611becdc82de6e28218c80e2e88f" }
any_vec = "0.14"
+381 -89
View File
@@ -154,9 +154,8 @@ pub fn meta_with_command_category(category: CommandCategory) -> acp_v2::Meta {
acp_v2::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), category.as_str().into())])
}
pub fn command_category_from_meta(meta: &Option<acp_v2::Meta>) -> Option<CommandCategory> {
meta.as_ref()
.and_then(|m| m.get(COMMAND_CATEGORY_META_KEY))
pub fn command_category_from_meta(meta: Option<&acp_v2::Meta>) -> Option<CommandCategory> {
meta.and_then(|m| m.get(COMMAND_CATEGORY_META_KEY))
.and_then(|v| v.as_str())
.and_then(CommandCategory::from_str)
}
@@ -586,7 +585,7 @@ impl ElicitationStore {
fn validate_request(request: &acp_v2::CreateElicitationRequest) -> Result<(), acp_v2::Error> {
match &request.mode {
acp_v2::ElicitationMode::Form(_) => {}
acp_v2::ElicitationMode::Form(mode) => validate_form_schema(&mode.requested_schema)?,
acp_v2::ElicitationMode::Url(mode) => {
let url = url::Url::parse(&mode.url)
.map_err(|_| acp_v2::Error::invalid_params().data("invalid elicitation URL"))?;
@@ -1138,7 +1137,7 @@ impl From<acp_v2::ToolCallLocation> for ToolCallLocation {
fn from(location: acp_v2::ToolCallLocation) -> Self {
Self {
path: location.path.0,
line: location.line,
line: location.line.map(std::num::NonZeroU32::get),
meta: location.meta,
}
}
@@ -1720,6 +1719,20 @@ impl ToolCall {
language_registry: &Arc<LanguageRegistry>,
cx: &mut App,
) {
// Agents may stream tool text one chunk at a time, like message text, so adjacent
// plain text continues the previous block instead of starting a new one.
if let PreparedToolCallContent::ContentBlock(acp_v2::Content {
content: acp_v2::ContentBlock::Text(text),
meta: None,
..
}) = &content
&& let Some(ToolCallContent::ContentBlock { block, meta: None }) =
self.structured_content.last_mut()
&& block.append_plain_text(text, cx)
{
self.update_raw_output_content(language_registry, cx);
return;
}
self.structured_content.push(ToolCallContent::from_prepared(
content,
language_registry,
@@ -1976,6 +1989,59 @@ impl From<acp_v1::ToolCallStatus> for ToolCallStatus {
}
}
/// Whether Zed can render a form property. Unknown property types and multi-select items
/// can't be rendered.
pub fn is_renderable_elicitation_property(property: &acp_v2::ElicitationPropertySchema) -> bool {
match property {
acp_v2::ElicitationPropertySchema::String(_)
| acp_v2::ElicitationPropertySchema::Number(_)
| acp_v2::ElicitationPropertySchema::Integer(_)
| acp_v2::ElicitationPropertySchema::Boolean(_) => true,
acp_v2::ElicitationPropertySchema::Array(schema) => matches!(
schema.items,
acp_v2::MultiSelectItems::String(_) | acp_v2::MultiSelectItems::Titled(_)
),
_ => false,
}
}
/// A form Zed can't render is rejected with `-32602` rather than answered with `decline` or
/// `cancel`, which would report a choice the user never made. Optional properties Zed can't
/// render are left out of the form instead.
fn validate_form_schema(schema: &acp_v2::ElicitationSchema) -> Result<(), acp_v2::Error> {
let unrenderable = |reason: String| Err(acp_v2::Error::invalid_params().data(reason));
for name in schema.required.iter().flatten() {
match schema.properties.get(name) {
None => return unrenderable(format!("required form property `{name}` is not defined")),
Some(property) if !is_renderable_elicitation_property(property) => {
return unrenderable(format!(
"required form property `{name}` has an unsupported type"
));
}
Some(_) => {}
}
}
for (name, property) in &schema.properties {
if let acp_v2::ElicitationPropertySchema::String(property) = property
&& property.enum_values.is_some()
&& property.one_of.is_some()
{
return unrenderable(format!(
"form property `{name}` sets both `enum` and `oneOf`"
));
}
}
Ok(())
}
/// Lets v1 handlers answer an unknown terminal with `-32002`, as the protocol's error page asks.
/// The data mirrors the `sessionId` that the error page specifies for unknown sessions.
fn terminal_not_found(terminal_id: &acp_v2::TerminalId) -> anyhow::Error {
acp_v1::Error::from(acp_v1::ErrorCode::ResourceNotFound)
.data(serde_json::json!({ "terminalId": terminal_id.0.as_ref() }))
.into()
}
impl ToolCallStatus {
fn from_reported(status: Option<&acp_v2::ToolCallStatus>) -> Option<Self> {
match status? {
@@ -1984,7 +2050,8 @@ impl ToolCallStatus {
acp_v2::ToolCallStatus::Completed => Some(Self::Completed),
acp_v2::ToolCallStatus::Failed => Some(Self::Failed),
acp_v2::ToolCallStatus::Cancelled => Some(Self::Canceled),
_ => None,
// The protocol says to treat an unrecognized status as still in progress.
_ => Some(Self::InProgress),
}
}
@@ -2655,6 +2722,23 @@ impl ContentBlock {
///
/// Recreating the entity on every streamed snapshot causes the rendered
/// element to tear down and rebuild, which flickers badly.
/// Appends text without annotations or metadata to a block holding the same kind of text.
fn append_plain_text(&mut self, text: &acp_v2::TextContent, cx: &mut App) -> bool {
let is_plain =
|text: &acp_v2::TextContent| text.annotations.is_none() && text.meta.is_none();
let (RenderBlock::Markdown { markdown }, Some(acp_v2::ContentBlock::Text(source))) =
(&self.render, &mut self.source)
else {
return false;
};
if !is_plain(text) || !is_plain(source) {
return false;
}
source.text.push_str(&text.text);
markdown.update(cx, |markdown, cx| markdown.append(&text.text, cx));
true
}
pub fn update_text_in_place(&mut self, block: &acp_v2::ContentBlock, cx: &mut App) -> bool {
let RenderBlock::Markdown { markdown } = &self.render else {
return false;
@@ -4836,12 +4920,12 @@ impl AcpThread {
.sender_session_id(
message
.sender_session_id
.map(|id| acp_v2::SessionId::new(id.0)),
.map_value(|id| acp_v2::SessionId::new(id.0)),
)
.recipient_session_id(
message
.recipient_session_id
.map(|id| acp_v2::SessionId::new(id.0)),
.map_value(|id| acp_v2::SessionId::new(id.0)),
)
.content(content)
.meta(message.meta),
@@ -4943,9 +5027,7 @@ impl AcpThread {
chunk: acp_v2::SessionMessageChunk,
cx: &mut Context<Self>,
) -> Result<()> {
// A chunk carries only content: its metadata does not patch the message's, and the
// RFD keeps a message's participants on `session_message`, so the participant fields
// that this schema version still has on chunks are ignored.
// A chunk carries only content: its metadata does not patch the message's.
let previous_entry_count = self.entries.len();
let location = self.keyed_message_location(MessageKind::Session, chunk.message_id, cx)?;
self.append_message_content(
@@ -4957,13 +5039,11 @@ impl AcpThread {
)
}
/// Participants that an update omits keep their earlier value, and a known participant
/// cannot change.
fn session_message_location(
&mut self,
id: acp_v2::MessageId,
sender: Option<acp_v2::SessionId>,
recipient: Option<acp_v2::SessionId>,
sender: MaybeUndefined<acp_v2::SessionId>,
recipient: MaybeUndefined<acp_v2::SessionId>,
cx: &mut Context<Self>,
) -> Result<MessageLocation> {
let location = self.keyed_message_location(MessageKind::Session, id, cx)?;
@@ -4976,14 +5056,11 @@ impl AcpThread {
(&mut message.sender_session_id, sender),
(&mut message.recipient_session_id, recipient),
] {
let Some(reported) = reported else {
continue;
};
anyhow::ensure!(
stored.as_ref().is_none_or(|stored| stored == &reported),
"Session message participants cannot change"
);
*stored = Some(reported);
match reported {
MaybeUndefined::Undefined => {}
MaybeUndefined::Null => *stored = None,
MaybeUndefined::Value(reported) => *stored = Some(reported),
}
}
Ok(location)
}
@@ -6360,6 +6437,11 @@ impl AcpThread {
.all(|option| option_ids.insert(&option.option_id)),
"Permission request has duplicate option IDs"
);
// The protocol applies a tool call subject exactly like a `tool_call_update`, before
// the prompt is shown, so the request can anchor to the tool call it describes.
if let Some(acp_v2::RequestPermissionSubject::ToolCall(subject)) = &request.subject {
self.upsert_wire_tool_call(subject.tool_call.clone(), cx)?;
}
let (respond_tx, receiver) = oneshot::channel();
let id = PermissionRequestId(Uuid::new_v4());
@@ -6379,7 +6461,9 @@ impl AcpThread {
cx.spawn(async move |_, _| {
receiver
.await
.unwrap_or(acp_v2::RequestPermissionOutcome::Cancelled)
.unwrap_or(acp_v2::RequestPermissionOutcome::Cancelled(
Default::default(),
))
}),
))
}
@@ -6649,7 +6733,9 @@ impl AcpThread {
respond_tx.send(outcome).is_ok()
}
PermissionRequestData::Generic { respond_tx, .. } => respond_tx
.send(acp_v2::RequestPermissionOutcome::Cancelled)
.send(acp_v2::RequestPermissionOutcome::Cancelled(
Default::default(),
))
.is_ok(),
};
if !delivered {
@@ -7883,7 +7969,7 @@ impl AcpThread {
) -> Result<()> {
self.terminals
.get(&terminal_id)
.context("Terminal not found")?
.ok_or_else(|| terminal_not_found(&terminal_id))?
.update(cx, |terminal, cx| {
terminal.kill(cx);
});
@@ -7898,7 +7984,7 @@ impl AcpThread {
) -> Result<()> {
self.terminals
.remove(&terminal_id)
.context("Terminal not found")?
.ok_or_else(|| terminal_not_found(&terminal_id))?
.update(cx, |terminal, cx| {
terminal.kill(cx);
});
@@ -7909,8 +7995,8 @@ impl AcpThread {
pub fn terminal(&self, terminal_id: acp_v2::TerminalId) -> Result<Entity<Terminal>> {
self.terminals
.get(&terminal_id)
.context("Terminal not found")
.cloned()
.ok_or_else(|| terminal_not_found(&terminal_id))
}
pub fn to_markdown(&self, cx: &App) -> String {
@@ -8313,14 +8399,14 @@ mod tests {
CommandCategory::Native | CommandCategory::Mcp => {}
}
let meta = meta_with_command_category(category);
assert_eq!(command_category_from_meta(&Some(meta)), Some(category));
assert_eq!(command_category_from_meta(Some(&meta)), Some(category));
}
// Absent meta and unknown categories both decode to `None`.
assert_eq!(command_category_from_meta(&None), None);
assert_eq!(command_category_from_meta(None), None);
let unknown =
acp_v1::Meta::from_iter([(COMMAND_CATEGORY_META_KEY.into(), "future-category".into())]);
assert_eq!(command_category_from_meta(&Some(unknown)), None);
assert_eq!(command_category_from_meta(Some(&unknown)), None);
}
#[test]
@@ -11596,7 +11682,10 @@ mod tests {
let (_, elicitation) = thread.elicitation(&elicitation_id).expect("elicitation");
assert!(matches!(elicitation.status, ElicitationStatus::Canceled));
});
assert_eq!(generic.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
generic.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert!(matches!(legacy.await, RequestPermissionOutcome::Cancelled));
assert!(matches!(
elicitation.await.action,
@@ -12092,7 +12181,7 @@ mod tests {
assert_eq!(elicitation.await.action, acp_v2::ElicitationAction::Cancel);
assert_eq!(
generic_permission.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
thread.update(cx, |thread, cx| {
assert_eq!(thread.foreground_activity(), ForegroundActivity::Running);
@@ -12184,7 +12273,7 @@ mod tests {
});
assert_eq!(
generic_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert!(matches!(
local_response.await,
@@ -12980,7 +13069,7 @@ mod tests {
});
assert_eq!(
permission.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
cx.run_until_parked();
assert_eq!(
@@ -13573,7 +13662,7 @@ mod tests {
}
#[gpui::test]
async fn test_session_messages_keep_participants_and_convert_from_v1(cx: &mut TestAppContext) {
async fn test_session_messages_patch_participants_and_convert_from_v1(cx: &mut TestAppContext) {
init_test(cx);
let thread = new_test_thread(cx).await;
thread.update(cx, |thread, cx| {
@@ -13593,19 +13682,23 @@ mod tests {
.expect("participants can arrive later");
thread
.append_session_message_chunk(
acp_v2::SessionMessageChunk::new("task", "reproducing".into())
.sender_session_id(acp_v2::SessionId::new("other")),
acp_v2::SessionMessageChunk::new("task", "reproducing".into()),
cx,
)
.expect("a chunk's participant fields are ignored");
let error = thread
.expect("a chunk appends content");
thread
.upsert_session_message(
acp_v2::SessionMessage::new("task")
.sender_session_id(acp_v2::SessionId::new("other")),
cx,
)
.expect_err("a known participant cannot change");
assert!(error.to_string().contains("cannot change"), "{error}");
.expect("a reported participant replaces the known one");
thread
.upsert_session_message(
acp_v2::SessionMessage::new("task").recipient_session_id(MaybeUndefined::Null),
cx,
)
.expect("null clears a participant");
thread
.upsert_assistant_message(
acp_v2::AgentMessage::new("task").content(vec!["answer".into()]),
@@ -13621,8 +13714,8 @@ mod tests {
panic!("expected a session message, then an assistant message");
};
assert_eq!(message.identity, MessageIdentity::Keyed("task".into()));
assert_eq!(message.sender_session_id, Some("parent".into()));
assert_eq!(message.recipient_session_id, Some("child".into()));
assert_eq!(message.sender_session_id, Some("other".into()));
assert_eq!(message.recipient_session_id, None);
assert_eq!(
message.content.source_blocks(),
&["Start by ".into(), "reproducing".into()]
@@ -16499,7 +16592,7 @@ mod tests {
call.reported_status,
Some(acp_v2::ToolCallStatus::Other("_future_status".into()))
);
assert_eq!(call.status(), ToolCallStatus::Pending);
assert_eq!(call.status(), ToolCallStatus::InProgress);
assert_eq!(call.name.as_deref(), Some("named"));
assert_eq!(
serde_json::to_value(&call.meta).expect("metadata"),
@@ -16597,6 +16690,48 @@ mod tests {
});
}
#[gpui::test]
async fn test_tool_text_chunks_merge_only_plain_adjacent_text(cx: &mut TestAppContext) {
init_test(cx);
let thread = new_test_thread(cx).await;
thread.update(cx, |thread, cx| {
let chunk =
|content: acp_v2::ContentBlock| acp_v2::ToolCallContentChunk::new("tool", content);
for chunk in [
chunk("Str".into()),
chunk("eam".into()),
chunk(acp_v2::ContentBlock::ResourceLink(
acp_v2::ResourceLink::new("notes", "file:///notes.md"),
)),
chunk(" after link".into()),
chunk(acp_v2::ContentBlock::Text(
acp_v2::TextContent::new(" annotated")
.annotations(acp_v2::Annotations::new().priority(0.5)),
)),
chunk(" plain".into()),
acp_v2::ToolCallContentChunk::new(
"tool",
acp_v2::ToolCallContent::Content(Box::new(
acp_v2::Content::new(" with meta")
.meta(acp_v2::Meta::from_iter([("item".into(), json!(true))])),
)),
),
] {
thread
.append_tool_call_content_chunk(chunk, cx)
.expect("tool chunk");
}
let (_, call) = thread.tool_call(&"tool".into()).expect("tool");
// Plain text merges; a link, annotations or item metadata start a new block.
let content = call.content();
assert_eq!(content.len(), 6);
assert_eq!(content[0].to_markdown(cx), "Stream");
assert_eq!(content[2].to_markdown(cx), " after link");
assert_eq!(content[3].to_markdown(cx), " annotated");
assert_eq!(content[4].to_markdown(cx), " plain");
});
}
#[gpui::test]
async fn test_tool_content_chunk_ordering_and_targeting(cx: &mut TestAppContext) {
init_test(cx);
@@ -16643,14 +16778,15 @@ mod tests {
let (index, first) = thread.tool_call(&first_id).expect("historical tool");
assert_eq!(index, 0);
assert_eq!(first.content()[0].markdown(), Some(&original));
assert_eq!(original.read(cx).source(), "original");
// Adjacent text chunks continue the same text block.
assert_eq!(original.read(cx).source(), "originalhistorical");
assert_eq!(
first
.content()
.iter()
.map(|item| item.to_markdown(cx))
.collect::<Vec<_>>(),
["original", "historical"]
["originalhistorical"]
);
let (index, second) = thread.tool_call(&second_id).expect("second tool");
assert_eq!(index, 1);
@@ -16679,7 +16815,7 @@ mod tests {
.iter()
.map(|item| item.to_markdown(cx))
.collect::<Vec<_>>(),
["replacement", "after replacement"]
["replacementafter replacement"]
);
thread
.upsert_wire_tool_call(acp_v2::ToolCallUpdate::new("first").content(Vec::new()), cx)
@@ -19512,7 +19648,6 @@ mod tests {
"_meta": {"request": {"opaque": [1, null]}},
"requestedSchema": {
"type": "object",
"required": ["future"],
"_meta": {"schema": {}},
"properties": {
"future": {"type": "_location", "nested": {"precision": "city"},
@@ -19595,7 +19730,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -19864,7 +19999,7 @@ mod tests {
.request_elicitation_with_id(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -19906,7 +20041,7 @@ mod tests {
})
});
let request_id = acp_v1::RequestId::Number(1);
let request_id = acp_v2::RequestId::Number(1);
let (elicitation_id, response_task) = store.update(cx, |store, cx| {
store
.request_elicitation_with_id(
@@ -19947,7 +20082,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -19979,7 +20114,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -19993,7 +20128,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(2)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(2)),
acp_v2::ElicitationSchema::new().string("account", true),
),
"Provide an account",
@@ -20043,7 +20178,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -20057,7 +20192,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(2)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(2)),
acp_v2::ElicitationSchema::new().string("account", true),
),
"Provide an account",
@@ -20071,7 +20206,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationUrlMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(3)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(3)),
url_elicitation_id,
"https://example.com/complete",
),
@@ -20154,7 +20289,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationUrlMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
url_elicitation_id.clone(),
"https://example.com/complete",
),
@@ -20233,7 +20368,7 @@ mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationUrlMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
url_elicitation_id.clone(),
"https://example.com/complete",
),
@@ -20470,7 +20605,7 @@ mod tests {
acp_v2::CreateElicitationRequest::new(
acp_v2::OtherElicitationMode::new(
"future",
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
std::collections::BTreeMap::new(),
),
"Use a future input mode",
@@ -20486,6 +20621,79 @@ mod tests {
store.read_with(cx, |store, _| assert!(store.elicitations().is_empty()));
}
#[gpui::test]
async fn test_request_elicitation_store_rejects_unrenderable_forms(cx: &mut TestAppContext) {
init_test(cx);
let store = cx.update(|cx| cx.new(|_| ElicitationStore::default()));
let request = |requested_schema: serde_json::Value| {
serde_json::from_value::<acp_v2::CreateElicitationRequest>(json!({
"mode": "form",
"requestId": 1,
"message": "Fill in the form",
"requestedSchema": requested_schema,
}))
.expect("form request")
};
for requested_schema in [
json!({
"type": "object",
"properties": {"when": {"type": "_future"}},
"required": ["when"],
}),
json!({
"type": "object",
"properties": {
"tags": {"type": "array", "items": {"type": "_future"}},
},
"required": ["tags"],
}),
json!({
"type": "object",
"properties": {"name": {"type": "string"}},
"required": ["name", "missing"],
}),
json!({
"type": "object",
"properties": {
"environment": {
"type": "string",
"enum": ["staging"],
"oneOf": [{"const": "production", "title": "Production"}],
},
},
}),
] {
let result = store.update(cx, |store, cx| {
store.request_elicitation(request(requested_schema.clone()), cx)
});
let Err(error) = result else {
panic!("unrenderable form should be rejected: {requested_schema}");
};
assert_eq!(error.code, acp_v2::ErrorCode::InvalidParams);
}
store.read_with(cx, |store, _| assert!(store.elicitations().is_empty()));
let accepted = store.update(cx, |store, cx| {
store.request_elicitation(
request(json!({
"type": "object",
"properties": {
"name": {"type": "string"},
"when": {"type": "_future"},
},
"required": ["name"],
})),
cx,
)
});
assert!(
accepted.is_ok(),
"optional properties of unknown types can be left out"
);
store.read_with(cx, |store, _| assert_eq!(store.elicitations().len(), 1));
}
async fn run_until_first_tool_call(
thread: &Entity<AcpThread>,
cx: &mut TestAppContext,
@@ -24115,17 +24323,6 @@ mod tests {
.collect(),
),
)),
Some(
acp_v2::ToolCallUpdate::new("not-a-transcript-tool")
.title("Context, not a tool update")
.status(acp_v2::ToolCallStatus::Completed)
.content(vec!["Context, not transcript content".into()])
.meta(acp_v2::Meta::from_iter([(
"tool-data".into(),
json!({"opaque": ["retained"]}),
)]))
.into(),
),
];
let mut pending = Vec::new();
for subject in subjects {
@@ -24145,13 +24342,12 @@ mod tests {
assert!(record.legacy_kind().is_none());
assert!(thread.entries().is_empty());
assert!(thread.tool_call(&"context-only".into()).is_none());
assert!(thread.tool_call(&"not-a-transcript-tool".into()).is_none());
assert!(!thread.is_idle_for_retention());
});
pending.push((id, response));
}
thread.read_with(cx, |thread, _| {
assert_eq!(thread.pending_permission_requests().count(), 4);
assert_eq!(thread.pending_permission_requests().count(), 3);
});
assert_eq!(
*events.borrow(),
@@ -24162,7 +24358,10 @@ mod tests {
);
for (id, response) in pending {
thread.update(cx, |thread, cx| thread.cancel_permission_request(id, cx));
assert_eq!(response.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
thread.read_with(cx, |thread, _| {
assert_eq!(thread.pending_permission_requests().count(), 0);
@@ -24171,6 +24370,90 @@ mod tests {
});
}
#[gpui::test]
async fn test_unknown_terminal_is_resource_not_found(cx: &mut TestAppContext) {
init_test(cx);
let thread = new_test_thread(cx).await;
thread.update(cx, |thread, cx| {
let errors = [
thread.terminal(acp_v2::TerminalId::new("missing")).err(),
thread
.kill_terminal(acp_v2::TerminalId::new("missing"), cx)
.err(),
thread
.release_terminal(acp_v2::TerminalId::new("missing"), cx)
.err(),
];
for error in errors {
let error = acp_v1::Error::from(error.expect("unknown terminal fails"));
assert_eq!(error.code, acp_v1::ErrorCode::ResourceNotFound);
assert_eq!(error.data, Some(json!({"terminalId": "missing"})));
}
});
}
#[gpui::test]
async fn test_tool_call_permission_subject_upserts_tool_call(cx: &mut TestAppContext) {
init_test(cx);
let thread = new_test_thread(cx).await;
let subject = |update: acp_v2::ToolCallUpdate| {
Some(acp_v2::RequestPermissionSubject::from(
acp_v2::ToolCallPermissionSubject::new(update),
))
};
let request = thread.read_with(cx, |thread, _| {
test_generic_permission_request(thread, "allow").subject(subject(
acp_v2::ToolCallUpdate::new("unseen")
.title("Run tests")
.content(vec!["cargo test".into()]),
))
});
let (first_id, first_response) = thread.update(cx, |thread, cx| {
thread
.request_permission(request, cx)
.expect("permission for an unseen tool call")
});
thread.read_with(cx, |thread, cx| {
let (_, call) = thread
.tool_call(&"unseen".into())
.expect("the subject creates the tool call");
assert_eq!(call.label.read(cx).source(), "Run tests");
assert_eq!(call.content().len(), 1);
});
let request = thread.read_with(cx, |thread, _| {
test_generic_permission_request(thread, "allow").subject(subject(
acp_v2::ToolCallUpdate::new("unseen").title("Run all tests"),
))
});
let (second_id, second_response) = thread.update(cx, |thread, cx| {
thread
.request_permission(request, cx)
.expect("permission for a known tool call")
});
thread.read_with(cx, |thread, cx| {
let [AgentThreadEntry::ToolCall(call)] = thread.entries() else {
panic!("expected the subject to patch the existing tool call");
};
assert_eq!(call.label.read(cx).source(), "Run all tests");
assert_eq!(call.content().len(), 1, "omitted fields keep their value");
});
thread.update(cx, |thread, cx| {
thread.cancel_permission_request(first_id, cx);
thread.cancel_permission_request(second_id, cx);
});
assert_eq!(
first_response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert_eq!(
second_response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
#[gpui::test]
async fn test_generic_permissions_for_same_subject_have_independent_choices(
cx: &mut TestAppContext,
@@ -24246,12 +24529,12 @@ mod tests {
);
assert_eq!(
second_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
#[gpui::test]
async fn test_generic_tool_permissions_do_not_replace_or_mutate_legacy_authorization(
async fn test_generic_tool_permissions_patch_tool_but_keep_legacy_authorization(
cx: &mut TestAppContext,
) {
init_test(cx);
@@ -24280,9 +24563,8 @@ mod tests {
test_generic_permission_request(thread, "future-choice").subject(
acp_v2::RequestPermissionSubject::from(
acp_v2::ToolCallUpdate::new("shared-tool")
.title("Must not replace the label")
.status(acp_v2::ToolCallStatus::Completed)
.content(vec!["Must not replace tool output".into()]),
.title("Patched label")
.content(vec!["Patched tool output".into()]),
),
)
});
@@ -24302,8 +24584,9 @@ mod tests {
let (_, call) = thread.tool_call(&tool_id).expect("legacy tool");
assert_eq!(call.authorization_id(), Some(legacy_id));
assert_eq!(call.status(), ToolCallStatus::WaitingForConfirmation);
assert_eq!(call.label.read(cx).source(), "Needs permission");
assert!(call.content().is_empty());
// The subject applies like a `tool_call_update`.
assert_eq!(call.label.read(cx).source(), "Patched label");
assert_eq!(call.content().len(), 1);
assert_eq!(thread.entries().len(), 1);
assert_eq!(
thread
@@ -24320,7 +24603,7 @@ mod tests {
.is_none()
);
});
assert_eq!(*transcript_events.borrow(), 0);
assert!(*transcript_events.borrow() > 0);
assert_eq!(
selected_response.await,
acp_v2::RequestPermissionOutcome::Selected(acp_v2::SelectedPermissionOutcome::new(
@@ -24329,7 +24612,7 @@ mod tests {
);
assert_eq!(
cancelled_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
thread.update(cx, |thread, cx| {
thread.authorize_tool_call(
@@ -24440,7 +24723,10 @@ mod tests {
drop(released_thread);
cx.run_until_parked();
assert!(released.upgrade().is_none());
assert_eq!(response.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
#[gpui::test]
@@ -24497,7 +24783,10 @@ mod tests {
);
});
thread.update(cx, |thread, cx| thread.cancel_permission_request(id, cx));
assert_eq!(response.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert_eq!(*events.borrow(), [(true, id), (false, id)]);
}
@@ -24684,11 +24973,11 @@ mod tests {
);
assert_eq!(
first_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert_eq!(
second_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
@@ -24744,7 +25033,10 @@ mod tests {
thread.update(cx, |thread, cx| thread.cancel_permission_request(id, cx));
}
assert_eq!(*events.borrow(), [(true, id), (false, id)]);
assert_eq!(response.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
}
+6 -6
View File
@@ -18,11 +18,11 @@ pub fn from_v1(commands: Vec<acp_v1::AvailableCommand>) -> Result<Vec<acp_v2::Av
})
})
.transpose()?;
Ok(
acp_v2::AvailableCommand::new(command.name, command.description)
Ok(acp_v2::AvailableCommand::Command(
acp_v2::Command::new(command.name, command.description)
.input(input)
.meta(command.meta),
)
))
})
.collect()
}
@@ -52,10 +52,10 @@ mod tests {
assert_eq!(
serde_json::to_value(from_v1(commands)?)?,
json!([
{"name": "/opaque.name", "description": ""},
{"name": "empty", "description": "", "_meta": {}},
{"type": "command", "name": "/opaque.name", "description": ""},
{"type": "command", "name": "empty", "description": "", "_meta": {}},
{
"name": "deploy", "description": "Deploy code",
"type": "command", "name": "deploy", "description": "Deploy code",
"input": {"type": "text", "hint": "", "_meta": {"input": [null, true]}},
"_meta": {"command_category": "mcp", "command": {"nested": [1, "value"]}}
}
+16 -6
View File
@@ -43,7 +43,8 @@ pub fn from_v1(block: acp_v1::ContentBlock) -> Result<acp_v2::ContentBlock> {
.title(content.title)
.description(content.description)
.mime_type(content.mime_type.map(acp_v2::MediaType::new))
.size(content.size)
// v2 sizes are byte counts, so a negative v1 size is unknown.
.size(content.size.and_then(|size| u64::try_from(size).ok()))
.annotations(annotations_from_v1(content.annotations)?)
.meta(content.meta),
),
@@ -107,7 +108,7 @@ pub fn to_v1(block: acp_v2::ContentBlock) -> Result<acp_v1::ContentBlock> {
.title(content.title)
.description(content.description)
.mime_type(content.mime_type.map(|mime_type| mime_type.0.to_string()))
.size(content.size)
.size(content.size.and_then(|size| i64::try_from(size).ok()))
.annotations(annotations_to_v1(content.annotations)?)
.meta(content.meta),
)
@@ -447,6 +448,18 @@ mod tests {
));
}
#[test]
fn negative_v1_resource_link_size_is_unknown_in_v2() {
let converted = from_v1(acp_v1::ContentBlock::ResourceLink(
acp_v1::ResourceLink::new("negative size", "file:///negative").size(-1),
))
.expect("v1 resource link converts to v2");
let acp_v2::ContentBlock::ResourceLink(link) = converted else {
panic!("expected a resource link");
};
assert_eq!(link.size, None);
}
fn round_trip_from_v2(block: acp_v2::ContentBlock) {
assert!(can_convert_to_v1(&block), "{block:?}");
let original_wire = serde_json::to_value(&block).expect("serialize original v2 block");
@@ -559,12 +572,9 @@ mod tests {
acp_v2::ContentBlock::Audio(acp_v2::AudioContent::new("", "")),
acp_v2::ContentBlock::ResourceLink(
acp_v2::ResourceLink::new("", "")
.size(i64::MAX)
.size(i64::MAX.unsigned_abs())
.annotations(acp_v2::Annotations::new().priority(0.125)),
),
acp_v2::ContentBlock::ResourceLink(
acp_v2::ResourceLink::new("negative size", "file:///negative").size(-1),
),
acp_v2::ContentBlock::Resource(acp_v2::EmbeddedResource::new(
acp_v2::EmbeddedResourceResource::TextResourceContents(
acp_v2::TextResourceContents::new("", ""),
+12 -2
View File
@@ -69,12 +69,20 @@ fn scope_from_v1(scope: v1::ElicitationScope) -> Result<v2::ElicitationScope> {
.into()
}
v1::ElicitationScope::Request(scope) => {
v2::ElicitationRequestScope::new(scope.request_id).into()
v2::ElicitationRequestScope::new(request_id_from_v1(scope.request_id)?).into()
}
_ => bail!("unsupported v1 elicitation scope"),
})
}
fn request_id_from_v1(id: v1::RequestId) -> Result<v2::RequestId> {
Ok(match id {
v1::RequestId::Number(id) => v2::RequestId::Number(id),
v1::RequestId::Str(id) => v2::RequestId::Str(id),
v1::RequestId::Null => bail!("elicitation cannot be scoped to a null request ID"),
})
}
fn schema_from_v1(schema: v1::ElicitationSchema) -> Result<v2::ElicitationSchema> {
let mut converted = v2::ElicitationSchema::new();
converted.type_ = match schema.type_ {
@@ -333,7 +341,9 @@ mod tests {
});
let request: v1::CreateElicitationRequest = serde_json::from_value(fixture.clone())?;
let request_id = match request.scope() {
v1::ElicitationScope::Request(scope) => scope.request_id.clone(),
v1::ElicitationScope::Request(scope) => {
request_id_from_v1(scope.request_id.clone())?
}
_ => bail!("expected request scope"),
};
let converted = request_from_v1(request)?;
+4 -7
View File
@@ -699,7 +699,7 @@ impl Terminal {
fn exit_status_from_v1(status: acp_v1::TerminalExitStatus) -> acp_v2::TerminalExitStatus {
acp_v2::TerminalExitStatus::new()
.exit_code(status.exit_code)
.exit_code(status.exit_code.map(i64::from))
.signal(status.signal)
.meta(status.meta)
}
@@ -901,7 +901,7 @@ impl Terminal {
}
// This method is adapted from `portable_pty::ExitStatus::from`, version 0.9.0
fn transform_exit_status(exit_status: ExitStatus) -> (u32, Option<String>) {
fn transform_exit_status(exit_status: ExitStatus) -> (i64, Option<String>) {
#[cfg(unix)]
{
use std::os::unix::process::ExitStatusExt;
@@ -915,16 +915,13 @@ impl Terminal {
signame.to_string_lossy().to_string()
};
return (
exit_status.code().map(|c| c as u32).unwrap_or(1),
Some(signal),
);
return (exit_status.code().map(i64::from).unwrap_or(1), Some(signal));
}
}
let code = exit_status
.code()
.map(|c| c as u32)
.map(i64::from)
.unwrap_or_else(|| if exit_status.success() { 0 } else { 1 });
(code, None)
+1 -1
View File
@@ -1,6 +1,6 @@
use std::{collections::HashSet, fmt::Display, rc::Rc, sync::Arc};
use agent_client_protocol::{Error, schema::v2::RequestId};
use agent_client_protocol::{Error, schema::v1::RequestId};
use agent_servers::{AcpDebugMessage, AcpDebugMessageContent, AcpDebugMessageDirection};
use agent_ui::agent_connection_store::AgentConnectionStatus;
use agent_ui::{Agent, AgentConnectionStore, AgentPanel};
+24 -21
View File
@@ -1710,13 +1710,15 @@ impl NativeAgent {
let Some(state) = project_state else {
return Vec::new();
};
let compact_command = acp_v2::AvailableCommand::new(
COMPACT_COMMAND_NAME,
"Summarize the conversation so far to free up context",
)
.meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Native,
));
let compact_command = acp_v2::AvailableCommand::Command(
acp_v2::Command::new(
COMPACT_COMMAND_NAME,
"Summarize the conversation so far to free up context",
)
.meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Native,
)),
);
let registry = state.context_server_registry.read(cx);
@@ -1740,10 +1742,9 @@ impl NativeAgent {
};
let mut command =
acp_v2::AvailableCommand::new(name, prompt.description.clone().unwrap_or_default())
.meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Mcp,
));
acp_v2::Command::new(name, prompt.description.clone().unwrap_or_default()).meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Mcp),
);
match prompt.arguments.as_deref() {
Some([arg]) => {
@@ -1760,7 +1761,7 @@ impl NativeAgent {
}
}
Some(command)
Some(acp_v2::AvailableCommand::Command(command))
});
std::iter::once(compact_command)
@@ -6005,13 +6006,15 @@ mod internal_tests {
assert_eq!(
commands,
&[acp_v2::AvailableCommand::new(
COMPACT_COMMAND_NAME,
"Summarize the conversation so far to free up context",
)
.meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Native,
))],
&[acp_v2::AvailableCommand::Command(
acp_v2::Command::new(
COMPACT_COMMAND_NAME,
"Summarize the conversation so far to free up context",
)
.meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Native,
))
)],
);
});
}
@@ -7880,7 +7883,7 @@ mod internal_tests {
acp_thread.read_with(cx, |thread, _cx| {
let commands = thread.available_commands();
let names: Vec<&str> = commands.iter().map(|c| c.name.as_str()).collect();
let names: Vec<&str> = commands.iter().map(|c| c.name()).collect();
assert!(
!names.contains(&"visible-skill"),
"skills should not be exposed as ACP slash commands: {names:?}"
@@ -7997,7 +8000,7 @@ mod internal_tests {
.collect::<Vec<_>>()
);
let commands = acp_thread.read(cx).available_commands();
let names: Vec<&str> = commands.iter().map(|c| c.name.as_str()).collect();
let names: Vec<&str> = commands.iter().map(|c| c.name()).collect();
assert!(
!names.contains(&"my-skill"),
"untrusted skill leaked into slash commands: {names:?}"
+1 -1
View File
@@ -105,7 +105,7 @@ impl FakeTerminalHandle {
}
}
pub(crate) fn new_with_immediate_exit(cx: &mut App, exit_code: u32) -> Self {
pub(crate) fn new_with_immediate_exit(cx: &mut App, exit_code: i64) -> Self {
let killed = Arc::new(AtomicBool::new(false));
let stopped_by_user = Arc::new(AtomicBool::new(false));
let (exit_sender, _exit_receiver) = futures::channel::oneshot::channel();
+2 -2
View File
@@ -686,7 +686,7 @@ mod tests {
locations.iter().any(|location| {
location.path.0.to_string_lossy().replace('\\', "/")
== path!("/root/src/alpha.txt").replace('\\', "/")
&& location.line == Some(1)
&& location.line.map(std::num::NonZeroU32::get) == Some(1)
}),
"missing location for alpha.txt, got: {locations:?}"
);
@@ -694,7 +694,7 @@ mod tests {
locations.iter().any(|location| {
location.path.0.to_string_lossy().replace('\\', "/")
== path!("/root/beta.txt").replace('\\', "/")
&& location.line == Some(1)
&& location.line.map(std::num::NonZeroU32::get) == Some(1)
}),
"missing location for beta.txt, got: {locations:?}"
);
+3 -1
View File
@@ -1,4 +1,6 @@
use agent_client_protocol::{Error, schema::v2::RequestId};
// The log shows v1 and v2 traffic. v1's ID type also covers the `null` ID of error
// responses, which v2 keeps even though v2 requests can't use it.
use agent_client_protocol::{Error, schema::v1::RequestId};
use std::{
collections::VecDeque,
sync::{Arc, Mutex},
@@ -54,18 +54,8 @@ pub(super) fn parse_terminal_notification(
agent_client_protocol::Error::invalid_params()
.data("Malformed ACP v2 terminal notification")
})?;
// The SDK defaults malformed output to Undefined; don't apply sibling fields in that case.
if let acp_v2::SessionUpdate::TerminalUpdate(update) = &notification.update
&& message
.params()
.get("update")
.and_then(|update| update.get("output"))
.is_some_and(|output| !output.is_null())
&& update.output.is_undefined()
{
return Err(agent_client_protocol::Error::invalid_params()
.data("Malformed ACP v2 terminal output snapshot"));
}
// The SDK parses a malformed `output` snapshot as omitted, so the rest of the update still
// applies, the same as a snapshot with invalid base64.
Ok(notification)
}
@@ -77,12 +67,17 @@ pub fn decode_terminal_notification(
let output = match update.output {
MaybeUndefined::Undefined => MaybeUndefined::Undefined,
MaybeUndefined::Null => MaybeUndefined::Null,
MaybeUndefined::Value(output) => MaybeUndefined::Value(DisplayTerminalOutput {
data: STANDARD
.decode(output.data)
.context("invalid base64 in ACP v2 terminal output snapshot")?,
meta: output.meta,
}),
MaybeUndefined::Value(output) => match STANDARD.decode(output.data) {
Ok(data) => MaybeUndefined::Value(DisplayTerminalOutput {
data,
meta: output.meta,
}),
// Keep the bytes already shown and still apply the rest of the update.
Err(_) => {
log::warn!("Ignoring ACP v2 terminal output snapshot with invalid base64");
MaybeUndefined::Undefined
}
},
};
DecodedTerminalUpdate::Patch {
terminal_id: update.terminal_id,
@@ -236,7 +231,7 @@ mod tests {
patch.exit_status,
MaybeUndefined::Value(
acp_v2::TerminalExitStatus::new()
.exit_code(7u32)
.exit_code(7)
.signal("SIGTERM")
.meta(scoped_meta("exit"))
)
@@ -390,41 +385,47 @@ mod tests {
}
#[test]
fn invalid_snapshot_and_chunk_are_rejected_without_echoing_payloads() -> Result<()> {
for (fixture, context) in [
(
r#"{
"sessionId": "session-1",
"update": {
"sessionUpdate": "terminal_update",
"terminalId": "terminal-1",
"command": "echo ready",
"cwd": "/tmp",
"output": {"data": "private-output!"}
}
}"#,
"terminal output snapshot",
),
(
r#"{
"sessionId": "session-1",
"update": {
"sessionUpdate": "terminal_output_chunk",
"terminalId": "terminal-1",
"data": "private-output!"
}
}"#,
"terminal output chunk",
),
] {
let error = match decode_terminal_notification(serde_json::from_str(fixture)?) {
Err(error) => error,
Ok(_) => bail!("expected invalid base64 to reject the entire notification"),
};
let message = format!("{error:#}");
assert!(message.contains(context));
assert!(!message.contains("private-output!"));
}
fn invalid_snapshot_is_ignored_and_other_fields_apply() -> Result<()> {
let decoded = decode_fixture(
r#"{
"sessionId": "session-1",
"update": {
"sessionUpdate": "terminal_update",
"terminalId": "terminal-1",
"command": "echo ready",
"cwd": "/tmp",
"output": {"data": "private-output!"}
}
}"#,
)?;
let DecodedTerminalUpdate::Patch { patch, .. } = decoded.update else {
bail!("expected a terminal patch");
};
assert!(patch.output.is_undefined());
assert_eq!(
patch.command,
MaybeUndefined::Value("echo ready".to_string())
);
Ok(())
}
#[test]
fn invalid_chunk_is_rejected_without_echoing_payload() -> Result<()> {
let fixture = r#"{
"sessionId": "session-1",
"update": {
"sessionUpdate": "terminal_output_chunk",
"terminalId": "terminal-1",
"data": "private-output!"
}
}"#;
let error = match decode_terminal_notification(serde_json::from_str(fixture)?) {
Err(error) => error,
Ok(_) => bail!("expected invalid base64 to reject the chunk"),
};
let message = format!("{error:#}");
assert!(message.contains("terminal output chunk"));
assert!(!message.contains("private-output!"));
Ok(())
}
+65 -41
View File
@@ -2602,7 +2602,7 @@ mod tests {
let meta =
acp_v2::Meta::from_iter([("custom".into(), json!({"values": [null, 7, "keep"]}))]);
let status = acp_v2::TerminalExitStatus::new()
.exit_code(u32::MAX)
.exit_code(-1)
.signal("SIG_CUSTOM")
.meta(meta);
let expected_status = json!({
@@ -3044,7 +3044,7 @@ mod tests {
use serde_json::json;
let harness = V2SessionHarness::new(cx).await;
for subject in [
for (index, subject) in [
json!(null),
json!({"type": "tool_call", "toolCall": {"toolCallId": "unseen",
"title": "Subject title", "kind": "_future", "rawInput": {"retain": [null, 7]},
@@ -3053,7 +3053,10 @@ mod tests {
"toolCallId": "unseen", "terminalId": "unseen", "_meta": {"scope": "subject"}}),
json!({"type": "_future", "payload": {"retain": [false, null]},
"_meta": {"scope": "subject"}}),
] {
]
.into_iter()
.enumerate()
{
let source = json!({"sessionId": "v2-terminal-session", "title": "Permission title",
"description": "Separate explanation", "subject": subject,
"options": [
@@ -3066,17 +3069,24 @@ mod tests {
serde_json::from_value(source.clone()).expect("permission request");
let (mut response, _cancellation) = harness.request(request.clone(), cx);
harness.drain(cx).await;
let id = harness.thread.read_with(cx, |thread, _| {
let id = harness.thread.read_with(cx, |thread, cx| {
let requests = thread.pending_permission_requests().collect::<Vec<_>>();
let [permission] = requests.as_slice() else {
panic!("one generic permission");
};
assert_eq!(permission.generic_request(), Some(&request));
assert!(permission.legacy_tool_call_id().is_none());
assert!(
thread.entries().is_empty(),
"permission subjects do not create tools"
);
// Only the `tool_call` subject (the second) creates a tool call, which
// remains for the later subjects.
if index == 0 {
assert!(thread.entries().is_empty());
} else {
let (_, tool_call) = thread
.tool_call(&acp_v2::ToolCallId::new("unseen"))
.expect("the tool call subject creates the tool call");
assert_eq!(tool_call.label.read(cx).source(), "Subject title");
assert_eq!(thread.entries().len(), 1);
}
permission.id
});
assert!(
@@ -3135,7 +3145,11 @@ mod tests {
}
harness.thread.read_with(cx, |thread, _| {
assert_eq!(thread.pending_permission_requests().count(), 0);
assert!(thread.entries().is_empty());
assert_eq!(
thread.entries().len(),
1,
"rejected requests add no entries beyond the earlier tool call subject"
);
});
}
@@ -3229,7 +3243,7 @@ mod tests {
.await
.expect("local cancellation response")
.outcome,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
let (response, _cancellation) = harness.request(request, cx);
@@ -3258,7 +3272,7 @@ mod tests {
.await
.expect("dropped-owner response")
.outcome,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
@@ -3709,16 +3723,18 @@ mod tests {
})
});
let first = json!([
{"name": "opaque/手動", "description": "First command",
{"type": "command", "name": "opaque/手動", "description": "First command",
"input": {"type": "text", "hint": "Describe the task", "_meta": {"scope": "input"}},
"_meta": {"scope": "command", "retain": [null, 7]}},
{"name": "future", "description": "Unknown input",
"input": {"type": "_future", "payload": {"retain": [false, null]}}}
{"type": "command", "name": "future", "description": "Unknown input",
"input": {"type": "_future", "payload": {"retain": [false, null]}}},
{"type": "_future_kind", "name": "skill", "description": "Unknown command kind",
"payload": {"retain": [true]}}
]);
let mut expected_events = Vec::new();
for commands in [
first,
json!([{"name": "only", "description": "Replacement command"}]),
json!([{"type": "command", "name": "only", "description": "Replacement command"}]),
json!([]),
] {
let expected: Vec<acp_v2::AvailableCommand> =
@@ -4877,7 +4893,9 @@ mod tests {
}
#[gpui::test]
async fn v2_terminal_sdk_invalid_base64_is_atomic(cx: &mut gpui::TestAppContext) {
async fn v2_terminal_sdk_invalid_snapshot_keeps_output_and_applies_other_fields(
cx: &mut gpui::TestAppContext,
) {
let harness = V2SessionHarness::new(cx).await;
harness.send(
serde_json::json!({
@@ -4891,31 +4909,25 @@ mod tests {
);
harness.drain(cx).await;
let terminal = harness.terminal("terminal-1", cx);
let observe = |cx: &gpui::TestAppContext| {
let observe_output = |cx: &gpui::TestAppContext| {
terminal.read_with(cx, |terminal, cx| {
let display = terminal.display_state().expect("display state");
let output = terminal.output().expect("completed terminal");
(
display.command().map(str::to_owned),
terminal.working_dir().clone(),
display.meta.clone(),
display.output_meta.clone(),
output.exit_status.clone(),
output.ended_at,
output.content.clone(),
terminal.inner().read(cx).get_content(),
)
})
};
let before = observe(cx);
let output_before = observe_output(cx);
let received_before = harness.received.lock().expect("receive mutex").len();
for terminal_id in ["terminal-1", "unseen"] {
harness.send(
serde_json::json!({
"sessionUpdate": "terminal_update", "terminalId": terminal_id,
"command": "must not apply", "cwd": "/changed",
"command": "applied", "cwd": "/changed",
"output": {"data": "not base64!", "_meta": {"scope": "bad snapshot"}},
"exitStatus": {"exitCode": 99, "_meta": {"scope": "bad exit"}},
"_meta": {"scope": "bad terminal"}
}),
Some(v2_terminal_meta("bad envelope")),
@@ -4930,10 +4942,8 @@ mod tests {
"_meta": {"scope": "malformed envelope"},
"update": {
"sessionUpdate": "terminal_update", "terminalId": terminal_id,
"command": "must not apply", "cwd": "/changed",
"output": {"data": 42},
"exitStatus": {"exitCode": 99, "_meta": {"scope": "bad exit"}},
"_meta": {"scope": "bad terminal"}
"_meta": {"scope": "malformed terminal"}
}
}),
)
@@ -4953,14 +4963,26 @@ mod tests {
}
}
harness.drain(cx).await;
assert_eq!(observe(cx), before);
assert_eq!(observe_output(cx), output_before);
assert_eq!(harness.terminal("terminal-1", cx), terminal);
harness.thread.read_with(cx, |thread, _| {
assert!(thread.terminal(acp_v2::TerminalId::new("unseen")).is_err());
terminal.read_with(cx, |terminal, _| {
let display = terminal.display_state().expect("display state");
assert_eq!(display.command(), Some("applied"));
assert_eq!(terminal.working_dir(), &Some(PathBuf::from("/changed")));
assert_eq!(display.meta, Some(v2_terminal_meta("malformed terminal")));
});
let unseen = harness.terminal("unseen", cx);
unseen.read_with(cx, |terminal, cx| {
assert_eq!(
terminal.display_state().expect("display state").command(),
Some("applied")
);
assert!(terminal.inner().read(cx).get_content().trim().is_empty());
});
// Only the four snapshot updates decode; every invalid chunk is ignored.
assert_eq!(
harness.received.lock().expect("receive mutex").len(),
received_before
received_before + 4
);
assert!(harness.fallback.lock().expect("fallback mutex").is_empty());
harness.send(
@@ -4981,14 +5003,10 @@ mod tests {
.trim_end(),
"old!"
);
assert_eq!(
terminal.display_state().expect("display").meta,
Some(v2_terminal_meta("terminal"))
);
});
assert_eq!(
harness.received.lock().expect("receive mutex").len(),
received_before + 1
received_before + 5
);
}
@@ -5381,7 +5399,7 @@ mod tests {
let acp_v2::ElicitationScope::Request(scope) = elicitation.request.scope() else {
panic!("expected request-scoped elicitation");
};
assert_eq!(scope.request_id, request_id);
assert_eq!(scope.request_id, acp_v2::RequestId::Number(1));
elicitation.id.clone()
});
assert!(
@@ -5480,7 +5498,7 @@ mod tests {
let acp_v2::ElicitationScope::Request(scope) = elicitation.request.scope() else {
panic!("expected request-scoped elicitation");
};
assert_eq!(scope.request_id, request_id);
assert_eq!(scope.request_id, acp_v2::RequestId::Number(1));
assert!(matches!(
elicitation.status,
acp_thread::ElicitationStatus::Pending { .. }
@@ -5591,7 +5609,7 @@ mod tests {
let acp_v2::ElicitationScope::Request(scope) = elicitation.request.scope() else {
panic!("expected request-scoped elicitation");
};
assert_eq!(scope.request_id, request_id);
assert_eq!(scope.request_id, acp_v2::RequestId::Number(1));
elicitation.id.clone()
});
@@ -10525,7 +10543,13 @@ fn process_output_to_v1(output: acp_thread::ProcessOutput) -> acp::TerminalOutpu
fn terminal_exit_status_to_v1(status: acp_v2::TerminalExitStatus) -> acp::TerminalExitStatus {
acp::TerminalExitStatus::new()
.exit_code(status.exit_code)
// v1 exit codes are unsigned, so a negative platform code (such as a Windows NTSTATUS)
// keeps the 32-bit pattern that v1 Agents have always received.
.exit_code(
status
.exit_code
.and_then(|code| i32::try_from(code).ok().map(|code| code as u32)),
)
.signal(status.signal)
.meta(status.meta)
}
+55 -22
View File
@@ -15,7 +15,7 @@ use action_log::ActionLog;
use agent_client_protocol::{
Agent, Client, ConnectTo, InitializeOutcome, JsonRpcRequest, JsonRpcResponse, Lines,
PreparedRequest, RequestCancellationHandle, V2ConnectionTo,
schema::{ProtocolVersion, v2 as acp},
schema::{ProtocolVersion, v1 as acp_v1, v2 as acp},
};
use anyhow::{Context as _, Result, anyhow};
use collections::HashMap;
@@ -39,6 +39,16 @@ fn is_connection_closed(connection: &V2ConnectionTo<Agent>) -> bool {
connection.is_incoming_closed() || connection.termination().is_some()
}
/// The SDK reports JSON-RPC IDs with the v1 type, which allows `null`. It never assigns
/// `null` to a request it sends and rejects incoming v2 requests that use it.
fn v2_request_id(request_id: &acp_v1::RequestId) -> Result<acp::RequestId> {
match request_id {
acp_v1::RequestId::Number(id) => Ok(acp::RequestId::Number(*id)),
acp_v1::RequestId::Str(id) => Ok(acp::RequestId::Str(id.clone())),
acp_v1::RequestId::Null => Err(anyhow!("v2 requests cannot have a null ID")),
}
}
fn cancel_request_elicitations(
request_id: acp::RequestId,
cx: &mut AsyncApp,
@@ -409,8 +419,9 @@ impl AcpV2Connection {
.url(acp::ElicitationUrlCapabilities::new()),
);
if supports_terminal_auth {
capabilities = capabilities
.auth(acp::AuthCapabilities::new().terminal(acp::TerminalAuthCapabilities::new()));
capabilities = capabilities.auth(
acp::ClientAuthCapabilities::new().terminal(acp::TerminalAuthCapabilities::new()),
);
}
let initialize_request =
acp::InitializeRequest::new(ProtocolVersion::V2, info).capabilities(capabilities);
@@ -583,7 +594,7 @@ impl AcpV2Connection {
// An eagerly spawned child can publish before cancellation drops an unpolled caller.
async move {
let request = connection.prepare_request(request);
let request_id = request.id().clone();
let request_id = v2_request_id(request.id())?;
let cancellation = request.cancellation_handle();
enqueue_notification(&dispatch_tx, request_id.clone(), register_request);
let response = request.block_task();
@@ -1019,7 +1030,10 @@ impl AcpV2Connection {
};
thread.update(cx, |thread, cx| thread.mark_activity_unconfirmed(cx));
let request = self.connection.prepare_request(request);
let request_id = request.id().clone();
let request_id = match v2_request_id(request.id()) {
Ok(request_id) => request_id,
Err(error) => return Task::ready(Err(error)),
};
let cancellation = request.cancellation_handle();
let (response, applied) = Self::ordered_prepared_response(
&self.connection,
@@ -1153,7 +1167,7 @@ impl AcpV2Connection {
let response = async move {
preflight()?;
let (sender, received) = futures::channel::oneshot::channel();
let request_id = request.id().clone();
let request_id = v2_request_id(request.id())?;
let cancellation = request.cancellation_handle();
enqueue_notification(&dispatch_tx, request_id.clone(), register_request);
let published = request.on_receiving_result({
@@ -1292,7 +1306,10 @@ impl AgentConnection for AcpV2Connection {
.additional_directories(context.additional_directories.clone())
.mcp_servers(context.mcp_servers.clone());
let request = self.connection.prepare_request(request);
let request_id = request.id().clone();
let request_id = match v2_request_id(request.id()) {
Ok(request_id) => request_id,
Err(error) => return Task::ready(Err(error)),
};
let (response, applied) = Self::ordered_prepared_response(
&self.connection,
&self.dispatch_tx,
@@ -2090,7 +2107,10 @@ mod tests {
responder: Responder<acp::NewSessionResponse>,
agent: V2ConnectionTo<Client>| {
new_sender
.try_send((request.clone(), responder.id().clone()))
.try_send((
request.clone(),
v2_request_id(responder.id()).expect("v2 request ID"),
))
.expect("record creation");
if *deferred_new.lock().expect("new response mode") {
new_reply_sender
@@ -2381,10 +2401,9 @@ mod tests {
acp::SessionConfigOption::boolean("enabled", "Enabled", false)
.meta(meta("initial-config")),
])
.available_commands(vec![
acp::AvailableCommand::new("initial", "Initial command")
.meta(meta("initial-command")),
])
.available_commands(vec![acp::AvailableCommand::Command(
acp::Command::new("initial", "Initial command").meta(meta("initial-command")),
)])
.meta(meta("delivery-not-session"))
}
@@ -3929,7 +3948,7 @@ done
harness.send_update(
"second",
acp::SessionUpdate::AvailableCommandsUpdate(acp::AvailableCommandsUpdate::new(vec![
acp::AvailableCommand::new("prefix", "Prefix"),
acp::AvailableCommand::Command(acp::Command::new("prefix", "Prefix")),
])),
);
cx.run_until_parked();
@@ -3945,7 +3964,9 @@ done
let config = vec![acp::SessionConfigOption::boolean(
"response", "Response", true,
)];
let commands = vec![acp::AvailableCommand::new("response", "Response")];
let commands = vec![acp::AvailableCommand::Command(acp::Command::new(
"response", "Response",
))];
second_response
.respond(
acp::NewSessionResponse::new("second")
@@ -4245,7 +4266,10 @@ done
assert_eq!(thread.session_info().title.as_deref(), Some("Early title"));
assert!(thread.to_markdown(cx).contains("Early content"));
let (_, tool) = thread.tool_call(&"early-tool".into()).expect("early tool");
assert_eq!(tool.content().len(), 2);
let [content] = tool.content() else {
panic!("the chunk continues the text block");
};
assert_eq!(content.to_markdown(cx), "tool prefixtool suffix");
let terminal = thread
.terminal("early-terminal".into())
.expect("early terminal");
@@ -5608,7 +5632,7 @@ while IFS= read -r request; do
printf '{"jsonrpc":"2.0","id":%s,"result":{"protocolVersion":2,"info":{"name":"session-stdio","version":"1"},"capabilities":{"session":{}}}}\n' "$id"
;;
*'"method":"session/new"'*)
printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"stdio-session","configOptions":[{"configId":"enabled","name":"Enabled","type":"boolean","currentValue":false}],"availableCommands":[{"name":"initial","description":"Initial"}]}}\n' "$id"
printf '{"jsonrpc":"2.0","id":%s,"result":{"sessionId":"stdio-session","configOptions":[{"configId":"enabled","name":"Enabled","type":"boolean","currentValue":false}],"availableCommands":[{"type":"command","name":"initial","description":"Initial"}]}}\n' "$id"
printf '{"jsonrpc":"2.0","method":"session/update","params":{"sessionId":"stdio-session","update":{"sessionUpdate":"session_info_update","title":"Immediate stdio title"}}}\n'
;;
*'"method":"session/set_config_option"'*)
@@ -5999,7 +6023,9 @@ done
.agent
.send_request(acp::CreateElicitationRequest::new(
acp::ElicitationFormMode::new(
acp::ElicitationRequestScope::new(responder.id().clone()),
acp::ElicitationRequestScope::new(
v2_request_id(responder.id()).expect("v2 request ID"),
),
acp::ElicitationSchema::new(),
),
"Resume setup input",
@@ -6337,7 +6363,9 @@ done
.agent
.send_request(acp::CreateElicitationRequest::new(
acp::ElicitationFormMode::new(
acp::ElicitationRequestScope::new(responder.id().clone()),
acp::ElicitationRequestScope::new(
v2_request_id(responder.id()).expect("v2 request ID"),
),
acp::ElicitationSchema::new(),
),
"Resume setup",
@@ -6685,7 +6713,8 @@ done
async move |request: acp::LoginAuthRequest,
responder: Responder<acp::LoginAuthResponse>,
agent: V2ConnectionTo<Client>| {
let request_id = responder.id().clone();
let request_id =
v2_request_id(responder.id()).expect("v2 request ID");
let method_id = request.method_id.clone();
logins
.lock()
@@ -6869,7 +6898,8 @@ done
.expect("published prompt");
assert_eq!(received, request);
let cancellation = responder.cancellation();
let input = harness.request_input(responder.id().clone(), cx);
let input =
harness.request_input(v2_request_id(responder.id()).expect("v2 request ID"), cx);
harness.registered(cx).await;
let expected = acp::PromptResponse::new("accepted-message").meta(meta("receipt"));
responder
@@ -6972,7 +7002,7 @@ done
.await
.expect("first prompt");
let first_cancellation = first_responder.cancellation();
let first_id = first_responder.id().clone();
let first_id = v2_request_id(first_responder.id()).expect("v2 request ID");
let first_input = harness.request_input(first_id.clone(), cx);
harness.registered(cx).await;
let second = cx.update(|cx| {
@@ -6985,7 +7015,10 @@ done
.await
.expect("second prompt");
let second_cancellation = second_responder.cancellation();
let second_input = harness.request_input(second_responder.id().clone(), cx);
let second_input = harness.request_input(
v2_request_id(second_responder.id()).expect("v2 request ID"),
cx,
);
harness.registered(cx).await;
drop(first);
bounded(first_cancellation.cancelled(), cx).await;
+51 -49
View File
@@ -4655,8 +4655,8 @@ pub(crate) mod tests {
response: response.clone(),
};
let (conversation_view, cx) = setup_conversation_view(server, cx).await;
let first_request_id = acp_v1::RequestId::Number(1);
let second_request_id = acp_v1::RequestId::Number(2);
let first_request_id = acp_v2::RequestId::Number(1);
let second_request_id = acp_v2::RequestId::Number(2);
let first_elicitation_id = store.read_with(cx, |store, _cx| {
assert_eq!(
store.elicitations().len(),
@@ -7472,8 +7472,8 @@ pub(crate) mod tests {
.available_commands()
.to_vec();
assert_eq!(available_commands.len(), 1);
assert_eq!(available_commands[0].name.as_str(), "help");
assert_eq!(available_commands[0].description.as_str(), "Get help");
assert_eq!(available_commands[0].name(), "help");
assert_eq!(available_commands[0].description(), "Get help");
});
assert_eq!(
@@ -7494,6 +7494,7 @@ pub(crate) mod tests {
let thread_view = active_thread(&conversation_view, cx);
let thread = thread_view.read_with(cx, |view, _cx| view.thread.clone());
let command_payload = json!({
"type": "command",
"name": "deploy",
"description": "Updated command",
"input": {
@@ -10149,7 +10150,7 @@ pub(crate) mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -10165,7 +10166,7 @@ pub(crate) mod tests {
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(
acp_v1::RequestId::Number(2),
acp_v2::RequestId::Number(2),
),
acp_v2::ElicitationSchema::new().string("account", true),
),
@@ -10281,7 +10282,7 @@ pub(crate) mod tests {
.request_elicitation(
acp_v2::CreateElicitationRequest::new(
acp_v2::ElicitationFormMode::new(
acp_v2::ElicitationRequestScope::new(acp_v1::RequestId::Number(1)),
acp_v2::ElicitationRequestScope::new(acp_v2::RequestId::Number(1)),
acp_v2::ElicitationSchema::new().string("name", true),
),
"Provide a name",
@@ -10435,22 +10436,25 @@ pub(crate) mod tests {
authenticated: Arc::new(Mutex::new(false)),
error_source: AuthErrorSource::Marker,
auth_methods: vec![
acp_v2::AuthMethod::Other(
acp_v2::OtherAuthMethod::new(
"_future_login",
Self::OTHER_AUTH_METHOD_ID,
"Future Login",
std::collections::BTreeMap::from([
("args".into(), json!(["must-not-run"])),
("details".into(), json!({"nested": [1, {"preserve": true}]})),
]),
)
.description("Not supported by this client")
.meta(serde_json::Map::from_iter([(
"terminal-auth".into(),
json!({"command": "must-not-run", "args": ["login"]}),
)])),
),
acp_v2::AuthMethod::Other(acp_v2::OtherAuthMethod::new(
"_future_login",
Self::OTHER_AUTH_METHOD_ID,
"Future Login",
std::collections::BTreeMap::from([
("args".into(), json!(["must-not-run"])),
("details".into(), json!({"nested": [1, {"preserve": true}]})),
("description".into(), json!("Not supported by this client")),
(
"_meta".into(),
json!({
"terminal-auth": {
"command": "must-not-run",
"args": ["login"],
},
}),
),
]),
)),
acp_v2::AuthMethod::Agent(
acp_v2::AuthMethodAgent::new(Self::AUTH_METHOD_ID, "Test Login")
.description("Sign in with the test provider")
@@ -13204,7 +13208,7 @@ pub(crate) mod tests {
thread
.update(cx, |thread, cx| {
thread.append_tool_call_content_chunk(
acp_v2::ToolCallContentChunk::new("historical-chunks", "New mango chunk"),
acp_v2::ToolCallContentChunk::new("historical-chunks", " New mango chunk"),
cx,
)
})
@@ -13215,21 +13219,23 @@ pub(crate) mod tests {
cx.run_until_parked();
assert_eq!(
search_bar.read_with(cx, |bar, _| bar.match_source_ranges()),
vec![9..14, 4..9],
vec![9..14, 26..31],
"the active query must refresh without an explicit update_matches",
);
thread.read_with(cx, |thread, cx| {
assert_eq!(thread.entries().len(), entry_count);
let (index, call) = thread.tool_call(&tool_call_id).expect("historical tool");
assert_eq!(index, original_index);
let [original, appended] = call.content() else {
panic!("expected original output and one appended chunk");
let [original] = call.content() else {
panic!("expected the chunk to continue the original output");
};
assert_eq!(original.markdown(), Some(&original_markdown));
assert_eq!(original_markdown.read(cx).source(), "Original mango output");
let appended = appended.markdown().expect("appended Markdown").read(cx);
assert_eq!(appended.source(), "New mango chunk");
assert_eq!(appended.search_highlights(), &[4..9]);
let original_markdown = original_markdown.read(cx);
assert_eq!(
original_markdown.source(),
"Original mango output New mango chunk"
);
assert_eq!(original_markdown.search_highlights(), &[9..14, 26..31]);
let (index, later_call) = thread.tool_call(&later_tool_call_id).expect("later tool");
assert_eq!(index, later_index);
let [later_content] = later_call.content() else {
@@ -18639,7 +18645,7 @@ pub(crate) mod tests {
click_generic_permission(first_id, None, cx);
assert_eq!(
first_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
thread.read_with(cx, |thread, _| {
let (_, tool) = thread.tool_call(&"permission-tool".into()).expect("tool");
@@ -18648,7 +18654,9 @@ pub(crate) mod tests {
}
#[gpui::test]
async fn test_generic_tool_permission_moves_when_its_tool_arrives(cx: &mut TestAppContext) {
async fn test_generic_tool_permission_attaches_to_the_tool_its_subject_creates(
cx: &mut TestAppContext,
) {
init_test(cx);
let (conversation_view, cx) =
setup_conversation_view(StubAgentServer::default_response(), cx).await;
@@ -18664,10 +18672,7 @@ pub(crate) mod tests {
);
let (request_id, response) = request_test_generic_permission(&thread, request, cx);
cx.run_until_parked();
assert!(cx.debug_bounds("standalone-generic-permissions").is_some());
thread.read_with(cx, |thread, _| assert!(thread.entries().is_empty()));
upsert_permission_test_tool(&thread, "late-permission-tool", cx);
cx.run_until_parked();
thread.read_with(cx, |thread, _| assert_eq!(thread.entries().len(), 1));
assert!(cx.debug_bounds("standalone-generic-permissions").is_none());
assert!(
cx.debug_bounds("tool-call-late-permission-tool-standalone")
@@ -18814,12 +18819,6 @@ pub(crate) mod tests {
})),
Some("generic-permission-unknown-_future_subject"),
),
(
Some(serde_json::json!({
"type": "tool_call", "toolCall": {"toolCallId": "unseen-tool"}
})),
None,
),
] {
let request = generic_permission_prompt(&thread, subject, cx);
let (request_id, response) =
@@ -18869,7 +18868,10 @@ pub(crate) mod tests {
);
});
click_generic_permission(request_id, None, cx);
assert_eq!(response.await, acp_v2::RequestPermissionOutcome::Cancelled);
assert_eq!(
response.await,
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert!(
cx.debug_bounds("generic-permission-title-**Permission title**")
.is_none()
@@ -19034,7 +19036,7 @@ pub(crate) mod tests {
click_generic_permission(third_id, None, cx);
assert_eq!(
third_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
drop(original_root);
}
@@ -19099,7 +19101,7 @@ pub(crate) mod tests {
click_generic_permission(generic_id, None, cx);
assert_eq!(
generic_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
cx.focus(&thread_view);
cx.dispatch_action(crate::AllowOnce);
@@ -19221,7 +19223,7 @@ pub(crate) mod tests {
click_generic_permission(child_id, None, cx);
assert_eq!(
child_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
assert!(root.read_with(cx, |thread, _| thread.permission_request(root_id).is_some()));
conversation_view.update_in(cx, |view, window, cx| {
@@ -19231,7 +19233,7 @@ pub(crate) mod tests {
click_generic_permission(root_id, None, cx);
assert_eq!(
root_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
@@ -19325,7 +19327,7 @@ pub(crate) mod tests {
click_generic_permission(later_id, None, cx);
assert_eq!(
later_response.await,
acp_v2::RequestPermissionOutcome::Cancelled
acp_v2::RequestPermissionOutcome::Cancelled(Default::default())
);
}
root.read_with(cx, |thread, _| assert!(thread.entries().is_empty()));
@@ -51,14 +51,23 @@ impl ElicitationFormState {
let mut fields = HashMap::default();
for (name, property) in &schema.properties {
// The store rejects forms whose required properties can't be rendered, so these
// are optional and left out of the form.
if !acp_thread::is_renderable_elicitation_property(property) {
continue;
}
let is_required = required.iter().any(|required| required == name);
let title = property_title(name, property);
let field = match property {
acp::ElicitationPropertySchema::String(schema) => {
let options = single_select_options(schema);
if options.is_empty() {
let default = schema.default.as_ref().filter(|default| {
validate_string_value(title.clone(), schema, default).is_ok()
});
let editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
if let Some(default) = &schema.default {
if let Some(default) = default {
editor.set_text(default.clone(), window, cx);
}
editor
@@ -74,20 +83,34 @@ impl ElicitationFormState {
}
}
acp::ElicitationPropertySchema::Number(schema) => {
let default =
schema
.default
.map(|default| default.to_string())
.filter(|default| {
validate_number_value(title.clone(), schema, default).is_ok()
});
let editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
if let Some(default) = schema.default {
editor.set_text(default.to_string(), window, cx);
if let Some(default) = default {
editor.set_text(default, window, cx);
}
editor
});
ElicitationFieldState::Text(editor)
}
acp::ElicitationPropertySchema::Integer(schema) => {
let default =
schema
.default
.map(|default| default.to_string())
.filter(|default| {
validate_integer_value(title.clone(), schema, default).is_ok()
});
let editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
if let Some(default) = schema.default {
editor.set_text(default.to_string(), window, cx);
if let Some(default) = default {
editor.set_text(default, window, cx);
}
editor
});
@@ -98,9 +121,7 @@ impl ElicitationFormState {
}
acp::ElicitationPropertySchema::Array(schema) => {
ElicitationFieldState::MultiSelect(
schema
.default
.clone()
multi_select_default_value(schema)
.unwrap_or_default()
.into_iter()
.collect(),
@@ -1159,6 +1180,42 @@ mod tests {
});
}
#[gpui::test]
fn form_state_skips_unrenderable_optional_properties_and_invalid_defaults(
cx: &mut TestAppContext,
) {
crate::conversation_view::tests::init_test(cx);
cx.add_window(|window, cx| {
let schema: acp::ElicitationSchema = serde_json::from_value(serde_json::json!({
"type": "object",
"properties": {
"when": {"type": "_future"},
"labels": {"type": "array", "items": {"type": "_future"}},
"code": {"type": "string", "pattern": "^[0-9]+$", "default": "abc"},
"count": {"type": "integer", "minimum": 1, "default": 0},
"ratio": {"type": "number", "maximum": 1, "default": 2},
"tags": {
"type": "array",
"items": {"type": "string", "enum": ["a", "b"]},
"default": ["a", "c"],
},
},
}))
.expect("form schema");
let form_state = ElicitationFormState::new(&schema, window, cx);
assert!(!form_state.fields.contains_key("when"));
assert!(!form_state.fields.contains_key("labels"));
let content = form_state
.collect(&schema, cx)
.expect("invalid defaults should be ignored");
assert!(content.is_empty(), "{content:?}");
Editor::single_line(window, cx)
});
}
#[gpui::test]
fn form_state_replaces_invalid_required_single_select_default(cx: &mut TestAppContext) {
crate::conversation_view::tests::init_test(cx);
@@ -1526,6 +1583,20 @@ fn single_select_default_value(
.cloned()
}
/// A default with an unknown value or the wrong number of selections doesn't match its schema
/// and is ignored.
fn multi_select_default_value(schema: &acp::MultiSelectPropertySchema) -> Option<Vec<String>> {
let default = schema.default.as_ref()?;
let options = multi_select_options(schema);
let all_offered = default
.iter()
.all(|value| options.iter().any(|option| &option.value == value));
let count = default.len() as u64;
let count_allowed = schema.min_items.is_none_or(|min_items| count >= min_items)
&& schema.max_items.is_none_or(|max_items| count <= max_items);
(all_offered && count_allowed).then(|| default.clone())
}
fn multi_select_options(schema: &acp::MultiSelectPropertySchema) -> Vec<ElicitationOption> {
match &schema.items {
acp::MultiSelectItems::String(items) => items
@@ -2165,7 +2165,7 @@ impl ThreadView {
.read()
.available_commands()
.iter()
.any(|available_command| available_command.name == "logout");
.any(|available_command| available_command.name() == "logout");
if can_login && !logout_supported {
message_editor.update(cx, |editor, cx| editor.clear(window, cx));
self.clear_external_source_prompt_warning(cx);
@@ -14301,8 +14301,8 @@ fn leading_native_command(
let name_end = rest.find(char::is_whitespace).unwrap_or(rest.len());
let name = &rest[..name_end];
let is_native = available_commands.iter().any(|command| {
command.name == name
&& acp_thread::command_category_from_meta(&command.meta)
command.name() == name
&& acp_thread::command_category_from_meta(command.meta())
== Some(acp_thread::CommandCategory::Native)
});
is_native.then(|| name.to_string())
@@ -14384,14 +14384,14 @@ mod tests {
}
fn native_command(name: &str) -> acp_v2::AvailableCommand {
acp_v2::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Native,
acp_v2::AvailableCommand::Command(acp_v2::Command::new(name, "").meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Native),
))
}
fn mcp_command(name: &str) -> acp_v2::AvailableCommand {
acp_v2::AvailableCommand::new(name, "").meta(acp_thread::meta_with_command_category(
acp_thread::CommandCategory::Mcp,
acp_v2::AvailableCommand::Command(acp_v2::Command::new(name, "").meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Mcp),
))
}
+76 -22
View File
@@ -116,14 +116,14 @@ impl SessionCapabilities {
self.available_commands
.iter()
.map(|command| AvailableCommand {
name: command.name.clone().into(),
description: command.description.clone().into(),
name: command.name().to_owned().into(),
description: command.description().to_owned().into(),
requires_argument: matches!(
command.input,
command_input(command),
Some(acp_v2::AvailableCommandInput::Text(_))
),
source: None,
category: acp_thread::command_category_from_meta(&command.meta),
category: acp_thread::command_category_from_meta(command.meta()),
})
.collect()
}
@@ -249,6 +249,14 @@ pub enum MessageEditorEvent {
impl EventEmitter<MessageEditorEvent> for MessageEditor {}
/// Command kinds Zed doesn't know are offered as plain commands without input.
fn command_input(command: &acp_v2::AvailableCommand) -> Option<&acp_v2::AvailableCommandInput> {
match command {
acp_v2::AvailableCommand::Command(command) => command.input.as_ref(),
_ => None,
}
}
const COMMAND_HINT_INLAY_ID: InlayId = InlayId::Hint(0);
fn insert_mention_for_project_path(
@@ -654,9 +662,9 @@ impl MessageEditor {
let command_name = parsed_command.command?;
let available_command = available_commands
.iter()
.find(|available_command| available_command.name == command_name)?;
.find(|available_command| available_command.name() == command_name)?;
let acp_v2::AvailableCommandInput::Text(input) = available_command.input.as_ref()? else {
let acp_v2::AvailableCommandInput::Text(input) = command_input(available_command)? else {
return None;
};
let mut hint = input.hint.clone();
@@ -798,7 +806,7 @@ impl MessageEditor {
// before reaching the resolver.
let direct_match = available_commands
.iter()
.any(|available_command| available_command.name == command_name)
.any(|available_command| available_command.name() == command_name)
|| available_skills
.iter()
.any(|skill| skill.name.as_ref() == command_name);
@@ -844,7 +852,11 @@ impl MessageEditor {
skills
.iter()
.map(|skill| format!("/{}:{}", skill.source, skill.name))
.chain(commands.iter().map(|command| format!("/{}", command.name)))
.chain(
commands
.iter()
.map(|command| format!("/{}", command.name())),
)
.collect::<Vec<_>>()
.join(", ")
}
@@ -2349,7 +2361,9 @@ mod tests {
};
let session_capabilities = SessionCapabilities::new(
acp_v2::PromptCapabilities::default(),
vec![acp_v2::AvailableCommand::new("help", "Get help")],
vec![acp_v2::AvailableCommand::Command(acp_v2::Command::new(
"help", "Get help",
))],
vec![skill],
);
@@ -2365,15 +2379,17 @@ mod tests {
let session_capabilities = SessionCapabilities::new(
acp_v2::PromptCapabilities::default(),
vec![
acp_v2::AvailableCommand::new("compact", "Built-in").meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Native),
acp_v2::AvailableCommand::Command(
acp_v2::Command::new("compact", "Built-in").meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Native),
),
),
acp_v2::AvailableCommand::new("deploy", "MCP").meta(
acp_v2::AvailableCommand::Command(acp_v2::Command::new("deploy", "MCP").meta(
acp_thread::meta_with_command_category(acp_thread::CommandCategory::Mcp),
),
)),
// No category meta: this is how external ACP agents' commands
// arrive, and they should group on their own.
acp_v2::AvailableCommand::new("help", "External"),
acp_v2::AvailableCommand::Command(acp_v2::Command::new("help", "External")),
],
Vec::new(),
);
@@ -2394,6 +2410,32 @@ mod tests {
assert_eq!(category("help"), None);
}
#[test]
fn test_completion_commands_offer_unknown_command_kinds_without_input() {
let command: acp_v2::AvailableCommand = serde_json::from_value(json!({
"type": "_future_kind",
"name": "future",
"description": "Future command",
"input": {"type": "text", "hint": "not a known input"},
}))
.expect("unknown command kinds parse");
let session_capabilities = SessionCapabilities::new(
acp_v2::PromptCapabilities::default(),
vec![command],
Vec::new(),
);
let [command] = session_capabilities
.completion_commands()
.try_into()
.unwrap_or_else(|commands: Vec<_>| {
panic!("expected one command, got {}", commands.len())
});
assert_eq!(command.name.as_ref(), "future");
assert_eq!(command.description.as_ref(), "Future command");
assert!(!command.requires_argument);
}
#[test]
fn test_validate_slash_commands_accepts_scope_qualified_skill() {
let agent_id = AgentId::from("Zed");
@@ -2409,7 +2451,9 @@ mod tests {
// `/:<name>`); project-local skills carry their worktree root
// name. The empty-scope encoding means a worktree literally
// named `global` no longer collides with the global source.
let commands = vec![acp_v2::AvailableCommand::new("help", "Get help")];
let commands = vec![acp_v2::AvailableCommand::Command(acp_v2::Command::new(
"help", "Get help",
))];
let skills = vec![make_skill("deploy", ""), make_skill("deploy", "zed")];
let no_skills = Vec::new();
@@ -2735,9 +2779,9 @@ mod tests {
assert!(error_message.contains("Available commands for Claude Agent: none"));
// Now simulate Claude providing its list of available commands (which doesn't include file)
session_capabilities
.write()
.set_available_commands(vec![acp_v2::AvailableCommand::new("help", "Get help")]);
session_capabilities.write().set_available_commands(vec![
acp_v2::AvailableCommand::Command(acp_v2::Command::new("help", "Get help")),
]);
// Test that unsupported slash commands trigger an error when we have a list of available commands
editor.update_in(cx, |editor, window, cx| {
@@ -2854,9 +2898,16 @@ mod tests {
let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands(
acp_v2::PromptCapabilities::default(),
vec![
acp_v2::AvailableCommand::new("quick-math", "2 + 2 = 4 - 1 = 3"),
acp_v2::AvailableCommand::new("say-hello", "Say hello to whoever you want").input(
acp_v2::AvailableCommandInput::Text(acp_v2::TextCommandInput::new("<name>")),
acp_v2::AvailableCommand::Command(acp_v2::Command::new(
"quick-math",
"2 + 2 = 4 - 1 = 3",
)),
acp_v2::AvailableCommand::Command(
acp_v2::Command::new("say-hello", "Say hello to whoever you want").input(
acp_v2::AvailableCommandInput::Text(acp_v2::TextCommandInput::new(
"<name>",
)),
),
),
],
)));
@@ -3136,7 +3187,10 @@ mod tests {
let session_capabilities = Arc::new(RwLock::new(SessionCapabilities::from_acp_commands(
acp_v2::PromptCapabilities::default(),
vec![acp_v2::AvailableCommand::new("hello", "Say hello")],
vec![acp_v2::AvailableCommand::Command(acp_v2::Command::new(
"hello",
"Say hello",
))],
)));
// Track every event emitted by the message editor across the
@@ -24,7 +24,7 @@ pub struct TerminalToolHeader {
running: bool,
truncated_tooltip: Option<SharedString>,
failed: bool,
exit_code: Option<u32>,
exit_code: Option<i64>,
sandbox_warning: Option<TerminalSandboxWarning>,
on_toggle_expand: Option<ClickHandler>,
on_stop: Option<ClickHandler>,
@@ -70,7 +70,7 @@ impl TerminalToolHeader {
self
}
pub fn failed(mut self, exit_code: Option<u32>) -> Self {
pub fn failed(mut self, exit_code: Option<i64>) -> Self {
self.failed = true;
self.exit_code = exit_code;
self