@@ -29,8 +29,9 @@ import {
2929 previewAnnotationContextId ,
3030 previewAnnotationContextRecord ,
3131 previewAnnotationFromRecord ,
32- reviewCommentContextId ,
32+ reviewCommentDraftContextId ,
3333 reviewCommentContextRecord ,
34+ reviewCommentContextReference ,
3435 reviewCommentFromRecord ,
3536 terminalContextDraftFromRecord ,
3637 terminalContextRecord ,
@@ -52,6 +53,7 @@ import {
5253 type ComposerDraftContextRecords ,
5354 uploadedContextRecordFromDraft ,
5455} from "../composerContextPresentation" ;
56+ import { buildPullRequestReferenceContext } from "../pullRequest/pullRequestDetail.logic" ;
5557import { useAtomCommand } from "../../state/use-atom-command" ;
5658import { useAtomQueryRunner } from "~/state/use-atom-query-runner" ;
5759import { useStableCallback } from "../../hooks/useStableCallback" ;
@@ -339,14 +341,16 @@ export function useComposerContextImport(input: {
339341 ? existing . record . id
340342 : undefined ,
341343 } )
342- : existing ?. kind === "thread" ||
343- existing ?. kind === "environment" ||
344- existing ?. kind === "jira" ||
345- existing ?. kind === "figma"
346- ? existing . record
347- : existing
348- ? ( uploadedContextRecordFromDraft ( existing ) ?? undefined )
349- : undefined ;
344+ : existing ?. kind === "pull-request"
345+ ? reviewCommentContextRecord ( existing . record )
346+ : existing ?. kind === "thread" ||
347+ existing ?. kind === "environment" ||
348+ existing ?. kind === "jira" ||
349+ existing ?. kind === "figma"
350+ ? existing . record
351+ : existing
352+ ? ( uploadedContextRecordFromDraft ( existing ) ?? undefined )
353+ : undefined ;
350354 if (
351355 existingRecord &&
352356 isSameComposerContextPayload ( existingRecord , record ) &&
@@ -376,7 +380,26 @@ export function useComposerContextImport(input: {
376380 addComposerDraftReviewComment ( composerDraftTarget , comment , {
377381 appendReference : false ,
378382 } ) ;
379- rewritten . set ( record . contextId , reviewCommentContextId ( comment . id ) ) ;
383+ rewritten . set ( record . contextId , reviewCommentDraftContextId ( comment ) ) ;
384+ break ;
385+ }
386+ case "pull-request" : {
387+ // Question answers carry no PR chips; keep them off the main draft while answering.
388+ if ( questionAttachmentTarget !== null ) break ;
389+ const imported = buildPullRequestReferenceContext ( {
390+ number : record . number ,
391+ title : record . title ,
392+ url : record . url ,
393+ headBranch : record . headBranch ,
394+ baseBranch : record . baseBranch ,
395+ state : record . state ,
396+ isDraft : record . isDraft ,
397+ } ) ;
398+ const comment = conflicts ? { ...imported , id : randomUUID ( ) } : imported ;
399+ addComposerDraftReviewComment ( composerDraftTarget , comment , {
400+ appendReference : false ,
401+ } ) ;
402+ rewritten . set ( record . contextId , reviewCommentContextReference ( comment ) . contextId ) ;
380403 break ;
381404 }
382405 case "element" :
0 commit comments