feat(desktop): add pricing override management UI - #4164
Open
liuxiaocs7 wants to merge 2 commits into
Open
Conversation
The Usage → Pricing tab was display-only. The Runtime Host pricing
authority (pricing.query/mutate, PricingStore) and the desktop IPC
handlers (usage:pricing:{list,put,reset}) were already built, but the
preload never bridged the mutation channels and UsagePricingPanel had
no add/edit/reset affordance, so custom per-model prices could not be
configured from the app.
- Expose settings.pricing.{put,reset} on the preload bridge, scoped to
the selected Runtime Host, unwrapping the Result so the form can
surface failures inline.
- Carry modelKey and optional cache rates on UsageStats.pricing so a row
can be edited or reset by its canonical key; project them in the main
process.
- Rework UsagePricingPanel: an "Add pricing" toolbar action, per-row
edit/reset, a Dialog form (provider, model, input/output rates and an
optional cache-rate section), and a destructive-confirm reset. Rates
are validated inline and again on the Host via normalizePricingConfig.
Fixes apache#4163
Generated-by: Claude Code
The pricing override panel adds Astryx surfaces (Dialog, AlertDialog, Layout, Collapsible, NumberInput, HStack, VStack); regenerate the tracked inventory via `npm run astryx:surface-inventory:write` so the CI consistency check passes.
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
The Usage → Pricing tab was display-only. The Runtime Host pricing authority (
pricing.query/pricing.mutate,PricingStore) and the Desktop IPC handlers (usage:pricing:{list,put,reset}) were already implemented and tested, but the preload never bridged the mutation channels andUsagePricingPanelhad no add/edit/reset affordance — so a user could not register a custom per-model price, and a model missing built-in pricing reads as "cost unavailable".This wires up the existing backend to a UI:
settings.pricing.put(config)/settings.pricing.reset(modelKey), scoped to the selected Runtime Host, unwrapping theResultso the form can surface a failure inline.modelKeyand optional cache rates onUsageStats.pricingso a row can be edited/reset by its canonical key; project them in the main process.UsagePricingPanel: an "Add pricing" toolbar action (always visible, so it is discoverable from the empty state), per-row edit/reset, aDialogform (provider, model, input/output rates, and a collapsible optional cache-rate section), and a destructive-confirmAlertDialogfor reset. Rates are validated inline and again on the Host vianormalizePricingConfig. After a mutation the panel reloads so the row and tab count update.zh + en copy added; provider/model are locked while editing since they form the identity key.
Fixes #4163
Verification
Ran locally:
tsc --noEmitfor all four desktop projects (preload, main, renderer, storybook) — pass.@maka/corebuild — pass.node --testonruntime-host-usage-ipc-main.test.js(5),desktop-session-projection.test.js+runtime-host-client-pricing.test.js(22) — pass. The pricing-projection test asserts the newmodelKey+ cache-rate fields and fails without the projection change.biome check(lint + format) on all changed TS files — clean.Not run: I did not launch the Electron app, so there is no screenshot/recording of the new UI yet. The renderer/preload wiring is covered by typecheck + lint against the shared bridge contract rather than an automated UI test. Happy to attach a screenshot on request.
AI use
Select exactly one:
Tool(s) and scope: Claude Code (Claude Opus 4.8) — investigated the existing pricing stack, implemented the preload bridge + panel UI + copy, and updated the projection test. Reviewed and submitted by the human contributor of record. Affected commit carries a
Generated-by: Claude Codetrailer.Checklist
Does this PR entail a change in behavior?