Summary
Add ability to display tokens-per-second (TPS) meter in the status bar during LLM streaming via config option and slash command.
PR is #1759
Motivation
Currently, users have no visibility into how fast tokens are being streamed. This feature helps users:
- Monitor streaming performance in real-time
- Understand when the model is actively generating vs idle
- Compare speeds across different models/providers
- It's cool to see. - inspired by This Extension of Opencode
Proposed Solution
Config Option
In ~/.kimi/config.toml:
show_tps_meter = true # Default: false
Slash Command
In kimi shell:
/tps on # Enable TPS meter
/tps off # Disable TPS meter
/tps # Show current status
Behavior
| Scenario |
TPS Display |
show_tps_meter = false (default) |
Hidden |
show_tps_meter = true, streaming |
Shows "· 85.3 tok/s" in status bar |
show_tps_meter = true, not streaming |
Hidden (no tokens flowing) |
/tps on during session |
Enables immediately, persists to config |
/tps off during session |
Disables immediately, persists to config |
Implementation Approach
The implementation mirrors the existing theme pattern for global UI state:
- UI State Module (
ui/tps_meter.py): Global getter/setter for the toggle state
- Config Field (
config.py): show_tps_meter: bool = Field(default=False)
- Slash Command (
ui/shell/slash.py): /tps on|off with persistence
- TPS Tracking (
soul/kimisoul.py): Rolling 3-second window with CJK-aware token estimation
- Display Integration (
visualize.py, prompt.py): Conditional display in status bar and bottom toolbar
Technical Details
- Rolling Window: 3-second sliding window for TPS calculation (configurable)
- Token Estimation: CJK-aware heuristic (1.5 tokens per CJK char, 0.25 per ASCII char)
- Performance: Zero overhead when disabled (short-circuit evaluation)
- Pattern: Mirrors
theme.py for consistency with existing codebase conventions
Checklist
Summary
Add ability to display tokens-per-second (TPS) meter in the status bar during LLM streaming via config option and slash command.
PR is #1759
Motivation
Currently, users have no visibility into how fast tokens are being streamed. This feature helps users:
Proposed Solution
Config Option
In
~/.kimi/config.toml:Slash Command
In kimi shell:
Behavior
show_tps_meter = false(default)show_tps_meter = true, streamingshow_tps_meter = true, not streaming/tps onduring session/tps offduring sessionImplementation Approach
The implementation mirrors the existing
themepattern for global UI state:ui/tps_meter.py): Global getter/setter for the toggle stateconfig.py):show_tps_meter: bool = Field(default=False)ui/shell/slash.py):/tps on|offwith persistencesoul/kimisoul.py): Rolling 3-second window with CJK-aware token estimationvisualize.py,prompt.py): Conditional display in status bar and bottom toolbarTechnical Details
theme.pyfor consistency with existing codebase conventionsChecklist
/tps)show_tps_meter)