Skip to content

feat: add onboarding tour for first-time users#58

Merged
jpdevhub merged 10 commits into
jpdevhub:mainfrom
prachishelke1312:feature-onboarding-tour
Jun 19, 2026
Merged

feat: add onboarding tour for first-time users#58
jpdevhub merged 10 commits into
jpdevhub:mainfrom
prachishelke1312:feature-onboarding-tour

Conversation

@prachishelke1312

@prachishelke1312 prachishelke1312 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #16

Adds a first-time onboarding tour using react-joyride to help users understand the main workflows in AgroNavis.

Changes

  • Added OnboardingTour component

  • Added onboarding steps for:

    • Farm location search
    • Polygon mapping
    • Boundary confirmation
    • Leaf image upload
    • Disease scan
  • Added tour target IDs in PolygonMapper

  • Added upload target ID in CropScanTab

  • Integrated onboarding tour into Dashboard

  • Added react-joyride dependency

Testing

  • npm run lint
  • npm run build

Build completed successfully.

Summary by CodeRabbit

  • New Features

    • Added a first-visit onboarding tour that guides users through polygon mapping, map interaction, boundary confirmation, and crop scan upload/scan.
  • Implementation Updates

    • Integrated the tour into the main dashboard so it appears during normal navigation.
    • Added stable UI identifiers and updated the map/upload layout to ensure tour steps target the correct controls.
  • Chores

    • Updated the project prepare script to run Husky without fallback.
    • Added react-joyride for the tour and removed the prior local dependency entry.

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@prachishelke1312 is attempting to deploy a commit to the karan3431's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

🎉 Thanks for your contribution, @prachishelke1312!

Please make sure CI passes and the checklist in the PR template is complete. A maintainer will review this soon.

— The AgroNavis team

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a first-time onboarding tour using react-joyride. A new OnboardingTour component checks localStorage on mount and activates a Joyride instance with five steps targeting specific DOM element IDs. Stable IDs are added to PolygonMapper and CropScanTab. The component is rendered at the top of Dashboard. Additionally, the npm prepare script now fails on husky errors instead of suppressing them.

Changes

Onboarding Tour

Layer / File(s) Summary
react-joyride dependency and OnboardingTour component
frontend/package.json, frontend/src/components/OnboardingTour.tsx
react-joyride is added as a dependency. OnboardingTour is created with a run state flag set on mount by reading localStorage["agronavis-tour-seen"]; when absent, Joyride renders with five steps targeting named DOM IDs. A separate effect derives the active tab from stepIndex, and onEvent updates both stepIndex and tab selection.
Dashboard integration
frontend/src/components/Dashboard.tsx
OnboardingTour is imported and rendered at the top of Dashboard, receiving setActiveTab as a prop to control tab navigation during the tour.
DOM instrumentation for tour targets
frontend/src/components/map/PolygonMapper.tsx, frontend/src/components/CropScanTab.tsx
id="polygon-search" wrapper div is added around the search box, id="polygon-map" wrapper div is added around MapInner, and id="confirm-boundary-btn" is added to the "Add field →" button in PolygonMapper; id="cropscan-upload-zone" is added to the upload drop-zone in CropScanTab, providing the DOM anchors referenced by the Joyride steps.

Build Script Update

Layer / File(s) Summary
Husky error propagation
package.json
The prepare script now runs husky directly without the || true fallback, causing build failures when husky hooks fail instead of silently succeeding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • jpdevhub
  • JainamDedhia

Poem

🐇 Hop, hop, first-time friend!
A tour to guide you start to end,
Click the map, upload a leaf,
No confusion, no grief!
LocalStorage seals the deal —
One tour shown, then conceal. 🌱

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The package.json change updating the prepare script (husky || true → husky) is the only potentially out-of-scope modification; it relates to build/CI setup rather than the onboarding tour feature. Either justify the husky script change as necessary for this PR or move it to a separate pull request focused on build configuration improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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: add onboarding tour for first-time users' directly and clearly summarizes the main change: adding an onboarding tour feature.
Linked Issues check ✅ Passed The code changes fully implement the core requirements from issue #16: adds react-joyride library, creates OnboardingTour component with steps for polygon drawing and leaf scanning, integrates it into Dashboard, adds required DOM IDs, and implements tab-switching logic.

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

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

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.

@jpdevhub

jpdevhub commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Add the issue no.
the frontend is failing due to various error go through this error which ai is flagging :

The CI lint job is failing due to three critical issues in your frontend code:

1. Missing OnboardingTour Import (Critical Error)

