fix: restore master agent relay guidance

This commit is contained in:
kris
2026-03-30 17:42:21 +08:00
parent 5eb1246f02
commit 7c6101f22b
9 changed files with 312 additions and 22 deletions

View File

@@ -57,6 +57,22 @@ function emptyDraft(): AccountDraft {
};
}
function buildMasterNodeLoginGuide(account: {
nodeLabel?: string;
nodeId?: string;
statusLabel?: string;
}) {
const nodeLabel = account.nodeLabel?.trim() || account.nodeId?.trim() || "绑定设备";
return [
`主 GPT 不在手机里直接登录。`,
`请到绑定设备 ${nodeLabel} 上打开 Codex / ChatGPT Plus 会话完成登录。`,
`登录完成后,回到这里点“测试连接”确认 relay 和主 Agent 已接通。`,
account.statusLabel ? `当前状态:${account.statusLabel}` : null,
]
.filter(Boolean)
.join("\n");
}
function draftFromAccount(account: AiAccountSummary): AccountDraft {
return {
label: account.label,
@@ -142,6 +158,7 @@ export function AiAccountsClient({
const [newDraft, setNewDraft] = useState<AccountDraft>(emptyDraft());
const [busyKey, setBusyKey] = useState<string | null>(null);
const [message, setMessage] = useState("");
const [guideAccountId, setGuideAccountId] = useState<string | null>(null);
const accountDrafts = useMemo(
() =>
@@ -437,6 +454,19 @@ export function AiAccountsClient({
</div>
<div className="mt-4 flex flex-wrap gap-2">
{account.provider === "master_codex_node" ? (
<button
type="button"
onClick={() =>
setGuideAccountId((current) =>
current === account.accountId ? null : account.accountId,
)
}
className="rounded-full border border-[#D9D9D9] px-3 py-2 text-[12px] font-semibold text-[#57606A]"
>
{guideAccountId === account.accountId ? "收起登录指引" : "登录指引"}
</button>
) : null}
<button
type="button"
onClick={() => void validateAccount(account.accountId)}
@@ -472,6 +502,12 @@ export function AiAccountsClient({
</button>
) : null}
</div>
{account.provider === "master_codex_node" && guideAccountId === account.accountId ? (
<div className="mt-3 rounded-2xl bg-[#F7F8FA] px-3 py-3 text-[12px] leading-6 text-[#57606A] whitespace-pre-line">
{buildMasterNodeLoginGuide(account)}
</div>
) : null}
</div>
);
})}