Skip to content

Sidebar usage can flicker/stick at 100% on thread resume #495

@amanthanvi

Description

@amanthanvi

Summary

Entering an in-progress thread can cause the bottom-left sidebar usage bars (Session, Weekly) to briefly show correct values, then flip to 100%, sometimes recover, and then get stuck at 100%.

Reproduction

  1. Enable Settings → Display → Show remaining Codex limits.
  2. Open a workspace with active/in-progress thread activity.
  3. Enter/switch into the in-progress thread.
  4. Observe the sidebar usage bars.

Actual

  • Usage values can oscillate between correct values and 100%.
  • In some runs, both bars eventually remain stuck at 100%.

Expected

  • Sidebar usage bars should only change when valid usage values actually change.
  • Partial rate-limit updates must not overwrite known-good usage values.
  • Unknown usage should render as unknown (--), not fabricated values.

Root Cause (frontend)

Rate-limit normalization currently defaults missing numeric fields to 0 and is used for both:

  • explicit account/rateLimits/read refresh responses, and
  • live account/rateLimits/updated events.

When incoming payloads are partial (for example, missing usedPercent / used_percent), the normalizer can coerce usage to 0. In remaining mode, that is rendered as 100% remaining, producing the observed flash/stuck behavior.

Proposed Fix

  • Make rate-limit normalization merge-aware:
    • preserve previous known-good usedPercent when incoming payload omits usage values;
    • support both used-style and remaining-style percent fields;
    • avoid fabricating usage from absent fields.
  • Apply merge-aware normalization in both refresh and live-event paths before reducer updates.
  • Add regression tests for:
    • partial payloads preserving prior usage,
    • missing percent fields not becoming fake 100%,
    • event + refresh path behavior.

Acceptance Criteria

  • No false 100% usage flashes during thread entry/resume.
  • No stuck 100% state from partial rate-limit updates.
  • Existing valid updates still propagate immediately.
  • Targeted tests and typecheck pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions