Skip to content

feat(tui): sweep running titles toward text and add KIMI_CODE_TUI_ANIMATION_FPS - #4870

Merged
Grapedge merged 1 commit into
release/2026-11-12from
grop-anim-cp
Nov 12, 2026
Merged

Grapedge merged 1 commit into
release/2026-11-12from
grop-anim-cp

Conversation

@Grapedge

@Grapedge Grapedge commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

本 PR 将已合并的 #4843 cherry-pick 到 release/2026-11-12。全屏模式下,折叠分组的摘要标题和 Thinking 标题在运行时有一道扫光;暗色主题下光带朝背景色走,把字压暗。这个 PR 让光带在两种主题下都朝正文色走,并新增一个环境变量来调整动画帧率。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

扫光改成从运行中底色扫到正文色 text。暗色主题的底色是 textDim;亮色主题是背景色往 text 走 60%,不到 4.5:1 时继续往 text 走,白底上是 #767676,对比度 4.54:1。分组结束后标题照旧淡回 textDim。节奏改成以分组开始为锚,600ms 后第一次扫,之后每 4s 扫一次,每次 1.6s。光带按标题实际画出的宽度走,展开的多行标题也会扫到每一行。

KIMI_CODE_TUI_ANIMATION_FPS 设置共享动画时钟的帧率,取 1 到 60,不设时仍是 120ms 一帧。pi-tui 为此新增了 TuiBase.setAnimationFrameRate,只收 1 到 60 的整数。

决策 选择 没选 理由
光带方向 朝 text 走 朝背景色走 暗色下朝背景色走会把字压暗
亮色底色 背景色往 text 走 60%,不到 4.5:1 时继续加深 textDim;走 50% textDim 离 text 太近,扫光几乎看不出来;50% 在白底只有 3.32:1,不到亮色文字 4.5:1 的要求
帧率 新环境变量,默认不变 调高默认帧率 低配机器的 CPU 开销
帧率接口 整数 FPS,1 到 60 毫秒间隔 限制直接写在接口上,过小、过大的间隔传不进来

建议先看 running-title.ts,它负责颜色和光带位置。再看 packages/pi-tui/src/animation-frame.ts 里帧率改变后的调度,以及 src/tui/config.ts 里的环境变量解析。其余是接线、常量、文档和测试。

Screenshots / Recordings

以下画面来自原 PR #4843 的真实 TUI 抓帧,本 PR cherry-pick 同一实现。左边是原 PR 的 main 基线,右边是改动后。

静态对比,光带扫到标题中间时的一帧

动图对比,8 秒内的两轮扫光

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
运行中标题的扫光(暗色) 光带朝背景色走,把字压暗 从 textDim 提亮到 text 没有正式版用户,扫光还没进正式版(2.5.3 没有),只在 canary 出现过 无
运行中标题的扫光(亮色) 静止为 textDim,光带变浅 静止为 #767676,光带加深到 text 同上 无
扫光节奏 连续循环 600ms 后开始,每 4s 扫一次 同上 无
动画帧率 固定 120ms 一帧 不设变量时不变,设了是 1000/fps 毫秒一帧 无 不设这个变量
非法的 KIMI_CODE_TUI_ANIMATION_FPS 不读这个变量 忽略,并在启动提示里说明 无 删掉这个变量

apps/kimi-code/src/cli/run-shell.ts 在契约文件清单里。它只在交互式 TUI 启动时多读一个环境变量,print 模式走 runPrompt,不受影响。CLI 参数、无头输出和已有的环境变量都没有变。

测试覆盖:

  • 扫光在 transcript-container.test.ts 和 thinking.test.ts。
  • 环境变量在 config.test.ts、run-shell.test.ts 和 kimi-tui-startup.test.ts。
  • 帧率在 packages/pi-tui/test/tui-render.test.ts。
验证

当前 release 分支验证:

  • pnpm --filter @moonshot-ai/kimi-code exec vitest run test/cli/run-shell.test.ts test/tui/components/messages/thinking.test.ts test/tui/components/messages/transcript-container.test.ts test/tui/config.test.ts test/tui/kimi-tui-startup.test.ts:5 个文件、402 个用例通过。
  • pnpm --filter @moonshot-ai/pi-tui test:1150 个用例通过,1 个跳过。
  • @moonshot-ai/kimi-code 与 @moonshot-ai/pi-tui 的 typecheck 均通过。
  • 完整差异的内部标识审计通过。

原 PR #4843 还完成了全量 TUI/run-shell 测试,以及在 tmux 中通过本地 mock 模型运行真实 TUI 的暗色、亮色和帧率验证;视觉证据见上。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6e0c085

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

This PR includes changesets to release 2 packages
Name Type
@moonshot-ai/pi-tui Patch
@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

@pkg-pr-new

pkg-pr-new Bot commented Nov 12, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@6e0c085
npx https://pkg.pr.new/@moonshot-ai/kimi-code@6e0c085

commit: 6e0c085

@Grapedge
Grapedge merged commit bd75a36 into release/2026-11-12 Nov 12, 2026
15 checks passed
@Grapedge
Grapedge deleted the grop-anim-cp branch November 12, 2026 08:56
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026

@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: 6e0c085cba

ℹ️ 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".

Comment on lines +1062 to +1064
setAnimationFrameRate(fps: number): void {
this.animationFrames.setFrameRate(fps);
}

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 Add the frame-rate setter to the shared TUI interface

When a host follows the documented package pattern and stores either renderer as the exported TUI type, TypeScript rejects tui.setAnimationFrameRate(...) because this new method exists only on TuiBase; the new test even had to change its helper from TUI to TuiMainScreen to call it. Declare the setter on TUI so this host-facing extension works through the library's shared public renderer interface.

