Skip to content

fix(ui): avoid ChatGPT 431 for long Copy for AI prompts#3404

Merged
gabrielmfern merged 3 commits into
resend:canaryfrom
ompathak2004:fix/chatgpt-long-prompt-copy-flow
Apr 27, 2026
Merged

fix(ui): avoid ChatGPT 431 for long Copy for AI prompts#3404
gabrielmfern merged 3 commits into
resend:canaryfrom
ompathak2004:fix/chatgpt-long-prompt-copy-flow

Conversation

@ompathak2004
Copy link
Copy Markdown
Contributor

@ompathak2004 ompathak2004 commented Apr 19, 2026

Fixes #3403

Intent

This PR fixes a bug in the demo/editor toolbar where Copy for AI -> Open in ChatGPT can fail with HTTP 431 when the generated prompt is too long.

Technical context

Open in ChatGPT uses a URL with ?q=${encodeURIComponent(prompt)}.
For large prompts (template code + diagnostics), the URL can exceed practical request limits and ChatGPT fails to load.

Changes

  • Added a safety check for ChatGPT URL length.
  • If prompt is within safe size, keep existing behavior (open prefilled ChatGPT URL).
  • If prompt is too long:
    • copy full prompt to clipboard
    • open plain https://chatgpt.com/ (no oversized query string)
    • show inline helper text in menu item:
      Long prompt: copied to clipboard. Paste with Ctrl+V / Cmd+V
  • Reused existing handleCopyMarkdown logic.

Scope

  • Changed file:
    • packages/ui/src/components/toolbar/copy-for-ai.tsx
  • No API/server changes.
  • No behavior changes for Claude/Cursor links.

Before

react email

After

react emailafter

Summary by cubic

Prevents ChatGPT 431 errors in the editor toolbar by handling very long “Copy for AI” prompts. Fixes #3403 and keeps the ChatGPT flow reliable with a clear fallback.

  • Bug Fixes

    • Enforce max ChatGPT URL length (7500 chars); if exceeded, open https://chatgpt.com/ without query.
    • On fallback, copy the full prompt to clipboard on click and show: “Long prompt: copied to clipboard. Paste with Ctrl+V / Cmd+V”.
    • Short prompts keep the prefilled ChatGPT URL; Claude and Cursor links are unchanged.
  • Dependencies

    • Add changeset for @react-email/ui patch; update lockfile only.

Written for commit a9ee0ac. Summary will update on new commits. Review in cubic

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 19, 2026

@ompathak2004 is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 19, 2026

🦋 Changeset detected

Latest commit: 484d3bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@react-email/ui Patch
react-email Patch
@react-email/editor Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 19, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/ui@3404

commit: 484d3bb

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Copy link
Copy Markdown
Member

@gabrielmfern gabrielmfern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! Thank you

@gabrielmfern gabrielmfern force-pushed the fix/chatgpt-long-prompt-copy-flow branch from 39952d2 to a9ee0ac Compare April 27, 2026 15:10
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Shadow auto-approve: would auto-approve. Isolated UI fix for ChatGPT URL length limits. Low risk, improves UX for long prompts by falling back to clipboard copy.

@gabrielmfern gabrielmfern merged commit 6b24228 into resend:canary Apr 27, 2026
9 of 12 checks passed
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.

Copy for AI: Open in ChatGPT fails with HTTP 431 for long prompts

2 participants