Skip to content

Conversation

@OrangeAndGreen
Copy link
Contributor

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

Product Description

No user visible change.

Technical Summary

Nulling out mFormController when FormEntryActivity shuts down (so other code knows when form entry is in progress).
This work is being done as part of a ticket to better handle kicking the user out when their PersonalID configuration is invalidated. But if the user is in the middle of form entry, we want to let them finish before interrupting their experience. This change will support that work.

Feature Flag

None

Safety Assurance

Safety story

Tested entering a form and backing out, then entering again. No issues encountered

Automated test coverage

Existing tests should cover this part of the code well (exiting form entry in various ways).

QA Plan

Test the functionality around exiting form entry (backing out or completing the form).

…er code knows when form entry is in progress).
@OrangeAndGreen OrangeAndGreen self-assigned this Jan 30, 2026
@OrangeAndGreen OrangeAndGreen added this to the 2.62 milestone Jan 30, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

In FormEntryActivity's onDestroy method, a null assignment for mFormController has been added before TextToSpeech shutdown and the super.onDestroy call. This clears the static form controller reference during activity destruction without altering existing control flow or functional behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested labels

skip-integration-tests

Suggested reviewers

  • avazirna
  • Jignesh-dimagi
  • pm-dimagi
🚥 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 'Improved form entry cleanup' accurately reflects the main change of nulling out mFormController during FormEntryActivity shutdown, summarizing the primary modification clearly and concisely.
Description check ✅ Passed The description includes all required template sections with appropriate details: product description, technical summary with JIRA link, feature flag status, and safety assurance with story, test coverage, and QA plan.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dv/ccct-2025-form-exit-cleanup

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

🤖 Fix all issues with AI agents
In `@app/src/org/commcare/activities/FormEntryActivity.java`:
- Line 1255: The onDestroy() currently unconditionally sets mFormController =
null which breaks the config-change survival path and can trigger the
SessionUnavailableException in the subsequent instance; change the logic in
FormEntryActivity.onDestroy so that mFormController is only cleared when the
Activity is actually finishing (use isFinishing() or equivalent) and leave
mFormController intact across rotations/config changes (refer to the
mFormController field and the code paths around SessionUnavailableException and
the config-change survival logic).

}
}

mFormController = null;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid clearing mFormController during configuration changes.

onDestroy() is invoked on rotations; clearing the static controller can make the next instance hit the SessionUnavailableException path (Line 242) since mFormController is used to survive config changes (see Line 733). Guard the nulling to only run when the activity is truly finishing.

💡 Suggested fix
-        mFormController = null;
+        if (!isChangingConfigurations()) {
+            mFormController = null;
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mFormController = null;
if (!isChangingConfigurations()) {
mFormController = null;
}
🤖 Prompt for AI Agents
In `@app/src/org/commcare/activities/FormEntryActivity.java` at line 1255, The
onDestroy() currently unconditionally sets mFormController = null which breaks
the config-change survival path and can trigger the SessionUnavailableException
in the subsequent instance; change the logic in FormEntryActivity.onDestroy so
that mFormController is only cleared when the Activity is actually finishing
(use isFinishing() or equivalent) and leave mFormController intact across
rotations/config changes (refer to the mFormController field and the code paths
around SessionUnavailableException and the config-change survival logic).

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.

2 participants