Skip to content

Conversation

@shubham1g5
Copy link
Contributor

Product Description

https://dimagi.atlassian.net/browse/CCCT-1660

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link

coderabbitai bot commented Sep 12, 2025

📝 Walkthrough

Walkthrough

Removes the credential toolbar menu item from menu_connect.xml and its handling in ConnectActivity.onOptionsItemSelected. Centralizes post-unlock navigation in ConnectNavHelper via a new private unlockAndGoTo helper. Adds public navigation methods unlockAndGoToCredentials and goToCredentials to launch PersonalIdCredentialActivity. Updates nav drawer: adds NavItemType.CREDENTIAL, drawer item creation gated by shouldShowCredential(), and a navigateToCredential() path in BaseDrawerActivity that uses unlockAndGoToCredentials and closes the drawer on success.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Drawer as BaseDrawerActivity
  participant Controller as BaseDrawerController
  participant Nav as ConnectNavHelper
  participant Unlock as Unlock Flow
  participant Cred as PersonalIdCredentialActivity

  User->>Drawer: Tap "Credential" in drawer
  Drawer->>Controller: onItemClick(CREDENTIAL)
  Controller-->>Drawer: Dispatch CREDENTIAL
  Drawer->>Nav: unlockAndGoToCredentials(activity, listener)
  Nav->>Unlock: Prompt user to unlock (if required)
  alt unlock success
    Unlock-->>Nav: success
    Nav->>Cred: startActivity()
    Cred-->>Drawer: onComplete
    Drawer->>Drawer: closeDrawer()
  else unlock canceled/failure
    Unlock-->>Nav: canceled/error
    Nav-->>Drawer: no-op
  end
Loading
sequenceDiagram
  autonumber
  participant Caller as Any Feature
  participant Nav as ConnectNavHelper
  participant Unlock as Unlock Flow
  participant Target as Navigation Target

  Note over Nav: New centralized helper
  Caller->>Nav: unlockAndGoTo(activity, listener, navigationAction)
  Nav->>Unlock: Ensure unlocked
  alt success
    Unlock-->>Nav: ok
    Nav->>Target: navigationAction()
    Target-->>Caller: done
  else failure
    Unlock-->>Nav: fail/cancel
    Nav-->>Caller: return without navigation
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

QA Note

Suggested reviewers

  • OrangeAndGreen
  • Jignesh-dimagi
  • avazirna

Pre-merge checks (1 passed, 2 warnings)

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description contains a product Jira link and a partial checklist but omits several required template sections: there is no Technical Summary (rationale/design details), no Feature Flag information, and the Safety Assurance sections (safety story, automated test coverage, and QA Plan) are missing. These omissions prevent reviewers from fully assessing risk, testing, and release impact, so the description is not sufficiently complete for review. Therefore the description check fails. Please update the PR description to include a Technical Summary with the CCCT-1660 link, rationale, and design notes (e.g., moved credential from options menu to nav drawer, added NavItemType.CREDENTIAL and ConnectNavHelper navigation methods, removed the menu resource), state any Feature Flag (or explicitly "none"), and complete Safety Assurance by adding a concise safety story describing local/manual testing and data impact, the automated test coverage status (tests added/updated or justification), and a QA Plan with test steps and a QA ticket. Also ensure Release Note/Risk/QA labels are set and list the intended reviewers to match the checklist.
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 (1 passed)
Check name Status Explanation
Title Check ✅ Passed The current title "Adds Credential in Left Side Drawer" is a short, single-sentence summary that accurately describes the primary user-facing change (adding the credential entry to the left navigation drawer and related navigation code updates). It is concise, specific, and free of noise or unrelated details, so a teammate scanning history would understand the main change. Therefore it meets the repository's title guidelines.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch credential_in_drawer

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

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

🧹 Nitpick comments (3)
app/src/org/commcare/navdrawer/BaseDrawerController.kt (1)

224-226: Redundant helper; keep or strengthen.

This method mirrors the enclosing if (isloggedIn()). Either inline the check (YAGNI) or expand it if additional constraints are required later (e.g., role/feature flag).

app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (1)

116-124: Nit: fix extra space; matches sibling methods.

Minor style tweak.

