fix(ui): surface model retry status (NAN-34) (#5504)
This commit is contained in:
1 parent
0b1fa0c3e4
commit
b581a496a6
52 files changed
+1697
-55
No files matched your search
@@ -57,7 +57,14 @@ import type { FileEditDisplayMode } from "@/lib/local-preferences";
|
||||
import { logoFallbackUrls } from "@/lib/provider-brand";
|
||||
import { canonicalToolTrace, formatToolCallTrace } from "@/lib/tool-traces";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { CliAppInfo, McpPresetInfo, ToolProgressEvent, UIFileEdit, UIMessage } from "@/lib/types";
|
||||
import type {
|
||||
CliAppInfo,
|
||||
McpPresetInfo,
|
||||
RetryStatus,
|
||||
ToolProgressEvent,
|
||||
UIFileEdit,
|
||||
UIMessage,
|
||||
} from "@/lib/types";
|
||||
|
||||
const ACTIVITY_SCROLL_NEAR_BOTTOM_PX = 24;
|
||||
|
||||
@@ -143,6 +150,7 @@ interface AgentActivityClusterProps {
|
||||
turnLatencyMs?: number;
|
||||
/** User turn start timestamp for live activity before the first trace/reasoning row. */
|
||||
startedAtMs?: number;
|
||||
retryStatus?: RetryStatus | null;
|
||||
cliApps?: CliAppInfo[];
|
||||
mcpPresets?: McpPresetInfo[];
|
||||
onOpenFilePreview?: (path: string) => void;
|
||||
@@ -158,6 +166,7 @@ export function AgentActivityCluster({
|
||||
hasBodyBelow,
|
||||
turnLatencyMs,
|
||||
startedAtMs,
|
||||
retryStatus = null,
|
||||
cliApps = [],
|
||||
mcpPresets = [],
|
||||
onOpenFilePreview,
|
||||
@@ -219,7 +228,34 @@ export function AgentActivityCluster({
|
||||
startedAtMs,
|
||||
);
|
||||
const activityDuration = formatActivityDuration(durationMs);
|
||||
const activityLabel = isTurnStreaming
|
||||
const retryError = retryStatus?.error_kind === "connection"
|
||||
? t("message.retryConnection", { defaultValue: "Connection failed" })
|
||||
: retryStatus?.error_kind === "timeout"
|
||||
? t("message.retryTimeout", { defaultValue: "Model timed out" })
|
||||
: retryStatus?.error_kind === "rate_limit"
|
||||
? t("message.retryRateLimit", { defaultValue: "Rate limited" })
|
||||
: 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",
|
||||
})
|
||||
: retryStatus?.state === "waiting"
|
||||
? t("message.retryWaiting", {
|
||||
error: retryError,
|
||||
seconds: retrySeconds,
|
||||
attempt: retryAttempt,
|
||||
defaultValue: "{{error}} · retrying in {{seconds}}s · attempt {{attempt}}",
|
||||
})
|
||||
: isTurnStreaming
|
||||
? t("message.activityWorkingFor", {
|
||||
duration: activityDuration,
|
||||
defaultValue: "Working for {{duration}}",
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { AlertTriangle, X } from "lucide-react";
|
||||
import type { TFunction } from "i18next";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { resolveModelRequestFailureCopy } from "@/lib/model-request-failure";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { StreamError } from "@/lib/nanobot-client";
|
||||
|
||||
@@ -53,7 +55,7 @@ export function StreamErrorNotice({ error, onDismiss }: StreamErrorNoticeProps)
|
||||
|
||||
function resolveCopy(
|
||||
error: StreamError,
|
||||
t: (key: string) => string,
|
||||
t: TFunction,
|
||||
): { title: string; body: string } {
|
||||
switch (error.kind) {
|
||||
case "message_too_big":
|
||||
@@ -71,6 +73,8 @@ function resolveCopy(
|
||||
title: t("errors.turnRejected.title"),
|
||||
body: t("errors.turnRejected.body"),
|
||||
};
|
||||
case "model_request_failed":
|
||||
return resolveModelRequestFailureCopy(error, t);
|
||||
default: {
|
||||
// Exhaustiveness guard: if a new StreamError kind is added, TS will
|
||||
// complain here until we add a corresponding i18n branch.
|
||||
|
||||
@@ -4,7 +4,7 @@ import { MessageBubble } from "@/components/MessageBubble";
|
||||
import { AgentActivityCluster } from "@/components/thread/AgentActivityCluster";
|
||||
import { AssistantSelectionAction } from "@/components/thread/AssistantSelectionAction";
|
||||
import { projectActivityTimeline, type TurnUnit } from "@/lib/activity-timeline";
|
||||
import type { CliAppInfo, McpPresetInfo, SlashCommand, UIMessage } from "@/lib/types";
|
||||
import type { CliAppInfo, McpPresetInfo, RetryStatus, SlashCommand, UIMessage } from "@/lib/types";
|
||||
|
||||
interface ThreadMessagesProps {
|
||||
messages: UIMessage[];
|
||||
@@ -14,6 +14,7 @@ interface ThreadMessagesProps {
|
||||
activeTurnId?: string | null;
|
||||
/** Optimistic or canonical active-turn start, in unix seconds. */
|
||||
runStartedAt?: number | null;
|
||||
retryStatus?: RetryStatus | null;
|
||||
hiddenUserMessageCount?: number;
|
||||
cliApps?: CliAppInfo[];
|
||||
mcpPresets?: McpPresetInfo[];
|
||||
@@ -63,6 +64,7 @@ export function ThreadMessages({
|
||||
isStreaming = false,
|
||||
activeTurnId = null,
|
||||
runStartedAt = null,
|
||||
retryStatus = null,
|
||||
hiddenUserMessageCount = 0,
|
||||
cliApps = [],
|
||||
mcpPresets = [],
|
||||
@@ -97,7 +99,7 @@ export function ThreadMessages({
|
||||
isStreaming
|
||||
&& liveActivityClusterIndices.size === 0
|
||||
&& pendingTurn !== null
|
||||
&& !pendingTurn.hasVisibleOutput
|
||||
&& (retryStatus !== null || !pendingTurn.hasVisibleOutput)
|
||||
) ? pendingTurn : null;
|
||||
const currentTurnStartIndex = isStreaming
|
||||
? activeTurnStartIndex(units, activeTurnId)
|
||||
@@ -161,6 +163,11 @@ export function ThreadMessages({
|
||||
: index > currentTurnStartIndex
|
||||
)
|
||||
}
|
||||
retryStatus={
|
||||
unit.type === "activity" && liveActivityClusterIndices.has(index)
|
||||
? retryStatus
|
||||
: null
|
||||
}
|
||||
forkIndex={forkIndex}
|
||||
showForkBoundary={index === forkBoundaryAfterUnitIndex}
|
||||
forkBoundaryLabel={t("thread.forkedFromHistory")}
|
||||
@@ -179,6 +186,7 @@ export function ThreadMessages({
|
||||
messages={[]}
|
||||
isTurnStreaming
|
||||
hasBodyBelow={false}
|
||||
retryStatus={retryStatus}
|
||||
startedAtMs={
|
||||
runStartedAt != null
|
||||
? runStartedAt * 1000
|
||||
@@ -243,6 +251,7 @@ interface ThreadDisplayUnitProps {
|
||||
hasBodyBelow: boolean;
|
||||
deferOffscreenRender: boolean;
|
||||
isTurnStreaming: boolean;
|
||||
retryStatus: RetryStatus | null;
|
||||
forkIndex?: number;
|
||||
showForkBoundary: boolean;
|
||||
forkBoundaryLabel: string;
|
||||
@@ -262,6 +271,7 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
|
||||
hasBodyBelow,
|
||||
deferOffscreenRender,
|
||||
isTurnStreaming,
|
||||
retryStatus,
|
||||
forkIndex,
|
||||
showForkBoundary,
|
||||
forkBoundaryLabel,
|
||||
@@ -293,6 +303,7 @@ const ThreadDisplayUnit = memo(function ThreadDisplayUnit({
|
||||
<AgentActivityCluster
|
||||
messages={unit.messages}
|
||||
isTurnStreaming={isTurnStreaming}
|
||||
retryStatus={retryStatus}
|
||||
hasBodyBelow={hasBodyBelow}
|
||||
turnLatencyMs={unit.turnLatencyMs}
|
||||
startedAtMs={unit.startedAtMs}
|
||||
@@ -329,6 +340,7 @@ function threadDisplayUnitPropsEqual(
|
||||
&& previous.hasBodyBelow === next.hasBodyBelow
|
||||
&& previous.deferOffscreenRender === next.deferOffscreenRender
|
||||
&& previous.isTurnStreaming === next.isTurnStreaming
|
||||
&& previous.retryStatus === next.retryStatus
|
||||
&& previous.forkIndex === next.forkIndex
|
||||
&& previous.showForkBoundary === next.showForkBoundary
|
||||
&& previous.forkBoundaryLabel === next.forkBoundaryLabel
|
||||
|
||||
@@ -820,6 +820,7 @@ export function ThreadShell({
|
||||
messagesReady,
|
||||
isStreaming,
|
||||
runStartedAt,
|
||||
retryStatus,
|
||||
goalState,
|
||||
recoveryState,
|
||||
continueRecovery,
|
||||
@@ -1726,6 +1727,7 @@ export function ThreadShell({
|
||||
temporary={temporary}
|
||||
isStreaming={turnActive}
|
||||
runStartedAt={currentRunStartedAt}
|
||||
retryStatus={retryStatus}
|
||||
emptyState={emptyState}
|
||||
composer={composerPortalTarget === undefined ? composer : null}
|
||||
activeTurnId={viewportTurnId}
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
promptTop,
|
||||
} from "@/components/thread/promptNavigation";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { CliAppInfo, McpPresetInfo, SlashCommand, UIMessage } from "@/lib/types";
|
||||
import type { CliAppInfo, McpPresetInfo, RetryStatus, SlashCommand, UIMessage } from "@/lib/types";
|
||||
|
||||
export interface ThreadViewportHandle {
|
||||
jumpToUserPrompt: (promptId: string) => void;
|
||||
@@ -39,6 +39,7 @@ interface ThreadViewportProps {
|
||||
isStreaming: boolean;
|
||||
/** Optimistic or canonical start time for the active turn, in unix seconds. */
|
||||
runStartedAt?: number | null;
|
||||
retryStatus?: RetryStatus | null;
|
||||
composer?: ReactNode;
|
||||
emptyState?: ReactNode;
|
||||
scrollToBottomSignal?: number;
|
||||
@@ -221,6 +222,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
temporary = false,
|
||||
isStreaming,
|
||||
runStartedAt = null,
|
||||
retryStatus = null,
|
||||
composer,
|
||||
emptyState,
|
||||
scrollToBottomSignal = 0,
|
||||
@@ -878,6 +880,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
isStreaming={isStreaming}
|
||||
activeTurnId={activeTurnId}
|
||||
runStartedAt={runStartedAt}
|
||||
retryStatus={retryStatus}
|
||||
hiddenUserMessageCount={hiddenUserMessageCount}
|
||||
cliApps={cliApps}
|
||||
mcpPresets={mcpPresets}
|
||||
|
||||
Reference in new issue
Block a user