fix(agents): update applied config only when model selection changes
This commit is contained in:
1 parent
03cf1167f7
commit
4d32f58ee2
2 files changed
+25
-9
No files matched your search
@@ -602,6 +602,7 @@ export const zhCN = {
|
||||
'agents.oauthLoginRequired.launchDescription': '已开启 OAuth 配置模式,但未检测到有效的 Codex 登录凭据。请先在 Codex 中登录 ChatGPT 账号,然后再启动。',
|
||||
'agents.oauthLoginRequired.confirm': '我知道了',
|
||||
'agents.modify.apply': '应用配置修改',
|
||||
'agents.modify.update': '更新配置',
|
||||
'agents.modify.close': '关闭配置修改',
|
||||
'agents.modify.default': '默认配置',
|
||||
'agents.modify.clear': '清空配置',
|
||||
@@ -1560,6 +1561,7 @@ export const en: Record<MessageKey, string> = {
|
||||
'agents.oauthLoginRequired.launchDescription': 'OAuth configuration mode is enabled, but no valid Codex sign-in credentials were found. Sign in to your ChatGPT account in Codex before launching it.',
|
||||
'agents.oauthLoginRequired.confirm': 'Got it',
|
||||
'agents.modify.apply': 'Apply Configuration Changes',
|
||||
'agents.modify.update': 'Update Configuration',
|
||||
'agents.modify.close': 'Close Configuration Changes',
|
||||
'agents.modify.default': 'Default Configuration',
|
||||
'agents.modify.clear': 'Clear Configuration',
|
||||
|
||||
@@ -119,10 +119,16 @@ const createClaudeModelMappings = (model: string): ClaudeModelMappings => ({
|
||||
haiku: model,
|
||||
});
|
||||
|
||||
const sameAgentModel = (left: string, right: string) => (
|
||||
left.trim().toLocaleLowerCase() === right.trim().toLocaleLowerCase()
|
||||
);
|
||||
|
||||
const sameClaudeModelMappings = (
|
||||
left: ClaudeModelMappings,
|
||||
right: ClaudeModelMappings,
|
||||
) => left.opus === right.opus && left.sonnet === right.sonnet && left.haiku === right.haiku;
|
||||
) => sameAgentModel(left.opus, right.opus)
|
||||
&& sameAgentModel(left.sonnet, right.sonnet)
|
||||
&& sameAgentModel(left.haiku, right.haiku);
|
||||
|
||||
const claudeMappingRoles = [
|
||||
{
|
||||
@@ -738,7 +744,7 @@ export function AgentsPage() {
|
||||
const modelDraftChanged = !isClaudeModelMappingClient && Boolean(
|
||||
selectedModel.trim()
|
||||
&& appliedModel.trim()
|
||||
&& selectedModel.trim() !== appliedModel.trim(),
|
||||
&& !sameAgentModel(selectedModel, appliedModel),
|
||||
);
|
||||
const appliedClaudeModelMappings = (selected === 'claude-code'
|
||||
? activeStatus?.claudeCodeModelMappings
|
||||
@@ -757,6 +763,8 @@ export function AgentsPage() {
|
||||
const oauthConfigurationChanged = selected === 'codex'
|
||||
&& oauthConfiguration !== Boolean(activeStatus?.oauthConfiguration);
|
||||
const draftChanged = modelDraftChanged || claudeMappingDraftChanged || oauthConfigurationChanged;
|
||||
const configurationUpdateRequired = activeStatus?.modificationState === 'applied'
|
||||
&& draftChanged;
|
||||
const canEnable = Boolean(
|
||||
activeStatus?.supportedPlatform
|
||||
&& activeStatus.installed
|
||||
@@ -1446,20 +1454,26 @@ export function AgentsPage() {
|
||||
<button
|
||||
type="button"
|
||||
className="primary-button"
|
||||
onClick={() => void (activeStatus?.modificationState === 'applied'
|
||||
? closeConfigurationChanges()
|
||||
: applyConfigurationChanges())}
|
||||
onClick={() => void (configurationUpdateRequired
|
||||
? applyConfigurationChanges()
|
||||
: activeStatus?.modificationState === 'applied'
|
||||
? closeConfigurationChanges()
|
||||
: applyConfigurationChanges())}
|
||||
disabled={
|
||||
busy
|
||||
|| (activeStatus?.modificationState === 'applied' ? false : !canEnable)
|
||||
|| (activeStatus?.modificationState === 'applied' && !configurationUpdateRequired
|
||||
? false
|
||||
: !canEnable)
|
||||
}
|
||||
>
|
||||
{busyAction === 'apply' || busyAction === 'close-config'
|
||||
? <LoaderCircle size={16} className="spin" />
|
||||
: null}
|
||||
{activeStatus?.modificationState === 'applied'
|
||||
? t('agents.modify.close')
|
||||
: t('agents.modify.apply')}
|
||||
{configurationUpdateRequired
|
||||
? t('agents.modify.update')
|
||||
: activeStatus?.modificationState === 'applied'
|
||||
? t('agents.modify.close')
|
||||
: t('agents.modify.apply')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user