feat(tui): add stats display mode for live thinking - #2921
feat(tui): add stats display mode for live thinking#2921jfwang-moonshot wants to merge 1 commit into
Conversation
Add a thinking_live_display preference in tui.toml. The default "preview" keeps the scrolling two-line tail while thinking streams; "stats" hides the text and shows an approximate token count plus elapsed thinking time, leaving a one-line "Thought for …" summary once thinking finishes.
🦋 Changeset detectedLatest commit: 2c02d8f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2c02d8f7cc
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| render_latex = ${String(config.renderLatex !== false)} # false keeps LaTeX math in assistant messages as raw source | ||
| disable_paste_burst = ${String(config.disablePasteBurst)} # true disables non-bracketed paste-burst fallback | ||
| cache_expiry_hint = ${String(config.cacheExpiryHint !== false)} # false disables the "cache expired" dialog on resume / idle submit | ||
| thinking_live_display = "${config.thinkingLiveDisplay ?? 'preview'}" # "preview" scrolls the last lines while thinking streams; "stats" shows ~tokens and elapsed time |
There was a problem hiding this comment.
Preserve stats preference when saving other TUI settings
When a user has thinking_live_display = "stats" and then runs a path that rewrites tui.toml without touching this option (for example /theme, /editor, the update preference, or the cache-expiry “never” action), those paths save { ...currentTuiConfig(host), ... }, but currentTuiConfig still omits thinkingLiveDisplay. Because this line serializes an omitted value as "preview", those unrelated saves silently reset the user's stats preference; include the new field in currentTuiConfig before defaulting on write.
Useful? React with 👍 / 👎.
| true, | ||
| 'live', | ||
| state.ui, | ||
| state.appState.thinkingLiveDisplay ?? 'preview', |
There was a problem hiding this comment.
Don't apply live stats timing to replayed thinking
When thinkingLiveDisplay is stats, replayed sessions also hit this constructor through SessionReplayRenderer.flushAssistant, which calls onThinkingUpdate(thinking) and then immediately onThinkingEnd() for historical messages. That creates a fresh live component with startedAt = Date.now() and finalizes it right away, so every resumed thinking block is hidden behind a misleading Thought for 0s summary instead of preserving the stored thinking preview; keep replay/finalized rendering out of the live stats mode or pass a replay-safe elapsed value.
Useful? React with 👍 / 👎.
| if (this.liveDisplay === 'stats') { | ||
| // No tokenizer is available to the client, and reasoning-token usage | ||
| // only arrives at step end — so the live count is a chars/4 estimate. | ||
| const approxTokens = Math.ceil(this.text.length / 4); |
There was a problem hiding this comment.
skews low for CJK characters
Related Issue
Resolves #287
Problem
What changed
Add a thinking_live_display preference in tui.toml. The default "preview" keeps the scrolling two-line tail while thinking streams; "stats" hides the text and shows an approximate token count plus elapsed thinking time, leaving a one-line "Thought for …" summary once thinking finishes.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.