2025-06-23 20:30:15 +02:00
|
|
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
|
|
|
import { X, ArrowDownToLine, PanelLeftOpen, PanelLeftClose, RotateCcw } from 'lucide-react';
|
2025-06-02 13:50:44 +02:00
|
|
|
import { Button, OGDialog, OGDialogContent, TooltipAnchor } from '~/components';
|
|
|
|
|
import { useLocalize } from '~/hooks';
|
|
|
|
|
|
2025-06-23 20:30:15 +02:00
|
|
|
const getQualityStyles = (quality: string): string => {
|
|
|
|
|
if (quality === 'high') {
|
|
|
|
|
return 'bg-green-100 text-green-800';
|
|
|
|
|
}
|
|
|
|
|
if (quality === 'low') {
|
|
|
|
|
return 'bg-orange-100 text-orange-800';
|
|
|
|
|
}
|
|
|
|
|
return 'bg-gray-100 text-gray-800';
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-02 13:50:44 +02:00
|
|
|
export default function DialogImage({ isOpen, onOpenChange, src = '', downloadImage, args }) {
|
|
|
|
|
const localize = useLocalize();
|
|
|
|
|
const [isPromptOpen, setIsPromptOpen] = useState(false);
|
|
|
|
|
const [imageSize, setImageSize] = useState<string | null>(null);
|
|
|
|
|
|
2025-06-23 20:30:15 +02:00
|
|
|
// Zoom and pan state
|
|
|
|
|
const [zoom, setZoom] = useState(1);
|
|
|
|
|
const [panX, setPanX] = useState(0);
|
|
|
|
|
const [panY, setPanY] = useState(0);
|
|
|
|
|
const [isDragging, setIsDragging] = useState(false);
|
|
|
|
|
const [dragStart, setDragStart] = useState({ x: 0, y: 0 });
|
|
|
|
|
|
|
|
|
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
|
|
const getImageSize = useCallback(async (url: string) => {
|
2025-06-02 13:50:44 +02:00
|
|
|
try {
|
|
|
|
|
const response = await fetch(url, { method: 'HEAD' });
|
|
|
|
|
const contentLength = response.headers.get('Content-Length');
|
|
|
|
|
|
|
|
|
|
if (contentLength) {
|
|
|
|
|
const bytes = parseInt(contentLength, 10);
|
|
|
|
|
return formatFileSize(bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fullResponse = await fetch(url);
|
|
|
|
|
const blob = await fullResponse.blob();
|
|
|
|
|
return formatFileSize(blob.size);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Error getting image size:', error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2025-06-23 20:30:15 +02:00
|
|
|
}, []);
|
2025-06-02 13:50:44 +02:00
|
|
|
|
|
|
|
|
const formatFileSize = (bytes: number): string => {
|
|
|
|
|
if (bytes === 0) return '0 Bytes';
|
|
|
|
|
|
|
|
|
|
const k = 1024;
|
|
|
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
|
|
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
|
|
|
|
|
|
|
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
|
|
|
};
|
|
|
|
|
|
2025-06-23 20:30:15 +02:00
|
|
|
const getImageMaxWidth = () => {
|
|
|
|
|
// On mobile (when panel overlays), use full width minus padding
|
|
|
|
|
// On desktop, account for the side panel width
|
|
|
|
|
if (isPromptOpen) {
|
|
|
|
|
return window.innerWidth >= 640 ? 'calc(100vw - 22rem)' : 'calc(100vw - 2rem)';
|
|
|
|
|
}
|
|
|
|
|
return 'calc(100vw - 2rem)';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const resetZoom = useCallback(() => {
|
|
|
|
|
setZoom(1);
|
|
|
|
|
setPanX(0);
|
|
|
|
|
setPanY(0);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const getCursor = () => {
|
|
|
|
|
if (zoom <= 1) return 'default';
|
|
|
|
|
return isDragging ? 'grabbing' : 'grab';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDoubleClick = useCallback(() => {
|
|
|
|
|
if (zoom > 1) {
|
|
|
|
|
resetZoom();
|
|
|
|
|
} else {
|
|
|
|
|
// Zoom in to 2x on double click when at normal zoom
|
|
|
|
|
setZoom(2);
|
|
|
|
|
}
|
|
|
|
|
}, [zoom, resetZoom]);
|
|
|
|
|
|
|
|
|
|
const handleWheel = useCallback(
|
|
|
|
|
(e: React.WheelEvent<HTMLDivElement>) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (!containerRef.current) return;
|
|
|
|
|
|
|
|
|
|
const rect = containerRef.current.getBoundingClientRect();
|
|
|
|
|
const mouseX = e.clientX - rect.left;
|
|
|
|
|
const mouseY = e.clientY - rect.top;
|
|
|
|
|
|
|
|
|
|
// Calculate zoom factor
|
|
|
|
|
const zoomFactor = e.deltaY > 0 ? 0.9 : 1.1;
|
|
|
|
|
const newZoom = Math.min(Math.max(zoom * zoomFactor, 1), 5);
|
|
|
|
|
|
|
|
|
|
if (newZoom === zoom) return;
|
|
|
|
|
|
|
|
|
|
// If zooming back to 1, reset pan to center the image
|
|
|
|
|
if (newZoom === 1) {
|
|
|
|
|
setZoom(1);
|
|
|
|
|
setPanX(0);
|
|
|
|
|
setPanY(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate the zoom center relative to the current viewport
|
|
|
|
|
const containerCenterX = rect.width / 2;
|
|
|
|
|
const containerCenterY = rect.height / 2;
|
|
|
|
|
|
|
|
|
|
// Calculate new pan position to zoom towards mouse cursor
|
|
|
|
|
const zoomRatio = newZoom / zoom;
|
|
|
|
|
const deltaX = (mouseX - containerCenterX - panX) * (zoomRatio - 1);
|
|
|
|
|
const deltaY = (mouseY - containerCenterY - panY) * (zoomRatio - 1);
|
|
|
|
|
|
|
|
|
|
setZoom(newZoom);
|
|
|
|
|
setPanX(panX - deltaX);
|
|
|
|
|
setPanY(panY - deltaY);
|
|
|
|
|
},
|
|
|
|
|
[zoom, panX, panY],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleMouseDown = useCallback(
|
|
|
|
|
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
if (zoom <= 1) return;
|
|
|
|
|
setIsDragging(true);
|
|
|
|
|
setDragStart({
|
|
|
|
|
x: e.clientX - panX,
|
|
|
|
|
y: e.clientY - panY,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
[zoom, panX, panY],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleMouseMove = useCallback(
|
|
|
|
|
(e: React.MouseEvent<HTMLDivElement>) => {
|
|
|
|
|
if (!isDragging || zoom <= 1) return;
|
|
|
|
|
const newPanX = e.clientX - dragStart.x;
|
|
|
|
|
const newPanY = e.clientY - dragStart.y;
|
|
|
|
|
setPanX(newPanX);
|
|
|
|
|
setPanY(newPanY);
|
|
|
|
|
},
|
|
|
|
|
[isDragging, dragStart, zoom],
|
|
|
|
|
);
|
|
|
|
|
const handleMouseUp = useCallback(() => {
|
|
|
|
|
setIsDragging(false);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && resetZoom();
|
|
|
|
|
document.addEventListener('keydown', onKey);
|
|
|
|
|
return () => document.removeEventListener('keydown', onKey);
|
|
|
|
|
}, [resetZoom]);
|
|
|
|
|
|
2025-06-02 13:50:44 +02:00
|
|
|
useEffect(() => {
|
|
|
|
|
if (isOpen && src) {
|
|
|
|
|
getImageSize(src).then(setImageSize);
|
2025-06-23 20:30:15 +02:00
|
|
|
resetZoom();
|
|
|
|
|
}
|
|
|
|
|
}, [isOpen, src, getImageSize, resetZoom]);
|
|
|
|
|
|
|
|
|
|
// Ensure image is centered when zoom changes to 1
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (zoom === 1) {
|
|
|
|
|
setPanX(0);
|
|
|
|
|
setPanY(0);
|
|
|
|
|
}
|
|
|
|
|
}, [zoom]);
|
|
|
|
|
|
|
|
|
|
// Reset pan when panel opens/closes to maintain centering
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (zoom === 1) {
|
|
|
|
|
setPanX(0);
|
|
|
|
|
setPanY(0);
|
2025-06-02 13:50:44 +02:00
|
|
|
}
|
2025-06-23 20:30:15 +02:00
|
|
|
}, [isPromptOpen, zoom]);
|
feat: Vision Support + New UI (#1203)
* feat: add timer duration to showToast, show toast for preset selection
* refactor: replace old /chat/ route with /c/. e2e tests will fail here
* refactor: move typedefs to root of /api/ and add a few to assistant types in TS
* refactor: reorganize data-provider imports, fix dependency cycle, strategize new plan to separate react dependent packages
* feat: add dataService for uploading images
* feat(data-provider): add mutation keys
* feat: file resizing and upload
* WIP: initial API image handling
* fix: catch JSON.parse of localStorage tools
* chore: experimental: use module-alias for absolute imports
* refactor: change temp_file_id strategy
* fix: updating files state by using Map and defining react query callbacks in a way that keeps them during component unmount, initial delete handling
* feat: properly handle file deletion
* refactor: unexpose complete filepath and resize from server for higher fidelity
* fix: make sure resized height, width is saved, catch bad requests
* refactor: use absolute imports
* fix: prevent setOptions from being called more than once for OpenAIClient, made note to fix for PluginsClient
* refactor: import supportsFiles and models vars from schemas
* fix: correctly replace temp file id
* refactor(BaseClient): use absolute imports, pass message 'opts' to buildMessages method, count tokens for nested objects/arrays
* feat: add validateVisionModel to determine if model has vision capabilities
* chore(checkBalance): update jsdoc
* feat: formatVisionMessage: change message content format dependent on role and image_urls passed
* refactor: add usage to File schema, make create and updateFile, correctly set and remove TTL
* feat: working vision support
TODO: file size, type, amount validations, making sure they are styled right, and making sure you can add images from the clipboard/dragging
* feat: clipboard support for uploading images
* feat: handle files on drop to screen, refactor top level view code to Presentation component so the useDragHelpers hook has ChatContext
* fix(Images): replace uploaded images in place
* feat: add filepath validation to protect sensitive files
* fix: ensure correct file_ids are push and not the Map key values
* fix(ToastContext): type issue
* feat: add basic file validation
* fix(useDragHelpers): correct context issue with `files` dependency
* refactor: consolidate setErrors logic to setError
* feat: add dialog Image overlay on image click
* fix: close endpoints menu on click
* chore: set detail to auto, make note for configuration
* fix: react warning (button desc. of button)
* refactor: optimize filepath handling, pass file_ids to images for easier re-use
* refactor: optimize image file handling, allow re-using files in regen, pass more file metadata in messages
* feat: lazy loading images including use of upload preview
* fix: SetKeyDialog closing, stopPropagation on Dialog content click
* style(EndpointMenuItem): tighten up the style, fix dark theme showing in lightmode, make menu more ux friendly
* style: change maxheight of all settings textareas to 138px from 300px
* style: better styling for textarea and enclosing buttons
* refactor(PresetItems): swap back edit and delete icons
* feat: make textarea placeholder dynamic to endpoint
* style: show user hover buttons only on hover when message is streaming
* fix: ordered list not going past 9, fix css
* feat: add User/AI labels; style: hide loading spinner
* feat: add back custom footer, change original footer text
* feat: dynamic landing icons based on endpoint
* chore: comment out assistants route
* fix: autoScroll to newest on /c/ view
* fix: Export Conversation on new UI
* style: match message style of official more closely
* ci: fix api jest unit tests, comment out e2e tests for now as they will fail until addressed
* feat: more file validation and use blob in preview field, not filepath, to fix temp deletion
* feat: filefilter for multer
* feat: better AI labels based on custom name, model, and endpoint instead of `ChatGPT`
2023-11-21 20:12:48 -05:00
|
|
|
|
|
|
|
|
return (
|
2025-05-16 17:50:18 +02:00
|
|
|
<OGDialog open={isOpen} onOpenChange={onOpenChange}>
|
|
|
|
|
<OGDialogContent
|
|
|
|
|
showCloseButton={false}
|
|
|
|
|
className="h-full w-full rounded-none bg-transparent"
|
|
|
|
|
disableScroll={false}
|
2025-05-20 09:24:52 -04:00
|
|
|
overlayClassName="bg-surface-primary opacity-95 z-50"
|
feat: Vision Support + New UI (#1203)
* feat: add timer duration to showToast, show toast for preset selection
* refactor: replace old /chat/ route with /c/. e2e tests will fail here
* refactor: move typedefs to root of /api/ and add a few to assistant types in TS
* refactor: reorganize data-provider imports, fix dependency cycle, strategize new plan to separate react dependent packages
* feat: add dataService for uploading images
* feat(data-provider): add mutation keys
* feat: file resizing and upload
* WIP: initial API image handling
* fix: catch JSON.parse of localStorage tools
* chore: experimental: use module-alias for absolute imports
* refactor: change temp_file_id strategy
* fix: updating files state by using Map and defining react query callbacks in a way that keeps them during component unmount, initial delete handling
* feat: properly handle file deletion
* refactor: unexpose complete filepath and resize from server for higher fidelity
* fix: make sure resized height, width is saved, catch bad requests
* refactor: use absolute imports
* fix: prevent setOptions from being called more than once for OpenAIClient, made note to fix for PluginsClient
* refactor: import supportsFiles and models vars from schemas
* fix: correctly replace temp file id
* refactor(BaseClient): use absolute imports, pass message 'opts' to buildMessages method, count tokens for nested objects/arrays
* feat: add validateVisionModel to determine if model has vision capabilities
* chore(checkBalance): update jsdoc
* feat: formatVisionMessage: change message content format dependent on role and image_urls passed
* refactor: add usage to File schema, make create and updateFile, correctly set and remove TTL
* feat: working vision support
TODO: file size, type, amount validations, making sure they are styled right, and making sure you can add images from the clipboard/dragging
* feat: clipboard support for uploading images
* feat: handle files on drop to screen, refactor top level view code to Presentation component so the useDragHelpers hook has ChatContext
* fix(Images): replace uploaded images in place
* feat: add filepath validation to protect sensitive files
* fix: ensure correct file_ids are push and not the Map key values
* fix(ToastContext): type issue
* feat: add basic file validation
* fix(useDragHelpers): correct context issue with `files` dependency
* refactor: consolidate setErrors logic to setError
* feat: add dialog Image overlay on image click
* fix: close endpoints menu on click
* chore: set detail to auto, make note for configuration
* fix: react warning (button desc. of button)
* refactor: optimize filepath handling, pass file_ids to images for easier re-use
* refactor: optimize image file handling, allow re-using files in regen, pass more file metadata in messages
* feat: lazy loading images including use of upload preview
* fix: SetKeyDialog closing, stopPropagation on Dialog content click
* style(EndpointMenuItem): tighten up the style, fix dark theme showing in lightmode, make menu more ux friendly
* style: change maxheight of all settings textareas to 138px from 300px
* style: better styling for textarea and enclosing buttons
* refactor(PresetItems): swap back edit and delete icons
* feat: make textarea placeholder dynamic to endpoint
* style: show user hover buttons only on hover when message is streaming
* fix: ordered list not going past 9, fix css
* feat: add User/AI labels; style: hide loading spinner
* feat: add back custom footer, change original footer text
* feat: dynamic landing icons based on endpoint
* chore: comment out assistants route
* fix: autoScroll to newest on /c/ view
* fix: Export Conversation on new UI
* style: match message style of official more closely
* ci: fix api jest unit tests, comment out e2e tests for now as they will fail until addressed
* feat: more file validation and use blob in preview field, not filepath, to fix temp deletion
* feat: filefilter for multer
* feat: better AI labels based on custom name, model, and endpoint instead of `ChatGPT`
2023-11-21 20:12:48 -05:00
|
|
|
>
|
2025-06-02 13:50:44 +02:00
|
|
|
<div
|
2025-06-23 20:30:15 +02:00
|
|
|
className={`ease-[cubic-bezier(0.175,0.885,0.32,1.275)] absolute left-0 top-0 z-10 flex items-center justify-between p-3 transition-all duration-500 sm:p-4 ${isPromptOpen ? 'right-0 sm:right-80' : 'right-0'}`}
|
2025-06-02 13:50:44 +02:00
|
|
|
>
|
|
|
|
|
<TooltipAnchor
|
|
|
|
|
description={localize('com_ui_close')}
|
|
|
|
|
render={
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => onOpenChange(false)}
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="h-10 w-10 p-0 hover:bg-surface-hover"
|
|
|
|
|
>
|
2025-06-23 20:30:15 +02:00
|
|
|
<X className="size-7 sm:size-6" />
|
2025-06-02 13:50:44 +02:00
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
/>
|
2025-06-23 20:30:15 +02:00
|
|
|
<div className="flex items-center gap-1 sm:gap-2">
|
|
|
|
|
{zoom > 1 && (
|
|
|
|
|
<TooltipAnchor
|
|
|
|
|
description={localize('com_ui_reset_zoom')}
|
|
|
|
|
render={
|
|
|
|
|
<Button onClick={resetZoom} variant="ghost" className="h-10 w-10 p-0">
|
|
|
|
|
<RotateCcw className="size-6" />
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2025-06-02 13:50:44 +02:00
|
|
|
<TooltipAnchor
|
2025-06-08 00:22:08 +02:00
|
|
|
description={localize('com_ui_download')}
|
2025-06-02 13:50:44 +02:00
|
|
|
render={
|
|
|
|
|
<Button onClick={() => downloadImage()} variant="ghost" className="h-10 w-10 p-0">
|
|
|
|
|
<ArrowDownToLine className="size-6" />
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<TooltipAnchor
|
|
|
|
|
description={
|
|
|
|
|
isPromptOpen
|
|
|
|
|
? localize('com_ui_hide_image_details')
|
|
|
|
|
: localize('com_ui_show_image_details')
|
|
|
|
|
}
|
|
|
|
|
render={
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setIsPromptOpen(!isPromptOpen)}
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="h-10 w-10 p-0"
|
|
|
|
|
>
|
|
|
|
|
{isPromptOpen ? (
|
2025-06-23 20:30:15 +02:00
|
|
|
<PanelLeftOpen className="size-7 sm:size-6" />
|
2025-06-02 13:50:44 +02:00
|
|
|
) : (
|
2025-06-23 20:30:15 +02:00
|
|
|
<PanelLeftClose className="size-7 sm:size-6" />
|
2025-06-02 13:50:44 +02:00
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-05-16 17:50:18 +02:00
|
|
|
</div>
|
2025-06-02 13:50:44 +02:00
|
|
|
|
|
|
|
|
{/* Main content area with image */}
|
|
|
|
|
<div
|
2025-06-23 20:30:15 +02:00
|
|
|
className={`ease-[cubic-bezier(0.175,0.885,0.32,1.275)] flex h-full transition-all duration-500 ${isPromptOpen ? 'mr-0 sm:mr-80' : 'mr-0'}`}
|
2025-06-02 13:50:44 +02:00
|
|
|
>
|
2025-06-23 20:30:15 +02:00
|
|
|
<div
|
|
|
|
|
ref={containerRef}
|
|
|
|
|
className="flex flex-1 items-center justify-center px-2 pb-4 pt-16 sm:px-4 sm:pt-20"
|
|
|
|
|
onWheel={handleWheel}
|
|
|
|
|
onMouseDown={handleMouseDown}
|
|
|
|
|
onMouseMove={handleMouseMove}
|
|
|
|
|
onMouseUp={handleMouseUp}
|
|
|
|
|
onMouseLeave={handleMouseUp}
|
|
|
|
|
onDoubleClick={handleDoubleClick}
|
|
|
|
|
style={{
|
|
|
|
|
cursor: getCursor(),
|
|
|
|
|
overflow: zoom > 1 ? 'hidden' : 'visible',
|
|
|
|
|
minHeight: 0, // Allow flexbox to shrink
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className="flex items-center justify-center transition-transform duration-100 ease-out"
|
2025-06-02 13:50:44 +02:00
|
|
|
style={{
|
2025-06-23 20:30:15 +02:00
|
|
|
transform: `translate(${panX}px, ${panY}px) scale(${zoom})`,
|
|
|
|
|
transformOrigin: 'center center',
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
display: 'flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
justifyContent: 'center',
|
2025-06-02 13:50:44 +02:00
|
|
|
}}
|
2025-06-23 20:30:15 +02:00
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={src}
|
|
|
|
|
alt="Image"
|
|
|
|
|
className="block object-contain"
|
|
|
|
|
style={{
|
|
|
|
|
maxHeight: 'calc(100vh - 8rem)',
|
|
|
|
|
maxWidth: getImageMaxWidth(),
|
|
|
|
|
width: 'auto',
|
|
|
|
|
height: 'auto',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2025-06-02 13:50:44 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Side Panel */}
|
|
|
|
|
<div
|
2025-06-23 20:30:15 +02:00
|
|
|
className={`sm:shadow-l-lg ease-[cubic-bezier(0.175,0.885,0.32,1.275)] fixed right-0 top-0 z-20 h-full w-full transform border-l border-border-light bg-surface-primary shadow-2xl backdrop-blur-sm transition-transform duration-500 sm:w-80 sm:rounded-l-2xl ${
|
2025-06-02 13:50:44 +02:00
|
|
|
isPromptOpen ? 'translate-x-0' : 'translate-x-full'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
2025-06-23 20:30:15 +02:00
|
|
|
{/* Mobile pull handle - removed for cleaner look */}
|
|
|
|
|
|
|
|
|
|
<div className="h-full overflow-y-auto p-4 sm:p-6">
|
|
|
|
|
{/* Mobile close button */}
|
|
|
|
|
<div className="mb-4 flex items-center justify-between sm:hidden">
|
|
|
|
|
<h3 className="text-lg font-semibold text-text-primary">
|
|
|
|
|
{localize('com_ui_image_details')}
|
|
|
|
|
</h3>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => setIsPromptOpen(false)}
|
|
|
|
|
variant="ghost"
|
|
|
|
|
className="h-12 w-12 p-0"
|
|
|
|
|
>
|
|
|
|
|
<X className="size-6" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="mb-4 hidden sm:block">
|
2025-06-02 13:50:44 +02:00
|
|
|
<h3 className="mb-2 text-lg font-semibold text-text-primary">
|
|
|
|
|
{localize('com_ui_image_details')}
|
|
|
|
|
</h3>
|
|
|
|
|
<div className="mb-4 h-px bg-border-medium"></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-06-23 20:30:15 +02:00
|
|
|
<div className="space-y-4 sm:space-y-6">
|
2025-06-02 13:50:44 +02:00
|
|
|
{/* Prompt Section */}
|
|
|
|
|
<div>
|
2025-06-08 00:22:08 +02:00
|
|
|
<h4 className="mb-2 text-sm font-medium text-text-primary">
|
2025-06-02 13:50:44 +02:00
|
|
|
{localize('com_ui_prompt')}
|
|
|
|
|
</h4>
|
|
|
|
|
<div className="rounded-md bg-surface-tertiary p-3">
|
|
|
|
|
<p className="text-sm leading-relaxed text-text-primary">
|
|
|
|
|
{args?.prompt || 'No prompt available'}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Generation Settings */}
|
|
|
|
|
<div>
|
2025-06-08 00:22:08 +02:00
|
|
|
<h4 className="mb-3 text-sm font-medium text-text-primary">
|
2025-06-02 13:50:44 +02:00
|
|
|
{localize('com_ui_generation_settings')}
|
|
|
|
|
</h4>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
2025-06-08 00:22:08 +02:00
|
|
|
<span className="text-sm text-text-primary">{localize('com_ui_size')}:</span>
|
2025-06-02 13:50:44 +02:00
|
|
|
<span className="text-sm font-medium text-text-primary">
|
|
|
|
|
{args?.size || 'Unknown'}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center justify-between">
|
2025-06-08 00:22:08 +02:00
|
|
|
<span className="text-sm text-text-primary">{localize('com_ui_quality')}:</span>
|
2025-06-02 13:50:44 +02:00
|
|
|
<span
|
2025-06-23 20:30:15 +02:00
|
|
|
className={`rounded px-2 py-1 text-xs font-medium capitalize ${getQualityStyles(args?.quality || '')}`}
|
2025-06-02 13:50:44 +02:00
|
|
|
>
|
|
|
|
|
{args?.quality || 'Standard'}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center justify-between">
|
2025-06-08 00:22:08 +02:00
|
|
|
<span className="text-sm text-text-primary">
|
2025-06-02 13:50:44 +02:00
|
|
|
{localize('com_ui_file_size')}:
|
|
|
|
|
</span>
|
|
|
|
|
<span className="text-sm font-medium text-text-primary">
|
|
|
|
|
{imageSize || 'Loading...'}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-05-16 17:50:18 +02:00
|
|
|
</OGDialogContent>
|
|
|
|
|
</OGDialog>
|
feat: Vision Support + New UI (#1203)
* feat: add timer duration to showToast, show toast for preset selection
* refactor: replace old /chat/ route with /c/. e2e tests will fail here
* refactor: move typedefs to root of /api/ and add a few to assistant types in TS
* refactor: reorganize data-provider imports, fix dependency cycle, strategize new plan to separate react dependent packages
* feat: add dataService for uploading images
* feat(data-provider): add mutation keys
* feat: file resizing and upload
* WIP: initial API image handling
* fix: catch JSON.parse of localStorage tools
* chore: experimental: use module-alias for absolute imports
* refactor: change temp_file_id strategy
* fix: updating files state by using Map and defining react query callbacks in a way that keeps them during component unmount, initial delete handling
* feat: properly handle file deletion
* refactor: unexpose complete filepath and resize from server for higher fidelity
* fix: make sure resized height, width is saved, catch bad requests
* refactor: use absolute imports
* fix: prevent setOptions from being called more than once for OpenAIClient, made note to fix for PluginsClient
* refactor: import supportsFiles and models vars from schemas
* fix: correctly replace temp file id
* refactor(BaseClient): use absolute imports, pass message 'opts' to buildMessages method, count tokens for nested objects/arrays
* feat: add validateVisionModel to determine if model has vision capabilities
* chore(checkBalance): update jsdoc
* feat: formatVisionMessage: change message content format dependent on role and image_urls passed
* refactor: add usage to File schema, make create and updateFile, correctly set and remove TTL
* feat: working vision support
TODO: file size, type, amount validations, making sure they are styled right, and making sure you can add images from the clipboard/dragging
* feat: clipboard support for uploading images
* feat: handle files on drop to screen, refactor top level view code to Presentation component so the useDragHelpers hook has ChatContext
* fix(Images): replace uploaded images in place
* feat: add filepath validation to protect sensitive files
* fix: ensure correct file_ids are push and not the Map key values
* fix(ToastContext): type issue
* feat: add basic file validation
* fix(useDragHelpers): correct context issue with `files` dependency
* refactor: consolidate setErrors logic to setError
* feat: add dialog Image overlay on image click
* fix: close endpoints menu on click
* chore: set detail to auto, make note for configuration
* fix: react warning (button desc. of button)
* refactor: optimize filepath handling, pass file_ids to images for easier re-use
* refactor: optimize image file handling, allow re-using files in regen, pass more file metadata in messages
* feat: lazy loading images including use of upload preview
* fix: SetKeyDialog closing, stopPropagation on Dialog content click
* style(EndpointMenuItem): tighten up the style, fix dark theme showing in lightmode, make menu more ux friendly
* style: change maxheight of all settings textareas to 138px from 300px
* style: better styling for textarea and enclosing buttons
* refactor(PresetItems): swap back edit and delete icons
* feat: make textarea placeholder dynamic to endpoint
* style: show user hover buttons only on hover when message is streaming
* fix: ordered list not going past 9, fix css
* feat: add User/AI labels; style: hide loading spinner
* feat: add back custom footer, change original footer text
* feat: dynamic landing icons based on endpoint
* chore: comment out assistants route
* fix: autoScroll to newest on /c/ view
* fix: Export Conversation on new UI
* style: match message style of official more closely
* ci: fix api jest unit tests, comment out e2e tests for now as they will fail until addressed
* feat: more file validation and use blob in preview field, not filepath, to fix temp deletion
* feat: filefilter for multer
* feat: better AI labels based on custom name, model, and endpoint instead of `ChatGPT`
2023-11-21 20:12:48 -05:00
|
|
|
);
|
|
|
|
|
}
|