Skip to content

replaced local storage with session storage for chat language and has… - #250

Merged
Vinod-V3 merged 2 commits into
ELEVATE-Project:release-1.0.6from
themohitbharti:hotfix/language-storage
Feb 26, 2026
Merged

replaced local storage with session storage for chat language and has…#250
Vinod-V3 merged 2 commits into
ELEVATE-Project:release-1.0.6from
themohitbharti:hotfix/language-storage

Conversation

@themohitbharti

@themohitbharti themohitbharti commented Feb 26, 2026

Copy link
Copy Markdown

…SelectedChatLanguage

Summary by CodeRabbit

  • New Features

    • Story actions can now conditionally show Download and Edit buttons (enabled by default).
  • Chores

    • Added a local development start script.
    • Migrated language preference storage from persistent local scope to session scope (clears when browser closes).

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 750f83b and f0e68f6.

📒 Files selected for processing (1)
  • src/components/Form/FormData.jsx
💤 Files with no reviewable changes (1)
  • src/components/Form/FormData.jsx

📝 Walkthrough

Walkthrough

Migrates language state access across the app from the local site-data store to a session-scoped store by replacing useSiteDataLocalStore with useSiteDataSessionStore in many components/pages. Adds a new npm script local to package.json to start the app with the local env via env-cmd.

Changes

Cohort / File(s) Summary
Build Configuration
package.json
Added local npm script: env-cmd -e local react-scripts start.
Core UI Components
src/components/Form/FormData.jsx, src/components/Header.jsx, src/components/LanguageSelectionGrid.jsx, src/components/LanguageSelector.jsx, src/components/ShowPageButton.jsx
Replaced useSiteDataLocalStore imports/usages with useSiteDataSessionStore for chat language and related setters.
Hooks & Utilities
src/hooks/useLanguage.js, src/i18n.js
Switched language state reads/writes from local store to session store (selectors and setters updated).
Login & Voice Chat
src/pages/Login/commonPage.jsx, src/pages/ShikshalokamVoiceChat/chat-container.js, src/pages/ShikshalokamVoiceChat/dynamic-voice-chat.js, src/pages/ShikshalokamVoiceChat/voice-chat.js
Replaced local store hook with session store hook for chat language and related setters across voice/chat flows.
Unified Chat
src/pages/UnifiedChat/StoryActionsModule.js, src/pages/UnifiedChat/UnifiedChat.jsx, src/pages/UnifiedChat/UnifiedVoiceBasedChat.jsx
Swapped local→session store for chatLanguage; StoryActionsContainer now accepts showDownload and showEdit props (default true).
AI Creation / Mitra pages
src/pages/ai-creation/components/textarea-with-mic/index.jsx, src/pages/ai-creation/pages/shikshalokam-mitra/.../DefineChallenge.jsx, .../StateMachineDefineChallenge.jsx, .../components/ChatBox.jsx
Changed getChatLanguage()/selectors to use useSiteDataSessionStore instead of local store.
Repository, SSO & Misc pages
src/pages/shikshagraha-repository/listing/Filters.jsx, src/pages/shikshalokamChat.js, src/pages/ssoFlow.jsx
Replaced local store imports with session store for language state; ssoFlow.jsx retains local store usage for SSO reroute URL.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • Vinod-V3

Poem

🐰 From local burrows to session light,
I hopped through files all day and night,
Swapped the store where languages play,
One small script to start the way,
Hooray — the rabbits coded right! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly and accurately summarizes the main change: migrating chat language state from local storage to session storage across the codebase.

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

✨ Finishing Touches
🧪 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.

@themohitbharti

Copy link
Copy Markdown
Author

@CodeRabbitReview

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown

@themohitbharti: I'll review the changes in this pull request for you.


🧠 Learnings used
Learnt from: VishnuKrishnathu
Repo: ELEVATE-Project/mohini-app-frontend PR: 244
File: src/components/LanguageSelectionGrid.jsx:47-68
Timestamp: 2026-02-16T06:38:02.503Z
Learning: In LanguageSelectionGrid.jsx (src/components/LanguageSelectionGrid.jsx), the `setPreviousUrl` and `setStorageFlow` calls are intentionally only set for specific route_mapping flows (ParentPerceptionSurvey, ListeningActivity) before navigation. For the COMMON_CHAT navigation path, these should NOT be set, as users should not be able to navigate back to /home or the current page. This is expected behavior.
✅ 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: 1

