Skip to content

Progress spinner flickers when the "Refreshing model pricing…" status line wraps on narrow terminals #1411

Closed

Description

@pzhang819

What happened

On an 80-column terminal, every online ccusage run shows this line flickering rapidly until loading finishes:

⠏ Refreshing model pricing from LiteLLM... :: Loading usage logs (0/2) :: Claude, Codex

That combined status is ~85 chars, so on my 80-col terminal it wraps to two rows. The spinner redraw in ProgressState::render (rust/crates/ccusage/src/progress.rs) writes "\r\x1b[K…" every 80ms — \x1b[K only clears the current line, so each frame leaves the wrapped remnant behind, which reads as flicker. Running with -O (which skips the pricing status) avoids it entirely, matching this diagnosis.

Reproduce

  1. Terminal width ≤ ~84 columns
  2. ccusage (online, no -O)
  3. Watch the status line — the flicker is deterministic.

Suggested fix

Truncate the status to terminal_width() - 2 display columns before writing, so it can never wrap (the single-line \r\x1b[K clear then stays correct). terminal_width() is already imported into the crate from ccusage-terminal, so this needs no new dependency.

I'd like to implement this myself.

Version: 20.0.14 · macOS · 80-column terminal

Activity

  1. github-actions commented on Jul 9, 2026

    @github-actions
    Contributor

    This issue was auto-closed. Issues from new contributors are auto-closed by default.

    Maintainers review auto-closed issues and reopen worthwhile ones. Issues that do not meet the quality bar in CONTRIBUTING.md may not be reopened or receive a reply.

    Keep the issue short, concrete, and written in your own voice.

    If a maintainer replies lgtmi, your future issues will stay open. If a maintainer replies lgtm, your future issues and PRs will stay open.

    See CONTRIBUTING.md.

  2. pzhang819 commented on Jul 11, 2026

    @pzhang819
    Author

    Thanks for reopening this. I've got the fix ready and would be happy to open a PR once approved.

    Root cause: ProgressState::render clears with a single-line \r\x1b[K, but the combined status (Refreshing model pricing from LiteLLM... :: Loading usage logs (0/2) :: Claude, Codex, ~85 cols) wraps on terminals ≤84 cols, so the wrapped remnant is never erased → flicker.

    Fix: truncate the status to terminal_width() - 2 before writing so the line always stays single-row, via a small CJK-aware truncate_to_width helper in ccusage-terminal. +76 lines across progress.rs and ccusage-terminal, no new deps.

    Verified on the pinned 1.96.0 toolchain: cargo fmt --check, cargo clippy --all-targets -- -D warnings, and tests all green (adds 3 width tests + 1 progress test, no regressions).

    Happy to send the PR whenever you lgtm.

  3. added a commit that references this issue on Jul 27, 2026
    292e720
  4. ryoppippi commented on Aug 31, 2026

    @ryoppippi
    Member

    Historical audit: this discussion was auto-closed by the legacy contributor gate. That closure did not assess technical importance.

    Audit result: resolved. A later merged change or the current main implementation covers this request. This item is kept for history and does not need to be reopened.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:resolvedResolved by a later change or current implementation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions