import { IpcClient } from "@/ipc/ipc_client"; import { X } from "lucide-react"; import ReactMarkdown from "react-markdown"; import remarkGfm from "remark-gfm"; export function ChatErrorBox({ onDismiss, error, isDyadProEnabled, }: { onDismiss: () => void; error: string; isDyadProEnabled: boolean; }) { if (error.includes("doesn't have a free quota tier")) { return ( {error} Access with Dyad Pro {" "} or switch to another model. ); } // Important, this needs to come after the "free quota tier" check // because it also includes this URL in the error message if ( error.includes("Resource has been exhausted") || error.includes("https://ai.google.dev/gemini-api/docs/rate-limits") ) { return ( {error} Upgrade to Dyad Pro {" "} or read the Rate limit troubleshooting guide. ); } if (error.includes("LiteLLM Virtual Key expected")) { return ( Looks like you don't have a valid Dyad Pro key.{" "} Upgrade to Dyad Pro {" "} today. ); } if (isDyadProEnabled && error.includes("ExceededBudget:")) { return ( You have used all of your Dyad AI credits this month.{" "} Upgrade to Dyad Max {" "} and get more AI credits ); } // This is a very long list of model fallbacks that clutters the error message. if (error.includes("Fallbacks=")) { error = error.split("Fallbacks=")[0]; } return {error}; } function ExternalLink({ href, children, }: { href: string; children: React.ReactNode; }) { return ( IpcClient.getInstance().openExternalUrl(href)} > {children} ); } function ChatErrorContainer({ onDismiss, children, }: { onDismiss: () => void; children: React.ReactNode | string; }) { return (
{typeof children === "string" ? ( ( { e.preventDefault(); if (props.href) { IpcClient.getInstance().openExternalUrl(props.href); } }} className="text-blue-500 hover:text-blue-700" > {linkChildren} ), }} > {children} ) : ( children )}
); } function ChatInfoContainer({ onDismiss, children, }: { onDismiss: () => void; children: React.ReactNode; }) { return (
{children}
); }