fix(tui): repaint the header context window on a /model switch
After `/model`, the header kept the previous model's window ("15K /
1.0M" on a 262K model) until the next turn or a restart. The pager
caches the window inside its context snapshot (streaming `totalTokens`
updates refresh it from the catalog) and nothing refreshed the cache
when the session's model changed. Comparing cached numbers against
catalog windows cannot tell a catalog-derived total from a shell
effective limit (KIGI_DEBUG_CONTEXT_WINDOW, header upgrades), so the
shell, which installs the effective window, now reports it:
- kigi-shell: `handle_set_session_model` returns the installed window;
`model_switch::apply` stamps it as `totalContextTokens` in the
`session/set_model` response meta and carries it on the
`ModelChanged` broadcast (`context_window`, serde-default: old pagers
ignore it, old leaders omit it). The response meta previously
serialized the actor's inner `Result` and reported success on an
actor failure; that error now propagates.
- kigi-tui: `Effect::SwitchModel` reads the meta; `SwitchModelComplete`
carries `Ok(Option<u64>)`; the completion handler and the follower
`ModelChanged` arm call `AgentView::apply_context_window`, which
re-derives the snapshot (pct, free tokens) and reports whether it
changed so a follower redraws on a window-only change.
- Tests: the bare `/model <name>` dispatch path asserts the snapshot and
the drawn header; follower with/without the field; same-model new
window redraw; actor returns the window; serde round trip.
Claude-Session: https://claude.ai/code/session_01RUqV8HVGXcAETyYbZ2tPQ4
This commit is contained in:
1 parent
ff92a00fea
commit
b957e12370
16 files changed
+288
-27
No files matched your search
@@ -1587,7 +1587,12 @@ pub(crate) fn execute(
|
||||
.meta(meta);
|
||||
let result = acp_send(req, &tx)
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map(|resp| {
|
||||
resp.meta
|
||||
.as_ref()
|
||||
.and_then(|m| m.get("totalContextTokens"))
|
||||
.and_then(serde_json::Value::as_u64)
|
||||
})
|
||||
.map_err(|e| {
|
||||
use kigi_shell::agent::config::ModelSwitchIncompatibleAgentError;
|
||||
if let Some(typed) = ModelSwitchIncompatibleAgentError::from_acp_error(
|
||||
|
||||
Reference in new issue
Block a user