diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx index 940d69cd..964b2971 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/ChatHistory/Citation/index.jsx @@ -39,21 +39,31 @@ const CIRCLE_IMAGES = { outlookAttachment: OutlookLogo, }; +/** + * Returns the custom image for a given type, or null if no custom image is available. + * @param {string} type + * @returns {string|null} + */ +export function getCustomImage(type) { + return CIRCLE_IMAGES[type] ?? null; +} + /** * Renders a circle with a source type icon inside, or a favicon if URL is provided. * @param {"file"|"link"|"youtube"|"github"|"gitlab"|"confluence"|"drupalwiki"|"obsidian"|"paperlessNgx"} props.type * @param {number} [props.size] - Circle diameter in px * @param {number} [props.iconSize] - Icon size in px * @param {string} [props.url] - Optional URL to fetch favicon from + * @param {string} [props.customImage] - Optional custom image to display */ export function SourceTypeCircle({ type = "file", size = 22, iconSize = 12, url = null, + customImage = null, }) { const Icon = CIRCLE_ICONS[type] || CIRCLE_ICONS.file; - const customImage = CIRCLE_IMAGES[type]; const [imgError, setImgError] = useState(false); let faviconUrl = null; @@ -72,7 +82,7 @@ export function SourceTypeCircle({ return (
{faviconUrl && !imgError ? ( @@ -87,8 +97,8 @@ export function SourceTypeCircle({ {type} ) : ( @@ -152,10 +162,11 @@ export default function Citations({ sources = [] }) { > {visibleSources.map((source, idx) => { const info = parseChunkSource(source); + const customImage = CIRCLE_IMAGES[info.icon]; return (
); diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/SourceItem/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/SourceItem/index.jsx index 03fb619c..eccbcd0c 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/SourceItem/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/SourcesSidebar/SourceItem/index.jsx @@ -1,10 +1,15 @@ -import { parseChunkSource, SourceTypeCircle } from "../../ChatHistory/Citation"; +import { + parseChunkSource, + SourceTypeCircle, + getCustomImage, +} from "../../ChatHistory/Citation"; import { useTranslation } from "react-i18next"; export default function SourceItem({ source, onClick }) { const { t } = useTranslation(); const info = parseChunkSource(source); - const subtitle = info.isUrl ? info.text : t("chat_window.document"); + const customImage = getCustomImage(info?.icon); + const subtitle = info?.isUrl ? info?.text : t("chat_window.document"); return (