@@ -53,6 +53,12 @@ export const AgentMetadata: FC<AgentMetadataProps> = ({
53
53
} ) => {
54
54
const [ activeMetadata , setActiveMetadata ] = useState ( storybookMetadata ) ;
55
55
useEffect ( ( ) => {
56
+ // This is an unfortunate pitfall with this component's testing setup,
57
+ // but even though we use the value of storybookMetadata as the initial
58
+ // value of the activeMetadata, we cannot put activeMetadata itself into
59
+ // the dependency array. If we did, we would destroy and rebuild each
60
+ // connection every single time a new message comes in from the socket,
61
+ // because the socket has to be wired up to the state setter
56
62
if ( storybookMetadata !== undefined ) {
57
63
return ;
58
64
}
@@ -108,13 +114,6 @@ export const AgentMetadata: FC<AgentMetadataProps> = ({
108
114
window . clearTimeout ( timeoutId ) ;
109
115
latestSocket ?. close ( ) ;
110
116
} ;
111
-
112
- // This is an unfortunate pitfall with this component's testing setup,
113
- // but even though we use the value of storybookMetadata as the initial
114
- // value of the activeMetadata, we cannot put activeMetadata itself into
115
- // the dependency array. If we did, we would destroy and rebuild each
116
- // connection every single time a new message comes in from the socket,
117
- // because the socket has to be wired up to the state setter
118
117
} , [ agent . id , storybookMetadata ] ) ;
119
118
120
119
if ( activeMetadata === undefined ) {
0 commit comments