Skip to content

FIX: #693 New registration and signout issues#701

Open
paretar758-cloud wants to merge 2 commits into
AOSSIE-Org:mainfrom
paretar758-cloud:New-Registration-And-Signout-issues
Open

FIX: #693 New registration and signout issues#701
paretar758-cloud wants to merge 2 commits into
AOSSIE-Org:mainfrom
paretar758-cloud:New-Registration-And-Signout-issues

Conversation

@paretar758-cloud
Copy link
Copy Markdown

@paretar758-cloud paretar758-cloud commented Dec 9, 2025

Fixing issue #693

Summary

This pull request resolves issue #693 affecting both the Onboarding flow and the Settings UI. The update addresses several critical navigation and session-management defects, including infinite navigation loops, invalid step counter states (e.g., “Step 4 of 3”), and the absence of a session reset mechanism (“Sign Out”), which prevented users from recovering from corrupted or invalid configurations.

Root Cause Analysis

  1. Navigation Logic Failures

Infinite Loop in Onboarding:
Each onboarding step executed a useEffect on mount that attempted to auto-advance based on localStorage values. When users navigated backward, these effects immediately forced the UI to jump forward again, creating an infinite loop with no way to return to prior steps.

Invalid Step Counter State:
The step counter relied on inconsistent state transitions, causing jumps from 2 / 3 directly to invalid values such as 4 / 3. This occurred due to unguarded increments and incorrect step indexing.

  1. Settings Page

No Exit Mechanism:
The Settings page did not expose a “Sign Out” or “Reset” option. This made it impossible for users to recover from misconfigurations (e.g., selecting an inaccessible folder), leaving them permanently trapped in a corrupted session state.

Fixes Implemented
✔ Corrected Step Counter Logic

Refactored state transitions to guarantee linear, bounded progression through onboarding steps (1 → 2 → 3). Guardrails prevent counter overflow into invalid states.

✔ Removed Auto-Skip Side Effects

Eliminated the useEffect hooks responsible for force-skipping onboarding steps. Users can now perform true bidirectional navigation without being redirected or blocked.

✔ State & Data Restoration

Implemented restoration of persisted form fields (name, avatar, folderPath) from localStorage. When navigating backward, previously entered data is rehydrated into the UI to provide a consistent onboarding experience.

✔ Added Full Sign-Out Support

Added a Sign Out button to Settings.tsx using react-router-dom.
Behavior:

Clears all persisted session data

Performs a controlled navigation back to the initial onboarding route

Restores the application to a clean state

Resulting Improvements

Accurate Step Progression: Step counter now reliably reflects the correct onboarding sequence.

Stability in Navigation: Users can move backward and forward without unintended redirects or loops.

Emergency Recovery: The new Sign Out control allows users to escape configuration lockouts or crash loops by fully resetting the app state.

Persistent User Input: All onboarding fields persist across navigations, improving user experience and preventing accidental data loss.

PictoPy.Shivansh.mp4

File-Level Changes

AvatarSelectionStep.tsx

Removed auto-advance logic

Corrected step increment/decrement mechanisms

Added localStorage-backed state restoration

FolderSetupStep.tsx

Removed auto-skip behavior

Stabilized step transition logic

Implemented folder path persistence

Settings.tsx

Added Sign Out button

Integrated useNavigate for controlled app reset

package.json

Added react-router-dom as a dependency

Summary by CodeRabbit

  • New Features

    • Added sign-out functionality to the Settings page for secure account management.
  • Bug Fixes

    • Corrected step numbering and progress indicator accuracy throughout the onboarding workflow.
  • Chores

    • Updated routing library dependency to the latest version.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 9, 2025

Walkthrough

Changes modify the OpenAPI schema for image clustering endpoints, add react-router-dom dependency, refactor onboarding steps to fix progress tracking and state persistence using 0-based indexing, and add sign-out functionality to the Settings page with localStorage clearing.

Changes

Cohort / File(s) Summary
OpenAPI Schema Updates
docs/backend/backend_python/openapi.json
Modified Face Clusters Face Search endpoint: wrapped input_type parameter's InputType schema in allOf composition and added "Input Type" title. Removed additionalProperties: true from ImageInCluster.Metadata, constraining it to defined properties only.
Dependency Addition
frontend/package.json
Added react-router-dom (^7.10.1) dependency to support navigation functionality.
Onboarding Step Components
frontend/src/components/OnboardingSteps/{AvatarSelectionStep,FolderSetupStep,ThemeSelectionStep}.tsx
Unified refactor: Switched step progress tracking from 1-based to 0-based indexing across UI labels and calculations. Removed auto-completion dispatches; now load saved values from localStorage on initialization. Restored unconditional rendering by removing guards that bypassed render when state exists. FolderSetupStep additionally persists folder path to localStorage.
Settings Page Enhancement
frontend/src/pages/SettingsPage/Settings.tsx
Added sign-out flow: imported useNavigate and Button; defined handleSignOut to clear localStorage and reload to root; rendered new "Sign Out" button aligned right.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • OpenAPI schema changes: Verify that schema composition change (direct $refallOf wrapper) and additionalProperties constraint do not break code generation or client contracts.
  • Onboarding components: Confirm 0-based indexing change is consistent across all three step components and correctly reflects progress. Validate localStorage persistence flow works as expected without side effects.
  • Settings sign-out: Ensure localStorage clearing is comprehensive and hard reload properly resets application state.

Possibly related PRs

Suggested labels

frontend

Poem

🐰 Hops through the steps with numbers now clear,
Zero-based indexing brings progress near.
Save to localStorage, persist with care,
Sign out and reload—off to fresh air!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the PR's core purpose: fixing registration and sign-out issues (#693), and aligns with all major changes (step counter corrections, removed auto-advance logic, localStorage persistence, and Sign Out functionality).
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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: 5

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d07d817 and 59d863b.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • docs/backend/backend_python/openapi.json (1 hunks)
  • frontend/package.json (1 hunks)
  • frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx (2 hunks)
  • frontend/src/components/OnboardingSteps/FolderSetupStep.tsx (3 hunks)
  • frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx (1 hunks)
  • frontend/src/pages/SettingsPage/Settings.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/src/pages/SettingsPage/Settings.tsx (1)
frontend/src/components/ui/button.tsx (1)
  • Button (59-59)
🔇 Additional comments (6)
docs/backend/backend_python/openapi.json (3)

1120-1128: OpenAPI schema refactor aligns with 3.1.0 best practices.

The change from a direct $ref to an allOf composition with explicit title and default metadata is a valid OpenAPI 3.1.0 pattern that improves schema clarity without changing the API contract. This allows tools and documentation generators to better understand the parameter intent.


2204-2213: Scope mismatch: backend API schema changes unrelated to PR objectives.

The PR objectives describe frontend registration and sign-out flow fixes, yet this OpenAPI schema file contains backend changes. The changes themselves appear sound (tightening metadata validation by removing additionalProperties), but their inclusion here suggests either unintended scope creep or incidental updates decoupled from the stated PR goals.

Please clarify: Are these backend schema changes intentional and part of the same issue #693 fix, or were they accidentally included?


2204-2213: Verify that metadata schema constraint change does not break existing consumers.

The removal of additionalProperties: true from the metadata object now prevents unknown properties. If downstream consumers rely on storing additional metadata fields beyond the defined schema, this will break their integrations. This concern requires verification against actual usage patterns in the codebase to confirm whether any consumers depend on dynamic metadata properties.

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

34-37: LGTM: Proper state persistence for folder path.

Loading the saved folder path from localStorage on mount and persisting it on Next enables proper state restoration during navigation, addressing the navigation issues mentioned in the PR objectives.

Also applies to: 57-57

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

37-45: LGTM: Proper state restoration for name and avatar.

Loading saved name and avatar from localStorage on mount enables proper state restoration during backward navigation, addressing the navigation issues mentioned in the PR objectives.

frontend/package.json (1)

65-65: No action required. React Router v7.10.1 is compatible with React 19.1.0 and is a stable, well-supported version with explicit React 19 compatibility.

<div className="text-muted-foreground mb-1 flex justify-between text-xs">
<span>
Step {stepIndex + 1} of {totalSteps}
Step {stepIndex} of {totalSteps}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical UX issue: 0-based step indexing displays "Step 0 of 3".

The change from 1-based to 0-based indexing will display "Step 0 of 3" for the first step and show 0% progress, which is confusing for users. Step labels should be 1-based for display purposes even if internal indexing is 0-based.

Apply this diff to restore proper display indexing:

            <span>
-              Step {stepIndex} of {totalSteps}
+              Step {stepIndex + 1} of {totalSteps}
            </span>
-            <span>{Math.round((stepIndex / totalSteps) * 100)}%</span>
+            <span>{Math.round(((stepIndex + 1) / totalSteps) * 100)}%</span>
            <div
              className="bg-primary h-full rounded-full transition-all duration-300"
-              style={{ width: `${(stepIndex / totalSteps) * 100}%` }}
+              style={{ width: `${((stepIndex + 1) / totalSteps) * 100}%` }}
            />

Also applies to: 72-72, 77-77

🤖 Prompt for AI Agents
In frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx around lines
70, 72 and 77, the UI is using a 0-based stepIndex directly which shows "Step 0
of 3" and 0% progress; update the display to use 1-based numbering by rendering
(stepIndex + 1) for the step label and adjust any progress calculation/display
to use (stepIndex + 1) or compute progress from (stepIndex + 1) over totalSteps
so the first step reads "Step 1 of N" and shows correct non-zero progress while
leaving internal indexing unchanged.

