1- import { Portal } from "@radix-ui/react-portal" ;
21import { useFetcher , useNavigate } from "@remix-run/react" ;
2+ import { AnimatePresence , motion } from "framer-motion" ;
33import { useEffect , useRef , useState } from "react" ;
44import { AISparkleIcon } from "~/assets/icons/AISparkleIcon" ;
55import { Input } from "~/components/primitives/Input" ;
6+ import { Popover , PopoverContent , PopoverTrigger } from "~/components/primitives/Popover" ;
67import { ShortcutKey } from "~/components/primitives/ShortcutKey" ;
78import { Spinner } from "~/components/primitives/Spinner" ;
89import { useEnvironment } from "~/hooks/useEnvironment" ;
910import { useOrganization } from "~/hooks/useOrganizations" ;
1011import { useProject } from "~/hooks/useProject" ;
11- import { useSearchParams } from "~/hooks/useSearchParam " ;
12+ import { cn } from "~/utils/cn " ;
1213import { objectToSearchParams } from "~/utils/searchParams" ;
1314import { type TaskRunListSearchFilters } from "./RunFilters" ;
14- import { cn } from "~/utils/cn" ;
15- import { motion , AnimatePresence } from "framer-motion" ;
16- import { Popover , PopoverContent , PopoverTrigger } from "~/components/primitives/Popover" ;
1715
1816type AIFilterResult =
1917 | {
@@ -39,33 +37,19 @@ export function AIFilterInput() {
3937
4038 useEffect ( ( ) => {
4139 if ( fetcher . data ?. success && fetcher . state === "loading" ) {
42- // Clear the input after successful application
4340 setText ( "" ) ;
44- // Ensure focus is removed after successful submission
4541 setIsFocused ( false ) ;
4642
4743 const searchParams = objectToSearchParams ( fetcher . data . filters ) ;
4844 if ( ! searchParams ) {
4945 return ;
5046 }
5147
52- console . log ( "AI filter success" , {
53- data : fetcher . data ,
54- searchParams : searchParams . toString ( ) ,
55- } ) ;
56-
5748 navigate ( `${ location . pathname } ?${ searchParams . toString ( ) } ` , { replace : true } ) ;
5849
59- //focus the input again
6050 if ( inputRef . current ) {
6151 inputRef . current . focus ( ) ;
6252 }
63-
64- // TODO: Show success message with explanation
65- console . log ( `AI applied filters: ${ fetcher . data . explanation } ` ) ;
66- } else if ( fetcher . data ?. success === false ) {
67- // TODO: Show error with suggestions
68- console . error ( fetcher . data . error , fetcher . data . suggestions ) ;
6953 }
7054 } , [ fetcher . data , navigate ] ) ;
7155
@@ -126,7 +110,6 @@ export function AIFilterInput() {
126110 } }
127111 onFocus = { ( ) => setIsFocused ( true ) }
128112 onBlur = { ( ) => {
129- // Only blur if the text is empty or we're not loading
130113 if ( text . length === 0 || ! isLoading ) {
131114 setIsFocused ( false ) ;
132115 }
0 commit comments