@@ -88,7 +88,7 @@ import { isDesktopLocalConnectionTarget } from "../connection/desktopLocal";
8888import { useDesktopLocalBootstraps } from "../connection/useDesktopLocalBootstraps" ;
8989import { useHandleNewThread } from "../hooks/useHandleNewThread" ;
9090import { useOpenPanelPullRequestUrl } from "../hooks/useOpenPanelPullRequestUrl" ;
91- import { writeTextToClipboard } from "../hooks/useCopyToClipboard " ;
91+ import { copyThreadReference } from "../lib/copyThreadReference " ;
9292import {
9393 composerPromptLink ,
9494 copyPromptLink ,
@@ -446,33 +446,16 @@ function OpenCommandPaletteDialog(props: {
446446 referenceThreadRef === null || ( pathname === "/pull-requests" && ! openPanelPullRequestUrl )
447447 ? null
448448 : resolveThreadReferenceCopyTarget ( {
449- threadId : referenceThreadRef . threadId ,
449+ threadRef : referenceThreadRef ,
450+ title : activeThread ?. title ?? "" ,
450451 openPanelPullRequestUrl,
451452 pullRequests : activeThread ?. pullRequests ,
452453 linkedPullRequestUrl :
453454 activeThread ?. linkedPullRequest ?. url ?? activeThread ?. branchPullRequest ?. url ?? null ,
454455 } ) ;
455456 const copyActiveThreadReference = async ( ) => {
456- const target = activeThreadReferenceCopyTarget ;
457- if ( target === null ) return ;
458- try {
459- const didCopy = await writeTextToClipboard ( target . value , target . clipboardTarget ) ;
460- if ( ! didCopy ) return ;
461- toastManager . add ( {
462- type : "success" ,
463- title : target . successTitle ,
464- description : target . value ,
465- } ) ;
466- } catch ( error ) {
467- console . error ( error ) ;
468- toastManager . add (
469- stackedThreadToast ( {
470- type : "error" ,
471- title : target . failureTitle ,
472- description : error instanceof Error ? error . message : "An error occurred." ,
473- } ) ,
474- ) ;
475- }
457+ if ( activeThreadReferenceCopyTarget === null ) return ;
458+ await copyThreadReference ( activeThreadReferenceCopyTarget ) ;
476459 } ;
477460 const threads = useThreadShells ( ) ;
478461 const keybindings = useAtomValue ( primaryServerKeybindingsAtom ) ;
@@ -1299,10 +1282,10 @@ function OpenCommandPaletteDialog(props: {
12991282 searchTerms :
13001283 activeThreadReferenceCopyTarget . kind === "pull-request"
13011284 ? [ "copy" , "pull request" , "link" , "reference" ]
1302- : [ "copy" , "thread id" , "reference" ] ,
1285+ : [ "copy" , "thread" , "thread id", "reference" ] ,
13031286 title :
1304- activeThreadReferenceCopyTarget . kind === "pull-request" ? "Copy PR link" : "Copy thread ID " ,
1305- description : activeThreadReferenceCopyTarget . value ,
1287+ activeThreadReferenceCopyTarget . kind === "pull-request" ? "Copy PR link" : "Copy thread" ,
1288+ description : activeThreadReferenceCopyTarget . description ,
13061289 icon : < LinkIcon className = { ITEM_ICON_CLASS } /> ,
13071290 shortcutCommand : "thread.copyReference" ,
13081291 run : copyActiveThreadReference ,
0 commit comments