AGENTS.md reference: packages/pi-tui/AGENTS.md:L7-L15

Useful? React with 👍 / 👎.

Comment on lines +1062 to +1064
setAnimationFrameRate(fps: number): void {
this.animationFrames.setFrameRate(fps);
}

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 Add the frame-rate setter to the shared TUI interface

When a host follows the package's documented pattern and stores either renderer as the exported TUI type, TypeScript rejects tui.setAnimationFrameRate(...) because this new method exists only on TuiBase; the new test even had to change its helper from TUI to TuiMainScreen to call it. Declare the setter on TUI so this host-facing extension works through the library's shared public renderer interface.

AGENTS.md reference: packages/pi-tui/AGENTS.md:L7-L15

Useful? React with 👍 / 👎.

return chalk.hex(mixColors(dim, band, eased * this.level))(character);
}).join('');
const peak = currentTheme.color('text');
const rest = currentTheme.isLight() ? lightRest(currentTheme.terminalBackground(), peak) : dim;

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 Invalidate live-thinking colors when the background changes

When an OSC 11 report changes the terminal background while a light-theme Thinking title is live between sweeps, the requested render returns ThinkingComponent's cached lines, so the newly background-derived rest color is not painted until a later animation frame dirties the cache. This affects explicit light themes and auto mode when the resolved theme remains light; invalidate the live-thinking cache on background updates or include the background in its cache key.

AGENTS.md reference: apps/kimi-code/AGENTS.md:L63-L63

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T08:58:07.886583Z 6e0c085 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Grapedge added a commit that referenced this pull request Nov 12, 2026
* fix(agent-core-v2): truncate oversized skill content (#4834)

* fix(kap-server): bind the main agent when a session is created (#4839)

* fix(kap-server): bind the main agent when a session is created

* fix(kap-server): reject a profile on prompt submissions

* fix(kap-server): reject a profile change through the session profile

* fix(kap-server): wait for model configuration before binding a new session

* fix(agent-core-v2): deduplicate restored task notifications (#4836)

* fix(agent-core-v2): deduplicate restored task notifications

* chore: add notification replay fix changeset

* fix(agent-core-v2): preserve task notifications after prompt-only crashes

* fix(agent-core-v2): complete prompts before ending turns

* test: align lifecycle snapshots with prompt completion order

* fix(agent-core-v2): settle all prompts during turn finalization

* fix(kap-server): drop reserved metadata keys from session profile updates (#4842)

* fix(kap-server): drop reserved metadata keys from session profile updates

* fix(kap-server): keep stored reserved metadata keys on profile updates

* docs: split and rewrite the server API reference (#4841)

* docs: split and rewrite the server API reference

* docs: redirect old server API anchors to the split pages

* docs: describe profile metadata as a replacement

* docs: mark question responses as answered-only

* fix(kap-server): avoid heartbeat timeout after scheduling stalls (#4823)

* fix(kap-server): avoid heartbeat timeout reaping after stalls or clock jumps

* fix(kap-server): grace heartbeat window for short scheduling stalls

* fix(kap-server): treat only clearly late heartbeats as scheduling stalls

* fix(kap-server): time heartbeats on a monotonic clock and drain queued input before reaping

---------

Co-authored-by: Kimi Code (Grok Bot) <[email protected]>

* fix(kap-server): undo a turn only once when requests race (#4846)

* docs: describe heartbeat stall handling (#4849)

* docs: describe heartbeat stall handling

* docs: explain the monotonic clock in the heartbeat notes

* fix(agent-core-v2): acquire session lock before loop restoration (#4848)

* fix(agent-core-v2): acquire session lock before loop restoration

* chore: add session lock lifecycle changeset

* fix(agent-core-v2): hold session lock through loop restoration

- add an operation-scoped lease to the session run gate
- hold it across loop initialization, reset, and pending drains
- cover idle timeout and release ordering

* fix(agent-core-v2): keep the output of stopped tool calls (#4854)

* fix(kap-server): drop the partial reply of a retried step (#4855)

* fix(agent-core-v2): dedupe historical tool schemas (#4862)

* fix(agent-core-v2): dedupe historical tool schemas

* chore: add duplicate tool schema changeset

* fix(agent-core-v2): preserve first tool schema declaration

* fix(agent-core-v2): remind on changed tool schemas

* fix(agent-core-v2): block stale tool schema calls

* fix(agent-core-v2): normalize registry schemas in pending checks

* fix(agent-core-v2): import registry tool metadata type

* fix(agent-core-v2): preserve abort handling during validation

* fix(agent-core-v2): refine validation hook preparation

* fix(agent-core-v2): make validation hooks synchronous

* fix(agent-core-v2): preserve tool result notes on fork (#4867)

* fix(agent-core-v2): preserve tool result notes on fork

* chore: add fork tool result note changeset

* fix(agent-core-v2): scope tool result note restoration to forks

* fix(agent-core-v2): normalize inherited tool result notes

* fix(agent-core-v2): isolate fork note restoration

* feat(tui): sweep running titles toward text and add KIMI_CODE_TUI_ANIMATION_FPS (#4843) (#4870)

* chore: sync web dist from code-app (#4871)

code-app: 8ab17294e031323186d357d121c5360b8353900e

Co-authored-by: kimi-agent-bot <[email protected]>

* ci: release packages (#4835)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* chore: sync web dist from code-app

code-app: 5835391dac3a2b9e0c65ffbd418f0d6042a7adb2

---------

Co-authored-by: Haozhe <[email protected]>
Co-authored-by: qer <[email protected]>
Co-authored-by: Kimi Code (Grok Bot) <[email protected]>
Co-authored-by: grapedge <[email protected]>
Co-authored-by: kimi-agent-bot <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

1 participant