支持部分agent实时更新上下文用量信息
This commit is contained in:
1
src-tauri/Cargo.lock
generated
1
src-tauri/Cargo.lock
generated
@@ -751,6 +751,7 @@ checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32"
|
||||
name = "codeg"
|
||||
version = "0.0.16"
|
||||
dependencies = [
|
||||
"agent-client-protocol-schema",
|
||||
"base64 0.22.1",
|
||||
"bzip2",
|
||||
"chrono",
|
||||
|
||||
@@ -46,6 +46,7 @@ sea-orm-migration = { version = "1.1", features = ["sqlx-sqlite", "runtime-tokio
|
||||
toml = "0.8"
|
||||
notify = "6"
|
||||
base64 = "0.22"
|
||||
agent-client-protocol-schema = { version = "0.10", features = ["unstable_session_usage"] }
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-window-state = "2"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -129,6 +129,12 @@ pub enum AcpEvent {
|
||||
connection_id: String,
|
||||
commands: Vec<AvailableCommandInfo>,
|
||||
},
|
||||
/// Session usage/context window updated during conversation
|
||||
UsageUpdate {
|
||||
connection_id: String,
|
||||
used: u64,
|
||||
size: u64,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user