From 67bbfd972bed9739fca35c60ed73d2dcc496fc2d Mon Sep 17 00:00:00 2001 From: twwu Date: Wed, 28 Jan 2026 10:43:13 +0800 Subject: [PATCH] feat(humanInput): add rate limit exceeded error handling and localization support --- .../(humanInputLayout)/form/[token]/form.tsx | 25 +++++++++++++++++++ web/i18n/en-US/share.json | 1 + web/i18n/zh-Hans/share.json | 1 + 3 files changed, 27 insertions(+) diff --git a/web/app/(humanInputLayout)/form/[token]/form.tsx b/web/app/(humanInputLayout)/form/[token]/form.tsx index 23263a8f2e..1bcdda3328 100644 --- a/web/app/(humanInputLayout)/form/[token]/form.tsx +++ b/web/app/(humanInputLayout)/form/[token]/form.tsx @@ -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) { +
+
+
+
+ +
+
+
{t('humanInput.rateLimitExceeded', { ns: 'share' })}
+
+
+
+
+
{t('chat.poweredBy', { ns: 'share' })}
+ +
+
+
+
+ } + if (!formData) { return (
diff --git a/web/i18n/en-US/share.json b/web/i18n/en-US/share.json index ec3eb28c6b..adb75ce181 100644 --- a/web/i18n/en-US/share.json +++ b/web/i18n/en-US/share.json @@ -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}}", diff --git a/web/i18n/zh-Hans/share.json b/web/i18n/zh-Hans/share.json index e4fa8baf9b..0a16583d22 100644 --- a/web/i18n/zh-Hans/share.json +++ b/web/i18n/zh-Hans/share.json @@ -63,6 +63,7 @@ "humanInput.expired": "此请求似乎已过期。", "humanInput.expiredTip": "此操作已过期。", "humanInput.formNotFound": "表单不存在。", + "humanInput.rateLimitExceeded": "请求过于频繁,请稍后再试。", "humanInput.recorded": "您的输入已被记录。", "humanInput.sorry": "抱歉!", "humanInput.thanks": "谢谢!",