Skip to content

feat(widget): say why a reply failed: rate limit, budget, unavailable, cut off - #319

Merged
anurag629 merged 1 commit into
devfrom
feat/widget-limit-messages
Oct 23, 2026
Merged

anurag629 merged 1 commit into
devfrom
feat/widget-limit-messages

Conversation

@anurag629

Copy link
Copy Markdown
Member

F-02 task 6 and F-04 task 10: the widget says why a reply failed, instead of showing "Something went wrong" for everything. The maintainer approved raising the size budget for this.

  • Before the stream: the client now reads the protocol v1 error body ({ error: { code, retryAfterMs } }) on any non-2xx. A 429 with retryAfterMs shows "Too many messages. Please try again in 42 seconds." and a 503 provider_unavailable shows "The assistant is unavailable right now". Bodies that aren't JSON (0.5 servers, proxy pages) keep the old behavior.
  • During the stream: budget_exceeded with scope conversation shows "This chat has reached its limit." Any other scope (IP, or the site's daily total) shows "The assistant has reached its limit for today". A v1 stream that ends without finish now says "The reply was cut off." instead of the network error.
  • Five new strings keys (errorRateLimitWait, errorBudget, errorBudgetDaily, errorUnavailable, errorCutOff), so sites can translate them. The i18n page has a table of every error message.
  • The wait is shown once, rounded up, not as a live countdown, to keep the bytes down.
  • Size budget: the script tag bundle goes from 14 kB to 14.5 kB (now 14.28 kB, up from 13.97) and ESM from 17.5 to 18 kB (now 17.87). CONTRIBUTING says so.
  • The vendored protocol type gets scope on the error part, with a test-d check against core.

Checks: build, typecheck, pnpm test:coverage (1152 passed; new client tests for every mapping and for non-JSON refusals, plus widget tests for each visible message and a strings override), lint at the dev baseline, size, publint, website build.

@anurag629
anurag629 merged commit 5b31899 into dev Oct 23, 2026
5 checks passed
@anurag629
anurag629 deleted the feat/widget-limit-messages branch October 23, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant