Skip to content

Back button error fix#892

Merged
rahulharpal1603 merged 1 commit intoAOSSIE-Org:mainfrom
ritigya03:fix/onboarding-back-button2
Dec 30, 2025
Merged

Back button error fix#892
rahulharpal1603 merged 1 commit intoAOSSIE-Org:mainfrom
ritigya03:fix/onboarding-back-button2

Conversation

@ritigya03
Copy link
Contributor

@ritigya03 ritigya03 commented Dec 30, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Onboarding steps now support editing mode, allowing users to navigate back and modify their selections (avatar, theme, folder configuration) at any point during onboarding. Steps no longer auto-complete when in edit mode, providing better flexibility and control over the onboarding process.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

⚠️ No issue was linked in the PR description.
Please make sure to link an issue (e.g., 'Fixes #issue_number')

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

These changes introduce an "editing mode" to the onboarding flow through Redux state management. An isEditing boolean flag is added to the Redux store and utilized across three onboarding step components to prevent premature step completion when users actively edit their selections. Two step components receive a new currentStepDisplayIndex prop.

Changes

Cohort / File(s) Summary
Redux State Management
frontend/src/features/onboardingSlice.ts
Added isEditing boolean to onboarding state (initialized to false), introduced setIsEditing reducer, and exported the new action.
Onboarding Step Components
frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx, frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx, frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
Integrated Redux isEditing state into each step component. Added conditional logic to guard step completion and rendering—steps now complete/hide only when user selections exist AND isEditing is false. Updated handleBack to dispatch setIsEditing(true). FolderSetupStep and ThemeSelectionStep now accept currentStepDisplayIndex prop.

Sequence Diagram

sequenceDiagram
    actor User
    participant Step as Onboarding Step<br/>(AvatarSelection,<br/>Theme, Folder)
    participant Redux as Redux Store<br/>(isEditing)
    participant Storage as localStorage

    User->>Step: Select avatar/theme/folder
    Step->>Storage: Persist selection
    Step->>Redux: Check isEditing state
    alt isEditing = true
        Redux-->>Step: Editing in progress
        Step-->>User: Allow continued editing
    else isEditing = false
        Redux-->>Step: Not editing
        Step->>Step: Mark step completed
        Step->>Redux: (Completion recorded)
        Step-->>User: Hide component / show next step
    end
    
    User->>Step: Click Back
    Step->>Redux: Dispatch setIsEditing(true)
    Redux-->>Step: isEditing updated
    Step->>User: Navigate to previous step
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • Fixed the Onboarding Page Setup #485: Modifies the same onboarding components (AvatarSelectionStep, FolderSetupStep, ThemeSelectionStep) and onboardingSlice, indicating overlapping changes and shared functionality.

Poem

🐰 Hop by hop, the onboarding flows,
With editing mode—no rushing prose!
Redux guards each choice we make,
No premature steps, for goodness' sake,
Back we go when edits arise—smooth as clover!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Back button error fix' is vague and doesn't convey the specific nature of the changes. The PR involves adding Redux-based editing state management to onboarding steps, not just a simple back button fix. Use a more descriptive title that captures the main intent, such as 'Add isEditing state to prevent premature step completion during onboarding' or 'Implement editing mode gating for onboarding step completion'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings

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.

@rahulharpal1603 rahulharpal1603 changed the title files changed Back button error fix Dec 30, 2025
@github-actions
Copy link
Contributor

⚠️ No issue was linked in the PR description.
Please make sure to link an issue (e.g., 'Fixes #issue_number')

1 similar comment
@github-actions
Copy link
Contributor

⚠️ No issue was linked in the PR description.
Please make sure to link an issue (e.g., 'Fixes #issue_number')

Copy link
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: 3

🧹 Nitpick comments (2)
frontend/src/components/OnboardingSteps/FolderSetupStep.tsx (1)

12-18: Consider consolidating imports.

The imports from @/features/onboardingSlice are split across lines 14 and 18. While functional, consolidating them improves readability.

🔎 Proposed consolidation
 import { AppDispatch, RootState } from '@/app/store';
