Skip to content

Commit 185480a

Browse files
authored
only display X references from the cse-copilot response (#55237)
1 parent fc16fa6 commit 185480a

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

src/search/components/input/AskAIResults.tsx

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type AISearchResultEventParams = {
4141
connectedEventId?: string
4242
}
4343

44+
const MAX_REFERENCES_TO_SHOW = 4
45+
4446
export function AskAIResults({
4547
query,
4648
version,
@@ -389,27 +391,34 @@ export function AskAIResults({
389391
>
390392
{t('search.ai.references')}
391393
</ActionList.GroupHeading>
392-
{references.map((source, index) => (
393-
<ActionList.Item
394-
sx={{
395-
marginLeft: '0px',
396-
paddingLeft: '0px',
397-
}}
398-
key={`reference-${index}`}
399-
id={`search-option-reference-${index + referencesIndexOffset}`}
400-
role="option"
401-
tabIndex={-1}
402-
onSelect={() => {
403-
referenceOnSelect(source.url)
404-
}}
405-
active={index + referencesIndexOffset === selectedIndex}
406-
>
407-
<ActionList.LeadingVisual aria-hidden="true">
408-
<FileIcon />
409-
</ActionList.LeadingVisual>
410-
{source.title}
411-
</ActionList.Item>
412-
))}
394+
{references
395+
.map((source, index) => {
396+
if (index >= MAX_REFERENCES_TO_SHOW) {
397+
return null
398+
}
399+
return (
400+
<ActionList.Item
401+
sx={{
402+
marginLeft: '0px',
403+
paddingLeft: '0px',
404+
}}
405+
key={`reference-${index}`}
406+
id={`search-option-reference-${index + referencesIndexOffset}`}
407+
role="option"
408+
tabIndex={-1}
409+
onSelect={() => {
410+
referenceOnSelect(source.url)
411+
}}
412+
active={index + referencesIndexOffset === selectedIndex}
413+
>
414+
<ActionList.LeadingVisual aria-hidden="true">
415+
<FileIcon />
416+
</ActionList.LeadingVisual>
417+
{source.title}
418+
</ActionList.Item>
419+
)
420+
})
421+
.filter(Boolean)}
413422
</ActionList.Group>
414423
</ActionList>
415424
</>

0 commit comments

Comments
 (0)