From 39952d2fbe3a598e6fe94ee0ff2a47394f7007a7 Mon Sep 17 00:00:00 2001 From: Om Pathak Date: Mon, 20 Apr 2026 02:35:18 +0530 Subject: [PATCH] fix(ui): avoid ChatGPT 431 for long Copy for AI prompts --- .../ui/src/components/toolbar/copy-for-ai.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/ui/src/components/toolbar/copy-for-ai.tsx b/packages/ui/src/components/toolbar/copy-for-ai.tsx index f8e9c95363..62cdd856c8 100644 --- a/packages/ui/src/components/toolbar/copy-for-ai.tsx +++ b/packages/ui/src/components/toolbar/copy-for-ai.tsx @@ -222,6 +222,8 @@ function buildChatGPTUrl(prompt: string): string { return `https://chatgpt.com/?q=${encodeURIComponent(prompt)}`; } +const MAX_SAFE_CHATGPT_URL_LENGTH = 7500; + function buildCursorUrl(prompt: string): string { return `cursor://prompt?text=${encodeURIComponent(prompt)}`; } @@ -254,7 +256,12 @@ export const CopyForAI = ({ }, [markdown]); const claudeUrl = buildClaudeUrl(markdown); - const chatGPTUrl = buildChatGPTUrl(markdown); + const directChatGPTUrl = buildChatGPTUrl(markdown); + const isChatGPTPromptTooLong = + directChatGPTUrl.length > MAX_SAFE_CHATGPT_URL_LENGTH; + const chatGPTUrl = isChatGPTPromptTooLong + ? 'https://chatgpt.com/' + : directChatGPTUrl; const cursorUrl = buildCursorUrl(markdown); return ( @@ -356,6 +363,10 @@ export const CopyForAI = ({ href={chatGPTUrl} target="_blank" rel="noreferrer noopener" + onClick={() => { + if (!isChatGPTPromptTooLong) return; + void navigator.clipboard.writeText(markdown); + }} className="flex items-center gap-2.5 p-2 rounded-lg cursor-pointer outline-none transition-colors hover:bg-white/5" > Open in ChatGPT - {linkDescription} + + {isChatGPTPromptTooLong + ? 'Long prompt: copied to clipboard. Paste with Ctrl+V / Cmd+V' + : linkDescription} +