diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 70b05b61..92edd4aa 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -501,7 +501,7 @@ pub fn run() { log::info!("✓ Imported {count} OpenCode provider(s) from live config"); } Ok(_) => log::debug!("○ No OpenCode providers found to import"), - Err(e) => log::debug!("○ Failed to import OpenCode providers: {e}"), + Err(e) => log::warn!("○ Failed to import OpenCode providers: {e}"), } // 2.2 OMO 配置导入(当数据库中无 OMO provider 时,从本地文件导入) @@ -534,7 +534,7 @@ pub fn run() { log::info!("✓ Imported {count} OpenClaw provider(s) from live config"); } Ok(_) => log::debug!("○ No OpenClaw providers found to import"), - Err(e) => log::debug!("○ Failed to import OpenClaw providers: {e}"), + Err(e) => log::warn!("○ Failed to import OpenClaw providers: {e}"), } // 3. 导入 MCP 服务器配置(表空时触发) diff --git a/src-tauri/src/services/provider/live.rs b/src-tauri/src/services/provider/live.rs index 01242fd5..2bd279a6 100644 --- a/src-tauri/src/services/provider/live.rs +++ b/src-tauri/src/services/provider/live.rs @@ -707,6 +707,16 @@ pub fn import_openclaw_providers_from_live(state: &AppState) -> Result { }; } - // Optional numeric fields + // Optional fields if (workspace.trim()) updated.workspace = workspace.trim(); else delete updated.workspace; - if (timeout.trim()) updated.timeout = Number(timeout); + // Numeric fields: validate before saving to avoid NaN + const parseNum = (v: string) => { + const n = Number(v); + return !isNaN(n) && isFinite(n) ? n : undefined; + }; + + const timeoutNum = timeout.trim() ? parseNum(timeout) : undefined; + if (timeoutNum !== undefined) updated.timeout = timeoutNum; else delete updated.timeout; - if (contextTokens.trim()) updated.contextTokens = Number(contextTokens); + const ctxNum = contextTokens.trim() ? parseNum(contextTokens) : undefined; + if (ctxNum !== undefined) updated.contextTokens = ctxNum; else delete updated.contextTokens; - if (maxConcurrent.trim()) updated.maxConcurrent = Number(maxConcurrent); + const concNum = maxConcurrent.trim() + ? parseNum(maxConcurrent) + : undefined; + if (concNum !== undefined) updated.maxConcurrent = concNum; else delete updated.maxConcurrent; await openclawApi.setAgentsDefaults(updated); diff --git a/src/components/openclaw/EnvPanel.tsx b/src/components/openclaw/EnvPanel.tsx index 9a36844a..53784506 100644 --- a/src/components/openclaw/EnvPanel.tsx +++ b/src/components/openclaw/EnvPanel.tsx @@ -112,7 +112,8 @@ const EnvPanel: React.FC = () => {
{entries.map((entry, index) => { const sensitive = isApiKey(entry.key); - const visible = visibleKeys.has(`${index}`); + const visibilityId = entry.key || `__new_${index}`; + const visible = visibleKeys.has(visibilityId); return (
@@ -138,7 +139,7 @@ const EnvPanel: React.FC = () => { variant="ghost" size="icon" className="flex-shrink-0 h-9 w-9 text-muted-foreground" - onClick={() => toggleVisibility(`${index}`)} + onClick={() => toggleVisibility(visibilityId)} > {visible ? (