Clean up todo update notification serialization

This commit is contained in:
Charles Cunningham
2026-01-29 11:09:16 -08:00
parent 26e007ba70
commit 1e7dab7e22
2 changed files with 7 additions and 26 deletions
@@ -2256,7 +2256,7 @@ pub struct TurnDiffUpdatedNotification {
}
#[derive(Debug, Clone, PartialEq, JsonSchema, TS)]
#[schemars(schema_with = "turn_todos_updated_schema")]
#[schemars(schema_with = "TurnTodosUpdatedNotificationWire::json_schema")]
#[ts(export_to = "v2/")]
#[ts(as = "TurnTodosUpdatedNotificationWire")]
/// Todo list update from the todo_write tool. `todo` is preferred; `plan` is a legacy alias.
@@ -2268,7 +2268,6 @@ pub struct TurnTodosUpdatedNotification {
pub todo: Vec<TurnTodoStep>,
}
#[allow(dead_code)]
#[derive(Serialize, Deserialize, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
@@ -2283,35 +2282,18 @@ struct TurnTodosUpdatedNotificationWire {
plan: Vec<TurnTodoStep>,
}
#[allow(dead_code)]
fn turn_todos_updated_schema(
generator: &mut schemars::r#gen::SchemaGenerator,
) -> schemars::schema::Schema {
TurnTodosUpdatedNotificationWire::json_schema(generator)
}
impl Serialize for TurnTodosUpdatedNotification {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct Wire<'a> {
thread_id: &'a str,
turn_id: &'a str,
explanation: Option<&'a str>,
todo: &'a [TurnTodoStep],
plan: &'a [TurnTodoStep],
}
// Emit both `todo` and the legacy `plan` alias with identical data.
Wire {
thread_id: &self.thread_id,
turn_id: &self.turn_id,
explanation: self.explanation.as_deref(),
todo: &self.todo,
plan: &self.todo,
TurnTodosUpdatedNotificationWire {
thread_id: self.thread_id.clone(),
turn_id: self.turn_id.clone(),
explanation: self.explanation.clone(),
todo: self.todo.clone(),
plan: self.todo.clone(),
}
.serialize(serializer)
}
@@ -1148,7 +1148,6 @@ async fn handle_turn_todo_update(
outgoing: &OutgoingMessageSender,
) {
if let ApiVersion::V2 = api_version {
// NOTE: The protocol keeps legacy plan aliases for compatibility; this is the todo list update.
let (explanation, todo_items) = todo_update_event.into_parts();
let steps: Vec<TurnTodoStep> = todo_items.into_iter().map(TurnTodoStep::from).collect();
let notification = TurnTodoUpdatedNotification {