@@ -3,7 +3,7 @@ import { act } from "react";
33import { createRoot } from "react-dom/client" ;
44import { expect , it , vi } from "vite-plus/test" ;
55import { Atom , AtomRegistry } from "effect/reactivity" ;
6- import { EnvironmentId , ThreadId } from "@t3tools/contracts" ;
6+ import { EnvironmentId , ThreadId , type ScopedThreadRef } from "@t3tools/contracts" ;
77
88vi . mock ( "./atom-registry" , ( ) => ( { appAtomRegistry : AtomRegistry . make ( ) } ) ) ;
99vi . mock ( "./projects" , ( ) => ( { environmentProjects : { } } ) ) ;
@@ -18,11 +18,15 @@ vi.mock("../native/ProjectChipIconImages", () => ({
1818} ) ) ;
1919vi . mock ( "./threads" , ( ) => {
2020 const shell = Atom . make < { title : string } | null > ( null ) ;
21+ const absent = Atom . make ( null ) ;
2122 return {
2223 environmentThreadDetails : { } ,
23- environmentThreadShells : { threadShellAtom : ( ) => shell } ,
24+ environmentThreadShells : {
25+ threadShellAtom : ( ref : ScopedThreadRef ) => ( ref . threadId === childId ? shell : absent ) ,
26+ } ,
2427 threadFamilies : {
25- mount : ( registry : AtomRegistry . AtomRegistry ) => {
28+ mount : ( registry : AtomRegistry . AtomRegistry , _env : EnvironmentId , id : ThreadId ) => {
29+ if ( id !== childId ) return ( ) => { } ;
2630 registry . set ( shell , { title : "Child result" } ) ;
2731 return ( ) => registry . set ( shell , null ) ;
2832 } ,
@@ -31,9 +35,11 @@ vi.mock("./threads", () => {
3135} ) ;
3236
3337import { appAtomRegistry } from "./atom-registry" ;
34- import { useLiveThreadLinkLabels } from "./entities" ;
38+ import { resolveThreadLink , useLiveThreadLinkLabels } from "./entities" ;
3539import { environmentThreadShells } from "./threads" ;
3640
41+ const childId = ThreadId . make ( "thread:delegated-task:command%3Amcp%3Achild" ) ;
42+
3743it ( "keeps a linked child title mounted until the message stops citing it" , async ( ) => {
3844 ( globalThis as { IS_REACT_ACT_ENVIRONMENT ?: boolean } ) . IS_REACT_ACT_ENVIRONMENT = true ;
3945 const container = document . createElement ( "div" ) ;
@@ -47,11 +53,15 @@ it("keeps a linked child title mounted until the message stops citing it", async
4753 await act ( async ( ) =>
4854 root . render (
4955 < RegistryContext . Provider value = { appAtomRegistry } >
50- < Probe text = "[Child]( t3-thread://v2/local/child)" />
56+ < Probe text = { `< t3-thread://v2/local/${ childId } >` } />
5157 </ RegistryContext . Provider > ,
5258 ) ,
5359 ) ;
54- expect ( container . textContent ) . toBe ( "[Child result](t3-thread://v2/local/child)" ) ;
60+ expect ( container . textContent ) . toBe ( `[Child result](t3-thread://v2/local/${ childId } )` ) ;
61+ const target = { environmentId : EnvironmentId . make ( "local" ) , threadId : childId } ;
62+ expect (
63+ resolveThreadLink ( ( atom ) => appAtomRegistry . get ( atom ) , target , target . environmentId ) ,
64+ ) . toEqual ( target ) ;
5565 expect ( renders ) . toBeLessThan ( 20 ) ;
5666 await act ( async ( ) =>
5767 root . render (
@@ -65,7 +75,7 @@ it("keeps a linked child title mounted until the message stops citing it", async
6575 appAtomRegistry . get (
6676 environmentThreadShells . threadShellAtom ( {
6777 environmentId : EnvironmentId . make ( "local" ) ,
68- threadId : ThreadId . make ( "child" ) ,
78+ threadId : childId ,
6979 } ) ,
7080 ) ,
7181 ) . toBeNull ( ) ;
0 commit comments