Skip to content

Conversation

@V4Vikaskumar
Copy link

@V4Vikaskumar V4Vikaskumar commented Dec 24, 2025

Summary

This PR improves the local development experience by clearly defining separate commands for running the backend and the Tauri frontend.


Why this change

Earlier, the development workflow was not very clear for first-time contributors.
By using explicit and independent commands, the setup and execution process becomes easier to understand and follow.


How this helps new contributors

  • Simple and clear commands to start the project
  • No confusion about which service runs where
  • Faster local setup with fewer troubleshooting steps
  • Easier debugging since backend and frontend run independently

Overall benefit

These changes make project setup more straightforward and consistent, helping both new and existing contributors run the project smoothly with less effort.


After this Command

After.this.command.mp4

I experimented with creating a single command to run both the frontend and backend, but I failed every time, as repeated attempts caused issues such as infinite loops and improper shutdown handling.

Related Issue

Fixes #837

Summary by CodeRabbit

  • Documentation

    • Added React Hooks Guidelines section covering dependency array best practices and ESLint compliance.
  • Chores

    • Added new npm scripts for running backend (npm run backend) and frontend (npm run frontend) environments.
  • Bug Fixes

    • Improved reliability of onboarding step completion tracking.
    • Enhanced server check error handling and database transaction management.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2025

📝 Walkthrough

Walkthrough

This change set addresses React hooks best practices in onboarding components by correcting useEffect dependency arrays, adds conditional database connection handling in the backend, includes React hooks documentation guidelines, and introduces npm scripts for running backend and frontend services during development.

Changes

Cohort / File(s) Summary
Backend Database Connection Management
backend/app/database/face_clusters.py
Modified database commit and connection closure to be conditional—now only triggered when the function creates its own connection (own_connection is True), preventing unintended resource management on borrowed connections
React Hooks Guidelines Documentation
docs/frontend/state-management.md
Added new React Hooks Guidelines section documenting dependency array rules for useEffect, discouraging empty dependency arrays for props/dispatch/context, and requiring ESLint compliance with React Rules of Hooks
Onboarding Steps — Dependency Array Corrections
frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx, FolderSetupStep.tsx, ThemeSelectionStep.tsx, ServerCheck.tsx
Updated useEffect dependency arrays from empty ([]) to include dispatch and stepIndex, enabling proper re-runs when these dependencies change. ServerCheck also adds early returns for loading and error states to prevent further processing
Advanced Onboarding Logic
frontend/src/components/OnboardingSteps/UpdateStep.tsx
Introduced isMount flag to guard asynchronous work against unmount race conditions; added cleanup function and early returns in async checks; extended dependency array to include dispatch, stepIndex, and checkForUpdates
Development Scripts
package.json
Added two new npm scripts: backend (runs uvicorn) and frontend (runs Tauri development build) to simplify local development startup

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

documentation, good first issue

Poem

A rabbit hops through dependencies so fine, 🐰
Hooks aligned in perfect time!
From backend gates to frontend views,
Connection flows in all the hues—
One script to start them all in line! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR adds individual dev:backend and dev:frontend commands as required [#837], but fails to implement the primary requirement: a unified 'npm run dev' command using concurrently to run both services together. Add a root-level 'dev' script using concurrently to run dev:backend and dev:frontend simultaneously, completing the unified workflow requested in issue #837.
Out of Scope Changes check ⚠️ Warning The PR includes unrelated changes to onboarding step components (AvatarSelectionStep, FolderSetupStep, ServerCheck, ThemeSelectionStep, UpdateStep) and documentation that are not addressed by issue #837's requirements. Remove or isolate changes unrelated to issue #837 (onboarding step modifications and docs). Focus PR on separating backend and frontend commands only, or document why these changes are necessary.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 clearly describes the main change: separating backend and Tauri frontend commands to improve dev workflow, and references issue #837.
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
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

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

36-42: LGTM! Clearer logic with proper dependencies.

The changes improve readability by extracting localStorage checks into variables and correctly include dispatch and stepIndex in the dependency array.

Minor: Add space in dependency array for consistency

For consistency with other onboarding step files in this PR:

-  }, [dispatch,stepIndex]);
+  }, [dispatch, stepIndex]);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 917daff and b2d0c49.

