diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js index eddc584f5..04b85fdab 100644 --- a/internal/gui/assets/i18n.js +++ b/internal/gui/assets/i18n.js @@ -943,6 +943,8 @@ const I18N = { "requests": "请求", "rerouted": "改道", "errors your agent saw": "Agent 收到的错误", + "It said: {error}": "原话:{error}", + "Show the latest request that failed": "查看最近一个失败的请求", "rate limited": "限流", "out of credit": "余额不足", "quota used up": "额度用尽", diff --git a/internal/gui/assets/routing.css b/internal/gui/assets/routing.css index 4b00548c8..fbbcdb1d3 100644 --- a/internal/gui/assets/routing.css +++ b/internal/gui/assets/routing.css @@ -103,6 +103,9 @@ .rt-steps li.why { color: var(--fg); } .rt-steps li.why::before { background: var(--fg); } .rt-steps li.aside { color: var(--muted); } +.rt-steps li.said { font-family: var(--mono, ui-monospace, monospace); font-size: 11.5px; overflow-wrap: anywhere; white-space: pre-wrap; } +.rt-stats > span.rt-errs { cursor: pointer; } +.rt-stats > span.rt-errs:hover b { color: var(--red); } .rt-steps li.aside::before { background: none; border: 1px solid var(--muted); width: 4px; height: 4px; } .rt-steps li.ok::before { background: var(--green); } .rt-steps li.bad::before { background: var(--red); } diff --git a/internal/gui/assets/routing.js b/internal/gui/assets/routing.js index 49d761411..b6e6286a0 100644 --- a/internal/gui/assets/routing.js +++ b/internal/gui/assets/routing.js @@ -54,6 +54,15 @@ const s = el("span"), b = el("b", "", "0"); s.append(b, el("span", "", k)); s.dataset.label = k; + if (k === "errors your agent saw") { + // the newest request whose agent got an error, to see what it got + s.classList.add("rt-errs"); + s.title = t("Show the latest request that failed"); + s.addEventListener("click", (e) => { + const r = listed().find((x) => x.done && x.status >= 400); + if (r) pick(r, e); + }); + } statB.push(b); stats.append(s); } @@ -887,7 +896,11 @@ items.push([affWhy(r, true) || ruleWhy(r, true) || firstWhy(r), "why"]); for (const s of nestedWhy(r)) items.push([s, "why"]); for (const a of asides(r)) items.push([a, "aside"]); - r.tries.forEach((_, i) => items.push([tryWhy(r, i), r.tries[i].done ? (r.tries[i].status < 400 ? "ok" : "bad") : "wait"])); + r.tries.forEach((tr, i) => { + items.push([tryWhy(r, i), tr.done ? (tr.status < 400 ? "ok" : "bad") : "wait"]); + // what the vendor said, word for word: the why above is magpie's reading of it + if (tr.done && tr.status >= 400 && tr.error) items.push([t("It said: {error}", { error: tr.error.length > 600 ? tr.error.slice(0, 600) + "…" : tr.error }), "aside said"]); + }); if (r.done && !r.tries.length) items.push([t("Nothing was tried: {error}", { error: r.error || r.status }), "bad"]); steps.replaceChildren(...items.map(([s, c]) => el("li", c, s))); }