Merge commit 'd0451e9a9dc85288149376a55ecf2153ba3facb4' into codex/20261014-code-settings-sidebar-8f4b2c71-code-settings-sidebar

This commit is contained in:
鲨鱼辣椒 committed 2026-10-14 11:37:11 +08:00
commit 75067bf027
1 file changed
+36 -10
+36 -10
View File
@@ -65,9 +65,18 @@ const qrLabels: Record<string, string> = {
const blockerText: Record<string, string> = {
target_unavailable: '当前智能体暂时不能使用,可以更换一个智能体。',
publish_required: '请先让智能体开始使用。',
worker_offline: '微信连接暂时不可用,请稍后刷新。',
channel_sync_degraded: '正在确认微信的使用状态。',
worker_offline: '智能体的微信服务暂时离线,暂时无法自动回复。',
channel_sync_degraded: '微信使用状态尚未同步,请刷新状态后再继续。',
};
function blockerMessage(blocker: string, account: CloudUserChannelAccount) {
const text = blockerText[blocker];
return blocker === 'worker_offline' &&
account.health === 'connected' &&
account.target_agent_slug &&
!account.blockers.includes('wechat_disconnect_pending')
? text + '微信登录和智能体选择已保留,服务恢复后请刷新状态。'
: text;
}
const unsettled = (account: CloudUserChannelAccount) =>
account.blockers.includes('wechat_disconnect_pending') ||
Boolean(account.sync_state && account.sync_state !== 'ready') ||
@@ -75,17 +84,28 @@ const unsettled = (account: CloudUserChannelAccount) =>
(['paused', 'disabled'].includes(account.desired_state ?? '') && account.enabled) ||
(account.desired_state === 'enabled' && !account.enabled);
function accountState(account: CloudUserChannelAccount, uncertain: boolean, targetDisabled = false) {
if (uncertain || unsettled(account)) return { text: '正在确认', tone: 'bg-[#fff0d8] text-[#876033]' };
if (uncertain || unsettled(account)) return { text: '状态待确认', tone: 'bg-[#fff0d8] text-[#876033]' };
if (!account.target_agent_slug) return { text: '未绑定', tone: 'bg-[#f0edf8] text-[#75618e]' };
if (['login_required', 'verification_required'].includes(account.health))
return { text: '需要重新扫码', tone: 'bg-[#fff0d8] text-[#876033]' };
if (targetDisabled) return { text: '智能体已停用', tone: 'bg-[#fff0d8] text-[#876033]' };
if (account.health === 'connected' && account.blockers.includes('worker_offline'))
return { text: '微信服务离线', tone: 'bg-[#fff0d8] text-[#876033]' };
if (account.health !== 'connected' || unsettled(account) || usableBlockers(account).length)
return { text: '正在确认', tone: 'bg-[#fff0d8] text-[#876033]' };
return { text: '状态待确认', tone: 'bg-[#fff0d8] text-[#876033]' };
return account.enabled
? { text: '使用中', tone: 'bg-[#e7f4ec] text-[#3f7458]' }
: { text: '已暂停', tone: 'bg-[#f0edf8] text-[#75618e]' };
}
function bindingReadinessMessage(account: CloudUserChannelAccount) {
if (unsettled(account)) return '微信使用状态尚未确认,请刷新状态后再继续。';
if (account.health !== 'connected')
return '微信登录状态尚未确认,请先完成微信登录,再检查连接。';
const blocker = usableBlockers(account).find((item) => blockerText[item]);
return blocker
? blockerMessage(blocker, account)
: '暂时无法完成微信绑定,请检查连接后再继续。';
}
async function loadAgents(): Promise<CloudAgentDraft[]> {
const items: CloudAgentDraft[] = [];
let cursor: string | null = null;
@@ -347,7 +367,7 @@ export function ChannelAccounts() {
if (!account || account.target_agent_slug !== target)
throw new Error('绑定的智能体已发生变化,请返回上一步确认。');
if (account.health !== 'connected' || unsettled(account) || usableBlockers(account).length)
throw new Error('微信还没有准备好,请稍后重试完成绑定。');
throw new Error(bindingReadinessMessage(account));
if (ownerPending.current) throw new Error('微信退出还在确认中,请先处理原来的操作。');
if (agentsRef.current.some((agent) => agent.slug === target && agent.enabled === false))
throw new Error('当前智能体已停用,请更换智能体后再使用。');
@@ -361,7 +381,7 @@ export function ChannelAccounts() {
account = await verifyFinal(id, { target, enabled: true });
}
if (account.health !== 'connected' || unsettled(account) || usableBlockers(account).length)
throw new Error('微信还没有准备好,请稍后重试完成绑定。');
throw new Error(bindingReadinessMessage(account));
intents.current.delete('enable');
return account;
});
@@ -785,7 +805,7 @@ export function ChannelAccounts() {
.filter((item) => blockerText[item])
.map((item) => (
<p key={item} className="mb-3 text-xs leading-5 text-[#876033]">
{blockerText[item]}
{blockerMessage(item, account)}
</p>
))}
<div className="mt-auto flex gap-2">
@@ -990,10 +1010,16 @@ export function ChannelAccounts() {
{qr?.status === 'confirmed' || selected?.health === 'connected' ? (
<div role="status" className="rounded-2xl bg-[#e7f4ec] p-5 text-center text-[#3f7458]">
<CheckCircle2 className="mx-auto h-9 w-9" />
<p className="mt-3 font-semibold">{busy ? '正在完成微信绑定…' : '微信登录已确认'}</p>
<p className="mt-3 font-semibold">
{busy
? '正在检查连接并完成绑定…'
: selected?.health === 'connected'
? '微信登录已确认'
: '扫码已确认'}
</p>
<p className="mt-2 text-sm">
{connectionFailed
? '还没有完成绑定,请查看上方提示。'
? '绑定尚未完成,请按上方提示处理,再检查连接。'
: '正在确认智能体和自动回复状态。'}
</p>
</div>
@@ -1052,7 +1078,7 @@ export function ChannelAccounts() {
disabled={disabled || checkingIds.includes(flow.accountId)}
onClick={() => void finishBinding(flow.accountId, flow.target)}
>
重试完成绑定
检查连接并完成绑定
</Button>
)}
{checkingIds.includes(flow.accountId) && (