@@ -222,6 +222,8 @@ function buildChatGPTUrl(prompt: string): string {
222222 return `https://chatgpt.com/?q=${ encodeURIComponent ( prompt ) } ` ;
223223}
224224
225+ const MAX_SAFE_CHATGPT_URL_LENGTH = 7500 ;
226+
225227function buildCursorUrl ( prompt : string ) : string {
226228 return `cursor://prompt?text=${ encodeURIComponent ( prompt ) } ` ;
227229}
@@ -254,7 +256,12 @@ export const CopyForAI = ({
254256 } , [ markdown ] ) ;
255257
256258 const claudeUrl = buildClaudeUrl ( markdown ) ;
257- const chatGPTUrl = buildChatGPTUrl ( markdown ) ;
259+ const directChatGPTUrl = buildChatGPTUrl ( markdown ) ;
260+ const isChatGPTPromptTooLong =
261+ directChatGPTUrl . length > MAX_SAFE_CHATGPT_URL_LENGTH ;
262+ const chatGPTUrl = isChatGPTPromptTooLong
263+ ? 'https://chatgpt.com/'
264+ : directChatGPTUrl ;
258265 const cursorUrl = buildCursorUrl ( markdown ) ;
259266
260267 return (
@@ -356,6 +363,10 @@ export const CopyForAI = ({
356363 href = { chatGPTUrl }
357364 target = "_blank"
358365 rel = "noreferrer noopener"
366+ onClick = { ( ) => {
367+ if ( ! isChatGPTPromptTooLong ) return ;
368+ void navigator . clipboard . writeText ( markdown ) ;
369+ } }
359370 className = "flex items-center gap-2.5 p-2 rounded-lg cursor-pointer outline-none transition-colors hover:bg-white/5"
360371 >
361372 < span
@@ -368,7 +379,11 @@ export const CopyForAI = ({
368379 < span className = "text-sm font-medium text-white" >
369380 Open in ChatGPT
370381 </ span >
371- < span className = "text-xs text-white/40" > { linkDescription } </ span >
382+ < span className = "text-xs text-white/40" >
383+ { isChatGPTPromptTooLong
384+ ? 'Long prompt: copied to clipboard. Paste with Ctrl+V / Cmd+V'
385+ : linkDescription }
386+ </ span >
372387 </ div >
373388 < IconArrowUpRight size = { 16 } className = "shrink-0 text-white/30" />
374389 </ a >
0 commit comments