fix: preserve config import order and restore editor focus
This commit is contained in:
1 parent
1066adb10b
commit
885a0d4597
4 files changed
+8
-5
No files matched your search
@@ -2,7 +2,6 @@
|
||||
|
||||
from copy import deepcopy
|
||||
|
||||
from nanobot.config.loader import resolve_config_env_vars, resolve_env_refs
|
||||
from nanobot.config.schema import Config, ModelPresetConfig, ProviderConfig, RequestOverrides
|
||||
|
||||
|
||||
@@ -10,6 +9,8 @@ def isolate_request_overrides(
|
||||
config: Config, previous: ModelPresetConfig, candidate: ModelPresetConfig,
|
||||
) -> ModelPresetConfig:
|
||||
"""Keep inherited request settings only within the same configured connection."""
|
||||
from nanobot.config.loader import resolve_config_env_vars, resolve_env_refs
|
||||
|
||||
if not any((previous.extra_headers, previous.extra_query, previous.extra_body)):
|
||||
return candidate
|
||||
routing = resolve_config_env_vars(config)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useRef, useState, type ReactElement } from "react";
|
||||
import { useEffect, useRef, useState, type ReactElement } from "react";
|
||||
import { SquarePen } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -25,6 +25,9 @@ export function SettingsTextEditor({ id, title, description, value, placeholder,
|
||||
const editor = useRef<HTMLTextAreaElement>(null);
|
||||
const help = description?.trim();
|
||||
const hasDescription = !!help && help !== title.trim();
|
||||
useEffect(() => {
|
||||
if (error && !saving) editor.current?.focus();
|
||||
}, [error, saving]);
|
||||
const save = async () => {
|
||||
setSaving(true);
|
||||
setError("");
|
||||
@@ -33,7 +36,6 @@ export function SettingsTextEditor({ id, title, description, value, placeholder,
|
||||
setOpen(false);
|
||||
} catch (cause) {
|
||||
setError(cause instanceof Error ? cause.message : String(cause));
|
||||
editor.current?.focus();
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
|
||||
@@ -1189,7 +1189,7 @@
|
||||
"manageProviders": "Manage providers",
|
||||
"configureProvider": "Configure {{provider}}…",
|
||||
"sharedProviderHelp": "Changes affect all presets that use this provider.",
|
||||
"parameterCount": "{{count}} entries",
|
||||
"parameterCount": "Entries: {{count}}",
|
||||
"useProviderSettings": "Use provider settings",
|
||||
"applyToDraft": "Use in preset",
|
||||
"draftHint": "Save the new preset to apply these settings.",
|
||||
|
||||
@@ -142,7 +142,7 @@ describe("Settings models", () => {
|
||||
await waitFor(() => expect(requestMutationMock).toHaveBeenCalledWith(
|
||||
"settings.model_configuration.update", { name: "primary", extra_headers: '{"X-Route":"preset"}' }, 20_000,
|
||||
));
|
||||
fireEvent.click(await screen.findByRole("button", { name: /Headers 1.*Edit/ }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Headers Entries: 1 Edit" }));
|
||||
editor = screen.getByRole("dialog", { name: "Headers", exact: true });
|
||||
fireEvent.change(within(editor).getByRole("textbox", { name: "Headers" }), { target: { value: "" } });
|
||||
fireEvent.click(within(editor).getByRole("button", { name: "Save", exact: true }));
|
||||
|
||||
Reference in new issue
Block a user