-    protected  fun navigateToCredential() {
+    protected fun navigateToCredential() {
app/src/org/commcare/connect/ConnectNavHelper.kt (1)

45-53: Credentials navigation added correctly; consider @JvmStatic for Java callers.

If any Java code will call these, add @JvmStatic for parity with goToNotification.

-    fun unlockAndGoToCredentials(activity: CommCareActivity<*>, listener: ConnectActivityCompleteListener) {
+    @JvmStatic
+    fun unlockAndGoToCredentials(activity: CommCareActivity<*>, listener: ConnectActivityCompleteListener) {
         unlockAndGoTo(activity, listener, ::goToCredentials)
     }
 
-    fun goToCredentials(context: Context) {
+    @JvmStatic
+    fun goToCredentials(context: Context) {
         val i = Intent(context, PersonalIdCredentialActivity::class.java)
         context.startActivity(i)
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a29e137 and dfd61b0.

📒 Files selected for processing (5)
  • app/res/menu/menu_connect.xml (0 hunks)
  • app/src/org/commcare/activities/connect/ConnectActivity.java (0 hunks)
  • app/src/org/commcare/connect/ConnectNavHelper.kt (2 hunks)
  • app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (3 hunks)
  • app/src/org/commcare/navdrawer/BaseDrawerController.kt (3 hunks)
💤 Files with no reviewable changes (2)
  • app/src/org/commcare/activities/connect/ConnectActivity.java
  • app/res/menu/menu_connect.xml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-05-08T11:08:18.530Z
Learnt from: shubham1g5
PR: dimagi/commcare-android#0
File: :0-0
Timestamp: 2025-05-08T11:08:18.530Z
Learning: PR #3048 "Phase 4 Connect PR" introduces a substantial feature called "Connect" to the CommCare Android app, which includes messaging, job management, delivery tracking, payment processing, authentication flows, and learning modules. It follows a modern architecture using Navigation Components with three navigation graphs, segregated business logic in Manager classes, and proper database persistence.

Applied to files:

  • app/src/org/commcare/connect/ConnectNavHelper.kt
  • app/src/org/commcare/navdrawer/BaseDrawerActivity.kt
🧬 Code graph analysis (1)
app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (2)
app/src/org/commcare/connect/ConnectNavHelper.kt (1)
  • unlockAndGoToCredentials (45-47)
app/src/org/commcare/navdrawer/BaseDrawerController.kt (1)
  • closeDrawer (228-230)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Lint Code Base
🔇 Additional comments (5)
app/src/org/commcare/navdrawer/BaseDrawerController.kt (1)

43-44: Enum addition looks good.

NavItemType.CREDENTIAL integrates cleanly with the existing drawer flow.

app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (1)

84-85: Drawer route wiring is correct.

NavItemType.CREDENTIAL -> navigateToCredential() aligns with existing patterns.

app/src/org/commcare/connect/ConnectNavHelper.kt (3)

17-28: Nice centralization; confirm callback thread.

unlockAndGoTo is a good abstraction. Please confirm PersonalIdManager.unlockConnect invokes its callback on the main thread; starting activities off-main can be problematic.


30-33: Refactor to helper looks good.

unlockAndGoToMessaging now delegates; behavior should be unchanged.


59-60: Access check retained — good.

goToConnectJobsList still guards via checkConnectAccess(context).

@shubham1g5 shubham1g5 marked this pull request as ready for review September 12, 2025 13:35
@shubham1g5 shubham1g5 added this to the 2.60 milestone Sep 15, 2025
@Jignesh-dimagi
Copy link
Contributor

Credentials have been changed to worker history, should we change in code also that naming convection at major places where it is reflecting the worker history like from unlockAndGoToCredentials to unlockAndGoToWorkerHistory?

Comment on lines +45 to +53
fun unlockAndGoToCredentials(activity: CommCareActivity<*>, listener: ConnectActivityCompleteListener) {
unlockAndGoTo(activity, listener, ::goToCredentials)
}

fun goToCredentials(context: Context) {
val i = Intent(context, PersonalIdCredentialActivity::class.java)
context.startActivity(i)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for making it generic, nit pic (optional):

fun unlockAndGoToCredentials(activity: CommCareActivity<*>, listener: ConnectActivityCompleteListener) {
        unlockAndGoTo(activity, listener){
            val i = Intent(activity, PersonalIdCredentialActivity::class.java)
            activity.startActivity(i)
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we are going to change this code soon to only require unlock in some cases (based on a time threshold) and not everytime, so keeping the non unlock version of these methods separately might be helpful to achive that.

@shubham1g5
Copy link
Contributor Author

Credentials have been changed to worker history, should we change in code also that naming convection at major places where it is reflecting the worker history like from unlockAndGoToCredentials to unlockAndGoToWorkerHistory?

@Jignesh-dimagi yeah, I will do a separate PR here to rename everything related to Worker History


private fun shouldShowCredential(): Boolean {
// we are keeping this off for now until we have go ahead to release this feature
return PersonalIdManager.getInstance().isloggedIn() && false;
Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham1g5 can we create variable in ConnectConstant so that it can be used at other places too to disable this feature and enable with this single variable only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do like the idea of it being gverned by a variable. We are going to transition soon to Feature flag variables where server tells us what features are enabled for the user with the help of an API call as well. Given that I am thinking to create a new FeatureToggle class that has methods like isWorkHistoryEnabled() and just return a hardcoded value of false at the moment but in future can fetch this from DB. Thoughts ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like good idea if Feature Flag functionality is going to be in our plate soon. I guess in this PR only you can create and use that FeatureFlag or FeatureToogle class so that minimal changes when implementing Feature Flag functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shubham1g5
Copy link
Contributor Author

@damagatchi retest this please

1 similar comment
@shubham1g5
Copy link
Contributor Author

@damagatchi retest this please

@shubham1g5 shubham1g5 merged commit 15bf8a7 into master Sep 18, 2025
6 of 10 checks passed
@shubham1g5 shubham1g5 deleted the credential_in_drawer branch September 18, 2025 12:04
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