Skip to content

ADFA-4318 Paper Cut: Change agent disclaimer to fire with onResume so adjacent tabs don't pre-fire it by accident#1389

Merged
hal-eisen-adfa merged 1 commit into
stagefrom
ADFA-4318-no-ai-disclaim-when-opening-the-git
Jun 16, 2026
Merged

ADFA-4318 Paper Cut: Change agent disclaimer to fire with onResume so adjacent tabs don't pre-fire it by accident#1389
hal-eisen-adfa merged 1 commit into
stagefrom
ADFA-4318-no-ai-disclaim-when-opening-the-git

Conversation

@hal-eisen-adfa

Copy link
Copy Markdown
Collaborator

The fix is a single change in AgentFragmentContainer.kt: moved showDisclaimerDialogIfNeeded() out of onViewCreated() and into a new onResume() override.

Why this works: ViewPager2 + FragmentStateAdapter creates adjacent pages through onViewCreated, but only the visible page reaches onResume. The disclaimer now only fires when the user actually lands on the Agent tab. SharedPreferences gating in showDisclaimerDialogIfNeeded already ensures one-shot behavior, so resuming the agent tab multiple times is safe.

Plugin robustness: The trigger is lifecycle-based, not position-based, so plugins inserting tabs adjacent to Agent (or removing Git, reordering, etc.) cannot resurface the bug.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 992af69e-fc70-4f4f-981f-a57a4e19c495

📥 Commits

Reviewing files that changed from the base of the PR and between 4d9b100 and c88cde5.

📒 Files selected for processing (1)
  • app/src/main/java/com/itsaky/androidide/agent/fragments/AgentFragmentContainer.kt

📝 Walkthrough

Release Notes

Agent Disclaimer Dialog Timing Fix

  • Fixed: Agent disclaimer dialog now displays only when the Agent tab is actively viewed, not when adjacent tabs are pre-created by ViewPager2
  • Implementation: Moved showDisclaimerDialogIfNeeded() trigger from onViewCreated() to new onResume() override in AgentFragmentContainer
  • Gating: Disclaimer is shown only once per app install via SharedPreferences flag (DISCLAIMER_SHOWN_KEY), making it safe to call during fragment resume cycles

Risks & Considerations

  • Lifecycle dependency: Disclaimer behavior now depends on fragment lifecycle callbacks. Edge cases where onResume() is called in unexpected timing could affect display, though this is unlikely in practice
  • Plugin extensibility: Change is robust against tab reordering, addition, or removal since trigger is lifecycle-based rather than fragment-position dependent
  • SharedPreferences persistence: Disclaimer will not re-display across app sessions even if user returns to the Agent tab, as the "shown" flag persists in SharedPreferences

Code Quality

  • Uses modern SharedPreferences API with edit { } extension
  • Includes clear inline documentation explaining the ViewPager2 pre-creation behavior
  • Appropriate use of childFragmentManager for dialog display

Walkthrough

AgentFragmentContainer adds an onResume() override that calls showDisclaimerDialogIfNeeded() after super.onResume(), moving the disclaimer trigger out of onViewCreated() to ensure it fires only when the Agent tab is actually visible, accounting for ViewPager2 pre-creation behavior.

Changes

Disclaimer Dialog Lifecycle Timing

Layer / File(s) Summary
Move disclaimer trigger to onResume
app/src/main/java/com/itsaky/androidide/agent/fragments/AgentFragmentContainer.kt
Adds onResume() override that calls super.onResume() then showDisclaimerDialogIfNeeded(), deferring the dialog from onViewCreated() so it only shows when the tab is truly visible under ViewPager2.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop! The dialog waits its turn,
No more popping up too soon,
ViewPager2 pre-builds the view —
But onResume sets the tune!
Only when you see the tab,
Does the disclaimer come in view. 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving the agent disclaimer dialog trigger from onViewCreated to onResume to prevent it from firing when adjacent tabs are pre-created.
Description check ✅ Passed The description is directly related to the changeset, explaining the specific change in AgentFragmentContainer.kt and the underlying cause of the bug being fixed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ADFA-4318-no-ai-disclaim-when-opening-the-git

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.

@hal-eisen-adfa hal-eisen-adfa merged commit 1703565 into stage Jun 16, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-4318-no-ai-disclaim-when-opening-the-git branch June 16, 2026 02:46
jatezzz pushed a commit that referenced this pull request Jun 22, 2026
… adjacent tabs don't pre-fire it by accident (#1389)

Change agent disclaimer to fire with onResume so adjacent tabs don't pre-fire it by accident
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