fix: render opencode text parts after tools

This commit is contained in:
lucaronin
2026-04-30 03:24:11 +02:00
parent 01a87ed478
commit 176f983dc9
2 changed files with 57 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ where
emit_session_event(json, emit);
}
match json["type"].as_str().unwrap_or_default() {
match event_type(json) {
"message" | "text" => emit_text(json, emit),
"reasoning" => emit_reasoning(json, emit),
"tool_use" | "tool" => emit_tool_start(json, emit),
@@ -29,6 +29,15 @@ where
}
}
fn event_type(json: &serde_json::Value) -> &str {
let direct = json["type"].as_str().unwrap_or_default();
match direct {
"session" | "message" | "text" | "reasoning" | "tool_use" | "tool" | "tool_result"
| "tool_done" | "error" => direct,
_ => json["part"]["type"].as_str().unwrap_or(direct),
}
}
pub(crate) fn session_id(json: &serde_json::Value) -> Option<&str> {
json["sessionID"]
.as_str()