return null;
}
const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
const progressPercent = Math.round((stepIndex / totalSteps) * 100);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical UX issue: 0-based step indexing displays "Step 0 of 3".

The change from 1-based to 0-based indexing will display "Step 0 of 3" for the first step and show 0% progress, which is confusing for users. Step labels should be 1-based for display purposes even if internal indexing is 0-based.

Apply this diff to restore proper display indexing:

-  const progressPercent = Math.round((stepIndex / totalSteps) * 100);
+  const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
            <span>
-              Step {stepIndex} of {totalSteps}
+              Step {stepIndex + 1} of {totalSteps}
            </span>

Also applies to: 74-74

}

const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
const progressPercent = Math.round((stepIndex / totalSteps) * 100);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical UX issue: 0-based step indexing displays "Step 0 of 3".

The change from 1-based to 0-based indexing will display "Step 0 of 3" for the first step and show 0% progress, which is confusing for users. Step labels should be 1-based for display purposes even if internal indexing is 0-based.

Apply this diff to restore proper display indexing:

-  const progressPercent = Math.round((stepIndex / totalSteps) * 100);
+  const progressPercent = Math.round(((stepIndex + 1) / totalSteps) * 100);
            <span>
-              Step {stepIndex} of {totalSteps}
+              Step {stepIndex + 1} of {totalSteps}
            </span>

Also applies to: 61-61

🤖 Prompt for AI Agents
In frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx around lines
54 and 61, the UI uses the 0-based stepIndex directly which produces "Step 0 of
N" and 0% progress on the first step; update the display and progress
calculation to use a 1-based value by adding 1 to stepIndex for user-facing text
and percent (e.g., use stepIndex+1 when computing progressPercent and when
rendering the "Step X of Y" label), and ensure values are clamped/rounded as
before so progressPercent remains an integer between 0 and 100.

* Acts as an orchestrator for the settings sections
*/
const Settings: React.FC = () => {
const navigate = useNavigate();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Remove unused navigate variable.

The navigate hook is declared but never used in this component.

Apply this diff to remove the unused variable:

-  const navigate = useNavigate();
-
📝 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 navigate = useNavigate();
🤖 Prompt for AI Agents
In frontend/src/pages/SettingsPage/Settings.tsx around line 15, the hook
variable "const navigate = useNavigate();" is declared but never used; remove
that line and also remove the useNavigate import from the top of the file (or
the entire named import from react-router if it becomes unused) so there are no
unused variables/imports remaining.

Comment on lines +17 to +22
const handleSignOut = () => {
// 1. Wipe all local storage (Auth, Folder, Name)
localStorage.clear();
// 2. Force a hard reload to reset state and go to Welcome screen
window.location.href = '/';
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Inconsistent navigation approach: hard reload defeats React Router.

Using window.location.href = '/' triggers a full page reload, which negates the benefits of React Router's SPA navigation. This also conflicts with importing useNavigate.

If a hard reload is truly necessary to reset application state, remove the unused useNavigate import. Otherwise, use navigate('/') for proper SPA navigation and ensure state cleanup happens through proper React/Redux patterns.

Option 1: Use React Router navigation (recommended)

  const handleSignOut = () => {
-    // 1. Wipe all local storage (Auth, Folder, Name)
     localStorage.clear();
-    // 2. Force a hard reload to reset state and go to Welcome screen
-    window.location.href = '/';
+    navigate('/');
  };

Option 2: If hard reload is required, remove unused import

- import { useNavigate } from 'react-router-dom';

  const Settings: React.FC = () => {
-  const navigate = useNavigate();
-
    const handleSignOut = () => {
      localStorage.clear();
      window.location.href = '/';
    };
📝 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 handleSignOut = () => {
// 1. Wipe all local storage (Auth, Folder, Name)
localStorage.clear();
// 2. Force a hard reload to reset state and go to Welcome screen
window.location.href = '/';
};
const handleSignOut = () => {
localStorage.clear();
navigate('/');
};
🤖 Prompt for AI Agents
In frontend/src/pages/SettingsPage/Settings.tsx around lines 17-22, the sign-out
handler clears localStorage then uses window.location.href='/' which forces a
hard reload and leaves the imported useNavigate unused; replace the hard reload
with React Router navigation by calling navigate('/') (after obtaining const
navigate = useNavigate()) and keep state cleanup via React/Redux flows, or if a
full reload is truly required remove the unused useNavigate import—choose one
approach and update the handler and imports accordingly.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them:
https://www.youtube.com/watch?v=Sqsz1-o7nXk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant