@@ -9,6 +9,16 @@ const state = vi.hoisted(() => ({
99 projection : null as unknown ,
1010 commandSucceeds : false ,
1111 relatedShells : [ ] as unknown [ ] ,
12+ threadTitles : { } as Record < string , string > ,
13+ archivedThreads : [ ] as unknown [ ] ,
14+ } ) ) ;
15+
16+ vi . mock ( import ( "../../state/query" ) , async ( original ) => ( {
17+ ...( await original ( ) ) ,
18+ useEnvironmentQuery : ( ( atom : unknown ) =>
19+ atom === null
20+ ? { data : null , isSuccess : false , isPending : false }
21+ : { data : state . threadTitles , isSuccess : true , isPending : false } ) as never ,
1222} ) ) ;
1323
1424vi . mock ( import ( "@effect/atom-react" ) , async ( original ) => ( {
@@ -33,7 +43,9 @@ vi.mock(import("../../state/environments"), () => ({
3343 useEnvironmentProviders : ( ( ) => new Map ( ) ) as never ,
3444} ) ) ;
3545vi . mock ( import ( "../../lib/archivedThreadsState" ) , ( ) => ( {
36- useArchivedThreadSnapshots : ( ( ) => ( { snapshots : [ ] } ) ) as never ,
46+ useArchivedThreadSnapshots : ( ( ) => ( {
47+ snapshots : [ { environmentId : "environment" , snapshot : { threads : state . archivedThreads } } ] ,
48+ } ) ) as never ,
3749} ) ) ;
3850vi . mock ( import ( "../../state/use-atom-command" ) , ( ) => ( {
3951 useAtomCommand : ( ( ) => async ( ) =>
@@ -53,6 +65,8 @@ const threadId = ThreadId.make("fork");
5365function setup ( ) {
5466 state . commandSucceeds = false ;
5567 state . relatedShells = [ ] ;
68+ state . threadTitles = { source : "Source" } ;
69+ state . archivedThreads = [ ] ;
5670 state . projection = {
5771 thread : {
5872 id : threadId ,
@@ -345,3 +359,37 @@ it("shows a delegated-from thread's full title in its tooltip even when its envi
345359 await row . click ( { force : true } ) ;
346360 expect ( screen . router ?. state . location . pathname ) . toBe ( "/environment/fork" ) ;
347361} ) ;
362+
363+ it ( "hides a deleted fork and keeps unloaded and archived forks with their current titles" , async ( ) => {
364+ setup ( ) ;
365+ const projection = makeThreadProjectionFixture ( ) ;
366+ state . threadTitles = { "unloaded-fork" : "Unloaded fork" , "archived-fork" : "Archived fork" } ;
367+ state . archivedThreads = [
368+ {
369+ ...projection . thread ,
370+ id : ThreadId . make ( "archived-fork" ) ,
371+ title : "Old archived title" ,
372+ archivedAt : projection . thread . updatedAt ,
373+ lineage : { parentThreadId : projection . thread . id , relationshipToParent : "fork" } ,
374+ } ,
375+ ] ;
376+ state . projection = {
377+ ...projection ,
378+ contextTransfers : [ "deleted-fork" , "unloaded-fork" , "archived-fork" ] . map ( ( id ) => ( {
379+ sourceThreadId : projection . thread . id ,
380+ targetThreadId : ThreadId . make ( id ) ,
381+ status : "pending" ,
382+ } ) ) ,
383+ } ;
384+ await using screen = await render (
385+ < ThreadRelationshipsPanel
386+ environmentId = { environmentId }
387+ threadId = { projection . thread . id }
388+ showLineage
389+ showSideChats
390+ /> ,
391+ ) ;
392+ await expect . element ( screen . getByText ( "Unloaded fork" , { exact : true } ) ) . toBeVisible ( ) ;
393+ await expect . element ( screen . getByText ( "Archived fork" , { exact : true } ) ) . toBeVisible ( ) ;
394+ await expect . element ( screen . getByText ( "deleted-fork" , { exact : true } ) ) . not . toBeInTheDocument ( ) ;
395+ } ) ;
0 commit comments