Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repo sync #37184

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/fixtures/tests/playwright-rendering.spec.ts
Original file line number Diff line number Diff line change
@@ -86,8 +86,8 @@ test('open new search, and perform a general search', async ({ page }) => {
// NOTE: In the UI we wait for results to load before allowing "enter", because we don't want
// to allow an unnecessary request when there are no search results. Easier to wait 1 second
await page.waitForTimeout(1000)
// Press enter to perform general search
await page.keyboard.press('Enter')
// Scroll down to "View all results" then press enter
await page.getByText('View more results').click()

await expect(page).toHaveURL(
/\/search\?search-overlay-input=serve\+playwright&query=serve\+playwright/,
2 changes: 1 addition & 1 deletion src/search/components/helpers/execute-search-actions.ts
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ export function executeGeneralSearch(
params.delete('search-overlay-open')
}
asPath += `?${params}`
router.push(asPath)
router.push(asPath, undefined, { shallow: false })
}

export async function executeAISearch(
20 changes: 9 additions & 11 deletions src/search/components/input/SearchOverlay.tsx
Original file line number Diff line number Diff line change
@@ -435,19 +435,15 @@ export function SearchOverlay({
let pressedGroupId = searchEventGroupId
let pressedOnContext = ''

// When enter is pressed and no option is manually selected (-1), perform an AI search with the user input
if (selectedIndex === -1) {
if (isAskAIState) {
pressedOnContext = AI_SEARCH_CONTEXT
pressedGroupKey = ASK_AI_EVENT_GROUP
pressedGroupId = askAIEventGroupId
// When we are in the Ask AI state, we want to ask another AI Search query
aiSearchOptionOnSelect({ term: urlSearchInputQuery } as AutocompleteSearchHit)
} else if (generalSearchResults.length > 0) {
pressedOnContext = GENERAL_SEARCH_CONTEXT
// Nothing manually selected, so general search the typed suggestion
performGeneralSearch()
}
return sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey)
sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey)
aiSearchOptionOnSelect({ term: urlSearchInputQuery } as AutocompleteSearchHit)
}

if (
@@ -456,28 +452,30 @@ export function SearchOverlay({
selectedIndex < combinedOptions.length
) {
const selectedItem = combinedOptions[selectedIndex]
let action = () => {} // Execute the action after we send the event
if (selectedItem.group === 'general') {
if (
(selectedItem.option as GeneralSearchHitWithOptions).isViewAllResults ||
(selectedItem.option as GeneralSearchHitWithOptions).isSearchDocsOption
) {
pressedOnContext = 'view-all'
performGeneralSearch()
action = performGeneralSearch
} else {
pressedOnContext = 'general-option'
generalSearchResultOnSelect(selectedItem.option as GeneralSearchHit)
action = () => generalSearchResultOnSelect(selectedItem.option as GeneralSearchHit)
}
} else if (selectedItem.group === 'ai') {
pressedOnContext = 'ai-option'
aiSearchOptionOnSelect(selectedItem.option as AutocompleteSearchHit)
action = () => aiSearchOptionOnSelect(selectedItem.option as AutocompleteSearchHit)
} else if (selectedItem.group === 'reference') {
// On a reference select, we are in the Ask AI State / Screen
pressedGroupKey = ASK_AI_EVENT_GROUP
pressedGroupId = askAIEventGroupId
pressedOnContext = 'reference-option'
referenceOnSelect(selectedItem.url || '')
action = () => referenceOnSelect(selectedItem.url || '')
}
sendKeyboardEvent(event.key, pressedOnContext, pressedGroupId, pressedGroupKey)
return action()
}
} else if (event.key === 'Escape') {
event.preventDefault()