mirror of
https://github.com/alphaXiv/OpenResearch.git
synced 2026-11-11 09:59:34 +08:00
* Per-session context-window usage meter
Surface how much of the model's context window each chat session has used —
a compact percent pill beside the model picker, with a popover breaking it
down into a progress bar and token caption (amber >=80%, red >=95%).
Backend: harness adapters now parse the token usage the CLIs already emit and
discard today, normalize it into a ContextUsage (used = latest request's
input + cache + output, not cumulative), stream it live over a chat.usage SSE
event, and persist the final value to a new chat_sessions.context_usage_json
column so it survives restarts. session_json carries contextUsage thereafter.
- Claude: assistant message.usage (live) + result modelUsage.contextWindow
(window), falling back to the last usage.iterations entry.
- Codex: app-server turn/completed usage and legacy exec token_count
(input + output; cached_input is a subset). Window from model_context_window
when reported; static fallback intentionally empty (no invented numbers).
- OpenCode: assistant message.updated tokens (input+output+reasoning+cache);
window left unknown (provider config only), so the pill shows the count.
Frontend: ChatSession.contextUsage + fmtTokens helper; a chat.usage listener
that updates the session in place; a ContextMeter pill/popover; and a shared
ProgressBar extracted from SettingsPage and reused in both.
ui/dist rebuilt. A release version bump is still needed to ship.
* Restyle context meter: ring trigger + desktop-style popover
* Context meter: darker value text, more gap before send