Skip to content

fix(cli): quota renders unrounded percents — 33.33333333333333% used for a one-third-full window #1797

Closed

Description

@developing-today

Problem

opencode quota (human-readable mode) prints each window's usedPercent with raw JavaScript number interpolation — no rounding anywhere in the render path. Most quota providers compute the percent as an unrounded division, so ordinary usage prints with full float noise:

OpenCode Go (opencode-go)
  weekly: 33.33333333333333% used, resets Mon, Dec 31, 6:00 PM

Evidence (verified this run on origin/main aa2fe24, laptop probe importing the real modules)

Probe (~/git/fleet/probe-2026-11-05-quota-render/probe2.ts, kept on the laptop) fed the real parseConsoleGoUsage (packages/ai/src/quota/providers/opencode-go.ts:81, clampPercent((used / limit) * 100)) a console meter of used 100 / limit 300 micro-cents and passed the result to the real renderQuotaResults:

parser windows: {"weekly":{"usedPercent":33.33333333333333, ...}}
rendered: "  weekly: 33.33333333333333% used, resets Mon, Dec 31, 6:00 PM"

The render sites interpolate the number verbatim:

  • packages/cli/src/commands/handlers/quota.ts — window line: ${window.usedPercent}% used
  • same file, per-model parts: ${label} ${window.usedPercent}%

Unrounded producers (grep on main): command-code.ts:67,87; groq.ts:108,120; meta.ts:91; opencode-go.ts:81; opendesign.ts:99; openrouter.ts:131 — all (used / limit) * 100 with clamping only. Turso is the exception: it rounds via its pct3 helper (turso.ts:47), so providers already disagree about percent precision. The existing CLI render tests (packages/cli/test/quota.test.ts:59-60) only use pre-rounded fixtures (4.66, 0.04), so the noise never shows in tests.

Why it matters

This is the human-facing surface of the quota subcommand — the number a user reads to decide whether a pool is spent. Sixteen-digit floats are noise, they differ per provider for no reason, and the JSON shape (which should keep full precision for machines) is not the place to fix it: the render layer owns presentation.

Acceptance criteria

  • Human-readable quota output rounds percents to at most 2 decimal places, trailing zeros trimmed (33.33333333333333 → 33.33; 4.66 stays 4.66; 100 stays 100), in both the window lines and the per-model parts of renderQuotaResults.
  • --json output is unchanged (full-precision numbers for machine consumers).
  • Regression tests in packages/cli/test/quota.test.ts with an unrounded percent (e.g. 100/300) for a window line and a model part.
  • packages/cli quota tests pass.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/cliPackage: cli (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

    @developing-today
    Author

    🤖 Agent note · picked up

    • Agent: new-issue-creator job (new-issue-creator-opencode)
    • Session / ID: cron new-issue-creator-opencode run 2026-11-05 20:35 CST; guarded self-solve per lifecycle protocol §4 (filed this run, trivial xs display fix, no safety labels)
    • Found via: filed this run
    • Task: round percents in renderQuotaResults (window lines + model parts) to ≤2dp with trailing zeros trimmed; --json unchanged; regression tests in packages/cli/test/quota.test.ts
    • Expectation: effort xs; done = fix + targeted tests green on laptop, PR opened and merged, closing note posted
    • Links: branch creator/1797-quota-render-percent-rounding (laptop worktree)
  3. added a commit that references this issue on Nov 6, 2026
  4. developing-today commented on Nov 6, 2026

    @developing-today
    Author

    🤖 Agent note · done

    • Agent: new-issue-creator job (new-issue-creator-opencode)
    • Session / ID: cron new-issue-creator-opencode run 2026-11-05 20:35 CST; guarded self-solve per lifecycle protocol §4
    • Found via: filed this run
    • Task: done — formatPercent rounds percents to ≤2dp (trailing zeros trimmed) at both renderQuotaResults sites (window lines + model parts); --json unchanged
    • Expectation: met — packages/cli quota tests 11 pass / 0 fail on laptop (negative control: new test fails with the handler change stashed), cli typecheck clean; PR fix(cli): round quota percents in human-readable rendering (#1797) #1798 MERGED 0fb9c2b, this issue auto-closed by the merge
    • Links: PR fix(cli): round quota percents in human-readable rendering (#1797) #1798 (branch creator/1797-quota-render-percent-rounding, head 84f28d9); probe ~/git/fleet/probe-2026-11-05-quota-render/
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

    app/cliPackage: cli (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions