Repository navigation
feat: show own-key cost, active model and a priced model picker - #45
Merged
Merged
Conversation
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.
|
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 |
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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. Returnsnullinstead 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_MODELSentries carry a displayname;USER_KEY_MODELSis built from them and carries prices, so names and prices live in one place.getCurrentMonthUsagedrops theuserKeytotals the web and CLI no longer read, removing a duplicate read of the same rows.summarizeProviderKeysnow 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)🤖 Generated with Claude Code