From cb15e9d002b7a305e99be91f30d920954f965aa0 Mon Sep 17 00:00:00 2001 From: dupf Date: Mon, 16 Mar 2026 01:24:40 +0800 Subject: [PATCH] control modify and ui modify --- apps/omninova-tauri/src-tauri/src/lib.rs | 45 +++++++++++++ .../src/components/Setup/Setup.tsx | 67 ++++++++++++------- config.template.toml | 4 +- crates/omninova-core/src/config/loader.rs | 2 +- crates/omninova-core/src/config/schema.rs | 7 +- crates/omninova-core/src/gateway/mod.rs | 2 + crates/omninova-core/src/tools/browser.rs | 19 +++++- 7 files changed, 118 insertions(+), 28 deletions(-) diff --git a/apps/omninova-tauri/src-tauri/src/lib.rs b/apps/omninova-tauri/src-tauri/src/lib.rs index f51d44b..9960d9a 100644 --- a/apps/omninova-tauri/src-tauri/src/lib.rs +++ b/apps/omninova-tauri/src-tauri/src/lib.rs @@ -442,6 +442,16 @@ async fn start_gateway( ) -> Result { let state_ref = state.inner().clone(); sync_gateway_task_state(&state_ref).await; + let runtime = { + let app_state = state_ref.lock().await; + app_state.runtime.clone() + }; + let mut config = runtime.get_config().await; + if ensure_desktop_automation_capabilities(&mut config) { + config.save().map_err(|e| e.to_string())?; + config.save_active_workspace().map_err(|e| e.to_string())?; + runtime.set_config(config).await.map_err(|e| e.to_string())?; + } { let mut app_state = state_ref.lock().await; @@ -750,10 +760,45 @@ fn setup_config_to_core( current.channels_config = channels_to_core(channels); } + ensure_desktop_automation_capabilities(&mut current); current.validate_or_bail().map_err(|e| e.to_string())?; Ok(current) } +fn ensure_desktop_automation_capabilities(config: &mut Config) -> bool { + let mut changed = false; + + if !config.browser.enabled { + config.browser.enabled = true; + changed = true; + } + + let desktop_open_commands = [ + "open", + "xdg-open", + "explorer", + "start", + "cmd", + "powershell", + "pwsh", + "osascript", + ]; + + for command in desktop_open_commands { + if !config + .autonomy + .allowed_commands + .iter() + .any(|existing| existing.eq_ignore_ascii_case(command)) + { + config.autonomy.allowed_commands.push(command.to_string()); + changed = true; + } + } + + changed +} + fn channel_entry_to_core(entry: Option) -> Option { let entry = entry?; if !entry.enabled && entry.token.is_none() && entry.token_env.is_none() { diff --git a/apps/omninova-tauri/src/components/Setup/Setup.tsx b/apps/omninova-tauri/src/components/Setup/Setup.tsx index 02acd49..8dbd943 100644 --- a/apps/omninova-tauri/src/components/Setup/Setup.tsx +++ b/apps/omninova-tauri/src/components/Setup/Setup.tsx @@ -10,7 +10,6 @@ import { ProviderConfigForm } from "./ProviderConfigForm"; import { RobotConfigForm } from "./RobotConfigForm"; import { SkillsConfigForm } from "./SkillsConfigForm"; import { PersonaConfigForm } from "./PersonaConfigForm"; -import { ControlPanel } from "../Console/ControlPanel"; import { invokeTauri } from "../../utils/tauri"; import omninovalLogo from "../../assets/omninoval-logo.png"; @@ -42,12 +41,28 @@ const initialConfig: Config = { }, }; +type SetupTab = "general" | "providers" | "channels" | "skills" | "persona"; +type SetupTabItem = { + id: SetupTab; + label: string; + icon: string; +}; + +const setupTabs: SetupTabItem[] = [ + { id: "general", label: "通用设置", icon: "⚙️" }, + { id: "providers", label: "模型服务", icon: "🤖" }, + { id: "channels", label: "渠道接入", icon: "🔌" }, + { id: "skills", label: "技能扩展", icon: "🛠️" }, + { id: "persona", label: "Agent 人设", icon: "🧠" }, +]; + export function Setup({ onConfigSuccess }: SetupProps) { - const [activeTab, setActiveTab] = useState<"general" | "providers" | "channels" | "skills" | "persona">("general"); + const [activeTab, setActiveTab] = useState("general"); const [config, setConfig] = useState(initialConfig); + const [previewCollapsed, setPreviewCollapsed] = useState(true); const [gatewayStatus, setGatewayStatus] = useState({ running: false, - url: "http://127.0.0.1:42617", + url: "http://127.0.0.1:10809", last_error: null, }); const [busyAction, setBusyAction] = useState< @@ -327,7 +342,7 @@ export function Setup({ onConfigSuccess }: SetupProps) { omninoval_gateway_url: event.target.value, }) } - placeholder="http://localhost:18789" + placeholder="http://localhost:10809" />