diff --git a/src/components/browser/BrowserWindow.tsx b/src/components/browser/BrowserWindow.tsx index c70f6fba..acc43637 100644 --- a/src/components/browser/BrowserWindow.tsx +++ b/src/components/browser/BrowserWindow.tsx @@ -2187,7 +2187,15 @@ export const BrowserWindow = () => { )} {/* Main content area */} -
+
{/* Add CSS for the spinner animation */} - {(getText === true || getList === true) && + {(getText || getList) && !showAttributeModal && highlighterData?.rect != null && ( <> @@ -2211,7 +2219,16 @@ export const BrowserWindow = () => { )} {isDOMMode && highlighterData && ( - <> +
{/* Individual element highlight (for non-group or hovered element) */} {((getText && !listSelector) || (getList && paginationMode && paginationType !== "" && @@ -2219,49 +2236,33 @@ export const BrowserWindow = () => {
)} - {/* Group elements highlighting with real-time coordinates */} + {/* Grouped list element highlights */} {getList && !listSelector && currentGroupInfo?.isGroupElement && - highlighterData.groupElements && - highlighterData.groupElements.map( - (groupElement, index) => ( + highlighterData.groupElements?.map((groupElement, index) => ( - {/* Highlight box */}
{
{ listSelector && !paginationMode && !limitMode && - highlighterData?.similarElements && - highlighterData.similarElements.rects.map( - (rect, index) => ( + highlighterData.similarElements?.rects?.map((rect, index) => ( - {/* Highlight box for similar element */}
{
{ Item {index + 1}
- ) - )} - - )} - - )} - + ))} +
+ )} + + )} + {/* --- Main DOM Renderer Section --- */} +
{isDOMMode ? ( -
+ <> {currentSnapshot ? ( { paginationMode={paginationMode} paginationType={paginationType} limitMode={limitMode} - onHighlight={(data) => { - domHighlighterHandler(data); - }} isCachingChildSelectors={isCachingChildSelectors} + onHighlight={domHighlighterHandler} onElementSelect={handleDOMElementSelection} onShowDatePicker={handleShowDatePicker} onShowDropdown={handleShowDropdown} @@ -2377,181 +2377,120 @@ export const BrowserWindow = () => { onShowDateTimePicker={handleShowDateTimePicker} /> ) : ( -
-
-
- Loading website... -
- -
+ )} - {/* Loading overlay positioned specifically over DOM content */} + {/* --- Loading overlay --- */} {isCachingChildSelectors && ( - <> - {/* Background overlay */} -
- - {/* Use processing coordinates captured before listSelector was set */} - {processingGroupCoordinates.map((groupElement, index) => ( - - {/* Original highlight box */} -
- - {/* Label */} -
- List item {index + 1} -
- - {/* Scanning animation */} -
-
-
- - - - ))} - - {/* Fallback loader */} - {processingGroupCoordinates.length === 0 && ( + <>
+ /> + {processingGroupCoordinates.map((groupElement, index) => ( + +
+
+ List item {index + 1} +
+
+
+
+ + + ))} + + {processingGroupCoordinates.length === 0 && (
-
- )} - - )} -
+ > +
+
+ )} + + )} + ) : ( - /* Screenshot mode canvas */ { )}
- ); +
+ ); }; +const DOMLoadingIndicator: React.FC = () => { + const [progress, setProgress] = useState(0); + const [pendingRequests, setPendingRequests] = useState(0); + const [hasStartedLoading, setHasStartedLoading] = useState(false); + const { socket } = useSocketStore(); + const { state } = useContext(AuthContext); + const { user } = state; + const { browserWidth, browserHeight } = useBrowserDimensionsStore(); + + useEffect(() => { + if (!socket) return; + + const handleLoadingProgress = (data: { + progress: number; + pendingRequests: number; + userId: string; + }) => { + if (!data.userId || data.userId === user?.id) { + // Once loading has started, never reset progress to 0 + if (!hasStartedLoading && data.progress > 0) { + setHasStartedLoading(true); + } + + // Only update progress if we haven't started or if new progress is higher + if (!hasStartedLoading || data.progress >= progress) { + setProgress(data.progress); + setPendingRequests(data.pendingRequests); + } + } + }; + + socket.on("domLoadingProgress", handleLoadingProgress); + + return () => { + socket.off("domLoadingProgress", handleLoadingProgress); + }; + }, [socket, user?.id, hasStartedLoading, progress]); + + return ( +
+ {/* Loading text with percentage */} +
+ Loading {progress}% +
+ + {/* Progress bar */} +
+
+
+
+ ); +}; + + const drawImage = (image: string, canvas: HTMLCanvasElement): void => { const ctx = canvas.getContext('2d'); if (!ctx) return;