Skip to content

Commit

Permalink
Merge branch 'dev' into checkpoint-2-vault-webui-and-api-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed Dec 17, 2024
2 parents 646191f + 387012f commit 5b86679
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion agenta-web/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({
justifyContent: "space-between",
flexDirection: "column",
flex: 1,
overflowY: "auto",
},
"& .ant-menu-submenu-title": {
display: "flex",
Expand All @@ -66,7 +67,6 @@ const useStyles = createUseStyles((theme: JSSTheme) => ({
},
menuContainer: {
borderRight: "0 !important",
maxHeight: "calc(100vh - 390px)",
overflowY: "auto",
position: "relative",
"& .ant-menu-item-selected": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type EvaluatorsProps = {
onSuccess: () => void
setEvaluatorsDisplay: any
evaluatorsDisplay: string
setSelectedEvaluatorCategory: React.Dispatch<React.SetStateAction<string>>
selectedEvaluatorCategory: string
}

const useStyles = createUseStyles((theme: JSSTheme) => ({
Expand Down Expand Up @@ -74,13 +72,12 @@ const Evaluators = ({
setCloneConfig,
setEvaluatorsDisplay,
evaluatorsDisplay,
selectedEvaluatorCategory,
setSelectedEvaluatorCategory,
}: EvaluatorsProps) => {
const classes = useStyles()
const [searchTerm, setSearchTerm] = useState("")
const evaluatorTags = getEvaluatorTags()
const evaluators = useAtom(evaluatorsAtom)[0]
const [selectedEvaluatorCategory, setSelectedEvaluatorCategory] = useState("view_all")

const updatedEvaluatorConfigs = useMemo(() => {
return evaluatorConfigs.map((config) => {
Expand Down Expand Up @@ -128,7 +125,7 @@ const Evaluators = ({
<div>
<div className="flex items-center justify-between">
<Radio.Group
defaultValue={"view_all"}
defaultValue={selectedEvaluatorCategory}
className={classes.radioBtnContainer}
onChange={(e) => setSelectedEvaluatorCategory(e.target.value)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const EvaluatorsModal = ({
"evaluator_view",
"list",
)
const [selectedEvaluatorCategory, setSelectedEvaluatorCategory] = useState("view_all")
const [selectedTestset, setSelectedTestset] = useState("")

const evalConfigFetcher = () => {
Expand Down Expand Up @@ -114,8 +113,6 @@ const EvaluatorsModal = ({
setCloneConfig={setCloneConfig}
setEvaluatorsDisplay={setEvaluatorsDisplay}
evaluatorsDisplay={evaluatorsDisplay}
selectedEvaluatorCategory={selectedEvaluatorCategory}
setSelectedEvaluatorCategory={setSelectedEvaluatorCategory}
/>
),
},
Expand All @@ -128,8 +125,6 @@ const EvaluatorsModal = ({
setSelectedEvaluator={setSelectedEvaluator}
setEvaluatorsDisplay={setEvaluatorsDisplay}
evaluatorsDisplay={evaluatorsDisplay}
selectedEvaluatorCategory={selectedEvaluatorCategory}
setSelectedEvaluatorCategory={setSelectedEvaluatorCategory}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ type NewEvaluatorProps = {
setSelectedEvaluator: React.Dispatch<React.SetStateAction<Evaluator | null>>
setEvaluatorsDisplay: any
evaluatorsDisplay: string
setSelectedEvaluatorCategory: React.Dispatch<React.SetStateAction<string>>
selectedEvaluatorCategory: string
}

const useStyles = createUseStyles((theme: JSSTheme) => ({
Expand Down Expand Up @@ -62,12 +60,11 @@ const NewEvaluator = ({
setSelectedEvaluator,
setEvaluatorsDisplay,
evaluatorsDisplay,
selectedEvaluatorCategory,
setSelectedEvaluatorCategory,
}: NewEvaluatorProps) => {
const classes = useStyles()
const [searchTerm, setSearchTerm] = useState("")
const evaluatorTags = getEvaluatorTags()
const [selectedEvaluatorCategory, setSelectedEvaluatorCategory] = useState("view_all")

const filteredEvaluators = useMemo(() => {
let filtered = evaluators
Expand Down Expand Up @@ -103,7 +100,7 @@ const NewEvaluator = ({
<div>
<div className="flex items-center justify-between">
<Radio.Group
defaultValue={"view_all"}
defaultValue={selectedEvaluatorCategory}
className={classes.radioBtnContainer}
onChange={(e) => setSelectedEvaluatorCategory(e.target.value)}
>
Expand Down
8 changes: 8 additions & 0 deletions agenta-web/src/hooks/useIsomorphicLayoutEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {useLayoutEffect, useEffect} from "react"

// useIsomorphicLayoutEffect is a custom hook that uses useLayoutEffect on the client-side
// (when window is defined) and useEffect on the server-side (when window is undefined).
// This ensures that the code runs correctly in both client-side and server-side environments.
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect

export default useIsomorphicLayoutEffect
5 changes: 3 additions & 2 deletions agenta-web/src/hooks/usePostHogAg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {useLayoutEffect} from "react"
import {isDemo, generateOrRetrieveDistinctId} from "@/lib/helpers/utils"
import {usePostHog} from "posthog-js/react"
import {useProfileData} from "@/contexts/profile.context"
import useIsomorphicLayoutEffect from "./useIsomorphicLayoutEffect"

export const usePostHogAg = () => {
const trackingEnabled = process.env.NEXT_PUBLIC_TELEMETRY_TRACKING_ENABLED === "true"
Expand All @@ -23,11 +24,11 @@ export const usePostHogAg = () => {
}
}

useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
if (!trackingEnabled) posthog.opt_out_capturing()
}, [trackingEnabled])

useLayoutEffect(() => {
useIsomorphicLayoutEffect(() => {
if (posthog.get_distinct_id() !== _id) identify()
}, [user?.id])

Expand Down

0 comments on commit 5b86679

Please sign in to comment.