Generator Error UX Improvements#10
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generator Error UX Improvements
Summary
This branch polishes the error messaging experience, derived from the hardened prompt security measures previously implemented:
error/reason/fieldpayloads from/api/generateinto user-readable copy that doesn't leak which specific filter fired.Friendly error mapper
Why. The route returns structured fields (
error,reason,field,details) but the UI was previously reading onlyerrorData.messageand falling back to status text. That meant our new 400/422/429 responses surfaced asError 422: Unprocessable Entity— useless to the user.Implementation (
lib/generator-errors.ts):friendlyGenerationError(status, body) → { title, description, kind }.kind: "hardening" | "limit" | "other"lets the UI decide where to show the message:hardening→ inline alert above the Generate button (component below).limit→ toast (daily-quota / auth, where the user typically expects a transient notification).other→ toast (server errors, network, unknown).Examples,Additional Instructions) without echoing the matched phrase or naming the heuristic. Maintainers see the precise reason in server logs.Status / reason coverage:
off_topic_refusalsql_dangerous_statementconcurrency_limitjailbreak_phrase/off_topicbyo_key_requireddetails<status>)Inline hardening alert
Why. Toasts are wrong for hardening errors because:
A persistent, dismissible inline alert next to the Generate button keeps the user's attention on the field they need to change and stays visible until they fix it or dismiss it.
Implementation (
components/generator/hardening-alert.tsx):Files added
lib/generator-errors.tsfriendlyGenerationError(status, body) → { title, description, kind }mappercomponents/generator/hardening-alert.tsx