@@ -266,12 +266,12 @@ export function SearchOverlay({
266
266
267
267
// Fetch initial search results on open
268
268
useEffect ( ( ) => {
269
- if ( searchOverlayOpen && ( ! isAskAIState || aiSearchError || aiCouldNotAnswer ) ) {
269
+ if ( searchOverlayOpen ) {
270
270
if ( ! searchEventGroupId . current ) {
271
271
searchEventGroupId . current = uuidv4 ( )
272
272
}
273
273
updateAutocompleteResults ( urlSearchInputQuery )
274
- } else if ( isAskAIState || aiSearchError || aiCouldNotAnswer ) {
274
+ } else {
275
275
// When opening the overlay via query params, we don't need to fetch autocomplete results
276
276
// However, on initial open, we need to clear the loading state
277
277
setSearchLoading ( false )
@@ -628,7 +628,10 @@ export function SearchOverlay({
628
628
/>
629
629
</ Box >
630
630
</ li >
631
- < ActionList . Divider key = "error-bottom-divider" />
631
+ { /* If there are general results, show bottom divider */ }
632
+ { generalOptionsWithViewStatus . length > 0 && (
633
+ < ActionList . Divider key = "error-middle-divider" />
634
+ ) }
632
635
</ >
633
636
) }
634
637
{ renderSearchGroups (
@@ -885,36 +888,8 @@ function renderSearchGroups(
885
888
const groups = [ ]
886
889
887
890
let isInAskAIState = askAIState ?. isAskAIState && ! askAIState . aiSearchError
888
- if ( isInAskAIState ) {
889
- groups . push (
890
- < ActionList . Group key = "ai" data-testid = "ask-ai" >
891
- < li tabIndex = { - 1 } >
892
- < AskAIResults
893
- query = { askAIState . aiQuery }
894
- debug = { askAIState . debug }
895
- version = { askAIState . currentVersion }
896
- setAISearchError = { askAIState . setAISearchError }
897
- references = { askAIState . references }
898
- setReferences = { askAIState . setReferences }
899
- referencesIndexOffset = { askAIState . referencesIndexOffset }
900
- referenceOnSelect = { askAIState . referenceOnSelect }
901
- selectedIndex = { selectedIndex }
902
- askAIEventGroupId = { askAIState . askAIEventGroupId }
903
- aiCouldNotAnswer = { askAIState . aiCouldNotAnswer }
904
- setAICouldNotAnswer = { askAIState . setAICouldNotAnswer }
905
- listElementsRef = { listElementsRef }
906
- />
907
- </ li >
908
- </ ActionList . Group > ,
909
- )
910
- }
911
-
912
891
let isInAskAIStateButNoAnswer = isInAskAIState && askAIState . aiCouldNotAnswer
913
892
914
- if ( isInAskAIStateButNoAnswer ) {
915
- groups . push ( < ActionList . Divider key = "no-answer-divider" /> )
916
- }
917
-
918
893
// already showing spinner when streaming AI response, so don't want to show 2 here
919
894
if ( showSpinner && ! isInAskAIState ) {
920
895
groups . push (
@@ -932,8 +907,8 @@ function renderSearchGroups(
932
907
return groups
933
908
}
934
909
935
- // We want to show general search suggestions underneath the AI Response section if the AI Could no answer
936
- if ( ( generalSearchOptions . length && ! isInAskAIState ) || isInAskAIStateButNoAnswer ) {
910
+ // We want to show general search suggestions above the AI Response section if the AI could not answer
911
+ if ( generalSearchOptions . length || isInAskAIStateButNoAnswer ) {
937
912
const items = [ ]
938
913
for ( let index = 0 ; index < generalSearchOptions . length ; index ++ ) {
939
914
const option = generalSearchOptions [ index ]
@@ -1034,17 +1009,43 @@ function renderSearchGroups(
1034
1009
</ ActionList . Group > ,
1035
1010
)
1036
1011
1012
+ if ( isInAskAIState || isInAskAIStateButNoAnswer ) {
1013
+ groups . push ( < ActionList . Divider key = "no-answer-divider" /> )
1014
+ }
1015
+
1016
+ if ( isInAskAIState ) {
1017
+ groups . push (
1018
+ < ActionList . Group key = "ai" data-testid = "ask-ai" >
1019
+ < li tabIndex = { - 1 } >
1020
+ < AskAIResults
1021
+ query = { askAIState . aiQuery }
1022
+ debug = { askAIState . debug }
1023
+ version = { askAIState . currentVersion }
1024
+ setAISearchError = { askAIState . setAISearchError }
1025
+ references = { askAIState . references }
1026
+ setReferences = { askAIState . setReferences }
1027
+ referencesIndexOffset = { askAIState . referencesIndexOffset }
1028
+ referenceOnSelect = { askAIState . referenceOnSelect }
1029
+ selectedIndex = { selectedIndex }
1030
+ askAIEventGroupId = { askAIState . askAIEventGroupId }
1031
+ aiCouldNotAnswer = { askAIState . aiCouldNotAnswer }
1032
+ setAICouldNotAnswer = { askAIState . setAICouldNotAnswer }
1033
+ listElementsRef = { listElementsRef }
1034
+ />
1035
+ </ li >
1036
+ </ ActionList . Group > ,
1037
+ )
1038
+ }
1039
+
1037
1040
// Don't show the bottom divider if:
1038
1041
// 1. We are in the AI could not answer state
1039
1042
// 2. We are in the AI Search error state
1040
1043
// 3. There are no AI suggestions to show in suggestions state
1041
1044
if (
1042
- ! askAIState . aiCouldNotAnswer &&
1045
+ ! isInAskAIState &&
1043
1046
! askAIState . aiSearchError &&
1044
- ( ! askAIState . isAskAIState ||
1045
- generalSearchOptions . filter (
1046
- ( option ) => ! option . isViewAllResults && ! option . isNoResultsFound ,
1047
- ) . length ) &&
1047
+ generalSearchOptions . filter ( ( option ) => ! option . isViewAllResults && ! option . isNoResultsFound )
1048
+ . length &&
1048
1049
aiOptionsWithUserInput . length
1049
1050
) {
1050
1051
groups . push ( < ActionList . Divider key = "bottom-divider" /> )
0 commit comments