Skip to content

feat: log "Check Price" as a job so the /price endpoints are testable - #22

Open
dawidope wants to merge 1 commit into
mainfrom
feat/log-price-checks-as-jobs
Open

feat: log "Check Price" as a job so the /price endpoints are testable#22
dawidope wants to merge 1 commit into
mainfrom
feat/log-price-checks-as-jobs

Conversation

@dawidope

Copy link
Copy Markdown
Contributor

Why

A price check was a throwaway pre-calculation. The proxy called the endpoint's /price path and deliberately skipped every history write, so there was no way to see the request it built, the response the API returned, or a validation error it hit — the /price endpoints were the one part of the API the tester could not actually test.

What changed

Price checks are now persisted like any other request, flagged with isPriceCheck.

  • The job stores the /price path (e.g. images/generations/price) plus the raw request, raw response and response headers — so the row's Raw panel exercises the endpoint the same way a generation row does.
  • A 422 lands as a failed job carrying the API's validation message (The model field is required. (and 3 more errors)), instead of vanishing.
  • The quote is recorded as the job's price and rendered blue with a "Quoted price — this was a price check, nothing was charged" tooltip, so it never reads as a real charge.
  • With the inline boost on, the separately quoted boost fee shows as the usual purple +$… badge (the /price endpoints don't include it, so it is still quoted on the side).
  • Duplicate works from a price row: getEndpointByApiPath now maps a /price path back to the endpoint it priced, and uploads are persisted for price checks too, so the form reloads with its files. (The four transcription variants share one price path, so those resolve to the first of them.)
  • The jobs list refreshes after a failed check too, not just a successful one.

A price check never enters the polling path — it has no request_id, and the async branch is now explicitly skipped for it.

Verified against the live API (dev profile)

case result
JSON price check (txt2img) completed, finalPrice 0.00128984
missing model → 422 failed, "The model field is required. (and 3 more errors)"
price check + enhance_prompt completed, breakdown {base: 0.00128984, boost: 0.010284}
multipart (/prompts/enhancements/price, top-level {price}) completed, finalPrice 0.010284
Check Price clicked in the UI row appears immediately, blue quote + purple boost badge
Duplicate from a price row reloads Text to Image with the same params

npm run lint, npx tsc --noEmit and npm run build are clean. Test history was cleared afterwards.

Not covered

  • No opt-out setting — every Check Price is logged. If the list gets noisy in practice, a filter or a toggle is the natural follow-up.
  • Price rows count toward the 1000-entry history cap like any other job.

🤖 Generated with Claude Code

A price check was a throwaway pre-calculation: the proxy called the
endpoint's /price path and deliberately skipped every history write, so
there was no way to inspect the request/response it produced.

Price checks are now persisted like any other request, flagged with
`isPriceCheck`:
- the job stores the /price path, the raw request/response and the
  response headers, so the Raw panel exercises the endpoint;
- a 422 lands as a failed job with the API's validation message;
- the quote is recorded as the job's price and rendered blue with a
  "nothing was charged" tooltip, so it never reads as a real charge;
- with the inline boost on, the separately quoted boost fee shows as the
  usual +$ badge;
- uploads are persisted for price checks too, and getEndpointByApiPath
  maps a /price path back to the endpoint it priced, so Duplicate reloads
  the same form with its files.

The jobs list also refreshes after a failed check, not just a successful
one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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