🧹 Nitpick comments (4)
src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/DefineChallenge.jsx (1)

25-25: Consider using a consistent selector pattern.

The current pattern useSiteDataSessionStore().getChatLanguage() works but is inconsistent with other files in this PR that use the selector pattern useSiteDataSessionStore(state => state.chatLanguage).

For consistency across the codebase, consider aligning with the selector pattern used elsewhere:

♻️ Suggested refactor for consistency
-  const [languageToUse, setLanguageToUse] = useState(
-    useSiteDataSessionStore().getChatLanguage() || "en"
-  );
+  const chatLanguage = useSiteDataSessionStore(state => state.chatLanguage);
+  const [languageToUse, setLanguageToUse] = useState(
+    chatLanguage || "en"
+  );

Also applies to: 88-89

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/DefineChallenge.jsx`
at line 25, Replace the direct method call pattern
useSiteDataSessionStore().getChatLanguage() with the selector pattern used
elsewhere: useSiteDataSessionStore(state => state.chatLanguage); update all
occurrences (including the ones around the referenced lines 88-89) so they
consistently use the selector form and reference the chatLanguage property
instead of calling getChatLanguage().
src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/components/ChatBox.jsx (1)

60-60: Consider using selector pattern for consistency.

This uses useSiteDataSessionStore().getChatLanguage() while other components use the selector pattern useSiteDataSessionStore(state => state.chatLanguage). The selector pattern is more performant as it subscribes only to the specific state slice.

♻️ Suggested change for consistency and performance
-  const languageToUse = useSiteDataSessionStore().getChatLanguage() || "en";
+  const languageToUse = useSiteDataSessionStore(state => state.chatLanguage) || "en";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/components/ChatBox.jsx`
at line 60, The code uses useSiteDataSessionStore().getChatLanguage() to
initialize languageToUse which bypasses the selector pattern used elsewhere;
replace that call with the selector pattern (useSiteDataSessionStore(state =>
state.chatLanguage) || "en") in ChatBox.jsx, remove or stop using
getChatLanguage here and ensure languageToUse derives from the selector so the
component only subscribes to the chatLanguage slice for better performance and
consistency.
src/components/ShowPageButton.jsx (1)

5-5: Minor: Inconsistent import path.

This file uses a direct path import from "store/slices/siteData/siteDataSession" while other files in this PR use the barrel import from "store". Consider using the consistent barrel import for maintainability.