⛔ Files ignored due to path filters (2)
  • frontend/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • backend/app/database/face_clusters.py
  • docs/frontend/state-management.md
  • frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx
  • frontend/src/components/OnboardingSteps/FolderSetupStep.tsx
  • frontend/src/components/OnboardingSteps/ServerCheck.tsx
  • frontend/src/components/OnboardingSteps/ThemeSelectionStep.tsx
  • frontend/src/components/OnboardingSteps/UpdateStep.tsx
  • package.json
🧰 Additional context used
🧬 Code graph analysis (3)
frontend/src/components/OnboardingSteps/UpdateStep.tsx (2)
frontend/src/features/loaderSlice.ts (2)
  • showLoader (17-20)
  • hideLoader (21-24)
frontend/src/features/onboardingSlice.ts (1)
  • markCompleted (31-42)
frontend/src/components/OnboardingSteps/ServerCheck.tsx (2)
frontend/src/features/loaderSlice.ts (1)
  • hideLoader (21-24)
frontend/src/features/onboardingSlice.ts (1)
  • markCompleted (31-42)
frontend/src/components/OnboardingSteps/AvatarSelectionStep.tsx (1)
frontend/src/features/onboardingSlice.ts (1)
  • markCompleted (31-42)
🔇 Additional comments (8)
backend/app/database/face_clusters.py (1)

229-235: LGTM! Consistent connection management pattern.

The conditional commit and close operations now match the pattern used throughout this file (e.g., db_delete_all_clusters, db_insert_clusters_batch), ensuring proper resource management when using external vs. owned connections.

frontend/src/components/OnboardingSteps/ServerCheck.tsx (3)

38-42: LGTM! Proper early return during loading state.

The early return prevents dispatching hideLoader or other actions while still loading, which is the correct behavior.


43-57: LGTM! Proper error handling with early exit.

The early return after initiating the exit prevents any subsequent logic from executing, which is appropriate given the error state.


63-72: LGTM! Comprehensive dependency array.

The dependency array now includes all values used within the effect (dispatch, stepIndex, and all query states), following React's Rules of Hooks and preventing stale closures.

docs/frontend/state-management.md (1)

239-246: LGTM! Clear hooks guidelines.

The documentation appropriately describes React hooks best practices and aligns with the dependency array updates made across the onboarding components in this PR.

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

33-37: LGTM! Proper dependency array for useEffect.

The dependency array now includes dispatch and stepIndex, ensuring the effect re-runs if the step index changes and following exhaustive-deps rules.

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

33-37: LGTM! Consistent dependency array pattern.

Matches the pattern applied across other onboarding steps, properly including dispatch and stepIndex in the dependency array.

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

25-45: LGTM! Proper async effect with unmount guard.

The implementation correctly:

  • Uses a mounted flag (isMount) to prevent state updates after unmount
  • Includes cleanup function to set the flag to false
  • Guards both the check initiation and completion dispatch with the mount flag
  • Includes checkForUpdates from the custom hook in dependencies

This prevents race conditions and "Can't perform a React state update on an unmounted component" warnings.

Comment on lines +6 to +18
"scripts": {
"backend": "cd backend && uvicorn main:app --reload",
"frontend": "cd frontend\\src-tauri && cargo tauri dev",
"linux-dev": "bash ./scripts/linux-dev.sh",
"win-dev": "cd scripts && win-dev.bat",
"prepare": "husky",
"lint:check": "cd frontend && eslint --max-warnings 0 --config .eslintrc.json .",
"lint:fix": "cd frontend && eslint --max-warnings 0 --config .eslintrc.json . --fix",
"format:fix": "cd frontend && prettier --write \"**/*.{ts,tsx,json}\"",
"format:check": "cd frontend && prettier --check \"**/*.{ts,tsx,json}\"",
"cargo:check": "cd backend && cargo check",
"setup": "cd scripts && node setup.js"
},
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

Major: PR objectives not fully met - missing unified "dev" command and "concurrently" package.

The PR objectives explicitly state:

  • "Provide root-level scripts (e.g., dev:backend, dev:frontend, and a combined dev)"
  • "Enable a single entrypoint (e.g., npm run dev) using a cross-platform process runner (suggested: concurrently)"

Current implementation:

  1. ✅ Separate backend and frontend scripts provided
  2. ❌ No unified dev script to run both services together
  3. concurrently package not installed
🔎 Proposed fix to meet PR objectives

First, install concurrently:

