Change onOAuthChange to pass all OAuth fields together

Replace onOAuthChange(field, value) with onOAuthChange(oauth) where
oauth is { clientId, clientSecret, scopes }. Each keystroke now
reports the full OAuth state, not just the single field that changed.
This lets the consumer see the complete picture on every change.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
cliffhall 2026-04-21 20:15:12 -04:00
commit d27018b4f2
3 changed files with 44 additions and 20 deletions

View file

@ -95,17 +95,14 @@ function InteractiveRender(args: ServerSettingsFormProps) {
settings: { ...args.settings, [field]: value },
});
}}
onOAuthChange={(field, value) => {
args.onOAuthChange(field, value);
const fieldMap: Record<string, string> = {
clientId: "oauthClientId",
clientSecret: "oauthClientSecret",
scopes: "oauthScopes",
};
onOAuthChange={(oauth) => {
args.onOAuthChange(oauth);
updateArgs({
settings: {
...args.settings,
[fieldMap[field] ?? field]: value,
oauthClientId: oauth.clientId,
oauthClientSecret: oauth.clientSecret,
oauthScopes: oauth.scopes,
},
});
}}

View file

@ -30,7 +30,13 @@ export interface ServerSettingsFormProps {
onRemoveMetadata: (index: number) => void;
onMetadataChange: (index: number, key: string, value: string) => void;
onTimeoutChange: (field: string, value: number) => void;
onOAuthChange: (field: string, value: string) => void;
onOAuthChange: (oauth: OAuthSettings) => void;
}
export interface OAuthSettings {
clientId: string;
clientSecret: string;
scopes: string;
}
const CONNECTION_MODE_OPTIONS = [
@ -113,6 +119,14 @@ export function ServerSettingsForm({
onTimeoutChange(field, numValue);
};
function currentOAuth(): OAuthSettings {
return {
clientId: settings.oauthClientId ?? "",
clientSecret: settings.oauthClientSecret ?? "",
scopes: settings.oauthScopes ?? "",
};
}
return (
<Accordion
multiple
@ -217,20 +231,33 @@ export function ServerSettingsForm({
<TextInput
label="Client ID"
value={settings.oauthClientId ?? ""}
onChange={(e) => onOAuthChange("clientId", e.currentTarget.value)}
onChange={(e) =>
onOAuthChange({
...currentOAuth(),
clientId: e.currentTarget.value,
})
}
/>
<TextInput
label="Client Secret"
value={settings.oauthClientSecret ?? ""}
type="password"
onChange={(e) =>
onOAuthChange("clientSecret", e.currentTarget.value)
onOAuthChange({
...currentOAuth(),
clientSecret: e.currentTarget.value,
})
}
/>
<TextInput
label="Scopes"
value={settings.oauthScopes ?? ""}
onChange={(e) => onOAuthChange("scopes", e.currentTarget.value)}
onChange={(e) =>
onOAuthChange({
...currentOAuth(),
scopes: e.currentTarget.value,
})
}
/>
</Stack>
</Accordion.Panel>

View file

@ -5,6 +5,7 @@ import { ListToggle } from "../../elements/ListToggle/ListToggle";
import {
ServerSettingsForm,
type ServerSettingsSection,
type OAuthSettings,
} from "../ServerSettingsForm/ServerSettingsForm";
const ALL_SECTIONS: ServerSettingsSection[] = [
@ -88,14 +89,13 @@ export function ServerSettingsModal({
onSettingsChange({ ...settings, [field]: value });
}
function handleOAuthChange(field: string, value: string) {
const oauthFieldMap: Record<string, string> = {
clientId: "oauthClientId",
clientSecret: "oauthClientSecret",
scopes: "oauthScopes",
};
const settingsKey = oauthFieldMap[field] ?? field;
onSettingsChange({ ...settings, [settingsKey]: value });
function handleOAuthChange(oauth: OAuthSettings) {
onSettingsChange({
...settings,
oauthClientId: oauth.clientId,
oauthClientSecret: oauth.clientSecret,
oauthScopes: oauth.scopes,
});
}
return (