Skip to content

feat: show own-key cost, active model and a priced model picker - #45

Merged
hyochan merged 1 commit into
mainfrom
feat/own-key-cost-display
Nov 20, 2026
Merged

hyochan merged 1 commit into
mainfrom
feat/own-key-cost-display

Conversation

@hyochan

@hyochan hyochan commented Nov 20, 2026

Copy link
Copy Markdown
Member

Summary

Owners who run Gitdog on their own Anthropic or OpenAI key could not see what a review cost them or which model ran it. This makes both visible and turns the model choice into a priced picker.

  • Usage page: a "Your API keys" section shows the key, model and effort reviews run on (with the OpenAI backup when both keys work) and a link to change the model; provider cost this period, number of runs and average cost per run; a by-model table; and the ten most recent runs with their cost and a link to the ticket. Each repository card adds its own-key cost.
  • Profile, Your own AI keys: models are square choices with their price per 1M tokens; effort is a radio group; a badge marks the key that runs reviews and its backup; each card shows this period's cost on that key.
  • Ticket page: every action header shows the models that served it and its cost on the owner's key, or the Gitdog tokens it used.

Backend

  • tokenUsage.query.getUserKeyUsage: this period's own-key rows (newest first, capped as before) grouped by model, repository and action, with ticket info for recent actions. Returns null instead of throwing when the quota cannot be verified, so the keys page keeps working.
  • tokenUsage.query.getTicketUsage({ ticketId }): per action, usage split by whose key paid; owner-only, newest 40 actions, at most 300 rows each (well under the read limit).
  • CHAT_MODELS entries carry a display name; USER_KEY_MODELS is built from them and carries prices, so names and prices live in one place.
  • getCurrentMonthUsage drops the userKey totals the web and CLI no longer read, removing a duplicate read of the same rows.
  • Shared helpers: summarizeProviderKeys now also returns the backup key (Claude first, OpenAI takes over), actionTypeLabelKey, useRelativeTime, formatUsdCents.

Costs are labelled as estimates at list prices; reconciling production on 2026-11-20 showed OpenAI bills slightly below list.

Checks

  • bun run lint, bun run typecheck, bun run build, bun run test (2116 passed), bun run check:api, bun run test:cli (115 passed)
  • New tests for both queries (grouping, fallback models, own-key vs Gitdog-key split, other users see nothing) and for the backup key rule.
  • Rendered the new sections with sample data in en and ko at desktop and phone width; an independent review's findings (profile crash on unverified quota, double counting, partial totals, duplicated key rule and labels, radio semantics, square indicators) are fixed.

🤖 Generated with Claude Code

Owners running Gitdog on their own Anthropic or OpenAI key can now see what
that usage costs and which model it runs on.

- Usage page: the key, model and effort reviews run on, provider cost this
  period, average per run, a by-model table and recent runs with their cost;
  own-key cost per repository.
- Profile: models as priced square choices, effort as a radio group, and a
  badge for the key that runs reviews and its backup.
- Ticket page: each action shows its models and what it cost on the owner's
  key, or the Gitdog tokens it used.
- New queries tokenUsage.getUserKeyUsage and getTicketUsage; model names and
  prices come from CHAT_MODELS in one place. getCurrentMonthUsage no longer
  returns the unused userKey totals.
@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit c96bd20):

https://codeyou-df251--pr45-feat-own-key-cost-di-kbe96n5l.web.app

(expires Fri, 27 Nov 2026 08:08:06 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 844dad9c62537d028cabc21008e4e2e4031ce4e5

@gitdogai gitdogai Bot 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.

No issues found in c96bd20

Approved because no issues were found in fully reviewed changes. Tests were not run. Gitdog

@hyochan
hyochan merged commit 0b267be into main Nov 20, 2026
9 checks passed
@hyochan
hyochan deleted the feat/own-key-cost-display branch November 20, 2026 08:10
hyochan added a commit that referenced this pull request Nov 20, 2026
## Summary

Follow-ups found reviewing today's auth 2.0 work (#46, #47, #48) and
own-key cost UI (#45).

- **Connect page**: after 2.0, installation recovery reports
`reauth_required` whenever no fresh attestation exists, so a brand-new
user saw "Finishing GitHub connection" instead of Install. Users without
an installation now see Install, with "Already installed? Verify GitHub
access" as a secondary action. The verification screen is shown only
while an installation callback is pending. Screen choice moved into
`resolveConnectScreen` with a table test.
- **Usage**: the own-key section said reviews run on Gitdog tokens
whenever no key worked, but saved keys never fall back. It now
distinguishes no key / no working key / temporary outage. The page waits
for own-key cost before rendering.
- **Consent page**: shows why a GitHub sign-in failed
(`useOauth().flowError`).
- **CLI**: `github verify` reuses `validateAuthRedirect` (also handles a
missing URL); install hints mention `github verify` before `github
recover`.
- **Smaller**: `getTicketUsage` and recent own-key runs respect
`githubLifecycleOnly`; long-context price note in the model picker;
per-provider "this period" wording; shared `actionTypeLabel`;
screen-reader request count on the usage chip; unused
`repositories[].actions` removed.
- **Docs**: `getAuthUserId` import path, CLI fixed ports, verify-access
architecture line, `CUSTOM_AUTH_SITE_URL` comment.
- **Tests**: session auth rejects a bare user-id subject and a revoked
session; sign-in redirect allow/deny at the mutation; CLI port fallback
and all-ports-busy; consent flow errors. `CONVEX_CLOUD_URL` moved to
test setup.

## Verification

`bun run lint`, `typecheck`, `build`, `format:check`, `check:api`,
`typecheck:cli`, `test:cli` (118 pass), `vitest run` (2124 pass).

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

1 participant