@@ -18,7 +18,6 @@ import {t} from 'sentry/locale';
18
18
import { space } from 'sentry/styles/space' ;
19
19
import { trackAnalytics } from 'sentry/utils/analytics' ;
20
20
import { getFieldDefinition } from 'sentry/utils/fields' ;
21
- import { getSelectedProjectList } from 'sentry/utils/project/useSelectedProjectsHaveField' ;
22
21
import { useMutation } from 'sentry/utils/queryClient' ;
23
22
import useApi from 'sentry/utils/useApi' ;
24
23
import { useFeedbackForm } from 'sentry/utils/useFeedbackForm' ;
@@ -131,10 +130,12 @@ export function AiQueryDrawer({initialQuery = ''}: {initialQuery?: string}) {
131
130
132
131
const { mutate : submitQuery , isPending} = useMutation ( {
133
132
mutationFn : async ( query : string ) => {
134
- const selectedProjects = getSelectedProjectList (
135
- pageFilters . selection . projects ,
136
- memberProjects
137
- ) . map ( p => p . id ) ;
133
+ const selectedProjects =
134
+ pageFilters . selection . projects &&
135
+ pageFilters . selection . projects . length > 0 &&
136
+ pageFilters . selection . projects [ 0 ] !== - 1
137
+ ? pageFilters . selection . projects
138
+ : memberProjects . map ( p => p . id ) ;
138
139
139
140
const result = await api . requestPromise (
140
141
`/api/0/organizations/${ organization . slug } /trace-explorer-ai/query/` ,
@@ -299,14 +300,15 @@ export function TraceExploreAiQueryProvider({children}: {children: React.ReactNo
299
300
const pageFilters = usePageFilters ( ) ;
300
301
const client = useApi ( ) ;
301
302
const { projects} = useProjects ( ) ;
303
+ const memberProjects = projects . filter ( p => p . isMember ) ;
302
304
303
305
useEffect ( ( ) => {
304
306
const selectedProjects =
305
307
pageFilters . selection . projects &&
306
308
pageFilters . selection . projects . length > 0 &&
307
309
pageFilters . selection . projects [ 0 ] !== - 1
308
310
? pageFilters . selection . projects
309
- : projects . map ( p => p . id ) ;
311
+ : memberProjects . map ( p => p . id ) ;
310
312
311
313
( async ( ) => {
312
314
try {
@@ -330,6 +332,7 @@ export function TraceExploreAiQueryProvider({children}: {children: React.ReactNo
330
332
organization . slug ,
331
333
pageFilters . selection . projects ,
332
334
projects ,
335
+ memberProjects ,
333
336
] ) ;
334
337
335
338
return (
0 commit comments