fix(share): surface the real error on the share AI widget (#87)

The widget hardcoded a generic 'Something went wrong' body and ignored
error.message, violating AGENTS.md. Render describeChatError(error.message, t) —
the same helper the internal chat uses — so a reader sees the real 402/429/503
cause instead of a bare 'try again'.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude code agent 227
2026-06-21 03:07:53 +03:00
parent 2b4ec0bfcc
commit d79f709742

View File

@@ -21,6 +21,7 @@ import { useTranslation } from "react-i18next";
import { useChat, type UIMessage } from "@ai-sdk/react"; import { useChat, type UIMessage } from "@ai-sdk/react";
import { DefaultChatTransport } from "ai"; import { DefaultChatTransport } from "ai";
import MessageList from "@/features/ai-chat/components/message-list.tsx"; import MessageList from "@/features/ai-chat/components/message-list.tsx";
import { describeChatError } from "@/features/ai-chat/utils/error-message.ts";
interface ShareAiWidgetProps { interface ShareAiWidgetProps {
/** The share id (or key) the assistant is scoped to. */ /** The share id (or key) the assistant is scoped to. */
@@ -174,7 +175,9 @@ export default function ShareAiWidget({ shareId, pageId }: ShareAiWidgetProps) {
mb="xs" mb="xs"
title={t("Something went wrong")} title={t("Something went wrong")}
> >
{t("The assistant is unavailable right now. Please try again.")} {/* Surface the real cause (provider/gating message) instead of a
generic line — same helper the internal chat uses. */}
{describeChatError(error.message ?? "", t)}
</Alert> </Alert>
)} )}