refactor(chat): update premium token error messages for clarity and consistency

This commit is contained in:
Anish Sarkar 2026-04-29 20:17:45 +05:30
parent d5ef0d2598
commit c598d7038f
3 changed files with 11 additions and 16 deletions

View file

@ -1542,7 +1542,7 @@ async def stream_new_chat(
llm_config_id,
)
yield streaming_service.format_error(
"Premium token quota exceeded for this pinned model. Select a free model or re-select Auto (Fastest) to repin."
"Premium tokens exhausted. Buy more tokens to continue with this model, or switch to a free model."
)
yield streaming_service.format_done()
return
@ -2263,7 +2263,7 @@ async def stream_resume_chat(
llm_config_id,
)
yield streaming_service.format_error(
"Premium token quota exceeded for this pinned model. Select a free model or re-select Auto (Fastest) to repin."
"Premium tokens exhausted. Buy more tokens to continue with this model, or switch to a free model."
)
yield streaming_service.format_done()
return

View file

@ -201,17 +201,16 @@ const BASE_TOOLS_WITH_UI = new Set([
// "write_todos", // Disabled for now
]);
const PINNED_PREMIUM_QUOTA_MESSAGE = "Premium token quota exceeded for this pinned model.";
function getPinnedPremiumQuotaErrorMessage(error: unknown): string | null {
if (!(error instanceof Error)) return null;
if (!error.message.toLowerCase().includes("premium token quota exceeded")) {
const normalized = error.message.toLowerCase();
if (
!normalized.includes("premium tokens exhausted")
&& !normalized.includes("premium token quota exceeded")
) {
return null;
}
if (!error.message.toLowerCase().includes("pinned model")) {
return null;
}
return error.message || PINNED_PREMIUM_QUOTA_MESSAGE;
return error.message;
}
export default function NewChatPage() {
@ -980,7 +979,6 @@ export default function NewChatPage() {
threadId: currentThreadId,
message: premiumQuotaAlertMessage,
});
toast.error(PINNED_PREMIUM_QUOTA_MESSAGE);
} else {
toast.error("Failed to get response. Please try again.");
}
@ -1290,7 +1288,6 @@ export default function NewChatPage() {
threadId: resumeThreadId,
message: premiumQuotaAlertMessage,
});
toast.error(PINNED_PREMIUM_QUOTA_MESSAGE);
} else {
toast.error("Failed to resume. Please try again.");
}
@ -1638,7 +1635,6 @@ export default function NewChatPage() {
threadId,
message: premiumQuotaAlertMessage,
});
toast.error(PINNED_PREMIUM_QUOTA_MESSAGE);
} else {
toast.error("Failed to regenerate response. Please try again.");
}

View file

@ -161,16 +161,15 @@ const PremiumQuotaPinnedAlert: FC = () => {
if (!alert) return null;
return (
<div className="mx-2 rounded-2xl border border-amber-300/40 bg-amber-500/10 px-4 py-3 text-amber-50 shadow-lg backdrop-blur-sm">
<div className="mx-0 bg-amber-500/10 px-3 py-2 text-amber-100">
<div className="flex items-start gap-2">
<AlertCircle className="mt-0.5 size-4 shrink-0 text-amber-300" />
<div className="min-w-0 flex-1">
<p className="text-sm font-medium">Premium quota exhausted</p>
<p className="mt-1 text-xs text-amber-100/90">{alert.message}</p>
<p className="text-sm">{alert.message}</p>
</div>
<button
type="button"
className="inline-flex size-6 items-center justify-center rounded-md text-amber-200 transition-colors hover:bg-amber-200/20 hover:text-amber-50"
className="inline-flex size-6 items-center justify-center text-amber-200 transition-colors hover:text-amber-50"
aria-label="Dismiss premium quota alert"
onClick={() => clearPremiumAlertForThread(currentThreadId)}
>