Skip to content

fix: guard addFolderMutate call when no folder is selected in onboarding#1287

Merged
rohan-pandeyy merged 1 commit into
AOSSIE-Org:mainfrom
Rishiii57:fix/folder-setup-validation-error
May 25, 2026
Merged

fix: guard addFolderMutate call when no folder is selected in onboarding#1287
rohan-pandeyy merged 1 commit into
AOSSIE-Org:mainfrom
Rishiii57:fix/folder-setup-validation-error

Conversation

@Rishiii57
Copy link
Copy Markdown
Contributor

@Rishiii57 Rishiii57 commented May 24, 2026

Addressed Issues:

Fixes #994

Screenshots/Recordings:

Before :
Screenshot 2026-05-25 at 03 27 44

Change :
Could not test locally as the full backend setup was required to reach the onboarding screen. The fix is just a one line obvious change : addFolderMutate(folder) is only called when folder is a non-empty string, which is verifiably correct by code inspection.

AI Usage Disclosure:

  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have reviewed the code and I am responsible for it.

I have used the following AI models and tools: Claude

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced folder setup validation during onboarding. The system now ensures a folder is properly selected before processing, preventing empty submissions and improving the overall setup experience.

Review Change Stack

@github-actions github-actions Bot added frontend good first issue Good for newcomers labels May 24, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 24, 2026

Walkthrough

The PR adds a conditional guard to the folder-add mutation in the onboarding flow. The handleNext function now checks whether a folder has been selected before calling the API mutation, preventing validation errors when proceeding without folder input.

Changes

Folder Selection Validation Guard

Layer / File(s) Summary
Guard folder mutation on selection
frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
The handleNext function wraps addFolderMutate(folder) with an if (folder) guard, preventing the mutation from executing when no folder is selected while allowing the onboarding step to progress.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

TypeScript/JavaScript

Poem

🐰 A guard so small, a check so bright,
Prevents the empty folder's plight,
No mutation without a name,
Onboarding now stays sane!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: guarding the addFolderMutate call when no folder is selected in onboarding, which directly addresses the fix being implemented.
Linked Issues check ✅ Passed The PR successfully addresses the requirement in issue #994 by adding a conditional guard to prevent calling addFolderMutate when folder is an empty string, eliminating the validation error.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to fixing the reported bug; only the FolderSetupStep component is modified with a minimal conditional guard, directly addressing issue #994 without introducing unrelated changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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
Copy Markdown
Contributor

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/components/OnboardingSteps/FolderSetupStep.tsx (1)

38-42: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add missing dependencies to the useEffect dependency array.

The effect uses dispatch, stepIndex, and isEditing but the dependency array is empty. Per React hook best practices, all values referenced in the effect should be included in the dependency array to prevent stale closures.

🔧 Add missing dependencies
 useEffect(() => {
   if (localStorage.getItem('folderChosen') === 'true' && !isEditing) {
     dispatch(markCompleted(stepIndex));
   }
-}, []);
+}, [dispatch, stepIndex, isEditing]);

As per coding guidelines: Check for proper React hook dependencies and prevent unnecessary re-renders.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/components/OnboardingSteps/FolderSetupStep.tsx` around lines 38
- 42, The useEffect that reads localStorage and calls
dispatch(markCompleted(stepIndex)) is missing dependencies and may capture stale
values; update the effect's dependency array to include dispatch, stepIndex, and
isEditing (i.e., useEffect(..., [dispatch, stepIndex, isEditing])) so the hook
reacts to changes in those values while still preserving the existing guard
(localStorage check and !isEditing); if you want it to run only on mount
instead, explicitly justify and memoize any values (e.g., wrap
markCompleted/dispatch usage) so ESLint rules are satisfied.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/OnboardingSteps/FolderSetupStep.tsx`:
- Around line 59-65: Add unit tests for the FolderSetupStep component to
exercise the handleNext guard: render FolderSetupStep, mock addFolderMutate and
the Redux dispatch (or spy on markCompleted), then simulate the user action that
triggers handleNext (e.g., click the Next button or call the exported handler).
Create two tests: (1) with folder undefined/empty assert addFolderMutate is not
called, dispatch(markCompleted(stepIndex)) is called, and
localStorage.setItem('folderChosen','true') was called; (2) with folder
populated assert addFolderMutate was called once with the folder,
dispatch(markCompleted(stepIndex)) is called, and
localStorage.setItem('folderChosen','true') was called. Use the component name
FolderSetupStep and the handler name handleNext to locate behavior and
reset/restore mocks and localStorage between tests.
- Line 60: The localStorage flag 'folderChosen' is being set unconditionally;
change the logic so you only call localStorage.setItem('folderChosen','true')
when a real folder is selected (e.g., inside the branch where the selected
folder variable is truthy in the Next/handleNext handler), and update all places
that read 'folderChosen' in the component's auto-complete logic to rely on that
true-only-when-selected behavior; alternatively, if you prefer to track step
completion instead, rename the key to 'folderStepCompleted' and update every
read/write of that key accordingly so semantics match.

---

Outside diff comments:
In `@frontend/src/components/OnboardingSteps/FolderSetupStep.tsx`:
- Around line 38-42: The useEffect that reads localStorage and calls
dispatch(markCompleted(stepIndex)) is missing dependencies and may capture stale
values; update the effect's dependency array to include dispatch, stepIndex, and
isEditing (i.e., useEffect(..., [dispatch, stepIndex, isEditing])) so the hook
reacts to changes in those values while still preserving the existing guard
(localStorage check and !isEditing); if you want it to run only on mount
instead, explicitly justify and memoize any values (e.g., wrap
markCompleted/dispatch usage) so ESLint rules are satisfied.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c8288016-71ad-4f2d-ba47-5463096ea4c4

📥 Commits

Reviewing files that changed from the base of the PR and between a20c1bb and 14cf922.

📒 Files selected for processing (1)
  • frontend/src/components/OnboardingSteps/FolderSetupStep.tsx

Comment thread frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
Comment thread frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
@rohan-pandeyy rohan-pandeyy merged commit 1545a90 into AOSSIE-Org:main May 25, 2026
4 checks passed
@Rishiii57 Rishiii57 deleted the fix/folder-setup-validation-error branch May 25, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: validation error in onboarding folder selection step

2 participants