Skip to content

feat(usage): expose Qoder account quota to omp usage - #47

Merged
simonsmh merged 1 commit into
simonsmh:mainfrom
Qiiks:feat/omp-usage
Nov 1, 2026
Merged

simonsmh merged 1 commit into
simonsmh:mainfrom
Qiiks:feat/omp-usage

Conversation

@Qiiks

@Qiiks Qiiks commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

What

omp usage shows the Qoder account with no data, even though the extension already fetches and parses Qoder's quota for /qoder-usage.

OMP renders provider quotas from a provider-level usage slot on the registration. pi's published ProviderConfig has no such field (the extension carries a separate fetchUsage hook on oauth for pi), so under OMP nothing answers the usage probe.

This maps the quota payload the extension already parses onto the host's normalized report:

  • one limit per Credit bucket (user / add-on / organization) with numeric used / limit / remaining and a usedFraction when the bucket has a total
  • the plan expiry as the window boundary, labelled plan expires; Qoder's year-9999 "no expiry" sentinel is dropped instead of rendering a ~8000-year countdown
  • the account kind and the manage URL as report notes

Two host-contract details, both from OMP's own packages/ai/src/usage.ts (v18.14.1):

  • validatesCredentials: false — a quota read is account-wide, so a failed read must render as missing data rather than mark a credential unhealthy (packages/ai/src/auth/health.ts:381).
  • the fetch accepts the host's normalized credential (accessToken, UsageCredential) and pi's OAuth grant (access, OAuthCredentials), returning null when neither is present.

Verification

Against a live OMP 18.14.1 install with this branch built:

$ omp usage
Qoder — 1 account
  Account kind: personal_standard
  0.00 credits remaining
  Manage: https://qoder.com
  ● account 1
      ● User Quota  ····························  0 / 0 credits

--json carries the same mapping (limits[].amount, status, notes). The other OMP surfaces were checked as-is and needed no change: omp models lists both models, omp login lists Qoder (Browser OAuth / PAT) and Qoder CN (PAT), and a live turn reaches Qoder's authenticated endpoint (this test account answers 403 … RESOURCE_LIMIT because its Credit balance is zero, which is also what the new usage row reports).

npm test 414 passed (8 new in src/__tests__/usage-provider.test.ts), npm run check clean, biome check clean.

Notes

  • The year-9999 sentinel and the zero-total bucket are covered by tests against the real payload's field names, so endpoint drift fails as a test rather than as an empty row.
  • pi behaviour is unchanged: the extra key is ignored by pi's registration, and /qoder-usage remains pi's quota view.

OMP renders provider quotas from a provider-level `usage` slot that pi's
published ProviderConfig lacks, so `omp usage` listed the Qoder account
with no data despite a working quota endpoint. Map the already-parsed
quota payload onto the host's normalized report: one limit per Credit
bucket with numeric used/limit/remaining, the plan expiry when the
account has one (Qoder's year-9999 sentinel is not a reset), and the
account kind.

A quota read is account-wide, so the provider reports
`validatesCredentials: false`: a failed read renders as missing data and
never marks a working credential unhealthy. The fetch accepts both the
host's normalized credential (`accessToken`) and pi's OAuth grant
(`access`), and returns null when neither exists.
Copilot AI balanced review requested due to automatic review settings October 31, 2026 06:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@simonsmh
simonsmh merged commit a0c3730 into simonsmh:main Nov 1, 2026
@simonsmh

simonsmh commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Merged — thank you! Squash-merged as a0c3730 and shipped in v0.6.7: https://github.com/simonsmh/pi-provider-qoder/releases/tag/v0.6.7

Verified before merging, beyond the test suite:

  • Checked OMP's own contract (usage slot on the provider registration, validatesCredentials: false health semantics) against OMP source — the mapping lines up.
  • Live A/B with an isolated OMP install: the PR build shows real quota rows (omp usage lists the account's Credit buckets, remaining balance, and plan expiry); v0.6.6 with the same login still reports 'No usage data'.
  • pi side checked too: the PR build loads in pi and lists models normally — the extra usage key is ignored as claimed.

One note from my run: two providers.test.ts tests timed out / miscounted in my sandbox. That turned out to be pre-existing, not caused by this PR — with stored credentials and a stale cache, the startup catalog refresh hung without direct egress. I fixed the tests on main after merging (12a3093, stub the network before registration); the full suite is now 414/414 green. Thanks again!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants