fix: complete per-bot agent preset lifecycle

This commit is contained in:
xmanrui 2026-08-22 00:20:23 +08:00
parent 8ab4b9e7de
commit 01576f65c6
27 changed files with 721 additions and 208 deletions

View file

@ -57,9 +57,8 @@ export function AgentPresetEditor({ agentPreset = '', disabled = false, onSave }
seen.add(item.id);
items.push(item);
}
if (current && !seen.has(current)) {
items.push({ id: current, label: current });
}
const currentUnavailable = Boolean(current && !seen.has(current));
if (currentUnavailable) items.push({ id: current, label: current, unavailable: true });
const inheritLabel = '跟随 Host 默认';
@ -92,10 +91,20 @@ export function AgentPresetEditor({ agentPreset = '', disabled = false, onSave }
...items.map((item) => h(
'option',
{ key: item.id, value: item.id },
item.label && item.label !== item.id ? `${item.label}(${item.id})` : item.id,
item.unavailable
? [item.id, '(已不可用)']
: item.label && item.label !== item.id ? `${item.label}(${item.id})` : item.id,
)),
),
h('small', { className: 'dim-presetHelp' }, '只影响之后新建的会话。'),
error ? h('p', { className: 'dim-presetError', role: 'alert' }, error) : null,
h(
'small',
{ className: 'dim-presetHelp' },
'只影响新建会话;若当前聊天已有会话,先发送 /new,再发送普通消息生效。',
),
error || currentUnavailable ? h(
'p',
{ className: 'dim-presetError', role: error ? 'alert' : 'status' },
error ?? '当前 Agent Preset 已不可用,请选择其他 Preset 或跟随 Host 默认。',
) : null,
);
}

View file

@ -119,10 +119,13 @@ const EN = Object.freeze({
'找不到要修改的机器人。': 'The bot could not be found.',
'Agent Preset': 'Agent Preset',
'跟随 Host 默认': 'Follow the Host default',
'只影响之后新建的会话。': 'Only later new sessions use this preset.',
'(已不可用)': ' (unavailable)',
'只影响新建会话;若当前聊天已有会话,先发送 /new,再发送普通消息生效。': 'This affects only new sessions. If the current chat already has a session, send /new, then send a regular message to apply it.',
'当前 Agent Preset 已不可用,请选择其他 Preset 或跟随 Host 默认。': 'The current Agent Preset is unavailable. Choose another preset or follow the Host default.',
'Agent Preset 修改失败,请重试。': 'Could not update the Agent Preset. Try again.',
'请选择 Agent Preset。': 'Choose an Agent Preset.',
'Agent Preset 无效。': 'The Agent Preset is invalid.',
'Agent Preset 不存在或不可用。': 'The Agent Preset does not exist or is unavailable.',
'尚未检查': 'Not checked yet',
'刚刚': 'Just now',
'检查连接': 'Check connection',