Skip to content

Commit 9e08db8

Browse files
authored
change the order of Copilot Search references (#55716)
1 parent 76565a3 commit 9e08db8

File tree

4 files changed

+68
-65
lines changed

4 files changed

+68
-65
lines changed

data/ui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ search:
4747
privacy_disclaimer: For product and service improvement purposes, the GitHub Docs team will retain questions and answers generated in the Docs search function. Please see the <a href="https://docs.github.com/privacy"><u>GitHub Privacy Statement</u></a> to review how GitHub collects and uses your data.
4848
ai:
4949
disclaimer: <a href="https://docs.github.com/en/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-chat-in-githubcom"}>Copilot</a> uses AI. Check for mistakes.
50-
references: Additional docs
50+
references: Copilot Sources
5151
loading_status_message: Loading Copilot response...
5252
done_loading_status_message: Done loading Copilot response
5353
copy_answer: Copy answer

src/fixtures/fixtures/data/ui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ search:
4747
privacy_disclaimer: For product and service improvement purposes, the GitHub Docs team will retain questions and answers generated in the Docs search function. Please see the <a href="https://docs.github.com/privacy"><u>GitHub Privacy Statement</u></a> to review how GitHub collects and uses your data.
4848
ai:
4949
disclaimer: <a href="https://docs.github.com/en/copilot/responsible-use-of-github-copilot-features/responsible-use-of-github-copilot-chat-in-githubcom"}>Copilot</a> uses AI. Check for mistakes.
50-
references: Additional docs
50+
references: Copilot Sources
5151
loading_status_message: Loading Copilot response...
5252
done_loading_status_message: Done loading Copilot response
5353
copy_answer: Copy answer

src/search/components/input/AskAIResults.tsx

Lines changed: 66 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ import { executeAISearch } from '../helpers/execute-search-actions'
44
import { useRouter } from 'next/router'
55
import { useTranslation } from '@/languages/components/useTranslation'
66
import { ActionList, IconButton, Spinner } from '@primer/react'
7-
import { CheckIcon, CopyIcon, FileIcon, ThumbsdownIcon, ThumbsupIcon } from '@primer/octicons-react'
7+
import {
8+
CheckIcon,
9+
CopilotIcon,
10+
CopyIcon,
11+
FileIcon,
12+
ThumbsdownIcon,
13+
ThumbsupIcon,
14+
} from '@primer/octicons-react'
815
import { announce } from '@primer/live-region-element'
916
import { useAISearchLocalStorageCache } from '../hooks/useAISearchLocalStorageCache'
1017
import { UnrenderedMarkdownContent } from '@/frame/components/ui/MarkdownContent/UnrenderedMarkdownContent'
@@ -334,6 +341,64 @@ export function AskAIResults({
334341

335342
return (
336343
<div className={styles.container}>
344+
{!aiCouldNotAnswer && references && references.length > 0 ? (
345+
<>
346+
<ActionList className={styles.referencesList} showDividers>
347+
<ActionList.Group>
348+
<ActionList.GroupHeading
349+
as="h3"
350+
aria-label={t('search.ai.references')}
351+
className={styles.referencesTitle}
352+
>
353+
{t('search.ai.references')}
354+
</ActionList.GroupHeading>
355+
{references
356+
.map((source, index) => {
357+
if (index >= MAX_REFERENCES_TO_SHOW) {
358+
return null
359+
}
360+
const refIndex = index + referencesIndexOffset
361+
return (
362+
<ActionList.Item
363+
sx={{
364+
marginLeft: '0px',
365+
}}
366+
key={`reference-${index}`}
367+
id={`search-option-reference-${index + referencesIndexOffset}`}
368+
role="option"
369+
tabIndex={-1}
370+
onSelect={() => {
371+
referenceOnSelect(source.url)
372+
}}
373+
active={refIndex === selectedIndex}
374+
ref={(element) => {
375+
if (listElementsRef.current) {
376+
listElementsRef.current[refIndex] = element
377+
}
378+
}}
379+
>
380+
<ActionList.LeadingVisual aria-hidden="true">
381+
<FileIcon />
382+
</ActionList.LeadingVisual>
383+
{source.title}
384+
</ActionList.Item>
385+
)
386+
})
387+
.filter(Boolean)}
388+
</ActionList.Group>
389+
<ActionList.Divider aria-hidden="true" />
390+
</ActionList>
391+
</>
392+
) : null}
393+
<ActionList.GroupHeading
394+
key="ai-heading"
395+
as="h3"
396+
tabIndex={-1}
397+
aria-label={t('search.overlay.ai_suggestions_list_aria_label')}
398+
>
399+
<CopilotIcon className="mr-1" />
400+
{t('search.overlay.ai_autocomplete_list_heading')}
401+
</ActionList.GroupHeading>
337402
{initialLoading ? (
338403
<div className={styles.loadingContainer} role="status">
339404
<Spinner />
@@ -423,55 +488,6 @@ export function AskAIResults({
423488
></IconButton>
424489
</div>
425490
) : null}
426-
{!aiCouldNotAnswer && references && references.length > 0 ? (
427-
<>
428-
<ActionList.Divider aria-hidden="true" />
429-
<ActionList className={styles.referencesList} showDividers>
430-
<ActionList.Group>
431-
<ActionList.GroupHeading
432-
as="h3"
433-
aria-label={t('search.ai.references')}
434-
className={styles.referencesTitle}
435-
>
436-
{t('search.ai.references')}
437-
</ActionList.GroupHeading>
438-
{references
439-
.map((source, index) => {
440-
if (index >= MAX_REFERENCES_TO_SHOW) {
441-
return null
442-
}
443-
const refIndex = index + referencesIndexOffset
444-
return (
445-
<ActionList.Item
446-
sx={{
447-
marginLeft: '0px',
448-
}}
449-
key={`reference-${index}`}
450-
id={`search-option-reference-${index + referencesIndexOffset}`}
451-
role="option"
452-
tabIndex={-1}
453-
onSelect={() => {
454-
referenceOnSelect(source.url)
455-
}}
456-
active={refIndex === selectedIndex}
457-
ref={(element) => {
458-
if (listElementsRef.current) {
459-
listElementsRef.current[refIndex] = element
460-
}
461-
}}
462-
>
463-
<ActionList.LeadingVisual aria-hidden="true">
464-
<FileIcon />
465-
</ActionList.LeadingVisual>
466-
{source.title}
467-
</ActionList.Item>
468-
)
469-
})
470-
.filter(Boolean)}
471-
</ActionList.Group>
472-
</ActionList>
473-
</>
474-
) : null}
475491
<div
476492
aria-live="assertive"
477493
style={{

src/search/components/input/SearchOverlay.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -879,23 +879,10 @@ function renderSearchGroups(
879879
) {
880880
const groups = []
881881

882-
const askAIGroupHeading = (
883-
<ActionList.GroupHeading
884-
key="ai-heading"
885-
as="h3"
886-
tabIndex={-1}
887-
aria-label={t('search.overlay.ai_suggestions_list_aria_label')}
888-
>
889-
<CopilotIcon className="mr-1" />
890-
{t('search.overlay.ai_autocomplete_list_heading')}
891-
</ActionList.GroupHeading>
892-
)
893-
894882
let isInAskAIState = askAIState?.isAskAIState && !askAIState.aiSearchError
895883
if (isInAskAIState) {
896884
groups.push(
897885
<ActionList.Group key="ai" data-testid="ask-ai">
898-
{askAIGroupHeading}
899886
<AskAIResults
900887
query={askAIState.aiQuery}
901888
debug={askAIState.debug}

0 commit comments

Comments
 (0)