支持部分agent实时更新上下文用量信息

This commit is contained in:
xintaofei
2026-03-08 23:48:47 +08:00
parent 53186c4ab5
commit 2b4f00484d
7 changed files with 116 additions and 3 deletions

View File

@@ -1653,6 +1653,10 @@ fn emit_conversation_update(
update: SessionUpdate,
) {
match update {
SessionUpdate::UserMessageChunk(_) => {
// User echo chunks are informational for transcript sync and
// currently not rendered in live ACP UI.
}
SessionUpdate::AgentMessageChunk(ContentChunk {
content: ContentBlock::Text(text),
..
@@ -1665,6 +1669,9 @@ fn emit_conversation_update(
},
);
}
SessionUpdate::AgentMessageChunk(_) => {
// Non-text chunks are currently not surfaced in live streaming UI.
}
SessionUpdate::AgentThoughtChunk(ContentChunk {
content: ContentBlock::Text(text),
..
@@ -1677,6 +1684,9 @@ fn emit_conversation_update(
},
);
}
SessionUpdate::AgentThoughtChunk(_) => {
// Non-text thought chunks are currently ignored.
}
SessionUpdate::ToolCall(tc) => {
let content = serialize_tool_call_content(&tc.content);
let raw_input = json_value_to_text(&tc.raw_input);
@@ -1762,6 +1772,16 @@ fn emit_conversation_update(
},
);
}
SessionUpdate::UsageUpdate(update) => {
let _ = app_handle.emit(
"acp://event",
AcpEvent::UsageUpdate {
connection_id: connection_id.into(),
used: update.used,
size: update.size,
},
);
}
other => {
// Log unhandled update types for debugging
eprintln!("[ACP] Unhandled SessionUpdate: {:?}", other);