@@ -193,11 +193,13 @@ it.each([
193193 ) ;
194194} ) ;
195195
196- it . each ( [ "same" , "renamed" , "other-environment" ] as const ) (
196+ it . each ( [ "same" , "renamed" , "other-environment" , "different-draft" ] as const ) (
197197 "preserves thread identity across repeated pastes: %s" ,
198198 async ( variant ) => {
199199 const otherEnvironment = variant === "other-environment" ;
200200 const target = DraftId . make ( `thread-collision-${ variant } ` ) ;
201+ const attachmentTarget =
202+ variant === "different-draft" ? DraftId . make ( "question-draft" ) : target ;
201203 const store = useComposerDraftStore . getState ( ) ;
202204 using _draft = { [ Symbol . dispose ] : ( ) => store . clearComposerContent ( target ) } ;
203205 const environmentId = EnvironmentId . make ( "thread-source" ) ;
@@ -224,10 +226,10 @@ it.each(["same", "renamed", "other-environment"] as const)(
224226 activeThread : undefined ,
225227 activeThreadId : null ,
226228 composerDraftTarget : target ,
227- attachmentDraftTarget : target ,
228- attachmentTargetKey : target ,
229- attachmentTargetKeyRef : { current : target } ,
230- questionAttachmentTarget : null ,
229+ attachmentDraftTarget : attachmentTarget ,
230+ attachmentTargetKey : attachmentTarget ,
231+ attachmentTargetKeyRef : { current : attachmentTarget } ,
232+ questionAttachmentTarget : attachmentTarget === target ? null : attachmentTarget ,
231233 pendingUserInputs : [ ] ,
232234 composerContextRecords : new Map ( [ [ first . contextId , { kind : "thread" , record : first } ] ] ) ,
233235 composerImages : [ ] ,
@@ -244,7 +246,7 @@ it.each(["same", "renamed", "other-environment"] as const)(
244246 let importedId : string | undefined ;
245247 await act ( ( ) => {
246248 importedId = importer
247- . importContextRecords ( [ pasted ] , pasted . environmentId )
249+ . importContextRecords ( [ pasted ] , pasted . environmentId , target )
248250 . get ( pasted . contextId ) ;
249251 } ) ;
250252 const records = store . getComposerDraft ( target ) ! . threadContexts ;
@@ -255,7 +257,7 @@ it.each(["same", "renamed", "other-environment"] as const)(
255257 expect ( records ) . toHaveLength ( otherEnvironment ? 2 : 1 ) ;
256258 expect ( records [ 0 ] ) . toEqual ( first ) ;
257259 await act ( ( ) => {
258- const repeated = importer . importContextRecords ( [ pasted ] , pasted . environmentId ) ;
260+ const repeated = importer . importContextRecords ( [ pasted ] , pasted . environmentId , target ) ;
259261 expect ( repeated . get ( pasted . contextId ) ) . toBe ( importedId ) ;
260262 } ) ;
261263 expect ( store . getComposerDraft ( target ) ! . threadContexts ) . toEqual ( records ) ;
0 commit comments