Skip to content

Add async-storage dependency and refactor ChatScreen refresh logic#163

Open
Naren456 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Naren456:Redesign-ChatScreen
Open

Add async-storage dependency and refactor ChatScreen refresh logic#163
Naren456 wants to merge 2 commits intoAOSSIE-Org:mainfrom
Naren456:Redesign-ChatScreen

Conversation

@Naren456
Copy link
Contributor

@Naren456 Naren456 commented Jan 9, 2026

Closes #

📝 Description:

This PR is related to dependency chnage and optimization in chatscreen .
It adds an important dependency required for the ChatScreen to store chat history using local storage.
*Dependency Name* : react native async storage.

This PR is a extended PR of Redesign ChatScreen
I resolve all the conflict issue regarding dependency .

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Chores

    • Added a local persistence dependency to improve offline/local data handling.
  • Improvements

    • UI now refreshes only when an operation actually changes data, reducing unnecessary backend calls and improving responsiveness.
    • Services include an explicit flag indicating when data changed so the app can avoid redundant refreshes.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Adds an async-storage dependency, tightens post-send refresh logic in the chat screen to require an explicit dataChanged flag, and updates RAG service success responses to include dataChanged: true for operations that modify data.

Changes

Cohort / File(s) Summary
Dependency
Frontend/package.json
Added dependency @react-native-async-storage/async-storage@^2.2.0.
Chat UI logic
Frontend/src/Screens/ChatScreen.jsx
Removed AsyncStorage and ragService imports; changed handleSendMessage to refresh only when result.success && result.dataChanged (avoids refresh for read-only results).
Backend service responses
Frontend/src/services/RAGService.js
Success responses for multiple actions now include an additive dataChanged: true flag (no other control-flow or error-handling changes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through code, a silent cheer,
A tiny flag now whispers near,
"Data changed" — the cache will know,
I stash the bits, then off I go,
Carrots, bytes, and progress clear. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding the async-storage dependency and refactoring the ChatScreen refresh logic to use a dataChanged flag.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@Naren456 Naren456 changed the title Urgent : Dependency Changes Add async-storage dependency for chat history Jan 9, 2026
@Naren456 Naren456 changed the title Add async-storage dependency for chat history Add async-storage dependency for chat history* Jan 9, 2026
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: 0

Caution

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

⚠️ Outside diff range comments (2)
Frontend/src/services/RAGService.js (2)

2090-2159: Inconsistent dataChanged flag: UPDATE and DELETE operations are missing it.

While CREATE/LOG operations now correctly include dataChanged: true, all UPDATE and DELETE operations lack this flag:

UPDATE operations without the flag:

  • updateProfile (line 1979)
  • updateAppointment (line 2146)
  • updateMedicine, updateBloodPressure, updateDischarge, updateSymptoms, updateWeight, updateMood, updateSleep

DELETE operations without the flag:

  • deleteAppointment (line 2219)
  • deleteMedicine, deleteBloodPressure, deleteDischarge, deleteSymptoms, deleteWeight, deleteMood, deleteSleep

Since these operations also mutate data, they should include dataChanged: true in their success responses. Without it, the ChatScreen won't refresh the context after updates/deletes, potentially showing stale data.

Example fix for updateAppointment
       if (response.ok) {
         return {
           success: true,
+          dataChanged: true,
           message: `✅ Appointment "${updateData.title}" updated successfully!\n\n📅 Date: ${updateData.appointment_date}\n⏰ Time: ${updateData.appointment_time}\n📍 Location: ${updateData.appointment_location}`
         };

Apply similar changes to all other UPDATE and DELETE operations.

Also applies to: 2164-2234, 3221-3250, 3255-3280, 3287-3315, 3320-3345, 3352-3379, 3384-3409, 3416-3443, 3448-3473, 3480-3507, 3512-3537, 3544-3571, 3576-3601, 3608-3637, 3642-3667


2614-2641: Missing dataChanged flag in logMood and logSleep operations.

The logMood (line 2628) and logSleep (line 2667) operations create new data entries but their success responses don't include dataChanged: true. This means the ChatScreen won't refresh the context after logging mood or sleep data, potentially causing stale data display.

Proposed fix
 // In logMood function
       if (response.ok) {
         return {
           success: true,
+          dataChanged: true,
           message: `😊 Mood logged successfully!\n\n**Mood:** ${data.mood}\n**Intensity:** ${data.intensity || 'medium'}\n**Week:** ${userContext.current_week || 12}`
         };

 // In logSleep function
       if (response.ok) {
         let message = `😴 Sleep logged successfully!\n\n**Duration:** ${data.duration} hours`;
         // ... message building ...
         
         return {
           success: true,
+          dataChanged: true,
           message: message
         };

Also applies to: 2646-2680

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dbbe77 and 76f1205.

📒 Files selected for processing (2)
  • Frontend/src/Screens/ChatScreen.jsx
  • Frontend/src/services/RAGService.js
🔇 Additional comments (3)
Frontend/src/Screens/ChatScreen.jsx (2)

151-155: LGTM! Smart optimization to reduce unnecessary backend calls.

The addition of the result.dataChanged check correctly prevents refreshing the context for read-only operations (like viewing logs, querying analytics, navigation, etc.), which avoids unnecessary backend load. The explanatory comments clearly document the intent.


1-23: Verify the PR scope: Title mentions adding async-storage, but changes remove AsyncStorage import.

The PR title and description indicate this PR is meant to "add async-storage dependency for chat history," but the actual changes in this file:

  1. Remove the AsyncStorage import (per AI summary)
  2. Remove the ragService import (per AI summary)
  3. Add a dataChanged flag check to optimize context refreshing

This appears to be a refactoring/optimization PR rather than adding new storage functionality. Please clarify:

  • Is the async-storage dependency actually being added for future use?
  • Should the PR title/description be updated to reflect the actual changes (optimizing refresh logic)?
  • If storage functionality is intended, where is it implemented?
Frontend/src/services/RAGService.js (1)

1704-1707: LGTM! Consistent addition of dataChanged flag to all data-creation operations.

The dataChanged: true flag has been correctly added to all CREATE/LOG operations (appointments, weight, symptoms, blood pressure, medicine, discharge, and tasks). This enables the ChatScreen to distinguish between operations that modify data (requiring a context refresh) and read-only operations (no refresh needed).

Also applies to: 1738-1741, 1772-1775, 1808-1811, 1844-1847, 1880-1883, 1918-1921

@Naren456 Naren456 changed the title Add async-storage dependency for chat history* Add async-storage dependency and refactor ChatScreen refresh logic Jan 9, 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.

1 participant