Skip to content

Add IP Zip Code management in ShikshalokamChat and ShikshalokamVoiceChat Components - #205

Merged
Vinod-V3 merged 2 commits into
ELEVATE-Project:release-1.0.4from
VishnuKrishnathu:feature/ip-socket
Dec 4, 2025
Merged

Add IP Zip Code management in ShikshalokamChat and ShikshalokamVoiceChat Components#205
Vinod-V3 merged 2 commits into
ELEVATE-Project:release-1.0.4from
VishnuKrishnathu:feature/ip-socket

Conversation

@VishnuKrishnathu

@VishnuKrishnathu VishnuKrishnathu commented Dec 4, 2025

Copy link
Copy Markdown

…hat components

Summary by CodeRabbit

  • Refactor
    • Streamlined internal state management for voice chat to improve UI flow and reliability.
  • Enhancement
    • WebSocket authentication now includes expanded address details for more robust validation.
    • User data storage updated to capture and persist ZIP code from location initialization.

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

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown

Walkthrough

Refactors the Shikshalokam voice-chat component's internal state and effects, adds ipZipCode to user storage, and wires ZIP code into location initialization; WebSocket auth payload now includes a location-derived address and guards execution when location data is missing.

Changes

Cohort / File(s) Summary
Voice Chat State Refactor
src/pages/ShikshalokamVoiceChat/voice-chat.js
Large-scale internal state reorganization: many useState hooks added/removed/renamed, adjusted useEffect blocks and dependency arrays, WebSocket auth payload expanded to include address (from ipCity, ipState, ipZipCode) and guarded to skip on open if location pieces are missing, import adjustments (Swal, env).
ZIP Code State Management
src/store/slices/userData/state.js
Added ipZipCode property (initialized to null) and setIpZipCode setter to the exported INITIAL_STATE.
Location-Based ZIP Code Initialization
src/pages/shikshalokamChat.js
Retrieves setIpZipCode from user storage and sets ipZipCode during initial location setup when locationData.location.zip is available.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • src/pages/ShikshalokamVoiceChat/voice-chat.js: high-density hook changes, many effect dependency updates — verify hook ordering, state transitions, side-effect guards, and modal/loading flows.
  • WebSocket auth and onOpen guard: confirm address composition logic, dependency correctness (ipCity, ipState, ipZipCode) and that open is skipped only when appropriate.
  • src/store/slices/userData/state.js & src/pages/shikshalokamChat.js: confirm setIpZipCode integration and that ZIP is persisted/consumed consistently.

Poem

🐰 I hopped through hooks and tidy threads,
Added a zipcode where the pathway led,
WebSocket greets with a map in hand,
State rearranged across the land,
A tiny rabbit cheers — changes well planned! 🎉

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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main change: adding IP zip code management functionality to two specific components.
✨ 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.

@KUNALTEMPEST

Copy link
Copy Markdown

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

Caution

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

⚠️ Outside diff range comments (1)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)

190-204: Guard condition may silently prevent WebSocket authentication.

The early return at line 191 will prevent WebSocket authentication if any of ipCity, ipState, or ipZipCode is missing. If the IP location service fails or returns partial data, the user may be stuck without any feedback.

Consider either:

  1. Providing fallback values (e.g., empty strings or "Unknown")
  2. Logging a warning when location data is incomplete
  3. Making the address field optional in the authentication payload
 const onWebSocketOpen = useCallback(() => {
-  if (!ipCity || !ipState || !ipZipCode) return
+  const address = [ipCity, ipState, ipZipCode].filter(Boolean).join(", ") || ""
   sendSocketMessage({
     type: "authenticate",
     sessionid: sessionId,
     profileid: profileToUse,
     projectid: projectIdStore || searchParams.get("projectId") || "",
     taskid: searchParams.get("taskId") || taskId,
     access_token: accessToken,
     route: chatLanguage,
     bot_route: getSessionRoute(),
     flow_name: storageFlow,
-    address: `${ipCity}, ${ipState}, ${ipZipCode}`,
+    address,
   })
 }, [sessionId, profileToUse, projectIdStore, searchParams, taskId, accessToken, chatLanguage, storageFlow, ipCity, ipState, ipZipCode])
🧹 Nitpick comments (1)
src/pages/shikshalokamChat.js (1)

33-33: Minor pattern inconsistency with other IP setters.

setIpZipCode uses useUserStorage().getState() while setIpCity, setIpState, and setIpCountry (lines 30-32) use the selector pattern useUserStorage()(state => state.setX). This works correctly but creates inconsistency. Consider aligning with one pattern for maintainability.

