feat(diagnostics): pin a Playground request to one relay (#167)

Resolved against #170 so a relay pin clears the per-attempt WARP choice
(attemptUseWARP). The relay list is now credential-redacted, and a pin may
name a relay by its redacted URL.
This commit is contained in:
Ray authored and Jason Xu committed 2026-11-05 12:56:56 +08:00
1 parent 46eb13ea03
commit b296a61d0e
7 files changed
+235 -7

No files matched your search

+11
View File
@@ -296,6 +296,17 @@
指定 Key 后只测试该 Key:不切换、不回退,也不改变冷却与代理健康。
</p>
</div>
<div class="field full">
<label for="play-relay" data-i18n="playground.relay">Relay</label>
<select id="play-relay">
<option value="auto" data-i18n="playground.relay.auto">
任意 Relay(正常路由)
</option>
</select>
<p class="section-caption" data-i18n="playground.relay.caption">
指定 Relay 后只经它发送一次尝试:真实 session、system prompt 与 tool shaping,不切换、不回退,也不改变冷却与代理健康。
</p>
</div>
</div>
<div class="field">
<label for="play-request" data-i18n="playground.request">请求 JSON</label>
+15
View File
@@ -209,6 +209,10 @@ const DICTIONARY = {
"playground.key.auto": "Automatic routing (anonymous / Tier fallback / Key rotation)",
"playground.key.caption":
"When a specific key is chosen, only that key is tried: no switch to another key, another Tier, or the anonymous channel, and no change to the key's cooldown state or the proxy's health.",
"playground.relay": "Relay",
"playground.relay.auto": "Any relay (normal routing)",
"playground.relay.caption":
"Pinning a relay sends exactly one attempt through it, with real session minting, system prompt and tool shaping: no failover, and no change to cooldown or proxy health.",
"playground.request": "Request JSON",
"playground.reset": "Reset sample",
"playground.run": "Send diagnostic request",
@@ -454,6 +458,7 @@ const DICTIONARY = {
"play.mode.selected": "Specified {0} key",
"play.mode.auto": "Automatic routing",
"play.testedKey": "Key tested",
"play.testedRelay": "Relay tested",
"play.keyVerdict": "Key verdict",
"play.keyVerdict.none": "Automatic routing has no dedicated verdict",
"play.key.usable": "Key usable",
@@ -781,6 +786,10 @@ const DICTIONARY = {
"playground.key.auto": "Định tuyến tự động (ẩn danh / dự phòng Tier / luân phiên Key)",
"playground.key.caption":
"Khi chọn một Key cụ thể, chỉ Key đó được thử: không chuyển sang Key khác, Tier khác hay kênh ẩn danh, và không làm thay đổi trạng thái cooldown của Key hay sức khoẻ của proxy.",
"playground.relay": "Relay",
"playground.relay.auto": "Mọi relay (định tuyến thường)",
"playground.relay.caption":
"Ghim một relay sẽ gửi đúng một lần thử qua nó, với session, system prompt và tool shaping thật: không failover, không đổi cooldown hay sức khoẻ proxy.",
"playground.request": "JSON của request",
"playground.reset": "Đặt lại mẫu",
"playground.run": "Gửi request chẩn đoán",
@@ -1027,6 +1036,7 @@ const DICTIONARY = {
"play.mode.selected": "Chỉ định Key {0}",
"play.mode.auto": "Định tuyến tự động",
"play.testedKey": "Key được thử",
"play.testedRelay": "Relay được thử",
"play.keyVerdict": "Kết luận về Key",
"play.keyVerdict.none": "Định tuyến tự động không có kết luận riêng",
"play.key.usable": "Key dùng được",
@@ -1364,6 +1374,10 @@ const DICTIONARY = {
"Instradamento automatico (anonimo / fallback Tier / rotazione chiavi)",
"playground.key.caption":
"Quando viene scelta una chiave specifica, si prova solo quella: nessun passaggio a un'altra chiave, a un altro Tier o al canale anonimo, e nessuna modifica allo stato di cooldown della chiave o all'integrità del proxy.",
"playground.relay": "Relay",
"playground.relay.auto": "Qualsiasi relay (routing normale)",
"playground.relay.caption":
"Fissare un relay invia esattamente un tentativo attraverso di esso, con sessione, system prompt e tool shaping reali: nessun failover, nessuna modifica a cooldown o integrità del proxy.",
"playground.request": "JSON della richiesta",
"playground.reset": "Reimposta esempio",
"playground.run": "Invia richiesta diagnostica",
@@ -1613,6 +1627,7 @@ const DICTIONARY = {
"play.mode.selected": "Chiave {0} specificata",
"play.mode.auto": "Instradamento automatico",
"play.testedKey": "Chiave testata",
"play.testedRelay": "Relay testato",
"play.keyVerdict": "Verdetto sulla chiave",
"play.keyVerdict.none": "L'instradamento automatico non ha un verdetto dedicato",
"play.key.usable": "Chiave utilizzabile",
+19 -1
View File
@@ -78,6 +78,19 @@ function renderKeys() {
else select.value = "auto";
}
function renderRelays() {
const select = $("#play-relay");
if (!select) return;
const selected = select.value;
select.replaceChildren();
select.append(el("option", { value: "auto", text: t("任意 Relay(正常路由)", "playground.relay.auto") }));
(store.get("debug")?.relays || []).forEach((name, index) => {
select.append(el("option", { value: String(index), text: `${index} · ${name}` }));
});
if (selected && [...select.options].some((option) => option.value === selected)) select.value = selected;
else select.value = "auto";
}
function renderModels() {
const select = $("#play-model");
const selected = select.value;
@@ -88,6 +101,7 @@ function renderModels() {
if (selected && [...select.options].some((option) => option.value === selected)) select.value = selected;
if (!$("#play-request").value.trim()) resetTemplate();
renderKeys();
renderRelays();
}
function showResult(result) {
@@ -119,6 +133,7 @@ function showResult(result) {
keyTest || t("自动路由未单独判定", "play.keyVerdict.none"),
result.key_test === "usable" ? "ok" : result.key_test ? "bad" : "",
],
[t("测试 Relay", "play.testedRelay"), result.relay_test || "—"],
[t("实际路由", "play.actualRoute"), routeLabel],
[t("原生协议", "play.nativeProtocol"), route.native_protocol || "—"],
[
@@ -143,6 +158,9 @@ async function run(event) {
toast(t(`请求 JSON 无效:${error.message}`, "toast.play.invalidJson", error.message), true);
return;
}
const relayValue = $("#play-relay")?.value || "auto";
const relayNames = store.get("debug")?.relays || [];
const relay = relayValue === "auto" ? undefined : { index: Number(relayValue), name: relayNames[Number(relayValue)] };
const keyValue = $("#play-key").value;
const key =
keyValue === "auto"
@@ -158,7 +176,7 @@ async function run(event) {
"lastPlayground",
await api("/api/debug/inference", {
method: "POST",
body: JSON.stringify({ protocol: $("#play-protocol").value, key, request }),
body: JSON.stringify({ protocol: $("#play-protocol").value, key, ...(relay ? { relay } : {}), request }),
}),
);
} catch (error) {