diff --git a/src/features/providers/sheets/forms/BaseProviderForm.tsx b/src/features/providers/sheets/forms/BaseProviderForm.tsx index 232d937..820bb16 100644 --- a/src/features/providers/sheets/forms/BaseProviderForm.tsx +++ b/src/features/providers/sheets/forms/BaseProviderForm.tsx @@ -642,7 +642,7 @@ export function BaseProviderForm({ className={styles.addBtn} disabled={mutating} onClick={() => - updateField('apiKeyEntries', [emptyApiKeyEntry(), ...apiKeyEntries]) + updateField('apiKeyEntries', [...apiKeyEntries, emptyApiKeyEntry()]) } > @@ -663,16 +663,17 @@ export function BaseProviderForm({ {t('providersPage.connectivity.testAll')} - {apiKeyEntries.map((entry, idx) => { - const status = connectivity.openaiStatuses[idx] ?? { + {[...apiKeyEntries].reverse().map((entry, visualIdx) => { + const realIdx = apiKeyEntries.length - 1 - visualIdx; + const status = connectivity.openaiStatuses[realIdx] ?? { state: 'idle' as ConnectivityState, message: '', }; return ( -
+
- {t('providersPage.form.apiKeyEntry', { index: idx + 1 })} + {t('providersPage.form.apiKeyEntry', { index: realIdx + 1 })}
@@ -680,7 +681,7 @@ export function BaseProviderForm({ type="button" className={styles.connectivityBtnGhost} disabled={mutating || status.state === 'loading'} - onClick={() => void connectivity.runOpenAIKey(idx)} + onClick={() => void connectivity.runOpenAIKey(realIdx)} > {status.state === 'loading' ? ( @@ -696,7 +697,7 @@ export function BaseProviderForm({ onClick={() => updateField( 'apiKeyEntries', - apiKeyEntries.filter((_, i) => i !== idx) + apiKeyEntries.filter((_, i) => i !== realIdx) ) } > @@ -716,7 +717,7 @@ export function BaseProviderForm({ updateField( 'apiKeyEntries', apiKeyEntries.map((it, i) => - i === idx ? { ...it, apiKey: e.target.value } : it + i === realIdx ? { ...it, apiKey: e.target.value } : it ) ) } @@ -735,7 +736,7 @@ export function BaseProviderForm({ updateField( 'apiKeyEntries', apiKeyEntries.map((it, i) => - i === idx ? { ...it, proxyUrl: e.target.value } : it + i === realIdx ? { ...it, proxyUrl: e.target.value } : it ) ) } @@ -759,7 +760,7 @@ export function BaseProviderForm({ updateField( 'apiKeyEntries', apiKeyEntries.map((it, i) => - i === idx ? { ...it, headersText: e.target.value } : it + i === realIdx ? { ...it, headersText: e.target.value } : it ) ) }