mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Show more references in teaser ref section of chat response on web app
This commit is contained in:
@@ -71,10 +71,9 @@ function NotesContextReferenceCard(props: NotesContextReferenceCardProps) {
|
||||
onMouseLeave={() => setIsHovering(false)}
|
||||
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none`}
|
||||
>
|
||||
{
|
||||
!props.showFullContent ?
|
||||
{!props.showFullContent ? (
|
||||
<SimpleIcon type="notes" key={`${props.title}`} />
|
||||
:
|
||||
) : (
|
||||
<>
|
||||
<h3
|
||||
className={`${props.showFullContent ? "block" : "line-clamp-1"} text-muted-foreground}`}
|
||||
@@ -87,7 +86,7 @@ function NotesContextReferenceCard(props: NotesContextReferenceCardProps) {
|
||||
dangerouslySetInnerHTML={{ __html: snippet }}
|
||||
></p>
|
||||
</>
|
||||
}
|
||||
)}
|
||||
</Card>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] mx-2">
|
||||
@@ -214,10 +213,9 @@ function CodeContextReferenceCard(props: CodeContextReferenceCardProps) {
|
||||
onMouseLeave={() => setIsHovering(false)}
|
||||
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none`}
|
||||
>
|
||||
{
|
||||
!props.showFullContent ?
|
||||
{!props.showFullContent ? (
|
||||
<SimpleIcon type="code" key={`code-${props.code}`} />
|
||||
:
|
||||
) : (
|
||||
<div className="flex flex-col px-1">
|
||||
<div className="flex items-center gap-2">
|
||||
{fileIcon}
|
||||
@@ -235,7 +233,7 @@ function CodeContextReferenceCard(props: CodeContextReferenceCardProps) {
|
||||
{props.output_files?.length > 0 &&
|
||||
renderOutputFiles(props.output_files, false)}
|
||||
</div>
|
||||
}
|
||||
)}
|
||||
</Card>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] mx-2">
|
||||
@@ -314,15 +312,18 @@ function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
||||
onMouseLeave={handleMouseLeave}
|
||||
className={`${props.showFullContent ? "w-auto bg-muted" : "w-auto"} overflow-hidden break-words text-balance rounded-lg border-none p-2 shadow-none`}
|
||||
>
|
||||
{
|
||||
!props.showFullContent ?
|
||||
{!props.showFullContent ? (
|
||||
<SimpleIcon type="online" key={props.title} link={props.link} />
|
||||
:
|
||||
) : (
|
||||
<div className="flex flex-col">
|
||||
{
|
||||
<Link href={props.link}>
|
||||
<div className="flex items-center gap-2">
|
||||
<img src={favicon} alt="" className="!w-4 h-4 flex-shrink-0" />
|
||||
<img
|
||||
src={favicon}
|
||||
alt=""
|
||||
className="!w-4 h-4 flex-shrink-0"
|
||||
/>
|
||||
<h3
|
||||
className={`overflow-hidden ${props.showFullContent ? "block" : "line-clamp-1"} text-muted-foreground flex-grow`}
|
||||
>
|
||||
@@ -342,7 +343,7 @@ function GenericOnlineReferenceCard(props: OnlineReferenceCardProps) {
|
||||
{props.description}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
)}
|
||||
</Card>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-[400px] mx-2">
|
||||
@@ -496,7 +497,6 @@ interface SimpleIconProps {
|
||||
}
|
||||
|
||||
function SimpleIcon(props: SimpleIconProps) {
|
||||
|
||||
let favicon = ``;
|
||||
let domain = "unknown";
|
||||
|
||||
@@ -519,16 +519,10 @@ function SimpleIcon(props: SimpleIconProps) {
|
||||
symbol = <Code className={`${itemClasses}`} />;
|
||||
break;
|
||||
case "online":
|
||||
symbol =
|
||||
<img
|
||||
src={favicon}
|
||||
alt=""
|
||||
className={`${itemClasses}`}
|
||||
/>;
|
||||
symbol = <img src={favicon} alt="" className={`${itemClasses}`} />;
|
||||
break;
|
||||
case "notes":
|
||||
symbol =
|
||||
<Note className={`${itemClasses}`} />;
|
||||
symbol = <Note className={`${itemClasses}`} />;
|
||||
break;
|
||||
default:
|
||||
symbol = null;
|
||||
@@ -538,11 +532,7 @@ function SimpleIcon(props: SimpleIconProps) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
{symbol}
|
||||
</div>
|
||||
);
|
||||
return <div className="flex items-center gap-2">{symbol}</div>;
|
||||
}
|
||||
|
||||
export interface TeaserReferenceSectionProps {
|
||||
@@ -597,7 +587,7 @@ export default function ReferencePanel(props: ReferencePanelDataProps) {
|
||||
const [numTeaserSlots, setNumTeaserSlots] = useState(3);
|
||||
|
||||
useEffect(() => {
|
||||
setNumTeaserSlots(props.isMobileWidth ? 1 : 3);
|
||||
setNumTeaserSlots(props.isMobileWidth ? 3 : 5);
|
||||
}, [props.isMobileWidth]);
|
||||
|
||||
if (!props.notesReferenceCardData && !props.onlineReferenceCardData) {
|
||||
@@ -611,10 +601,9 @@ export default function ReferencePanel(props: ReferencePanelDataProps) {
|
||||
);
|
||||
const onlineDataToShow =
|
||||
notesDataToShow.length + codeDataToShow.length < numTeaserSlots
|
||||
? props.onlineReferenceCardData.filter((online) => online.link).slice(
|
||||
0,
|
||||
numTeaserSlots - codeDataToShow.length - notesDataToShow.length,
|
||||
)
|
||||
? props.onlineReferenceCardData
|
||||
.filter((online) => online.link)
|
||||
.slice(0, numTeaserSlots - codeDataToShow.length - notesDataToShow.length)
|
||||
: [];
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user