Skip to content

What the upstream page needs to edit in one save - #32

Merged
fylorn merged 1 commit into
mainfrom
feat/ui-gaps
Sep 17, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/ui-gaps

Conversation

@fylorn

@fylorn fylorn commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Why

The desktop app's upstream page (next lite PR) edits upstreams, price sheets and speed tests in dialogs. Five things it needs had no endpoint. Without them the page would re-derive core logic, or save one dialog in several config versions.

What

Speed tests for the upstreams the user ticked (/speed/quote, /speed/run)

  • SpeedRunRequest.providers replaces provider. An empty list means all upstreams, and naming an unknown upstream is a 404.
  • Each quote item carries skipped when the upstream cannot serve the model: out_of_scope (outside models_only) or not_offered (missing from its model list). Skipped items stay out of the total and are not sent, because the request would only come back as a 4xx.
  • A disabled upstream can still be tested, which is the point of testing before enabling it. tw_gateway::models::fit is the check shared with routing, minus the disabled test.

A price sheet and the upstreams that use it, in one save

  • PriceSheetSave.used_by: when given, exactly those upstreams use the sheet afterwards, and upstreams that used it but are not listed go back to the default table.
  • The assignment is written in the same config version as the sheet, together with a rename's cascade. An unknown upstream is a 404 and writes nothing.
  • This backs "set prices for these unpriced models on these upstreams" from the pricing tab.

Reads the dialogs need

  • GET /pricing/sheets/{name} returns a sheet's full definition. The overview only carries counts.
  • ProviderView.billing_effective is how the upstream is actually billed when billing is not written, decided the way the ledger decides.
  • POST /providers/preview reports what automatic detection picks for an address: protocol, official endpoint or not, and default redaction kinds. It makes no network calls, so a dialog can call it while the address is typed and the rules stay in core.

The workspace version goes to 0.2.1, the tag the desktop app will pin.

Tests

  • tw-control/tests/speed.rs:
    • a quote for two named upstreams marks the one out of scope and leaves it out of the total;
    • a run skips it without sending;
    • an unknown upstream is a 404.
  • tw-control/tests/pricing.rs:
    • creating with used_by assigns;
    • renaming while moving to another upstream is one version and resets the old user;
    • saving without used_by changes nothing;
    • an unknown upstream writes nothing;
    • a sheet reads back in full.
  • tw-control/tests/models.rs:
    • preview for an official and a relay address;
    • billing_effective when billing is unset.
  • Gates: fmt, clippy -D warnings and cargo test --workspace (1,250 tests) pass.
  • scripts/smoke.sh: 48 passed, 0 failed, 1 over target and not a regression (memory 33 MB against a 30 MB target).

🤖 Generated with Claude Code

The desktop app's upstream page edits upstreams, price sheets and speed
tests in dialogs. Five things it needs had no endpoint, so the page would
have had to re-derive core logic or save in several steps:

- Speed tests take `providers` (empty means all) instead of a single
  `provider`, so a dialog can test the upstreams the user ticked. Each
  quote item says when an upstream cannot serve the model: `out_of_scope`
  when the model is outside `models_only`, `not_offered` when its model
  list lacks it. Those are left out of the total and are not sent, since
  the request would only come back as a 4xx. A disabled upstream can
  still be tested, which is the point of testing before enabling it.
- Saving a price sheet can carry `used_by`: exactly those upstreams use the
  sheet afterwards, and upstreams that used it but are not listed go back to
  the default table. It is written in the same version as the sheet, so
  "set prices for these unpriced models on these upstreams" is one save.
- `GET /pricing/sheets/{name}` returns a sheet's full definition for
  editing. The overview only carries counts.
- `ProviderView.billing_effective` says how an upstream is actually
  billed when `billing` is not written, the same way the ledger decides.
- `POST /providers/preview` reports what automatic detection picks for an
  address, without touching the network: the protocol, whether it is an
  official endpoint, and which kinds would be redacted. A dialog can show
  what "automatic" means while the address is being typed, and the rules
  stay in core.

The workspace version goes to 0.2.1 for the desktop app to pin.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Thanks for the PR. One thing before review: this targets main, and it should target dev.

main is a release-only line — branch-protected, linear history, and every commit on it is a tagged release snapshot. Routine work lands on dev and reaches main with the next release. GitHub pre-filled main here because it is the default branch, so this is our defaults being unhelpful rather than anything you did wrong.

No need to close and reopen: click Edit next to the PR title and change the base branch to dev. The commits and the discussion carry over.

See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract.

@fylorn
fylorn merged commit 529be7c into main Sep 17, 2026
2 checks passed
@fylorn
fylorn deleted the feat/ui-gaps branch September 17, 2026 05:28
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