fix(ui): surface model retry status (NAN-34) (#5504)

This commit is contained in:
chengyongru authored and GitHub committed 2026-09-07 15:12:39 +08:00
1 parent 0b1fa0c3e4
commit b581a496a6
52 files changed
+1697 -55

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import type { TFunction } from "i18next";
export interface ModelRequestFailureDetails {
errorKind?: string;
attempts?: number;
}
export function resolveModelRequestFailureCopy(
details: ModelRequestFailureDetails,
t: TFunction,
): { title: string; body: string } {
let titleKey = "errors.modelRequestFailed.unknownTitle";
if (details.errorKind === "billing") {
titleKey = "errors.modelRequestFailed.billingTitle";
} else if (details.errorKind === "connection") {
titleKey = "errors.modelRequestFailed.connectionTitle";
} else if (details.errorKind === "timeout") {
titleKey = "errors.modelRequestFailed.timeoutTitle";
} else if (details.errorKind === "rate_limit") {
titleKey = "errors.modelRequestFailed.rateLimitTitle";
} else if (details.errorKind === "server") {
titleKey = "errors.modelRequestFailed.serverTitle";
}
const attempts = details.attempts;
let bodyKey = "errors.modelRequestFailed.body";
if (details.errorKind === "billing") {
bodyKey = "errors.modelRequestFailed.billingBody";
} else if (typeof attempts === "number" && Number.isInteger(attempts) && attempts > 0) {
bodyKey = "errors.modelRequestFailed.bodyWithAttempt";
}
return {
title: t(titleKey),
body: t(bodyKey, { attempts }),
};
}
+10 -3
View File
@@ -79,9 +79,9 @@ type RunStatusHandler = (chatId: string, startedAt: number | null) => void;
/** Structured errors surfaced to the UI.
*
* Most entries are transport-level or protocol-level faults. Workspace scope
* rejections are server application errors promoted here because they affect
* controls outside the message stream and must be visible immediately.
* Most entries are transport-level or protocol-level faults. Runtime and
* workspace failures are promoted here when they must remain visible outside
* the message stream.
*/
export type StreamError =
/** Server rejected the inbound frame as too large (WS close code 1009).
@@ -100,6 +100,13 @@ export type StreamError =
reason?: string;
chatId: string;
turnId: string;
}
| {
kind: "model_request_failed";
chatId: string;
turnId?: string;
errorKind?: string;
attempts?: number;
};
type ErrorHandler = (error: StreamError) => void;
+10 -1
View File
@@ -1,4 +1,4 @@
import type { ContextCompaction, NotificationEvent, RecoveryState } from "../../../packages/client-events/notifications";
import type { ContextCompaction, NotificationEvent, RecoveryState, RetryStatus as WireRetryStatus } from "../../../packages/client-events/notifications";
export type { RecoveryState, RecoveryStatus } from "../../../packages/client-events/notifications";
type Role = "user" | "assistant" | "tool" | "system";
@@ -64,6 +64,10 @@ export interface TurnUsage {
export type RoundUsage = TurnUsage;
export interface RetryStatus extends WireRetryStatus {
next_retry_at?: number;
turn_id?: string;
}
export interface UIMessage {
id: string;
role: Role;
@@ -1422,6 +1426,11 @@ export type InboundEvent =
context_window_tokens?: number;
/** Authoritative sustained-goal snapshot for this chat (same shape as ``goal_state`` events). */
goal_state?: GoalStateWsPayload;
outcome?: "completed" | "failed" | "cancelled" | "interrupted";
failure_kind?: string;
failure_error_kind?: string;
failure_attempts?: number;
failure_message?: string;
} & InboundTurnMetadata)
| ({
event: "goal_status";