Skip to content

Conversation

@RohitR311
Copy link
Collaborator

@RohitR311 RohitR311 commented Nov 7, 2025

What this PR does?

Adds a validity check to ensure unique names among each capture action type.

2025-11-07.14-17-34.mp4

Summary by CodeRabbit

Release Notes

  • New Features
    • Added duplicate name validation for list and screenshot steps
    • System now alerts users when attempting to save steps with duplicate names

@RohitR311 RohitR311 added the Scope: Recorder All issues/PRs related to recorder label Nov 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Walkthrough

Added a duplicate-name validation feature to InterpretationLog by introducing a checkForDuplicateName helper function that detects name collisions among list and screenshot steps, integrating the check into the save/edit workflow with error notifications.

Changes

Cohort / File(s) Summary
Duplicate Name Validation
src/components/run/InterpretationLog.tsx
Extended useGlobalInfoStore() destructure to include notify. Introduced checkForDuplicateName(stepId, type, newName) helper to validate name collisions for 'list' and 'screenshot' types. Integrated validation into startEdit/saveEdit workflow to abort updates on duplicate detection.

Sequence Diagram

sequenceDiagram
    actor User
    participant InterpretationLog
    participant checkForDuplicateName
    participant useGlobalInfoStore
    
    User->>InterpretationLog: Attempt to save/edit step with new name
    InterpretationLog->>checkForDuplicateName: checkForDuplicateName(stepId, type, newName)
    alt Duplicate Found
        checkForDuplicateName->>useGlobalInfoStore: notify(error message)
        useGlobalInfoStore-->>InterpretationLog: Error emitted
        InterpretationLog-->>User: Update aborted
    else No Duplicate
        checkForDuplicateName-->>InterpretationLog: Validation passed
        InterpretationLog->>InterpretationLog: Apply edits
        InterpretationLog-->>User: Update successful
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review the checkForDuplicateName function logic for correctness in detecting collisions across both 'list' and 'screenshot' types
  • Verify integration points in startEdit/saveEdit workflows to ensure duplicate checks are applied consistently across all relevant step types
  • Confirm error messages are clear and user-friendly

Possibly related PRs

  • PR #282 — Also modifies src/components/run/InterpretationLog.tsx and updates destructured values from useGlobalInfoStore, indicating related edits to the same component integration point.

Suggested labels

Type: Enhancement

Suggested reviewers

  • amhsirak

Poem

🐰 A name checker hops through the list,
Spotting duplicates it won't miss!
Before you save, the validation runs,
Preventing collisions—oh what fun!
Clean names for all, no more strife,
Harmonious steps in workflow life. ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat: prevent duplicate action name' directly aligns with the main change: adding duplicate-name validation checks for capture actions. It accurately summarizes the primary functionality introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unique-tab

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8489f95 and d89e78c.

📒 Files selected for processing (1)
  • src/components/run/InterpretationLog.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/components/run/InterpretationLog.tsx (1)
src/context/globalInfo.tsx (1)
  • useGlobalInfoStore (186-186)

Comment on lines +157 to +177
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;
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Handle duplicate text labels too

checkForDuplicateName short-circuits only for lists and screenshots. When editing a text step, it always falls through and returns false, so two text captures can still share the same label—failing the “unique per capture action type” requirement and the helper’s own 'text' signature. Add a text-specific guard before returning.

     } 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;
       }
+    } else if (type === 'text') {
+      const textSteps = browserSteps.filter(step => step.type === 'text' && step.id !== stepId);
+      const duplicate = textSteps.find(step => step.label?.trim() === trimmedName);
+      if (duplicate) {
+        notify('error', `A text entry with the name "${trimmedName}" already exists. Please choose a different name.`);
+        return true;
+      }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 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;
}
} else if (type === 'text') {
const textSteps = browserSteps.filter(step => step.type === 'text' && step.id !== stepId);
const duplicate = textSteps.find(step => step.label?.trim() === trimmedName);
if (duplicate) {
notify('error', `A text entry with the name "${trimmedName}" already exists. Please choose a different name.`);
return true;
}
}
return false;
};
🤖 Prompt for AI Agents
In src/components/run/InterpretationLog.tsx around lines 157 to 177, the
duplicate-name check only handles 'list' and 'screenshot' so 'text' edits can
create non-unique labels; add a branch for type === 'text' that filters
browserSteps for type 'text' excluding the current stepId, checks for an
existing step with the same trimmed name, calls notify('error', `A text capture
with the name "${trimmedName}" already exists. Please choose a different name.`)
if found, and returns true; keep the existing return false at the end.

@amhsirak amhsirak merged commit 865a7ab into develop Nov 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Recorder All issues/PRs related to recorder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants