SIGN IN SIGN UP

Fix multi-page paywall state after dismissal (#3944)

Supersedes #3921.

Multi-page paywalls could reopen on the last rendered workflow step
because the retained `PaywallViewModel` outlived the dismissed
presentation. This PR resets presentation state on dismissal and reload
from the initial step when the paywall enters composition again.

Ideally we use `rememberViewModelStoreProvider`, but it requires
updating `lifecycle-viewmodel-compose` to `2.11.0` which requires AGP 9+
and we are blocked on that.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Touches paywall dismiss/re-present lifecycle, workflow navigation
state, and analytics session boundaries; behavior is heavily tested but
affects core paywall UX paths.
> 
> **Overview**
> Fixes **embedded/multi-step workflow paywalls reopening on a later
step** when the same retained `PaywallViewModel` is shown again after
dismiss.
> 
> `InternalPaywall` now wires **`onPaywallPresented` /
`onPaywallDismissed`** via `DisposableEffect` so presentation boundaries
follow Compose composition (after exit animations), not only
`closePaywall()`. On dismiss, **`endPresentationSession()`** clears
workflow/session state and sets a flag to **reload on the next
presentation**, while **keeping the last loaded UI** until the paywall
leaves composition. Re-entry triggers **`updateState()`** from the
initial workflow step; impression tracking and async refreshes are
**blocked during teardown** so stale steps and events are not applied.
Purchase/restore auto-dismiss paths use the same session end logic.
> 
> Adds a **Maestro workflow regression** and **unit/instrumentation
tests** for Compose, `PaywallActivity`, `PaywallView`, and workflow
ViewModel re-presentation.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
926652b89282dc321900edfe17d7b47646216c7a. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Jacob Rakidzich <Jacob@JacobZivanDesign.com>
C
Cesar de la Vega committed
d13dfddcc2a09206017d4eefa23057b247adaec8
Parent: 826c49f
Committed by GitHub <noreply@github.com> on 8/13/2026, 2:38:15 PM