npm install --save-dev concurrently

Then update package.json:

     "scripts": {
-        "backend": "cd backend && uvicorn main:app --reload",
-        "frontend": "cd frontend\\src-tauri && cargo tauri dev",
+        "dev": "concurrently \"npm run dev:backend\" \"npm run dev:frontend\"",
+        "dev:backend": "cd backend && uvicorn main:app --reload",
+        "dev:frontend": "cd frontend/src-tauri && cargo tauri dev",
         "linux-dev": "bash ./scripts/linux-dev.sh",

This provides:

  • Individual commands: npm run dev:backend, npm run dev:frontend
  • Unified command: npm run dev (runs both with concurrently)
  • Cross-platform compatibility via concurrently

Note: The PR title mentions this "fixes #837" which specifically requested a unified workflow, so this is a blocker for the stated objectives.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
package.json lines 6-18: the PR missed adding a unified dev script and the
concurrently devDependency; install concurrently as a devDependency (npm install
--save-dev concurrently) and update the scripts section to expose dev:backend
and dev:frontend (reusing the existing backend and frontend commands) and add a
new dev script that runs both with concurrently (e.g., "dev": "concurrently
\"npm:dev:backend\" \"npm:dev:frontend\"") so a single npm run dev starts both
services cross-platform.

},
"scripts": {
"backend": "cd backend && uvicorn main:app --reload",
"frontend": "cd frontend\\src-tauri && cargo tauri dev",
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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Search for tauri.conf.json to understand the directory structure
fd -t f "tauri.conf.json"

Repository: AOSSIE-Org/PictoPy

Length of output: 96


🏁 Script executed:

# Check the directory structure under frontend
fd -type d "frontend" -o -type d "src-tauri" | head -20

Repository: AOSSIE-Org/PictoPy

Length of output: 232


🏁 Script executed:

# List the actual directory structure
ls -la frontend 2>/dev/null | head -20

Repository: AOSSIE-Org/PictoPy

Length of output: 1279


🏁 Script executed:

# Check the full package.json to see all scripts and how paths are used
cat package.json

Repository: AOSSIE-Org/PictoPy

Length of output: 920


🏁 Script executed:

# Check the content of tauri.conf.json to understand the project structure
cat frontend/src-tauri/tauri.conf.json

Repository: AOSSIE-Org/PictoPy

Length of output: 1927


🏁 Script executed:

# Check if there's a Cargo.toml in the src-tauri directory
ls -la frontend/src-tauri/ | grep -E "Cargo|tauri"

Repository: AOSSIE-Org/PictoPy

Length of output: 252


Cross-platform compatibility broken by Windows-specific path separator.

The frontend script uses backslashes (\\), which only work on Windows. This breaks compatibility on macOS and Linux.

-    "frontend": "cd frontend\\src-tauri && cargo tauri dev",
+    "frontend": "cd frontend/src-tauri && cargo tauri dev",

Forward slashes work on all platforms. The directory path frontend/src-tauri is correct (Cargo.toml and tauri.conf.json are located there).

📝 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
"frontend": "cd frontend\\src-tauri && cargo tauri dev",
"frontend": "cd frontend/src-tauri && cargo tauri dev",
🤖 Prompt for AI Agents
In package.json around line 8, the "frontend" npm script uses a Windows-only
backslash path ("cd frontend\\src-tauri && cargo tauri dev"); replace the
backslash with a forward slash so the script is cross-platform (use "cd
frontend/src-tauri && cargo tauri dev") or otherwise use a platform-agnostic
approach (e.g., run the command from the project root with the forward-slash
path). Ensure the script points to frontend/src-tauri exactly and works on
macOS/Linux and Windows.

@V4Vikaskumar V4Vikaskumar marked this pull request as draft December 24, 2025 16:58
@V4Vikaskumar V4Vikaskumar marked this pull request as ready for review December 24, 2025 17:10
@nugget-cloud
Copy link

nugget-cloud commented Dec 25, 2025

@V4Vikaskumar why did you change the package manager from npm to pnpm
why have you written a documentation on react hooks ??

@V4Vikaskumar
Copy link
Author

@nugget-cloud you are right. now i fix this and i am working now.

@V4Vikaskumar V4Vikaskumar marked this pull request as draft December 26, 2025 06:30
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.

DX Improvement: No single command to run backend + frontend (onboarding friction)

2 participants