mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-28 16:56:16 +08:00
fix: address Hermes review findings (5 medium issues)
- Add missing Hermes MCP import on first launch (lib.rs) - Add Hermes branch in ProviderForm defaultValues fallback - Include Hermes in session manager subtitle (zh/en/ja) - Rename check_openclaw_stream to check_additive_app_stream - Cache parsed HERMES_DEFAULT_CONFIG to avoid repeated JSON.parse
This commit is contained in:
@@ -99,6 +99,7 @@ import {
|
||||
OPENCLAW_DEFAULT_CONFIG,
|
||||
normalizePricingSource,
|
||||
} from "./helpers/opencodeFormUtils";
|
||||
import { HERMES_DEFAULT_CONFIG } from "./hooks/useHermesFormState";
|
||||
import { resolveManagedAccountId } from "@/lib/authBinding";
|
||||
import { useOpenClawLiveProviderIds } from "@/hooks/useOpenClaw";
|
||||
import { useHermesLiveProviderIds } from "@/hooks/useHermes";
|
||||
@@ -261,7 +262,9 @@ export function ProviderForm({
|
||||
? OPENCODE_DEFAULT_CONFIG
|
||||
: appId === "openclaw"
|
||||
? OPENCLAW_DEFAULT_CONFIG
|
||||
: CLAUDE_DEFAULT_CONFIG,
|
||||
: appId === "hermes"
|
||||
? HERMES_DEFAULT_CONFIG
|
||||
: CLAUDE_DEFAULT_CONFIG,
|
||||
icon: initialData?.icon ?? "",
|
||||
iconColor: initialData?.iconColor ?? "",
|
||||
}),
|
||||
|
||||
@@ -12,12 +12,14 @@ interface UseHermesFormStateParams {
|
||||
getSettingsConfig: () => string;
|
||||
}
|
||||
|
||||
const HERMES_DEFAULT_CONFIG_OBJ = {
|
||||
name: "",
|
||||
base_url: "",
|
||||
api_key: "",
|
||||
} as const;
|
||||
|
||||
export const HERMES_DEFAULT_CONFIG = JSON.stringify(
|
||||
{
|
||||
name: "",
|
||||
base_url: "",
|
||||
api_key: "",
|
||||
},
|
||||
HERMES_DEFAULT_CONFIG_OBJ,
|
||||
null,
|
||||
2,
|
||||
);
|
||||
@@ -46,8 +48,7 @@ function parseHermesField<T>(
|
||||
if (initialData?.settingsConfig) {
|
||||
return (initialData.settingsConfig[field] as T) || fallback;
|
||||
}
|
||||
const config = JSON.parse(HERMES_DEFAULT_CONFIG);
|
||||
return (config[field] as T) || fallback;
|
||||
return ((HERMES_DEFAULT_CONFIG_OBJ as Record<string, unknown>)[field] as T) || fallback;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user