Skip to content

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

Open
ompathak2004 wants to merge 1 commit intoresend:canaryfrom
ompathak2004:fix/chatgpt-long-prompt-copy-flow
Open

fix(ui): avoid ChatGPT 431 for long Copy for AI prompts#3404
ompathak2004 wants to merge 1 commit intoresend:canaryfrom
ompathak2004:fix/chatgpt-long-prompt-copy-flow

Conversation

@ompathak2004
Copy link
Copy Markdown

@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
    • Add URL length check (7500 chars) before building ChatGPT ?q= link.
    • If too long, copy the full prompt to clipboard and open https://chatgpt.com/ without query.
    • Show hint: “Long prompt: copied to clipboard. Paste with Ctrl+V / Cmd+V”.
    • Short prompts keep the prefilled ChatGPT URL; Claude and Cursor links are unchanged.

Written for commit 39952d2. Summary will update on new commits.

@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

⚠️ No Changeset found

Latest commit: 39952d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a 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: 39952d2

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.

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

1 participant