Skip to content

feat(control): hand the UI upstream and proxy settings as written - #213

Merged
fylorn merged 1 commit into
mainfrom
feat/settings-as-written
Sep 26, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/settings-as-written

Conversation

@fylorn

@fylorn fylorn commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Summary

The upstream and proxy views masked what they showed, so the edit dialog could not show what is configured:

  • base_url was cut down to its origin. https://bedrock-mantle.us-east-1.api.aws/v1 came back as https://bedrock-mantle.us-east-1.api.aws, flagged base_url_masked, and the dialog said credentials had been hidden when there were none. (The same cut also made the Z.ai sign-in dialog's "replaces the existing upstream" check compare https://api.z.ai with https://api.z.ai/api/anthropic and never match.)
  • The API key and header values were masked; the OAuth refresh token, the client secret and the proxy credentials were left out.

Because the form could not be filled in, every write carried "keep what is saved" states instead of values. GET /config already hands the UI the same file unmasked (only the control key is masked there), so the masking kept nothing from the UI.

Views (as written)

before after
ProviderView.base_url origin only + base_url_masked as written
ProviderView.key SecretView { display, env } string (value or ${NAME})
HeaderView { name, value (masked), masked } { name, value }
OAuthView endpoint, client id + refresh, client_secret (the access token stays out: the gateway renews it)
ProxyView has_auth auth: { user, pass }

Writes (the whole definition)

  • ProviderInput.base_url is required; key is an optional string (no key when absent); every HeaderInput has a value. SecretChange is removed.
  • ProxyInput.auth is optional (no authentication when absent). ProxyAuthInput is removed.
  • OAuthChange keeps Keep: while the dialog is open the gateway may renew the token and write back a new refresh token, which revokes the one in the view.
  • A proxy password may be a ${NAME} reference, as docs/config shows (pass: ${PROXY_PASSWORD}), so the dialog can hand it back as written. control.pass_has_expansion is removed.

Diagnostics bundles and logs still mask; they do not use these views. Secret::shown and Secret::env_var lost their only caller and are removed.

CONTROL_API_VERSION is now 25. ThinkWatch Lite follows in a separate PR once this is released.

Test plan

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings, and -p tw-api --features ts
  • cargo test --workspace — tw-control/tests/resources.rs now covers: the overview shows base URL (with path), key, ${NAME} key and header values as written; saving the upstream as the overview shows it leaves the file untouched apart from the edit (comments kept); a header without a value is refused; a proxy password round-trips, including ${PROXY_PASSWORD}; testing an edited upstream uses the form's key, not the saved one
  • msg-codes.txt regenerated

🤖 Generated with Claude Code

The upstream and proxy views masked what they showed. The base URL was
cut down to its origin, so `https://bedrock-mantle.us-east-1.api.aws/v1`
came back without `/v1` and with a note that credentials had been
hidden when there were none. The API key and header values were masked,
and the OAuth refresh token, the client secret and the proxy
credentials were left out. The edit dialog could not fill them in, so
every write carried "keep what is saved" states instead of values.
`GET /config` hands the UI the same file unmasked, so the masking kept
nothing from the UI; it only kept the form from showing what is set.

Views:
- ProviderView: `base_url` and `key` as written (`key` is the value or
  the `${NAME}` reference); `base_url_masked` and `SecretView` are gone.
- HeaderView: `name` and `value` as written; `masked` is gone.
- OAuthView gains `refresh` and `client_secret`. The access token stays
  out: the gateway renews it and writes it back.
- ProxyView: `auth` ({ user, pass }) replaces `has_auth`.

Writes carry the whole definition:
- ProviderInput: `base_url` is required, `key` is an optional string (no
  key when absent) and every header has a value. `SecretChange` is gone.
- ProxyInput: `auth` is optional (no authentication when absent).
  `ProxyAuthInput` is gone.
- OAuthChange keeps `Keep`: while the dialog is open the gateway may
  renew the token and write back a new refresh token, which revokes the
  one in the view.
- A proxy password may be a `${NAME}` reference, as the configuration
  reference shows (`pass: ${PROXY_PASSWORD}`), so the dialog can hand it
  back as written. `control.pass_has_expansion` is gone.

Diagnostics bundles and logs still mask; they do not use these views.
`Secret::shown` and `Secret::env_var` had no other caller and are gone.

CONTROL_API_VERSION is now 25.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn force-pushed the feat/settings-as-written branch from 99efe51 to a082490 Compare September 26, 2026 11:53
@fylorn
fylorn merged commit 733db3d into main Sep 26, 2026
4 checks passed
@fylorn
fylorn deleted the feat/settings-as-written branch September 26, 2026 12:02
@fylorn fylorn mentioned this pull request Sep 26, 2026
2 tasks done
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