fix: switch to active action data tab on capture
This commit is contained in:
@@ -354,6 +354,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let shouldOpenDrawer = false;
|
let shouldOpenDrawer = false;
|
||||||
|
let switchToListTab = false;
|
||||||
let switchToTextTab = false;
|
let switchToTextTab = false;
|
||||||
let switchToScreenshotTab = false;
|
let switchToScreenshotTab = false;
|
||||||
|
|
||||||
@@ -362,6 +363,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
if (captureListData.length > lastListDataLength.current) {
|
if (captureListData.length > lastListDataLength.current) {
|
||||||
userClosedDrawer.current = false;
|
userClosedDrawer.current = false;
|
||||||
shouldOpenDrawer = true;
|
shouldOpenDrawer = true;
|
||||||
|
switchToListTab = true;
|
||||||
}
|
}
|
||||||
lastListDataLength.current = captureListData.length;
|
lastListDataLength.current = captureListData.length;
|
||||||
}
|
}
|
||||||
@@ -386,18 +388,31 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
lastScreenshotDataLength.current = screenshotData.length;
|
lastScreenshotDataLength.current = screenshotData.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getLatestCaptureType = () => {
|
||||||
|
for (let i = browserSteps.length - 1; i >= 0; i--) {
|
||||||
|
const type = browserSteps[i].type;
|
||||||
|
if (type === "list" || type === "text" || type === "screenshot") {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
if (shouldOpenDrawer) {
|
if (shouldOpenDrawer) {
|
||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
if (switchToTextTab) {
|
const latestType = getLatestCaptureType();
|
||||||
setTimeout(() => {
|
|
||||||
const textTabIndex = getAvailableTabs().findIndex(tab => tab.id === 'captureText');
|
setTimeout(() => {
|
||||||
if (textTabIndex !== -1) {
|
if (latestType === "text") {
|
||||||
setActiveTab(textTabIndex);
|
const idx = getAvailableTabs().findIndex(t => t.id === "captureText");
|
||||||
}
|
if (idx !== -1) setActiveTab(idx);
|
||||||
}, 100);
|
|
||||||
} else if (switchToScreenshotTab) {
|
} else if (latestType === "list") {
|
||||||
setTimeout(() => {
|
const idx = getAvailableTabs().findIndex(t => t.id === "captureList");
|
||||||
const screenshotTabIndex = getAvailableTabs().findIndex(tab => tab.id === 'captureScreenshot');
|
if (idx !== -1) setActiveTab(idx);
|
||||||
|
|
||||||
|
} else if (latestType === "screenshot") {
|
||||||
|
const screenshotTabIndex = getAvailableTabs().findIndex(tab => tab.id === "captureScreenshot");
|
||||||
if (screenshotTabIndex !== -1) {
|
if (screenshotTabIndex !== -1) {
|
||||||
setActiveTab(screenshotTabIndex);
|
setActiveTab(screenshotTabIndex);
|
||||||
const latestIndex = screenshotData.length - 1;
|
const latestIndex = screenshotData.length - 1;
|
||||||
@@ -406,7 +421,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
if (!autoFocusedScreenshotIndices.current.has(latestIndex)) {
|
if (!autoFocusedScreenshotIndices.current.has(latestIndex)) {
|
||||||
autoFocusedScreenshotIndices.current.add(latestIndex);
|
autoFocusedScreenshotIndices.current.add(latestIndex);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const screenshotSteps = browserSteps.filter(step => step.type === 'screenshot') as Array<{ id: number; name?: string; type: 'screenshot' }>;
|
const screenshotSteps = browserSteps.filter(step => step.type === "screenshot");
|
||||||
const latestScreenshotStep = screenshotSteps[latestIndex];
|
const latestScreenshotStep = screenshotSteps[latestIndex];
|
||||||
if (latestScreenshotStep) {
|
if (latestScreenshotStep) {
|
||||||
const screenshotName = latestScreenshotStep.name || `Screenshot ${latestIndex + 1}`;
|
const screenshotName = latestScreenshotStep.name || `Screenshot ${latestIndex + 1}`;
|
||||||
@@ -415,8 +430,8 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
|||||||
}, 300);
|
}, 300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 100);
|
}
|
||||||
}
|
}, 100);
|
||||||
}
|
}
|
||||||
}, [hasScrapeListAction, hasScrapeSchemaAction, hasScreenshotAction, captureListData, captureTextData, screenshotData, setIsOpen, getText]);
|
}, [hasScrapeListAction, hasScrapeSchemaAction, hasScreenshotAction, captureListData, captureTextData, screenshotData, setIsOpen, getText]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user