Add image support for search (#4090)

* add support for image search

* quick fix up

* k

* k

* k

* k

* nit

* quick fix for connector tests
This commit is contained in:
pablonyx
2025-03-05 09:44:18 -08:00
committed by GitHub
parent f731beca1f
commit 20f2b9b2bb
36 changed files with 1857 additions and 589 deletions

View File

@@ -204,7 +204,6 @@ export function ChatPage({
const [documentSidebarVisible, setDocumentSidebarVisible] = useState(false);
const [proSearchEnabled, setProSearchEnabled] = useState(proSearchToggled);
const [streamingAllowed, setStreamingAllowed] = useState(false);
const toggleProSearch = () => {
Cookies.set(
PRO_SEARCH_TOGGLED_COOKIE_NAME,

View File

@@ -41,6 +41,15 @@ export default function TextView({
return markdownFormats.some((format) => mimeType.startsWith(format));
};
const isImageFormat = (mimeType: string) => {
const imageFormats = [
"image/png",
"image/jpeg",
"image/gif",
"image/svg+xml",
];
return imageFormats.some((format) => mimeType.startsWith(format));
};
// Detect if a given MIME type can be rendered in an <iframe>
const isSupportedIframeFormat = (mimeType: string): boolean => {
const supportedFormats = [
@@ -126,6 +135,7 @@ export default function TextView({
<DialogTitle className="text-lg font-medium truncate">
{fileName}
</DialogTitle>
<div className="flex items-center space-x-2">
<Button variant="ghost" size="icon" onClick={handleZoomOut}>
<ZoomOut className="h-4 w-4" />
@@ -161,7 +171,13 @@ export default function TextView({
className="w-full h-full transform origin-center transition-transform duration-300 ease-in-out"
style={{ transform: `scale(${zoom / 100})` }}
>
{isSupportedIframeFormat(fileType) ? (
{isImageFormat(fileType) ? (
<img
src={fileUrl}
alt={fileName}
className="w-full h-full object-contain object-center"
/>
) : isSupportedIframeFormat(fileType) ? (
<iframe
src={`${fileUrl}#toolbar=0`}
className="w-full h-full border-none"