feat(humanInput): add rate limit exceeded error handling and localization support

This commit is contained in:
twwu 2026-01-28 10:43:13 +08:00
parent 1968589fdf
commit 67bbfd972b
3 changed files with 27 additions and 0 deletions

View File

@ -48,6 +48,7 @@ const FormContent = () => {
const expired = (error as HumanInputFormError | null)?.code === 'human_input_form_expired'
const submitted = (error as HumanInputFormError | null)?.code === 'human_input_form_submitted'
const rateLimitExceeded = (error as HumanInputFormError | null)?.code === 'web_form_rate_limit_exceeded'
const splitByOutputVar = (content: string): string[] => {
const outputVarRegex = /(\{\{#\$output\.[^#]+#\}\})/g
@ -180,6 +181,30 @@ const FormContent = () => {
)
}
if (rateLimitExceeded) {
<div className={cn('flex h-full w-full flex-col items-center justify-center')}>
<div className="min-w-[480px] max-w-[640px]">
<div className="border-components-divider-subtle flex h-[320px] flex-col gap-4 rounded-[20px] border bg-chat-bubble-bg p-10 pb-9 shadow-lg backdrop-blur-sm">
<div className="flex h-14 w-14 shrink-0 items-center justify-center rounded-2xl border border-components-panel-border-subtle bg-background-default-dodge p-3">
<RiErrorWarningFill className="h-8 w-8 text-text-destructive" />
</div>
<div className="grow">
<div className="title-4xl-semi-bold text-text-primary">{t('humanInput.rateLimitExceeded', { ns: 'share' })}</div>
</div>
</div>
<div className="flex flex-row-reverse px-2 py-3">
<div className={cn(
'flex shrink-0 items-center gap-1.5 px-1',
)}
>
<div className="system-2xs-medium-uppercase text-text-tertiary">{t('chat.poweredBy', { ns: 'share' })}</div>
<DifyLogo size="small" />
</div>
</div>
</div>
</div>
}
if (!formData) {
return (
<div className={cn('flex h-full w-full flex-col items-center justify-center')}>

View File

@ -63,6 +63,7 @@
"humanInput.expired": "Seems like this request has expired.",
"humanInput.expiredTip": "This action has expired.",
"humanInput.formNotFound": "Form not found.",
"humanInput.rateLimitExceeded": "Too many requests, please try again later.",
"humanInput.recorded": "Your input has been recorded.",
"humanInput.sorry": "Sorry!",
"humanInput.submissionID": "submission_id: {{id}}",

View File

@ -63,6 +63,7 @@
"humanInput.expired": "此请求似乎已过期。",
"humanInput.expiredTip": "此操作已过期。",
"humanInput.formNotFound": "表单不存在。",
"humanInput.rateLimitExceeded": "请求过于频繁,请稍后再试。",
"humanInput.recorded": "您的输入已被记录。",
"humanInput.sorry": "抱歉!",
"humanInput.thanks": "谢谢!",