Skip to content

Commit

Permalink
Stop no context message showing on search results
Browse files Browse the repository at this point in the history
  • Loading branch information
taiyab committed Jan 27, 2025
1 parent a5fabd2 commit 4903df6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 19 deletions.
6 changes: 3 additions & 3 deletions vscode/webviews/chat/cells/agenticCell/AgenticContextCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export const AgenticContextCell: FunctionComponent<{
<div className="tw-flex tw-flex-col tw-ml-[1rem]">
<ContextList
contextItems={contextItems}
isForFirstMessage={isForFirstMessage}
isAgenticChat={true}
model={model}
isForFirstMessage={false}
isAgenticChat={intent === 'chat'}
isSearchResponse={true}
/>
</div>
)}
Expand Down
79 changes: 65 additions & 14 deletions vscode/webviews/chat/cells/contextCell/ContextList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,80 @@ export const ContextList: React.FC<{
isAgenticChat: boolean
model?: string
headerIconClassName?: string
}> = ({ contextItems, isForFirstMessage, isAgenticChat, model, headerIconClassName }) => {
isSearchResponse?: boolean
}> = ({
contextItems,
isForFirstMessage,
isAgenticChat,
model,
headerIconClassName,
isSearchResponse,
}) => {
const hasNoContext = !contextItems || contextItems.length === 0

if (hasNoContext) {
return (
<div className="tw-flex tw-flex-col tw-gap-2 tw-my-2 tw-border-t tw-border-t-muted tw-pt-4">
<div className="tw-text-sm tw-text-muted-foreground tw-flex tw-gap-3 tw-flex-col">
<div className="tw-flex tw-gap-4">
<CircleSlash
size={14}
strokeWidth={1.75}
className={clsx(headerIconClassName, 'tw-mt-0.5')}
/>
<div className="tw-flex tw-flex-col">
No additional context used
<div className="tw-text-sm tw-font-normal">Using public knowledge only</div>
// First handle search responses
if (!isAgenticChat && hasNoContext && isSearchResponse) {
return null
}

// For agentic chat, always show either context or "no context" message
if (isAgenticChat) {
if (hasNoContext) {
return (
<div className="tw-flex tw-flex-col tw-gap-2 tw-my-2 tw-border-t tw-border-t-muted tw-pt-4">
<div className="tw-text-sm tw-text-muted-foreground tw-flex tw-gap-3 tw-flex-col">
<div className="tw-flex tw-gap-4">
<CircleSlash
size={14}
strokeWidth={1.75}
className={clsx(headerIconClassName, 'tw-mt-0.5')}
/>
<div className="tw-flex tw-flex-col">
No additional context used
<div className="tw-text-sm tw-font-normal">
Using public knowledge only
</div>
</div>
</div>
</div>
</div>
)
}
return (
<div className="tw-flex tw-flex-col tw-gap-2 tw-my-2 tw-border-t tw-border-t-muted tw-pt-4">
<div className="tw-text-sm tw-font-medium tw-text-foreground tw-flex tw-items-center tw-gap-3">
<DatabaseIcon size={14} strokeWidth={1.75} className="tw-text-muted-foreground" />
Context used
</div>
<ul className="tw-list-none tw-flex tw-flex-col tw-gap-1">
{contextItems?.map((item, i) => (
<li key={i} data-testid="context-item">

Check failure on line 61 in vscode/webviews/chat/cells/contextCell/ContextList.tsx

View workflow job for this annotation

GitHub Actions / build

Avoid using the index of an array as key property in an element.
<FileLink
uri={item.uri}
repoName={item.repoName}
revision={item.revision}
source={item.source}
range={item.range}
title={item.title}
isTooLarge={item.isTooLarge}
isTooLargeReason={item.isTooLargeReason}
isIgnored={item.isIgnored}
linkClassName={styles.contextItemLink}
className={clsx(styles.linkContainer, MENTION_CLASS_NAME)}
/>
</li>
))}
</ul>
</div>
)
}

// Handle non-agentic cases
if (hasNoContext) {
return null
}

// Show context list for non-agentic chat with context
return (
<div className="tw-flex tw-flex-col tw-gap-2 tw-my-2 tw-border-t tw-border-t-muted tw-pt-4">
<div className="tw-text-sm tw-font-medium tw-text-foreground tw-flex tw-items-center tw-gap-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
FilterX,
OctagonX,
PanelLeftClose,
Search,
} from 'lucide-react'
import { useCallback, useContext, useLayoutEffect, useMemo, useReducer, useState } from 'react'
import {
Expand Down Expand Up @@ -249,7 +248,6 @@ export const SearchResults = ({
</>
)}
<div className="tw-flex tw-gap-4 tw-items-center tw-font-medium tw-text-sm tw-text-muted-foreground tw-px-2">
<Search className="tw-size-6 md:tw-size-8 tw-flex-shrink-0" />
Displaying {resultsToShow.length} code search results
</div>
</div>
Expand Down

0 comments on commit 4903df6

Please sign in to comment.