-  const { setIpZipCode } = useUserStorage().getState()
+  const setIpZipCode = useUserStorage()(state => state.setIpZipCode)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a60e536 and 852e078.

📒 Files selected for processing (3)
  • src/pages/ShikshalokamVoiceChat/voice-chat.js (8 hunks)
  • src/pages/shikshalokamChat.js (2 hunks)
  • src/store/slices/userData/state.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/store/slices/userData/state.js (1)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)
  • ipZipCode (173-173)
src/pages/shikshalokamChat.js (4)
src/pages/ShikshalokamVoiceChat/voice-chat.js (1)
  • useUserStorage (179-179)
src/hooks/useStorage.js (2)
  • useUserStorage (24-26)
  • useUserStorage (24-26)
src/pages/UnifiedChat/UnifiedChat.jsx (1)
  • useUserStorage (18-18)
src/pages/UnifiedChat/UnifiedVoiceBasedChat.jsx (1)
  • useUserStorage (98-98)
src/pages/ShikshalokamVoiceChat/voice-chat.js (6)
src/pages/shikshalokamChat.js (5)
  • useUserStorage (18-18)
  • useUserStorage (33-33)
  • ipCity (22-22)
  • ipState (24-24)
  • accessToken (41-41)
src/pages/ssoFlow.jsx (1)
  • useSiteDataLocalStore (25-25)
src/api/endpoints/auth.js (1)
  • accessToken (18-18)
src/i18n.js (4)
  • languageToUse (13-13)
  • languageToUse (31-31)
  • setLanguage (29-34)
  • setLanguage (29-34)
src/pages/ShikshalokamVoiceChat/enum.js (4)
  • sessionFlowName (32-43)
  • sessionFlowName (32-43)
  • LANGUAGE_ENUMS (12-17)
  • LANGUAGE_ENUMS (12-17)
src/services/storage_service.js (1)
  • clearFromStorage (109-122)
🔇 Additional comments (4)
src/store/slices/userData/state.js (1)

10-18: LGTM!

The ipZipCode state property and its setter follow the established pattern used for other IP-related fields (ipCity, ipState, ipCountry). Clean and consistent implementation.

src/pages/shikshalokamChat.js (1)

134-139: LGTM!

The ZIP code is properly extracted from locationData.location.zip and set alongside other location fields, following the existing pattern.

src/pages/ShikshalokamVoiceChat/voice-chat.js (2)

171-173: LGTM!

The IP location state selectors are consistently implemented using the same pattern.


1227-1250: LGTM!

The ParentPerceptionSurvey completion flow is well-structured with proper cleanup (storage clearing, language reset, audio stop) before navigation. The guard conditions ensure the popup only shows when appropriate.

@VishnuKrishnathu VishnuKrishnathu changed the title Add IP Zip Code management in ShikshalokamChat and ShikshalokamVoiceC… Add IP Zip Code management in ShikshalokamChat and ShikshalokamVoiceChat Components Dec 4, 2025
@VishnuKrishnathu

Copy link
Copy Markdown
Author

@coderabbitai generate docstrings

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #206

coderabbitai Bot added a commit that referenced this pull request Dec 4, 2025
Docstrings generation was requested by @VishnuKrishnathu.

* #205 (comment)

The following files were modified:

* `src/pages/shikshalokamChat.js`
@VishnuKrishnathu

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

🧹 Nitpick comments (1)
src/pages/shikshalokamChat.js (1)

133-139: Zip extraction is safe; consider normalizing missing values (optional)

Using setIpZipCode(locationData?.location?.zip) under the existing locationData && locationData?.location guard is safe and aligns with how city/state/country are set. If consumers of ipZipCode assume a string (similar to how other_params sends "" for missing city/state/country), you might optionally normalize to an empty string:

-          setIpZipCode(locationData?.location?.zip)
+          setIpZipCode(locationData?.location?.zip ?? "")

Not required for correctness, but it can simplify downstream handling.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 852e078 and 4bfb9fd.

📒 Files selected for processing (1)
  • src/pages/shikshalokamChat.js (2 hunks)
🔇 Additional comments (1)
src/pages/shikshalokamChat.js (1)

29-37: setIpZipCode selector wiring looks consistent

The new setIpZipCode selector mirrors how other IP-related setters (setIpCity, setIpState, setIpCountry) are accessed from useUserStorage, so the wiring here looks consistent with the existing pattern in this component.

@Vinod-V3

Vinod-V3 commented Dec 4, 2025

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 4, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

3 participants