Skip to content

Commit d89e78c

Browse files
committed
feat: add duplicate tab name check
1 parent 8489f95 commit d89e78c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/components/run/InterpretationLog.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
6161
const { captureStage, getText } = useActionContext();
6262

6363
const { browserWidth, outputPreviewHeight, outputPreviewWidth } = useBrowserDimensionsStore();
64-
const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName } = useGlobalInfoStore();
64+
const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName, notify } = useGlobalInfoStore();
6565

6666
const [showPreviewData, setShowPreviewData] = useState<boolean>(false);
6767
const userClosedDrawer = useRef<boolean>(false);
@@ -154,6 +154,28 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
154154
}
155155
};
156156

157+
const checkForDuplicateName = (stepId: number, type: 'list' | 'text' | 'screenshot', newName: string): boolean => {
158+
const trimmedName = newName.trim();
159+
160+
if (type === 'list') {
161+
const listSteps = browserSteps.filter(step => step.type === 'list' && step.id !== stepId);
162+
const duplicate = listSteps.find(step => step.name === trimmedName);
163+
if (duplicate) {
164+
notify('error', `A list with the name "${trimmedName}" already exists. Please choose a different name.`);
165+
return true;
166+
}
167+
} else if (type === 'screenshot') {
168+
const screenshotSteps = browserSteps.filter(step => step.type === 'screenshot' && step.id !== stepId);
169+
const duplicate = screenshotSteps.find(step => step.name === trimmedName);
170+
if (duplicate) {
171+
notify('error', `A screenshot with the name "${trimmedName}" already exists. Please choose a different name.`);
172+
return true;
173+
}
174+
}
175+
176+
return false;
177+
};
178+
157179
const startEdit = (stepId: number, type: 'list' | 'text' | 'screenshot', currentValue: string) => {
158180
setEditing({ stepId, type, value: currentValue });
159181
};
@@ -168,6 +190,10 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
168190
return;
169191
}
170192

193+
if (checkForDuplicateName(stepId, type, finalValue)) {
194+
return;
195+
}
196+
171197
if (type === 'list') {
172198
updateListStepName(stepId, finalValue);
173199
} else if (type === 'text') {

0 commit comments

Comments
 (0)