Skip to content

Compact number formatter shows "1000.0K" instead of "1.0M" near 1M #33947

Closed as not planned

Description

@IbrahimKhan12

Description

Locale.number() (the TUI compact count formatter in packages/tui/src/util/locale.ts) rounds the thousands value with toFixed(1), so counts from 999,950 to 999,999 render as 1000.0K instead of rolling over to 1.0M. It is user-visible in the TUI context/token displays (and the CLI run summary) for a session approaching a 1,000,000-token context window, e.g. 1000.0K (100%).

Steps to reproduce

  1. Use a model with a ~1,000,000-token context window.
  2. Grow a session's token usage into the 999,950-999,999 range.
  3. The context indicator shows 1000.0K instead of 1.0M.

Equivalently, Locale.number(999950) returns "1000.0K"; expected "1.0M".

OpenCode version

1.17.10 (also present on dev)

Operating System

All

Activity

  1. Hotragn commented on Jul 28, 2026

    @Hotragn

    Taking this one if nobody's on it. The K branch formats num / 1000 with toFixed(1), so anything from 999,950 up rounds to 1000.0K before the >= 1000000 check can promote it to M. Fix is to roll over at 999,950 — the point where one-decimal rounding reaches 1000.0K — so those values format as 1.0M. Sending a PR with a unit test shortly.

  2. added a commit that references this issue on Aug 21, 2026
    4c7241d
  3. added a commit that references this issue on Sep 5, 2026
    9a5156e
  4. github-actions commented on Sep 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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