File: frontend/src/components/Dashboard.tsx at line 277

The component uses <OnboardingTour /> but it's never imported or defined.

Fix:
Add the import at the top of Dashboard.tsx:

import OnboardingTour from './OnboardingTour'; // Add this line

Or if the component doesn't exist yet, create it or remove the usage from line 277 if it's not needed.


2. Syntax Error in PolygonMapper.tsx (Critical Error)

File: frontend/src/components/map/PolygonMapper.tsx around line 142

There's a malformed JSX closing tag. The parser is encountering an unexpected token.

Fix:
Review lines 141-151 and ensure proper JSX syntax. The current structure appears to have unclosed or misaligned tags:

<div style={{ position: 'relative', borderRadius: '12px', overflow: 'hidden', border: '1px solid var(--color-border-tertiary)' }}>
  <div style={{position: 'absolute',top: '12px',right: '200px',zIndex: 800}}>
    <WeatherStatusBadge lat={mapCenter.lat} lng={mapCenter.lng}/>
  </div>
  <MapInner
    center={mapCenter}
    zoom={mapZoom}
    points={points}
    onMapClick={addPoint}
  />
  {/* Rest of JSX... */}
</div>

Verify all tags are properly closed and aligned.


3. Missing React Hook Dependencies (Warnings)

Files: Dashboard.tsx, PWAInstallPrompt.tsx, WeatherStatusBadge.tsx

Several useEffect hooks have missing dependencies. While these are warnings, they should be addressed:

  • Dashboard.tsx (line 193): Add router and setActiveTab to dependencies
  • PWAInstallPrompt.tsx (line 69, 75): Add t and fetchWeather to dependencies
  • WeatherStatusBadge.tsx (line 59, 65): Add t and fetchWeatherData to dependencies

Example fix:

useEffect(() => {
  const mode = router.query.mode as string;
  const farmId = router.query.farmId as string;
  if (mode === 'draw' && farmId && farms.length > 0) {
    setSelectedFarmId(farmId);
    setActiveTab('map');
    router.replace('/dashboard', undefined, { shallow: true });
  }
}, [router.query, farms, router, setActiveTab]); // Add router and setActiveTab

Summary

  1. Import OnboardingTour in Dashboard.tsx or remove its usage
  2. Fix JSX syntax in PolygonMapper.tsx (check for unclosed tags around line 142)
  3. Add missing dependencies to useEffect hooks across multiple files

These fixes will resolve the ESLint errors blocking your CI pipeline.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 (2)
frontend/src/components/CropScanTab.tsx (1)

97-104: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing dependency in useEffect hook.

The hook calls loadHistory() (line 103), but loadHistory is not in the dependency array. Since loadHistory is defined with useCallback, it should be included.

♻️ Proposed fix to add missing dependency
   useEffect(() => {
     farmApi.getFarms().then((data: Farm[]) => {
       setFarms(data || [])
     }).catch(console.error)
 
     // Load all scan history
     loadHistory()
-  }, [])
+  }, [loadHistory])
🤖 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/CropScanTab.tsx` around lines 97 - 104, The useEffect
hook in CropScanTab.tsx calls the loadHistory function but does not include it
in the dependency array. Since loadHistory is defined with useCallback, add
loadHistory to the dependency array of the useEffect hook (currently an empty
array) to ensure the effect properly responds to changes in the loadHistory
function and follows React's rules of hooks.
frontend/src/components/Dashboard.tsx (1)

184-193: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Missing dependencies in useEffect hook.

The hook depends on router (used on line 191) and setActiveTab (used on line 190), but they are not in the dependency array. This can cause stale closures.

♻️ Proposed fix to add missing dependencies
   useEffect(() => {
     const mode = router.query.mode as string;
     const farmId = router.query.farmId as string;
     if (mode === 'draw' && farmId && farms.length > 0) {
       setSelectedFarmId(farmId);
       setActiveTab('map');
       router.replace('/dashboard', undefined, { shallow: true });
     }
-  }, [router.query, farms]);
+  }, [router.query, farms, router, setActiveTab]);
🤖 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/Dashboard.tsx` around lines 184 - 193, The useEffect
hook in the Dashboard component uses router and setActiveTab but they are
missing from the dependency array. Add router, setActiveTab, and
setSelectedFarmId to the dependency array of the useEffect hook so that the
effect properly re-runs when these dependencies change and avoids stale closure
issues.
🤖 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/Dashboard.tsx`:
- Line 277: The OnboardingTour component is used in the file but lacks an import
statement, causing a build failure. Add an import statement for OnboardingTour
at the top of the file alongside the other component imports to resolve the
missing dependency.

In `@frontend/src/components/OnboardingTour.tsx`:
- Around line 7-13: The component reads the "agronavis-tour-seen" localStorage
key in the useEffect hook to determine if the tour should run, but it never
writes to this key after the tour completes. Add a callback prop to the Joyride
component that fires when the tour finishes, and in that callback function, set
localStorage.setItem("agronavis-tour-seen", "true") to persist the completion
state so the tour only runs once.

---

Outside diff comments:
In `@frontend/src/components/CropScanTab.tsx`:
- Around line 97-104: The useEffect hook in CropScanTab.tsx calls the
loadHistory function but does not include it in the dependency array. Since
loadHistory is defined with useCallback, add loadHistory to the dependency array
of the useEffect hook (currently an empty array) to ensure the effect properly
responds to changes in the loadHistory function and follows React's rules of
hooks.

In `@frontend/src/components/Dashboard.tsx`:
- Around line 184-193: The useEffect hook in the Dashboard component uses router
and setActiveTab but they are missing from the dependency array. Add router,
setActiveTab, and setSelectedFarmId to the dependency array of the useEffect
hook so that the effect properly re-runs when these dependencies change and
avoids stale closure issues.
🪄 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 Plus

Run ID: c8626804-b0e5-40d2-858c-4fe4126d5d76

📥 Commits

Reviewing files that changed from the base of the PR and between 58186ea and 70495c5.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • frontend/package.json
  • frontend/src/components/CropScanTab.tsx
  • frontend/src/components/Dashboard.tsx
  • frontend/src/components/OnboardingTour.tsx
  • frontend/src/components/map/PolygonMapper.tsx

Comment thread frontend/src/components/Dashboard.tsx Outdated
Comment thread frontend/src/components/OnboardingTour.tsx
@jpdevhub

Copy link
Copy Markdown
Owner

Still failing and some
At line 277 of Dashboard.tsx, the component uses , but this component is never imported. This causes an ESLint error: 'OnboardingTour' is not defined.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@package.json`:
- Line 12: The package.json manifest has been modified (including the prepare
script), but the corresponding lockfile(s) have not been updated, causing npm ci
to fail in CI. Regenerate the lockfile by running npm install locally, which
will update package-lock.json (and any other lockfiles like npm-shrinkwrap.json
if present) to reflect the changes in package.json, then commit the updated
lockfile(s) along with the package.json changes to make the PR installable in
CI.
🪄 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 Plus

Run ID: 1f07d325-82db-49c7-b264-b0100194acb8

📥 Commits

Reviewing files that changed from the base of the PR and between 284eec3 and 53b1650.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json

Comment thread package.json
@prachishelke1312

Copy link
Copy Markdown
Contributor Author

Resolved the requested CI issues.

Changes made:

  • Added the missing OnboardingTour import in Dashboard.tsx
  • Fixed the PolygonMapper JSX issue
  • Updated dependencies and lockfile consistency

Current status:

  • Frontend lint & build ✅
  • Backend checks ✅
  • Security checks ✅

Could you please re-review the PR when convenient?

@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agronavis-ai-farm-assiatant Ready Ready Preview, Comment Jun 19, 2026 1:14pm

@jpdevhub

Copy link
Copy Markdown
Owner

Thanks for working on this! The onboarding tour is a fantastic idea and installing react-joyride was the perfect choice. The design of the steps is exactly what we need.

I was testing this out locally and noticed two issues that cause the tour to crash when logging in:

  1. Missing Search Bar ID
    In frontend/src/components/OnboardingTour.tsx, the first step targets #polygon-search. However, that ID hasn't been added to the actual Mapbox Geocoder component in PolygonMapper.tsx yet! Can you wrap or attach the id="polygon-search" attribute to the location search bar?

  2. Cross-Tab DOM Issues (The tricky one!)
    Because this is a Single Page Application, elements from the Map and CropScan tabs don't exist in the browser's DOM when the user is on the main Dashboard overview.

When react-joyride tries to find #polygon-map, it throws an error and breaks the tour because the user hasn't clicked on the "Field Map" tab yet.

To fix this, we need to programmatically switch tabs using Joyride's callback prop. Could you modify OnboardingTour.tsx to accept the setActiveTab function from Dashboard.tsx? Then, inside OnboardingTour, you can listen to step changes:

Before step 1 (Map steps), call setActiveTab('map')
Before step 3 (CropScan steps), call setActiveTab('cropscan')
If you need any help intercepting the Joyride steps to trigger the tab changes, just let me know!

