mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-30 18:33:04 +08:00
feat: overhaul OpenClaw config panels with JSON5 round-trip write engine
- Add json-five crate for JSON5 serialization preserving comments and formatting - Rewrite openclaw_config.rs with comment-preserving JSON5 read/write engine - Add Tauri commands: get_openclaw_live_provider, write_openclaw_config_section - Redesign EnvPanel as full JSON editor with structured error handling - Add tools.profile selection (minimal/coding/messaging/full) to ToolsPanel - Add legacy timeout migration support to AgentsDefaultsPanel - Add OpenClawHealthBanner component for config validation warnings - Add supporting hooks, mutations, utility functions, and unit tests
This commit is contained in:
@@ -18,6 +18,7 @@ export const openclawKeys = {
|
||||
env: ["openclaw", "env"] as const,
|
||||
tools: ["openclaw", "tools"] as const,
|
||||
agentsDefaults: ["openclaw", "agentsDefaults"] as const,
|
||||
health: ["openclaw", "health"] as const,
|
||||
};
|
||||
|
||||
// ============================================================
|
||||
@@ -81,6 +82,15 @@ export function useOpenClawAgentsDefaults() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useOpenClawHealth(enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: openclawKeys.health,
|
||||
queryFn: () => openclawApi.scanHealth(),
|
||||
staleTime: 30_000,
|
||||
enabled,
|
||||
});
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// Mutation hooks
|
||||
// ============================================================
|
||||
@@ -95,6 +105,7 @@ export function useSaveOpenClawEnv() {
|
||||
mutationFn: (env: OpenClawEnvConfig) => openclawApi.setEnv(env),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.env });
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.health });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -109,6 +120,7 @@ export function useSaveOpenClawTools() {
|
||||
mutationFn: (tools: OpenClawToolsConfig) => openclawApi.setTools(tools),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.tools });
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.health });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -126,6 +138,7 @@ export function useSaveOpenClawAgentsDefaults() {
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.agentsDefaults });
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.defaultModel });
|
||||
queryClient.invalidateQueries({ queryKey: openclawKeys.health });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user