From d89e78c713e4972312dfa2c1be7223a9e630d8af Mon Sep 17 00:00:00 2001 From: Rohit Rajan Date: Fri, 7 Nov 2025 14:18:46 +0530 Subject: [PATCH] feat: add duplicate tab name check --- src/components/run/InterpretationLog.tsx | 28 +++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/run/InterpretationLog.tsx b/src/components/run/InterpretationLog.tsx index a0042694..bdc31b76 100644 --- a/src/components/run/InterpretationLog.tsx +++ b/src/components/run/InterpretationLog.tsx @@ -61,7 +61,7 @@ export const InterpretationLog: React.FC = ({ isOpen, se const { captureStage, getText } = useActionContext(); const { browserWidth, outputPreviewHeight, outputPreviewWidth } = useBrowserDimensionsStore(); - const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName } = useGlobalInfoStore(); + const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName, notify } = useGlobalInfoStore(); const [showPreviewData, setShowPreviewData] = useState(false); const userClosedDrawer = useRef(false); @@ -154,6 +154,28 @@ export const InterpretationLog: React.FC = ({ isOpen, se } }; + const checkForDuplicateName = (stepId: number, type: 'list' | 'text' | 'screenshot', newName: string): boolean => { + const trimmedName = newName.trim(); + + if (type === 'list') { + const listSteps = browserSteps.filter(step => step.type === 'list' && step.id !== stepId); + const duplicate = listSteps.find(step => step.name === trimmedName); + if (duplicate) { + notify('error', `A list with the name "${trimmedName}" already exists. Please choose a different name.`); + return true; + } + } else if (type === 'screenshot') { + const screenshotSteps = browserSteps.filter(step => step.type === 'screenshot' && step.id !== stepId); + const duplicate = screenshotSteps.find(step => step.name === trimmedName); + if (duplicate) { + notify('error', `A screenshot with the name "${trimmedName}" already exists. Please choose a different name.`); + return true; + } + } + + return false; + }; + const startEdit = (stepId: number, type: 'list' | 'text' | 'screenshot', currentValue: string) => { setEditing({ stepId, type, value: currentValue }); }; @@ -168,6 +190,10 @@ export const InterpretationLog: React.FC = ({ isOpen, se return; } + if (checkForDuplicateName(stepId, type, finalValue)) { + return; + } + if (type === 'list') { updateListStepName(stepId, finalValue); } else if (type === 'text') {