Draw a model's thinking, and what a reply cost to produce
A llama.cpp session's `reasoning_content` becomes `Event::Thinking` deltas closed by an `Event::ThinkingDone` carrying the span the driver measured, and the phone draws it as a card of its own: "Thinking" with the spinner a running command has, then "Thought for 12.4s". Deliberately not a tool call, so a run of calls cannot collapse the reasoning into "Called 6 tools"; the reasoning is also kept out of the next prompt, which `conversation` already ignored. `UsageDelta` gains `tokensPerSecond`, the provider's own figure or nothing -- llama.cpp reports `timings.predicted_per_second` and the coding CLIs report no such thing -- and a finished reply carries a small line under it saying when it was sent and, where there is one, how fast it came out: "3:00 PM · 149 tok/s". The compact usage bar drops the provider's name for the window and puts its length after the time left instead: "42% · 3h 20m left / 5h". Three things that had to come with it: the transcript coalesces runs of thinking deltas as it does reply deltas, so one block is one row of a page rather than a page of its own; `joinPages` welds a block cut by a page boundary (`healSplitThinking`), since the half with no ending spun for ever; and `UsageDelta` now reaches the fold, which is what carries the rate to the reply. Verified on the emulator against a real Qwen3-0.6B session and the echo rig's new `/think [seconds]`: the spinner while it runs, "Thought for 1.4s" and "2:54 PM · 149 tok/s" after, the reasoning on tapping the card, and the usage bar reading "42% · 3h 19m left / 5h". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
45f249ae91
commit
bb5ac1a242
18 files changed
+900
-101
No files matched your search
@@ -229,6 +229,7 @@ impl Translator {
|
||||
tokens,
|
||||
// Cached input is a subset of this figure, not an additional count.
|
||||
context: last.get("inputTokens").and_then(Value::as_u64),
|
||||
tokens_per_second: None,
|
||||
})
|
||||
.into_iter()
|
||||
.collect()
|
||||
@@ -245,6 +246,7 @@ impl Translator {
|
||||
events.push(Event::UsageDelta {
|
||||
tokens: input.unwrap_or(0) + output.unwrap_or(0),
|
||||
context: input,
|
||||
tokens_per_second: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -935,7 +937,8 @@ mod tests {
|
||||
events[0],
|
||||
Event::UsageDelta {
|
||||
tokens: 18,
|
||||
context: Some(13)
|
||||
context: Some(13),
|
||||
tokens_per_second: None,
|
||||
}
|
||||
);
|
||||
assert!(translator.completed());
|
||||
@@ -1157,7 +1160,8 @@ mod tests {
|
||||
)),
|
||||
vec![Event::UsageDelta {
|
||||
tokens: 42,
|
||||
context: Some(39)
|
||||
context: Some(39),
|
||||
tokens_per_second: None,
|
||||
}]
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -1166,7 +1170,8 @@ mod tests {
|
||||
)),
|
||||
vec![Event::UsageDelta {
|
||||
tokens: 65,
|
||||
context: Some(61)
|
||||
context: Some(61),
|
||||
tokens_per_second: None,
|
||||
}]
|
||||
);
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user