-import { markCompleted, previousStep } from '@/features/onboardingSlice';
+import { markCompleted, previousStep, setIsEditing } from '@/features/onboardingSlice';
 import { AppFeatures } from '@/components/OnboardingSteps/AppFeatures';
 import { useFolder } from '@/hooks/useFolder';
 import { useEffect, useState } from 'react';
-import { setIsEditing } from '@/features/onboardingSlice';
frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx (1)

21-24: Reorganize imports for better readability.

The imports could be better organized by grouping related imports together and removing the empty line.

🔎 Suggested reorganization
 import React, { useEffect } from 'react';
-import { useDispatch } from 'react-redux';
+import { useDispatch, useSelector } from 'react-redux';
-import { AppDispatch } from '@/app/store';
-import { markCompleted, previousStep } from '@/features/onboardingSlice';
+import { AppDispatch, RootState } from '@/app/store';
+import { markCompleted, previousStep, setIsEditing } from '@/features/onboardingSlice';

 import { Button } from '@/components/ui/button';
 // ... rest of imports
-
-import { setIsEditing } from '@/features/onboardingSlice';
-import { useSelector } from 'react-redux';
-import { RootState } from '@/app/store';
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a91a07d and 5ea5f6a.

📒 Files selected for processing (4)
  • frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx
  • frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
  • frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx
  • frontend/src/features/onboardingSlice.ts
🧰 Additional context used
🧬 Code graph analysis (3)
frontend/src/components/OnboardingSteps/FolderSetupStep.tsx (2)
frontend/src/app/store.ts (1)
  • RootState (22-22)
frontend/src/features/onboardingSlice.ts (2)
  • setIsEditing (33-35)
  • previousStep (48-55)
frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx (1)
frontend/src/app/store.ts (1)
  • RootState (22-22)
frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx (2)
frontend/src/app/store.ts (2)
  • RootState (22-22)
  • AppDispatch (24-24)
frontend/src/features/onboardingSlice.ts (2)
  • setIsEditing (33-35)
  • previousStep (48-55)
🔇 Additional comments (2)
frontend/src/features/onboardingSlice.ts (1)

12-12: LGTM! Clean Redux state addition.

The isEditing state field and setIsEditing reducer follow Redux Toolkit conventions correctly. The implementation is clean and properly typed.

Also applies to: 21-21, 33-35, 59-59

frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx (1)

36-39: Good initialization from localStorage.

Loading initial state from localStorage ensures the form displays previously saved values when users navigate back for editing.

