@@ -2,29 +2,25 @@ import { RegistryContext, useAtomValue } from "@effect/atom-react";
22import type { EnvironmentId } from "@t3tools/contracts" ;
33import * as Option from "effect/Option" ;
44import { AsyncResult , Atom } from "effect/reactivity" ;
5- import { useContext , useMemo } from "react" ;
5+ import { useContext } from "react" ;
66
77import { agentSessionScan } from "../state/agentSessions" ;
88import { formatEnvironmentQueryError } from "../state/query" ;
99
1010export function useProjectScans ( environmentIds : readonly EnvironmentId [ ] ) {
1111 const registry = useContext ( RegistryContext ) ;
12- const scansAtom = useMemo (
13- ( ) =>
14- Atom . make ( ( get ) =>
15- environmentIds . map ( ( environmentId ) => {
16- const atom = agentSessionScan ( { environmentId, input : { } } ) ;
17- const result = get ( atom ) ;
18- return {
19- environmentId,
20- data : Option . getOrNull ( AsyncResult . value ( result ) ) ,
21- error : result . _tag === "Failure" ? formatEnvironmentQueryError ( result . cause ) : null ,
22- isPending : result . waiting || result . _tag === "Initial" ,
23- refresh : ( ) => registry . refresh ( atom ) ,
24- } ;
25- } ) ,
26- ) ,
27- [ environmentIds , registry ] ,
12+ const scansAtom = Atom . make ( ( get ) =>
13+ environmentIds . map ( ( environmentId ) => {
14+ const atom = agentSessionScan ( { environmentId, input : { } } ) ;
15+ const result = get ( atom ) ;
16+ return {
17+ environmentId,
18+ data : Option . getOrNull ( AsyncResult . value ( result ) ) ,
19+ error : result . _tag === "Failure" ? formatEnvironmentQueryError ( result . cause ) : null ,
20+ isPending : result . waiting || result . _tag === "Initial" ,
21+ refresh : ( ) => registry . refresh ( atom ) ,
22+ } ;
23+ } ) ,
2824 ) ;
2925 return useAtomValue ( scansAtom ) ;
3026}
0 commit comments