Compare commits

...

2 Commits

Author SHA1 Message Date
openhands 4b60d2d89c Revert changes to settings-utils.ts and use-save-settings.ts 2025-03-31 22:13:23 +00:00
openhands d08f315610 Fix API key being set to asterisks in initial setup modal 2025-03-31 22:09:13 +00:00
2 changed files with 20 additions and 2 deletions
@@ -27,7 +27,7 @@ describe("useSaveSettings", () => {
);
});
result.current.mutate({ LLM_API_KEY: null });
result.current.mutate({ LLM_API_KEY: undefined });
await waitFor(() => {
expect(saveSettingsSpy).toHaveBeenCalledWith(
expect.objectContaining({
@@ -41,7 +41,25 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
};
const handleFormSubmission = async (formData: FormData) => {
const newSettings = extractSettings(formData);
// Get the API key input value
const apiKeyInput = formData.get("llm-api-key-input")?.toString();
// Create a new FormData object to avoid modifying the original
const processedFormData = new FormData();
// Copy all entries except the API key
for (const [key, value] of formData.entries()) {
if (key !== "llm-api-key-input") {
processedFormData.append(key, value);
}
}
// Only add the API key if it's not empty and not just whitespace
if (apiKeyInput && apiKeyInput.trim() !== "") {
processedFormData.append("llm-api-key-input", apiKeyInput);
}
const newSettings = extractSettings(processedFormData);
await saveUserSettings(newSettings, {
onSuccess: () => {