优化设置页面代码
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
type ReactNode,
|
type ReactNode,
|
||||||
} from "react"
|
} from "react"
|
||||||
import { Reorder, useDragControls } from "motion/react"
|
import { Reorder, useDragControls } from "motion/react"
|
||||||
import { useTranslations } from "next-intl"
|
import { useLocale, useTranslations } from "next-intl"
|
||||||
import { useSearchParams } from "next/navigation"
|
import { useSearchParams } from "next/navigation"
|
||||||
import {
|
import {
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
@@ -2270,6 +2270,7 @@ function AgentReorderItem({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AcpAgentSettings() {
|
export function AcpAgentSettings() {
|
||||||
|
const locale = useLocale()
|
||||||
const t = useTranslations("AcpAgentSettings")
|
const t = useTranslations("AcpAgentSettings")
|
||||||
const rawTranslator = t as unknown as AcpTranslator
|
const rawTranslator = t as unknown as AcpTranslator
|
||||||
acpTranslator = (key, values) => rawTranslator(key, values)
|
acpTranslator = (key, values) => rawTranslator(key, values)
|
||||||
@@ -3029,27 +3030,36 @@ export function AcpAgentSettings() {
|
|||||||
const selectedIsSaving = selectedAgent
|
const selectedIsSaving = selectedAgent
|
||||||
? Boolean(saving[selectedAgent.agent_type])
|
? Boolean(saving[selectedAgent.agent_type])
|
||||||
: false
|
: false
|
||||||
const selectedCodexAuthError =
|
const selectedAgentKind = selectedAgent?.agent_type ?? null
|
||||||
selectedAgent?.agent_type === "codex" && selectedDraft
|
const selectedCodexAuthJsonText = selectedDraft?.codexAuthJsonText ?? ""
|
||||||
? parseCodexAuthJsonText(selectedDraft.codexAuthJsonText)
|
const selectedConfigText = selectedDraft?.configText ?? ""
|
||||||
: null
|
const selectedOpenCodeAuthJsonText = selectedDraft?.openCodeAuthJsonText ?? ""
|
||||||
|
const selectedCodexAuthError = useMemo(() => {
|
||||||
|
if (selectedAgentKind !== "codex" || !locale) return null
|
||||||
|
return parseCodexAuthJsonText(selectedCodexAuthJsonText)
|
||||||
|
}, [locale, selectedAgentKind, selectedCodexAuthJsonText])
|
||||||
const selectedCodexReasoningEffortOption =
|
const selectedCodexReasoningEffortOption =
|
||||||
selectedAgent?.agent_type === "codex" && selectedDraft
|
selectedAgent?.agent_type === "codex" && selectedDraft
|
||||||
? (CODEX_REASONING_EFFORT_OPTIONS.find(
|
? (CODEX_REASONING_EFFORT_OPTIONS.find(
|
||||||
(option) => option.value === selectedDraft.codexReasoningEffort
|
(option) => option.value === selectedDraft.codexReasoningEffort
|
||||||
) ?? null)
|
) ?? null)
|
||||||
: null
|
: null
|
||||||
const selectedOpenCodeConfig =
|
const selectedOpenCodeConfig = useMemo(() => {
|
||||||
selectedAgent?.agent_type === "open_code" && selectedDraft
|
if (selectedAgentKind !== "open_code" || !locale) return null
|
||||||
? extractOpenCodeConfigValues(
|
return extractOpenCodeConfigValues(
|
||||||
selectedDraft.configText,
|
selectedConfigText,
|
||||||
selectedDraft.openCodeAuthJsonText
|
selectedOpenCodeAuthJsonText
|
||||||
)
|
|
||||||
: null
|
|
||||||
const selectedChecks = useMemo(
|
|
||||||
() => (selectedAgent ? getAgentChecks(selectedAgent, selectedCurrent) : []),
|
|
||||||
[selectedAgent, selectedCurrent]
|
|
||||||
)
|
)
|
||||||
|
}, [
|
||||||
|
locale,
|
||||||
|
selectedAgentKind,
|
||||||
|
selectedConfigText,
|
||||||
|
selectedOpenCodeAuthJsonText,
|
||||||
|
])
|
||||||
|
const selectedChecks = useMemo(() => {
|
||||||
|
if (!selectedAgent || !locale) return []
|
||||||
|
return getAgentChecks(selectedAgent, selectedCurrent)
|
||||||
|
}, [locale, selectedAgent, selectedCurrent])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectedAgent || selectedChecks.length === 0) return
|
if (!selectedAgent || selectedChecks.length === 0) return
|
||||||
@@ -3179,7 +3189,7 @@ export function AcpAgentSettings() {
|
|||||||
claudeDefaultOpusModel: important.claudeDefaultOpusModel,
|
claudeDefaultOpusModel: important.claudeDefaultOpusModel,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleImportantConfigChange = useCallback(
|
const handleImportantConfigChange = useCallback(
|
||||||
@@ -3212,7 +3222,7 @@ export function AcpAgentSettings() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleGeminiFieldChange = useCallback(
|
const handleGeminiFieldChange = useCallback(
|
||||||
@@ -3298,7 +3308,7 @@ export function AcpAgentSettings() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleGeminiAuthModeChange = useCallback(
|
const handleGeminiAuthModeChange = useCallback(
|
||||||
@@ -3364,7 +3374,7 @@ export function AcpAgentSettings() {
|
|||||||
configText: nextConfig.configText,
|
configText: nextConfig.configText,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleOpenClawFieldChange = useCallback(
|
const handleOpenClawFieldChange = useCallback(
|
||||||
@@ -3393,7 +3403,7 @@ export function AcpAgentSettings() {
|
|||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleOpenCodeConfigPatch = useCallback(
|
const handleOpenCodeConfigPatch = useCallback(
|
||||||
@@ -3956,7 +3966,7 @@ export function AcpAgentSettings() {
|
|||||||
codexSupportsWebsockets: important.supportsWebsockets,
|
codexSupportsWebsockets: important.supportsWebsockets,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleCodexConfigTomlTextChange = useCallback(
|
const handleCodexConfigTomlTextChange = useCallback(
|
||||||
@@ -4014,7 +4024,7 @@ export function AcpAgentSettings() {
|
|||||||
codexConfigTomlText: nextToml,
|
codexConfigTomlText: nextToml,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
[selectedAgent, selectedDraft, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleCodexImportantConfigChange = useCallback(
|
const handleCodexImportantConfigChange = useCallback(
|
||||||
@@ -4081,7 +4091,7 @@ export function AcpAgentSettings() {
|
|||||||
codexConfigTomlText: nextToml,
|
codexConfigTomlText: nextToml,
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
[selectedAgent, selectedDraft, updateSelectedDraft]
|
[selectedAgent, selectedDraft, t, updateSelectedDraft]
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleCodexSupportsWebsocketsChange = useCallback(
|
const handleCodexSupportsWebsocketsChange = useCallback(
|
||||||
|
|||||||
@@ -559,7 +559,14 @@ export function McpSettings() {
|
|||||||
} finally {
|
} finally {
|
||||||
setRunningAction(null)
|
setRunningAction(null)
|
||||||
}
|
}
|
||||||
}, [localAppsDraft, localSpecText, refreshLocalServers, selectedLocal, t])
|
}, [
|
||||||
|
localAppsDraft,
|
||||||
|
localSpecText,
|
||||||
|
mcpT,
|
||||||
|
refreshLocalServers,
|
||||||
|
selectedLocal,
|
||||||
|
t,
|
||||||
|
])
|
||||||
|
|
||||||
const switchInstallOption = useCallback(
|
const switchInstallOption = useCallback(
|
||||||
(optionId: string) => {
|
(optionId: string) => {
|
||||||
@@ -668,6 +675,7 @@ export function McpSettings() {
|
|||||||
marketDetail,
|
marketDetail,
|
||||||
marketSpecDirty,
|
marketSpecDirty,
|
||||||
marketSpecText,
|
marketSpecText,
|
||||||
|
mcpT,
|
||||||
refreshLocalServers,
|
refreshLocalServers,
|
||||||
selectedInstallOption,
|
selectedInstallOption,
|
||||||
t,
|
t,
|
||||||
|
|||||||
Reference in New Issue
Block a user