@@ -19,6 +19,7 @@ import { useSuggestionModeAndQuery } from "./useSuggestionModeAndQuery";
1919import { useSuggestionsData } from "./useSuggestionsData" ;
2020import { useToast } from "@/components/hooks/use-toast" ;
2121import { ContextItem } from "./contextSelector" ;
22+ import { SearchContextQuery } from "@/lib/types" ;
2223
2324interface ChatBoxProps {
2425 onSubmit : ( children : Descendant [ ] , editor : CustomEditor ) => void ;
@@ -29,6 +30,7 @@ interface ChatBoxProps {
2930 isGenerating ?: boolean ;
3031 languageModels : LanguageModelInfo [ ] ;
3132 selectedItems : ContextItem [ ] ;
33+ searchContexts : SearchContextQuery [ ] ;
3234 onContextSelectorOpenChanged : ( isOpen : boolean ) => void ;
3335}
3436
@@ -41,6 +43,7 @@ export const ChatBox = ({
4143 isGenerating,
4244 languageModels,
4345 selectedItems,
46+ searchContexts,
4447 onContextSelectorOpenChanged,
4548} : ChatBoxProps ) => {
4649 const suggestionsBoxRef = useRef < HTMLDivElement > ( null ) ;
@@ -50,7 +53,20 @@ export const ChatBox = ({
5053 const { suggestions, isLoading } = useSuggestionsData ( {
5154 suggestionMode,
5255 suggestionQuery,
53- selectedRepos : selectedItems . filter ( item => item . type === 'repo' ) . map ( item => item . value ) ,
56+ selectedRepos : selectedItems . map ( ( item ) => {
57+ if ( item . type === 'repo' ) {
58+ return [ item . value ] ;
59+ }
60+
61+ if ( item . type === 'context' ) {
62+ const context = searchContexts . find ( ( context ) => context . name === item . value ) ;
63+ if ( context ) {
64+ return context . repoNames ;
65+ }
66+ }
67+
68+ return [ ] ;
69+ } ) . flat ( ) ,
5470 } ) ;
5571 const { selectedLanguageModel } = useSelectedLanguageModel ( {
5672 initialLanguageModel : languageModels . length > 0 ? languageModels [ 0 ] : undefined ,
0 commit comments