♻️ Suggested change for consistency
-import useSiteDataSessionStore from "store/slices/siteData/siteDataSession"
+import { useSiteDataSessionStore } from "store"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/ShowPageButton.jsx` at line 5, Update the import in
ShowPageButton.jsx to use the project's barrel export instead of the deep path:
replace the direct import of useSiteDataSessionStore from
"store/slices/siteData/siteDataSession" with the barrel import from "store" so
it matches other files and centralizes exports (locate the import statement that
references useSiteDataSessionStore and change its module specifier to "store").
src/pages/ai-creation/components/textarea-with-mic/index.jsx (1)

8-8: Consider using selector pattern for consistency.

Same observation as ChatBox.jsx - this uses useSiteDataSessionStore().getChatLanguage() while most other components use the selector pattern. Consider aligning with the selector pattern used elsewhere.

♻️ Suggested change
-  const languageToUse = useSiteDataSessionStore().getChatLanguage() || "en";
+  const languageToUse = useSiteDataSessionStore(state => state.chatLanguage) || "en";

Also applies to: 58-58

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/ai-creation/components/textarea-with-mic/index.jsx` at line 8, The
component currently calls useSiteDataSessionStore().getChatLanguage() directly;
change it to the selector pattern used elsewhere (e.g., ChatBox.jsx) by
selecting the getter or value via useSiteDataSessionStore(selector) — for
example useSiteDataSessionStore(state => state.getChatLanguage) and then invoke
it, or useSiteDataSessionStore(state => state.getChatLanguage()) to obtain the
chat language directly; update both occurrences (including the one at line 58)
so the hook is called with a selector function instead of accessing the store
instance directly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/Form/FormData.jsx`:
- Line 3: Remove the unused import useSiteDataSessionStore from the FormData
component: locate the import statement referencing useSiteDataSessionStore in
FormData.jsx and delete it so only the used imports (e.g., useTranslation from
react-i18next) remain; ensure there are no remaining references to
useSiteDataSessionStore in the component to avoid breaking imports.

---

Nitpick comments:
In `@src/components/ShowPageButton.jsx`:
- Line 5: Update the import in ShowPageButton.jsx to use the project's barrel
export instead of the deep path: replace the direct import of
useSiteDataSessionStore from "store/slices/siteData/siteDataSession" with the
barrel import from "store" so it matches other files and centralizes exports
(locate the import statement that references useSiteDataSessionStore and change
its module specifier to "store").

In `@src/pages/ai-creation/components/textarea-with-mic/index.jsx`:
- Line 8: The component currently calls
useSiteDataSessionStore().getChatLanguage() directly; change it to the selector
pattern used elsewhere (e.g., ChatBox.jsx) by selecting the getter or value via
useSiteDataSessionStore(selector) — for example useSiteDataSessionStore(state =>
state.getChatLanguage) and then invoke it, or useSiteDataSessionStore(state =>
state.getChatLanguage()) to obtain the chat language directly; update both
occurrences (including the one at line 58) so the hook is called with a selector
function instead of accessing the store instance directly.

In
`@src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/components/ChatBox.jsx`:
- Line 60: The code uses useSiteDataSessionStore().getChatLanguage() to
initialize languageToUse which bypasses the selector pattern used elsewhere;
replace that call with the selector pattern (useSiteDataSessionStore(state =>
state.chatLanguage) || "en") in ChatBox.jsx, remove or stop using
getChatLanguage here and ensure languageToUse derives from the selector so the
component only subscribes to the chatLanguage slice for better performance and
consistency.

In
`@src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/DefineChallenge.jsx`:
- Line 25: Replace the direct method call pattern
useSiteDataSessionStore().getChatLanguage() with the selector pattern used
elsewhere: useSiteDataSessionStore(state => state.chatLanguage); update all
occurrences (including the ones around the referenced lines 88-89) so they
consistently use the selector form and reference the chatLanguage property
instead of calling getChatLanguage().

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c505c19 and 750f83b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (22)
  • package.json
  • src/components/Form/FormData.jsx
  • src/components/Header.jsx
  • src/components/LanguageSelectionGrid.jsx
  • src/components/LanguageSelector.jsx
  • src/components/ShowPageButton.jsx
  • src/hooks/useLanguage.js
  • src/i18n.js
  • src/pages/Login/commonPage.jsx
  • src/pages/ShikshalokamVoiceChat/chat-container.js
  • src/pages/ShikshalokamVoiceChat/dynamic-voice-chat.js
  • src/pages/ShikshalokamVoiceChat/voice-chat.js
  • src/pages/UnifiedChat/StoryActionsModule.js
  • src/pages/UnifiedChat/UnifiedChat.jsx
  • src/pages/UnifiedChat/UnifiedVoiceBasedChat.jsx
  • src/pages/ai-creation/components/textarea-with-mic/index.jsx
  • src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/DefineChallenge.jsx
  • src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/StateMachineDefineChallenge.jsx
  • src/pages/ai-creation/pages/shikshalokam-mitra/mitra-pages/components/ChatBox.jsx
  • src/pages/shikshagraha-repository/listing/Filters.jsx
  • src/pages/shikshalokamChat.js
  • src/pages/ssoFlow.jsx

Comment thread src/components/Form/FormData.jsx Outdated
@themohitbharti

Copy link
Copy Markdown
Author

@CodeRabbitReview

@coderabbitai

coderabbitai Bot commented Feb 26, 2026

Copy link
Copy Markdown

@themohitbharti: I'll review the changes in this pull request for you.


🧠 Learnings used
Learnt from: VishnuKrishnathu
Repo: ELEVATE-Project/mohini-app-frontend PR: 244
File: src/components/LanguageSelectionGrid.jsx:47-68
Timestamp: 2026-02-16T06:38:02.503Z
Learning: In LanguageSelectionGrid.jsx (src/components/LanguageSelectionGrid.jsx), the `setPreviousUrl` and `setStorageFlow` calls are intentionally only set for specific route_mapping flows (ParentPerceptionSurvey, ListeningActivity) before navigation. For the COMMON_CHAT navigation path, these should NOT be set, as users should not be able to navigate back to /home or the current page. This is expected behavior.
✅ 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.

@Vinod-V3
Vinod-V3 merged commit 53f38a5 into ELEVATE-Project:release-1.0.6 Feb 26, 2026
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 13, 2026
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