Looking forward to merging this once those DOM issues are ironed out!

@prachishelke1312

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

I've addressed the reported issues:

  • Added the missing OnboardingTour integration in Dashboard.tsx.
  • Fixed the JSX structure issues in PolygonMapper.tsx.
  • Added the required DOM targets (polygon-search, polygon-map, etc.) used by the onboarding tour.
  • Resolved the frontend build and type-check errors related to the onboarding implementation.
  • Verified locally with npm run build and the build completes successfully.

I've pushed the latest changes to this PR. Could you please take another look and let me know if there's anything else that needs adjustment?

Thank you!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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/map/PolygonMapper.tsx (1)

252-256: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

#confirm-boundary-btn target is conditionally mounted, so the tour step can miss its target.

At Line 252/Line 255, the button exists only when isComplete is true. The onboarding step that targets #confirm-boundary-btn can fail for first-time users before polygon completion. Keep the target mounted consistently (e.g., render a disabled button with the same id until complete), or retarget the step to an always-present container.

Suggested minimal fix
-          {isComplete && (
-            <button
-              onClick={handleConfirm}
-              id="confirm-boundary-btn"
+          <button
+              onClick={handleConfirm}
+              id="confirm-boundary-btn"
+              disabled={!isComplete}
               style={{
                 padding: '6px 16px',
                 border: 'none',
                 borderRadius: '6px',
                 background: '`#16a34a`',
                 fontSize: '13px',
-                cursor: 'pointer',
+                cursor: isComplete ? 'pointer' : 'not-allowed',
                 color: 'white',
                 fontWeight: 500,
+                opacity: isComplete ? 1 : 0.6,
               }}
             >
               Add field →
-            </button>
-          )}
+          </button>
🤖 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/map/PolygonMapper.tsx` around lines 252 - 256, The
button with id "confirm-boundary-btn" in the handleConfirm block is
conditionally rendered only when isComplete is true, which causes the onboarding
tour step targeting it to fail for first-time users before polygon completion.
Fix this by keeping the button mounted at all times but rendering it in a
disabled state until isComplete becomes true, or alternatively by retargeting
the tour step to target a parent container or other always-present element
instead of the conditionally mounted button.
🤖 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/Dashboard.tsx`:
- Line 278: The OnboardingTour component receives setActiveTab as a prop but is
not using Joyride callbacks to preemptively switch tabs before steps that target
elements in the map or cropscan tabs are displayed. Modify the OnboardingTour
component to implement Joyride's callback mechanism (such as the callback prop
with event types like before or after) to call setActiveTab to switch to the
appropriate tab (map or cropscan) before advancing to steps that target
selectors within those tabs. This ensures the target elements are mounted and
accessible when Joyride tries to display them, preventing the tour from breaking
when activeTab is overview.

---

Outside diff comments:
In `@frontend/src/components/map/PolygonMapper.tsx`:
- Around line 252-256: The button with id "confirm-boundary-btn" in the
handleConfirm block is conditionally rendered only when isComplete is true,
which causes the onboarding tour step targeting it to fail for first-time users
before polygon completion. Fix this by keeping the button mounted at all times
but rendering it in a disabled state until isComplete becomes true, or
alternatively by retargeting the tour step to target a parent container or other
always-present element instead of the conditionally mounted button.
🪄 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 Plus

Run ID: 21e2b771-1a3e-4b07-8288-921370198cbc

📥 Commits

Reviewing files that changed from the base of the PR and between 53b1650 and d1fbc49.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • frontend/package.json
  • frontend/src/components/Dashboard.tsx
  • frontend/src/components/OnboardingTour.tsx
  • frontend/src/components/map/PolygonMapper.tsx
💤 Files with no reviewable changes (1)
  • frontend/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/OnboardingTour.tsx

Comment thread frontend/src/components/Dashboard.tsx
@prachishelke1312

Copy link
Copy Markdown
Contributor Author

Thanks for the review. I've updated the onboarding tour to switch tabs before steps targeting the Field Map and Crop Scan sections. The tour now uses Joyride event handling together with setActiveTab so the required elements are mounted before those steps are shown.

I also verified the project builds successfully after the change and pushed the update to the branch. Please take another look when you have a chance.

@jpdevhub jpdevhub left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for contributing

@jpdevhub jpdevhub merged commit 9175d29 into jpdevhub:main Jun 19, 2026
6 checks passed
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.

[Docs/UI] Create an Interactive Onboarding Tour

2 participants