Skip to content

Your lightweight open-source personal agent.

fix(webui): simplify retry status copy

chengyongru4cd277f65d00
diff --git a/webui/browser/answer-order.spec.ts b/webui/browser/answer-order.spec.ts
index d84ecf2c5..38769d084 100644
--- a/webui/browser/answer-order.spec.ts
+++ b/webui/browser/answer-order.spec.ts
@@ -6,10 +6,10 @@ const turnId = "answer-order-turn";
const source = { provider: "fixture", model: "fixture", preset: "fixture" };
const base = { chat_id: chatId, turn_id: turnId };
-async function openThread(page: Page, events: ThreadProjectionEvent[] = []) {
+async function openThread(page: Page, events: ThreadProjectionEvent[] = [], locale = "en") {
const errors: string[] = [];
page.on("pageerror", (error) => errors.push(error.message));
- await page.addInitScript(() => { localStorage.setItem("nanobot.locale", "en"); });
+ await page.addInitScript((language) => { localStorage.setItem("nanobot.locale", language); }, locale);
await page.route("**/api/**", (route) => route.fulfill({ status: 404, json: {} }));
await page.route("**/api/commands", (route) => route.fulfill({ json: { commands: [] } }));
await page.route("**/api/sessions/*/webui-thread?*", (route) => {
@@ -46,6 +46,31 @@ async function expectAnswerOrder(page: Page) {
.toBeLessThan(texts.findIndex((text) => text.includes("Later answer")));
}
+for (const scenario of [
+ { locale: "en", width: 1440, waiting: /Connection failed Retrying in [1-9][0-9]*s/, retrying: "Connection failed Retrying" },
+ { locale: "zh-CN", width: 390, waiting: /连接失败 [1-9][0-9]* 秒后重试/, retrying: "连接失败 正在重试" },
+]) {
+ test(`shows retry progress in the live thread at ${scenario.width}px (${scenario.locale})`, async ({ page }, info) => {
+ await page.setViewportSize({ width: scenario.width, height: 900 });
+ await page.clock.install();
+ const { emit, errors } = await openThread(page, [], scenario.locale);
+ emit({ event: "user_message", ...base, text: "Retry fixture", starts_turn: true, active_turn_id: turnId });
+ await expect(page.getByText("Retry fixture", { exact: true })).toBeVisible();
+ emit(
+ { event: "goal_status", ...base, status: "running", started_at: Date.now() / 1000 },
+ { event: "retry_status", ...base, state: "waiting", attempt: 1, max_attempts: 4, error_kind: "connection", retry_after_s: 30 },
+ );
+ await expect(page.getByRole("status", { name: scenario.waiting })).toBeVisible();
+ await page.screenshot({ path: info.outputPath("retry-waiting.png") });
+ await page.clock.fastForward(30_000);
+ await expect(page.getByRole("status", { name: scenario.retrying, exact: true })).toBeVisible();
+ await page.screenshot({ path: info.outputPath("retry-status.png") });
+ emit({ event: "retry_status", ...base, state: "recovered", attempt: 2, max_attempts: 4, error_kind: "connection" });
+ await expect(page.getByRole("status", { name: scenario.retrying, exact: true })).toHaveCount(0);
+ expect(errors).toEqual([]);
+ });
+}
+
test.describe("answer order", () => {
test.use({ viewport: { width: 1440, height: 1000 } });
diff --git a/webui/src/components/thread/AgentActivityCluster.tsx b/webui/src/components/thread/AgentActivityCluster.tsx
index 232e87831..a3c45ec69 100644
--- a/webui/src/components/thread/AgentActivityCluster.tsx
+++ b/webui/src/components/thread/AgentActivityCluster.tsx
@@ -337,24 +337,25 @@ function FoldedAgentActivity({
: retryStatus?.error_kind === "server"
? t("message.retryServer", { defaultValue: "Model unavailable" })
: t("message.retryUnknown", { defaultValue: "Model request failed" });
- const retryAttempt = retryStatus?.max_attempts
- ? `${retryStatus.attempt}/${retryStatus.max_attempts}`
- : String(retryStatus?.attempt ?? "");
const retrySeconds = retryStatus?.next_retry_at === undefined
? 0
: Math.max(0, Math.ceil(retryStatus.next_retry_at - now / 1000));
const activityLabel = retryStatus?.state === "exhausted"
? t("message.retryExhausted", {
error: retryError,
- defaultValue: "{{error}}. Ending turn.",
+ defaultValue: "{{error}} Ending turn",
})
: retryStatus?.state === "waiting"
- ? t("message.retryWaiting", {
- error: retryError,
- seconds: retrySeconds,
- attempt: retryAttempt,
- defaultValue: "{{error}}. Retrying in {{seconds}}s (attempt {{attempt}}).",
- })
+ ? retrySeconds > 0
+ ? t("message.retryWaiting", {
+ error: retryError,
+ seconds: retrySeconds,
+ defaultValue: "{{error}} Retrying in {{seconds}}s",
+ })
+ : t("message.retrying", {
+ error: retryError,
+ defaultValue: "{{error}} Retrying",
+ })
: isTurnStreaming
? t("message.activityWorkingFor", {
duration: activityDuration,
diff --git a/webui/src/i18n/locales/en/common.json b/webui/src/i18n/locales/en/common.json
index 43473207f..dbbffc890 100644
--- a/webui/src/i18n/locales/en/common.json
+++ b/webui/src/i18n/locales/en/common.json
@@ -2495,8 +2495,9 @@
"retryRateLimit": "Rate limited",
"retryServer": "Model unavailable",
"retryUnknown": "Model request failed",
- "retryWaiting": "{{error}}. Retrying in {{seconds}}s (attempt {{attempt}}).",
- "retryExhausted": "{{error}}. Ending turn.",
+ "retryWaiting": "{{error}} Retrying in {{seconds}}s",
+ "retrying": "{{error}} Retrying",
+ "retryExhausted": "{{error}} Ending turn",
"cliActivityRunningOne": "Using {{name}}",
"cliActivityRanOne": "Used {{name}}",
"cliActivityFailedOne": "Could not use {{name}}",
diff --git a/webui/src/i18n/locales/es/common.json b/webui/src/i18n/locales/es/common.json
index 775c4dfe1..4e0e47bc5 100644
--- a/webui/src/i18n/locales/es/common.json
+++ b/webui/src/i18n/locales/es/common.json
@@ -2318,8 +2318,9 @@
"retryRateLimit": "Límite de solicitudes alcanzado",
"retryServer": "Modelo no disponible",
"retryUnknown": "La solicitud al modelo falló",
- "retryWaiting": "{{error}}, reintentando en {{seconds}} s, intento {{attempt}}",
- "retryExhausted": "{{error}}, finalizando el turno",
+ "retryWaiting": "{{error}} Reintentando en {{seconds}} s",
+ "retrying": "{{error}} Reintentando",
+ "retryExhausted": "{{error}} Finalizando el turno",
"cliActivityRunningOne": "Usando {{name}}",
"cliActivityRanOne": "Usó {{name}}",
"cliActivityFailedOne": "No se pudo usar {{name}}",
diff --git a/webui/src/i18n/locales/fr/common.json b/webui/src/i18n/locales/fr/common.json
index e993d36f9..4b665121a 100644
--- a/webui/src/i18n/locales/fr/common.json
+++ b/webui/src/i18n/locales/fr/common.json
@@ -2317,8 +2317,9 @@
"retryRateLimit": "Limite de requêtes atteinte",
"retryServer": "Modèle indisponible",
"retryUnknown": "Échec de la requête au modèle",
- "retryWaiting": "{{error}}, nouvelle tentative dans {{seconds}} s, tentative {{attempt}}",
- "retryExhausted": "{{error}}, fin du tour",
+ "retryWaiting": "{{error}} Nouvelle tentative dans {{seconds}} s",
+ "retrying": "{{error}} Nouvelle tentative en cours",
+ "retryExhausted": "{{error}} Fin du tour",
"cliActivityRunningOne": "Utilisation de {{name}}",
"cliActivityRanOne": "{{name}} utilisé",
"cliActivityFailedOne": "Impossible d’utiliser {{name}}",
diff --git a/webui/src/i18n/locales/id/common.json b/webui/src/i18n/locales/id/common.json
index 86ca75938..15c93fa09 100644
--- a/webui/src/i18n/locales/id/common.json
+++ b/webui/src/i18n/locales/id/common.json
@@ -2317,8 +2317,9 @@
"retryRateLimit": "Batas permintaan tercapai",
"retryServer": "Model tidak tersedia",
"retryUnknown": "Permintaan model gagal",
- "retryWaiting": "{{error}}, mencoba lagi dalam {{seconds}} dtk, percobaan {{attempt}}",
- "retryExhausted": "{{error}}, mengakhiri giliran",
+ "retryWaiting": "{{error}} Mencoba lagi dalam {{seconds}} detik",
+ "retrying": "{{error}} Sedang mencoba lagi",
+ "retryExhausted": "{{error}} Mengakhiri giliran",
"cliActivityRunningOne": "Menggunakan {{name}}",
"cliActivityRanOne": "Menggunakan {{name}} selesai",
"cliActivityFailedOne": "Tidak dapat menggunakan {{name}}",
diff --git a/webui/src/i18n/locales/ja/common.json b/webui/src/i18n/locales/ja/common.json
index ea9c0be0f..5f609f1ff 100644
--- a/webui/src/i18n/locales/ja/common.json
+++ b/webui/src/i18n/locales/ja/common.json
@@ -2317,8 +2317,9 @@
"retryRateLimit": "リクエスト制限に達しました",
"retryServer": "モデルを利用できません",
"retryUnknown": "モデルリクエストに失敗しました",
- "retryWaiting": "{{error}}, {{seconds}}秒後に再試行, 試行 {{attempt}}",
- "retryExhausted": "{{error}}, ターンを終了します",
+ "retryWaiting": "{{error}} {{seconds}}秒後に再試行",
+ "retrying": "{{error}} 再試行中",
+ "retryExhausted": "{{error}} ターンを終了します",
"cliActivityRunningOne": "{{name}} を使用中",
"cliActivityRanOne": "{{name}} を使用しました",
"cliActivityFailedOne": "{{name}} を使用できませんでした",
diff --git a/webui/src/i18n/locales/ko/common.json b/webui/src/i18n/locales/ko/common.json
index 32b36843c..f66f639fb 100644
--- a/webui/src/i18n/locales/ko/common.json
+++ b/webui/src/i18n/locales/ko/common.json
@@ -2317,8 +2317,9 @@
"retryRateLimit": "요청 한도 초과",
"retryServer": "모델을 사용할 수 없음",
"retryUnknown": "모델 요청 실패",
- "retryWaiting": "{{error}}, {{seconds}}초 후 재시도, 시도 {{attempt}}",
- "retryExhausted": "{{error}}, 턴 종료 중",
+ "retryWaiting": "{{error}} {{seconds}}초 후 재시도",
+ "retrying": "{{error}} 재시도 중",
+ "retryExhausted": "{{error}} 턴 종료 중",
"cliActivityRunningOne": "{{name}} 사용 중",
"cliActivityRanOne": "{{name}} 사용함",
"cliActivityFailedOne": "{{name}} 사용 실패",
diff --git a/webui/src/i18n/locales/pt-BR/common.json b/webui/src/i18n/locales/pt-BR/common.json
index 7c9232a1f..70b8c99c2 100644
--- a/webui/src/i18n/locales/pt-BR/common.json
+++ b/webui/src/i18n/locales/pt-BR/common.json
@@ -2303,8 +2303,9 @@
"retryRateLimit": "Limite de solicitações atingido",
"retryServer": "Modelo indisponível",
"retryUnknown": "Falha na solicitação ao modelo",
- "retryWaiting": "{{error}}, tentando novamente em {{seconds}} s, tentativa {{attempt}}",
- "retryExhausted": "{{error}}, encerrando o turno",
+ "retryWaiting": "{{error}} Tentando novamente em {{seconds}} s",
+ "retrying": "{{error}} Tentando novamente",
+ "retryExhausted": "{{error}} Encerrando o turno",
"cliActivityRunningOne": "Usando {{name}}",
"cliActivityRanOne": "Usou {{name}}",
"cliActivityFailedOne": "Não foi possível usar {{name}}",
diff --git a/webui/src/i18n/locales/vi/common.json b/webui/src/i18n/locales/vi/common.json
index f82bfdad8..1d8655a05 100644
--- a/webui/src/i18n/locales/vi/common.json
+++ b/webui/src/i18n/locales/vi/common.json
@@ -2317,8 +2317,9 @@
"retryRateLimit": "Đã đạt giới hạn yêu cầu",
"retryServer": "Mô hình không khả dụng",
"retryUnknown": "Yêu cầu mô hình thất bại",
- "retryWaiting": "{{error}}, thử lại sau {{seconds}} giây, lần thử {{attempt}}",
- "retryExhausted": "{{error}}, đang kết thúc lượt",
+ "retryWaiting": "{{error}} Thử lại sau {{seconds}} giây",
+ "retrying": "{{error}} Đang thử lại",
+ "retryExhausted": "{{error}} Đang kết thúc lượt",
"cliActivityRunningOne": "Đang dùng {{name}}",
"cliActivityRanOne": "Đã dùng {{name}}",
"cliActivityFailedOne": "Không thể dùng {{name}}",
diff --git a/webui/src/i18n/locales/zh-CN/common.json b/webui/src/i18n/locales/zh-CN/common.json
index c1fa3a69a..63a0a98de 100644
--- a/webui/src/i18n/locales/zh-CN/common.json
+++ b/webui/src/i18n/locales/zh-CN/common.json
@@ -2495,8 +2495,9 @@
"retryRateLimit": "请求频率受限",
"retryServer": "模型服务不可用",
"retryUnknown": "模型请求失败",
- "retryWaiting": "{{error}},{{seconds}} 秒后重试(第 {{attempt}} 次)。",
- "retryExhausted": "{{error}},正在结束本次任务。",
+ "retryWaiting": "{{error}} {{seconds}} 秒后重试",
+ "retrying": "{{error}} 正在重试",
+ "retryExhausted": "{{error}} 正在结束本次任务",
"cliActivityRunningOne": "正在使用 {{name}}",
"cliActivityRanOne": "已使用 {{name}}",
"cliActivityFailedOne": "无法使用 {{name}}",
diff --git a/webui/src/i18n/locales/zh-TW/common.json b/webui/src/i18n/locales/zh-TW/common.json
index a81667868..732894714 100644
--- a/webui/src/i18n/locales/zh-TW/common.json
+++ b/webui/src/i18n/locales/zh-TW/common.json
@@ -2319,8 +2319,9 @@
"retryRateLimit": "請求頻率受限",
"retryServer": "模型服務無法使用",
"retryUnknown": "模型請求失敗",
- "retryWaiting": "{{error}},{{seconds}} 秒後重試,第 {{attempt}} 次",
- "retryExhausted": "{{error}},正在結束本輪",
+ "retryWaiting": "{{error}} {{seconds}} 秒後重試",
+ "retrying": "{{error}} 正在重試",
+ "retryExhausted": "{{error}} 正在結束本輪",
"cliActivityRunningMany": "正在使用 {{count}} 個 CLI 應用程式",
"cliActivityRanMany": "已使用 {{count}} 個 CLI 應用程式",
"cliActivityFailedMany": "{{count}} 個 CLI 應用程式失敗",
diff --git a/webui/src/tests/agent-activity-cluster.test.tsx b/webui/src/tests/agent-activity-cluster.test.tsx
index 0671b5be8..1ab1a3794 100644
--- a/webui/src/tests/agent-activity-cluster.test.tsx
+++ b/webui/src/tests/agent-activity-cluster.test.tsx
@@ -215,25 +215,53 @@ describe("AgentActivityCluster", () => {
});
});
- it("shows model retries in the existing live activity header", () => {
- render(
- <AgentActivityCluster
- messages={[]}
- isTurnStreaming
- hasBodyBelow={false}
- retryStatus={{
- state: "waiting",
- attempt: 1,
- max_attempts: 4,
- error_kind: "connection",
- next_retry_at: Date.now() / 1000 + 5,
- }}
- />,
- );
+ it.each([
+ {
+ locale: "en" as const,
+ waiting: "Connection failed Retrying in 5s",
+ retrying: "Connection failed Retrying",
+ exhausted: "Connection failed Ending turn",
+ },
+ {
+ locale: "zh-CN" as const,
+ waiting: "连接失败 5 秒后重试",
+ retrying: "连接失败 正在重试",
+ exhausted: "连接失败 正在结束本次任务",
+ },
+ ])("shows localized model retry progress in the activity header ($locale)", async ({
+ locale, waiting, retrying, exhausted,
+ }) => {
+ await act(async () => setAppLanguage(locale));
+ vi.useFakeTimers();
+ try {
+ const retryStatus = {
+ state: "waiting" as const,
+ attempt: 1,
+ max_attempts: 4,
+ error_kind: "connection" as const,
+ next_retry_at: Date.now() / 1000 + 5,
+ };
+ const { rerender, unmount } = render(
+ <AgentActivityCluster messages={[]} isTurnStreaming hasBodyBelow={false} retryStatus={retryStatus} />,
+ );
+
+ expect(screen.getByRole("status", { name: waiting })).toBeVisible();
+ act(() => { vi.advanceTimersByTime(5_000); });
+ expect(screen.getByRole("status", { name: retrying })).toBeVisible();
- expect(
- screen.getByText("Connection failed. Retrying in 5s (attempt 1/4)."),
- ).toBeInTheDocument();
+ rerender(
+ <AgentActivityCluster
+ messages={[]}
+ isTurnStreaming
+ hasBodyBelow={false}
+ retryStatus={{ ...retryStatus, state: "exhausted", attempt: 4 }}
+ />,
+ );
+ expect(screen.getByRole("status", { name: exhausted })).toBeVisible();
+ unmount();
+ } finally {
+ vi.useRealTimers();
+ }
});
it("keeps intermediate assistant output as normal Markdown inside live activity", async () => {
@@ -616,7 +644,7 @@ describe("AgentActivityCluster", () => {
retryStatus={{ state: "waiting", attempt: 1, max_attempts: 4, error_kind: "connection" }}
/>,
);
- expect(screen.getByRole("status", { name: "Connection failed. Retrying in 0s (attempt 1/4)." }))
+ expect(screen.getByRole("status", { name: "Connection failed Retrying" }))
.toBeVisible();
unmount();
render(<AgentActivityCluster messages={messages} isTurnStreaming={false} hasBodyBelow />);