Skip to content

Feature Request: Add show_tps_meter config and /tps command for TPS display #1760

@leonidlouis

Description

@leonidlouis

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:

  1. UI State Module (ui/tps_meter.py): Global getter/setter for the toggle state
  2. Config Field (config.py): show_tps_meter: bool = Field(default=False)
  3. Slash Command (ui/shell/slash.py): /tps on|off with persistence
  4. TPS Tracking (soul/kimisoul.py): Rolling 3-second window with CJK-aware token estimation
  5. 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

  • CLI slash command (/tps)
  • Config option (show_tps_meter)
  • Proper precedence logic (runtime toggle > config > default)
  • Session persistence (config saved on toggle)
  • Unit tests (19 tests covering calculation, state, slash command, display)
  • Type checking passes (pyright)
  • Linting passes (ruff)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions