@@ -198,64 +198,59 @@ it.each([
198198 ) ;
199199} ) ;
200200
201- it . each ( [ false , true ] ) (
202- "keeps an unreadable thread as a link (already attached: %s)" ,
203- async ( alreadyAttached ) => {
204- const target = DraftId . make ( "clipboard-threads" ) ;
205- const store = useComposerDraftStore . getState ( ) ;
206- using _draft = { [ Symbol . dispose ] : ( ) => store . clearComposerContent ( target ) } ;
207- const thread = ( environmentId : string , threadId : string ) => ( {
208- version : 1 as const ,
209- kind : "thread" as const ,
210- contextId : ComposerContextId . make ( `thread_${ threadId } ` ) ,
211- label : `Thread ${ threadId } ` ,
212- environmentId : EnvironmentId . make ( environmentId ) ,
213- threadId : ThreadId . make ( threadId ) ,
214- title : `Thread ${ threadId } ` ,
215- } ) ;
216- const unlinked = thread ( "unlinked-source" , "remote" ) ;
217- const linked = thread ( "linked-source" , "linked" ) ;
218- if ( alreadyAttached ) store . addThreadContexts ( target , [ unlinked ] , { appendReference : false } ) ;
219- let importer ! : Importer ;
220- await using _screen = await render (
221- < Harness
222- input = { {
223- environmentId : EnvironmentId . make ( "clipboard-target" ) ,
224- linkedEnvironments : new Map ( [ [ linked . environmentId , "Linked" ] ] ) ,
225- activeThread : undefined ,
226- activeThreadId : null ,
227- composerDraftTarget : target ,
228- attachmentDraftTarget : target ,
229- attachmentTargetKey : target ,
230- attachmentTargetKeyRef : { current : target } ,
231- questionAttachmentTarget : null ,
232- pendingUserInputs : [ ] ,
233- composerContextRecords : new Map (
234- alreadyAttached ? [ [ unlinked . contextId , { kind : "thread" , record : unlinked } ] ] : [ ] ,
235- ) ,
236- composerImages : [ ] ,
237- composerFilesRef : { current : [ ] } ,
238- pendingThreadImportsRef : { current : new Map ( ) } ,
239- promptRef : { current : "" } ,
240- addComposerFilesToDraft : ( files ) => store . addFiles ( target , files ) ,
241- } }
242- ready = { ( value ) => {
243- importer = value ;
244- } }
245- /> ,
246- ) ;
247- let remapped ! : ReturnType < Importer [ "importContextRecords" ] > ;
248- await act ( async ( ) => {
249- remapped = importer . importContextRecords ( [ unlinked , linked ] , unlinked . environmentId ) ;
250- } ) ;
251- expect ( Object . fromEntries ( remapped ) ) . toEqual ( {
252- [ unlinked . contextId ] : {
253- markdown : "[Thread remote](t3-thread://v2/unlinked-source/remote)" ,
254- } ,
255- [ linked . contextId ] : linked . contextId ,
256- } ) ;
257- expect ( store . getComposerDraft ( target ) ?. threadContexts ) . toEqual (
258- alreadyAttached ? [ unlinked , linked ] : [ linked ] ,
259- ) ;
260- } ,
261- ) ;
201+ it ( "keeps an unreadable thread as a link even when the draft already attaches it" , async ( ) => {
202+ const target = DraftId . make ( "clipboard-threads" ) ;
203+ const store = useComposerDraftStore . getState ( ) ;
204+ using _draft = { [ Symbol . dispose ] : ( ) => store . clearComposerContent ( target ) } ;
205+ const thread = ( environmentId : string , threadId : string ) => ( {
206+ version : 1 as const ,
207+ kind : "thread" as const ,
208+ contextId : ComposerContextId . make ( `thread_${ threadId } ` ) ,
209+ label : `Thread ${ threadId } ` ,
210+ environmentId : EnvironmentId . make ( environmentId ) ,
211+ threadId : ThreadId . make ( threadId ) ,
212+ title : `Thread ${ threadId } ` ,
213+ } ) ;
214+ const unlinked = thread ( "unlinked-source" , "remote" ) ;
215+ const linked = thread ( "linked-source" , "linked" ) ;
216+ store . addThreadContexts ( target , [ unlinked ] , { appendReference : false } ) ;
217+ let importer ! : Importer ;
218+ await using _screen = await render (
219+ < Harness
220+ input = { {
221+ environmentId : EnvironmentId . make ( "clipboard-target" ) ,
222+ linkedEnvironments : new Map ( [ [ linked . environmentId , "Linked" ] ] ) ,
223+ activeThread : undefined ,
224+ activeThreadId : null ,
225+ composerDraftTarget : target ,
226+ attachmentDraftTarget : target ,
227+ attachmentTargetKey : target ,
228+ attachmentTargetKeyRef : { current : target } ,
229+ questionAttachmentTarget : null ,
230+ pendingUserInputs : [ ] ,
231+ composerContextRecords : new Map ( [
232+ [ unlinked . contextId , { kind : "thread" , record : unlinked } ] ,
233+ ] ) ,
234+ composerImages : [ ] ,
235+ composerFilesRef : { current : [ ] } ,
236+ pendingThreadImportsRef : { current : new Map ( ) } ,
237+ promptRef : { current : "" } ,
238+ addComposerFilesToDraft : ( files ) => store . addFiles ( target , files ) ,
239+ } }
240+ ready = { ( value ) => {
241+ importer = value ;
242+ } }
243+ /> ,
244+ ) ;
245+ let remapped ! : ReturnType < Importer [ "importContextRecords" ] > ;
246+ await act ( async ( ) => {
247+ remapped = importer . importContextRecords ( [ unlinked , linked ] , unlinked . environmentId ) ;
248+ } ) ;
249+ expect ( Object . fromEntries ( remapped ) ) . toEqual ( {
250+ [ unlinked . contextId ] : {
251+ markdown : "[Thread remote](t3-thread://v2/unlinked-source/remote)" ,
252+ } ,
253+ [ linked . contextId ] : linked . contextId ,
254+ } ) ;
255+ expect ( store . getComposerDraft ( target ) ?. threadContexts ) . toEqual ( [ unlinked , linked ] ) ;
256+ } ) ;
0 commit comments