Skip to content

feat(tui): add stats display mode for live thinking - #2921

Open
jfwang-moonshot wants to merge 1 commit into
MoonshotAI:mainfrom
jfwang-moonshot:feat/thinking-live-stats
Open

feat(tui): add stats display mode for live thinking#2921
jfwang-moonshot wants to merge 1 commit into
MoonshotAI:mainfrom
jfwang-moonshot:feat/thinking-live-stats

Conversation

@jfwang-moonshot

Copy link
Copy Markdown

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

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

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-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2c02d8f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skews low for CJK characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toggle to disable thinking content

1 participant