fix up settings saves (#4037)

This commit is contained in:
Robert Brennan
2024-09-24 14:18:19 -04:00
committed by GitHub
parent 2f1b537471
commit 7b2b1eff57
3 changed files with 5 additions and 9 deletions

View File

@@ -54,8 +54,6 @@ function SettingsForm({
const handleAdvancedChange = (value: boolean) => {
setEnableAdvanced(value);
// Reset the base URL if the user disables advanced options
if (!value) onBaseURLChange("");
};
return (

View File

@@ -87,10 +87,10 @@ export const getSettings = (): Settings => {
export const saveSettings = (settings: Partial<Settings>) => {
Object.keys(settings).forEach((key) => {
const isValid = validKeys.includes(key as keyof Settings);
const value = settings[key as keyof Settings];
if (isValid && typeof value !== "undefined")
localStorage.setItem(key, value.toString());
if (!isValid) return;
let value = settings[key as keyof Settings];
if (value === undefined || value === null) value = "";
localStorage.setItem(key, value.toString());
});
localStorage.setItem("SETTINGS_VERSION", LATEST_SETTINGS_VERSION.toString());
};

View File

@@ -76,9 +76,7 @@ class Session:
AgentStateChangedObservation('', AgentState.LOADING), EventSource.AGENT
)
# Extract the agent-relevant arguments from the request
args = {
key: value for key, value in data.get('args', {}).items() if value != ''
}
args = {key: value for key, value in data.get('args', {}).items()}
agent_cls = args.get(ConfigType.AGENT, self.config.default_agent)
self.config.security.confirmation_mode = args.get(
ConfigType.CONFIRMATION_MODE, self.config.security.confirmation_mode