TUIにThinkingを表示する実装

This commit is contained in:
2026-04-28 16:10:48 +09:00
parent 513653ce55
commit cf4c454a03
8 changed files with 366 additions and 7 deletions
+22
View File
@@ -7,6 +7,8 @@
#![allow(dead_code)] // Phase 5 will consume `output` in detail mode.
use std::time::Instant;
use protocol::{AlertLevel, AlertSource, Greeting, Segment};
pub enum Block {
@@ -20,6 +22,7 @@ pub enum Block {
AssistantText {
text: String,
},
Thinking(ThinkingBlock),
ToolCall(ToolCallBlock),
Alert {
level: AlertLevel,
@@ -34,6 +37,25 @@ pub enum Block {
},
}
pub struct ThinkingBlock {
/// Accumulated reasoning body. Empty for providers that emit only
/// metadata (no plaintext deltas).
pub text: String,
pub state: ThinkingState,
}
pub enum ThinkingState {
/// Live block: actively streaming. `started_at` is `None` only for
/// blocks materialised from `Event::History`, which never enter the
/// streaming state.
Streaming { started_at: Instant },
/// Block ended cleanly with `ThinkingDone`.
Finished { elapsed_secs: Option<u64> },
/// `TurnEnd` arrived before `ThinkingDone`. Elapsed time is frozen
/// at the last observed instant.
Incomplete { elapsed_secs: Option<u64> },
}
pub enum CompactEvent {
Start,
Done { new_session_id: uuid::Uuid },