Comment on lines 44 to 52
useEffect(() => {
if (localStorage.getItem('name') && localStorage.getItem('avatar')) {
if (
localStorage.getItem('name') &&
localStorage.getItem('avatar') &&
!isEditing
) {
dispatch(markCompleted(stepIndex));
}
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing useEffect dependency and incomplete editing cycle.

Two concerns with this useEffect:

  1. Missing dependency: The effect uses isEditing but doesn't include it in the dependency array. If the component re-mounts while isEditing is true, the effect won't reflect the current editing state correctly.

  2. Incomplete editing cycle: When users click "Next" after editing (via handleNextClick), isEditing is never reset to false. This means once editing mode is activated, it stays active indefinitely, potentially affecting subsequent navigation.

🔎 Suggested fixes

Option 1: Add isEditing to dependencies

  useEffect(() => {
    if (
      localStorage.getItem('name') &&
      localStorage.getItem('avatar') &&
      !isEditing
    ) {
      dispatch(markCompleted(stepIndex));
    }
- }, []);
+ }, [isEditing, dispatch, stepIndex]);

Option 2: Reset isEditing when completing the step

  const handleNextClick = () => {
    dispatch(setName(name));
    dispatch(setAvatar(selectedAvatar));
    localStorage.setItem('name', name);
    localStorage.setItem('avatar', selectedAvatar);
+   dispatch(setIsEditing(false));
    dispatch(markCompleted(stepIndex));
  };

Consider whether the editing mode should persist across steps or reset when moving forward.

📝 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
useEffect(() => {
if (localStorage.getItem('name') && localStorage.getItem('avatar')) {
if (
localStorage.getItem('name') &&
localStorage.getItem('avatar') &&
!isEditing
) {
dispatch(markCompleted(stepIndex));
}
}, []);
useEffect(() => {
if (
localStorage.getItem('name') &&
localStorage.getItem('avatar') &&
!isEditing
) {
dispatch(markCompleted(stepIndex));
}
}, [isEditing, dispatch, stepIndex]);
🤖 Prompt for AI Agents
In frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx around lines
44-52, the useEffect reads isEditing but omits it from the dependency array and
the editing flag is never reset when the user completes the step; update the
useEffect dependency array to include isEditing (and any other used values like
stepIndex/dispatch if referenced) so the effect re-runs when editing state
changes, and modify the handleNextClick flow to reset isEditing to false (or
dispatch an action that clears editing) when marking the step completed so
editing mode does not persist after moving forward.

Comment on lines 38 to 42
useEffect(() => {
if (localStorage.getItem('folderChosen') === 'true') {
if (localStorage.getItem('folderChosen') === 'true' && !isEditing) {
dispatch(markCompleted(stepIndex));
}
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Incomplete editing mode cycle - same issue as AvatarSelectionStep.

This component has the same two issues found in AvatarSelectionStep.tsx:

  1. Missing useEffect dependency: isEditing is used but not included in the dependency array (line 39).
  2. No reset mechanism: handleNext (lines 59-63) never resets isEditing to false, while handleBack (lines 65-68) sets it to true.

This creates a one-way state change where editing mode, once activated, never deactivates. Consider the same fixes suggested for AvatarSelectionStep.tsx:

  • Add isEditing to the useEffect dependency array, OR
  • Dispatch setIsEditing(false) in handleNext before marking the step complete

Also applies to: 59-68

🤖 Prompt for AI Agents
In frontend/src/components/OnboardingSteps/FolderSetupStep.tsx around lines
38-42 and 59-68, the useEffect reads localStorage and uses isEditing but does
not include isEditing in the dependency array (line 39), and handleNext never
resets isEditing while handleBack sets it true, causing a one-way editing state;
add isEditing to the useEffect dependency array so the effect re-runs when
editing mode changes, and in handleNext (before dispatching markCompleted)
dispatch setIsEditing(false) to exit editing mode (keep handleBack setting
true).

Comment on lines 42 to 46
useEffect(() => {
if (localStorage.getItem('themeChosen')) {
if (localStorage.getItem('themeChosen') === 'true' && !isEditing) {
dispatch(markCompleted(stepIndex));
}
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Incomplete editing mode cycle - consistent across all step components.

This is the third step component with the same two issues:

  1. Missing useEffect dependency: isEditing is used in the condition (line 43) but not in the dependency array.
  2. No reset mechanism: handleBack sets isEditing to true (line 57), but handleNext (lines 51-54) never resets it to false.

Impact: Once a user clicks "Back" from any step, isEditing remains true throughout the rest of the onboarding flow. This might be intentional to force users to review all steps, but without documentation or a clear reset point, it creates an incomplete state machine.

Recommendation: Establish a clear editing mode lifecycle. Consider one of these approaches:

  • Reset isEditing to false when any step's "Next" button is clicked
  • Reset isEditing to false when the final onboarding step is completed
  • Document if the persistent true state is intentional behavior

Also applies to: 51-59

🤖 Prompt for AI Agents
frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx around lines
42-46 and 51-59: the useEffect reads localStorage and checks isEditing but does
not include isEditing in its dependency array, and handleBack sets isEditing to
true while handleNext never resets it; update the useEffect dependency array to
include isEditing (so the completion check runs when editing state changes) and
modify handleNext to set isEditing(false) before/after dispatching the next-step
actions (so editing mode is cleared when advancing); ensure these changes
satisfy lint rules and mirror the same fix in the other step components.

@rahulharpal1603 rahulharpal1603 merged commit 4043751 into AOSSIE-Org:main Dec 30, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants