Skip to content

Rebuild workflow step states on color scheme change#3419

Merged
vegaro merged 5 commits into
mainfrom
cesar/wfl-46-workflow-color-refresh
May 14, 2026
Merged

Rebuild workflow step states on color scheme change#3419
vegaro merged 5 commits into
mainfrom
cesar/wfl-46-workflow-color-refresh

Conversation

@vegaro

@vegaro vegaro commented Apr 30, 2026

Copy link
Copy Markdown
Member

Motivation

In a multi-step workflow paywall, toggling dark/light mode while on a non-first step would silently navigate the user back to step 1. The configuration change calls updateState(), which re-runs the full workflow setup — including resetting WorkflowNavigator to the initial step — instead of just rebuilding the cached step states for the new color scheme.

Description

Introduces rebuildWorkflowStepStates(), called from the configuration-change path instead of updateState() when the active paywall is a workflow. It:

  • Clears the existing workflowStepStateCache.
  • Rebuilds the current step's PaywallState.Loaded.Components against the new color scheme.
  • Leaves WorkflowNavigator's currentStepId and backStack untouched, so the user stays on the step they were on.
  • Re-kicks the off-thread pre-warm so visited and unvisited steps repopulate with the new colors.

Note

Medium Risk
Changes workflow paywall refresh behavior to rebuild step UI state in-place instead of reloading the workflow, which could impact navigation/state caching if edge cases exist. Covered by new unit tests that assert navigation position and network call count are preserved.

Overview
Fixes a workflow-paywall bug where changing the Compose ColorScheme (e.g., dark/light toggle) could reset multi-step workflow navigation back to the initial step.

When a workflow is active, refreshStateIfColorsChanged now rebuilds workflow step states via rebuildWorkflowStepStates/buildWorkflowStates (clearing and repopulating the step cache using the current step) instead of calling updateState() and re-fetching/resetting the WorkflowNavigator. Adds tests ensuring the current workflow step is preserved and that awaitGetWorkflow is not called again on color refresh.

Reviewed by Cursor Bugbot for commit 8472463. Bugbot is set up for automated code reviews on this repo. Configure here.

vegaro commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov

codecov Bot commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (e9b0f74) to head (8472463).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3419   +/-   ##
=======================================
  Coverage   79.88%   79.88%           
=======================================
  Files         368      368           
  Lines       14858    14858           
  Branches     2042     2042           
=======================================
  Hits        11869    11869           
  Misses       2156     2156           
  Partials      833      833           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vegaro vegaro force-pushed the cesar/wfl-46-two-surface-workflow-slide branch from 1f8ba59 to e72fe0f Compare April 30, 2026 09:25
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from 5172165 to 3f6a88c Compare April 30, 2026 09:25
@vegaro vegaro force-pushed the cesar/wfl-46-two-surface-workflow-slide branch 2 times, most recently from b935b86 to 241a0f1 Compare April 30, 2026 09:49
@vegaro vegaro changed the base branch from cesar/wfl-46-two-surface-workflow-slide to graphite-base/3419 April 30, 2026 10:11
@vegaro vegaro force-pushed the graphite-base/3419 branch from b935b86 to 686d62d Compare April 30, 2026 10:12
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from 3f6a88c to 85c4f32 Compare April 30, 2026 10:12
@vegaro vegaro changed the base branch from graphite-base/3419 to cesar/wfl-46-workflow-image-preloader April 30, 2026 10:12
@emerge-tools

emerge-tools Bot commented Apr 30, 2026

Copy link
Copy Markdown

📸 Snapshot Test

591 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
TestPurchasesUIAndroidCompatibility
com.revenuecat.testpurchasesuiandroidcompatibility
0 0 0 0 334 0 N/A
TestPurchasesUIAndroidCompatibility Paparazzi
com.revenuecat.testpurchasesuiandroidcompatibility.paparazzi
0 0 0 0 257 0 N/A

🛸 Powered by Emerge Tools

@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch from 686d62d to c9ac67b Compare April 30, 2026 11:01
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch 2 times, most recently from 1369710 to ad0f28b Compare April 30, 2026 11:31
@vegaro vegaro marked this pull request as ready for review April 30, 2026 12:05
@vegaro vegaro requested a review from a team as a April 30, 2026 12:05
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from ad0f28b to e342f98 Compare April 30, 2026 12:09
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch 2 times, most recently from 0d10d7d to e4bf0f4 Compare April 30, 2026 12:30
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch 2 times, most recently from 607983a to 2bea6c5 Compare April 30, 2026 13:09
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch from e4bf0f4 to 6f01bee Compare April 30, 2026 13:09
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch from 2fcc54d to 297d4af Compare May 4, 2026 13:22
@vegaro vegaro changed the title fix: rebuild workflow step states on color scheme change without resetting navigation Rebuild workflow step states on color scheme change May 4, 2026
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from b743b96 to feb1571 Compare May 4, 2026 15:16
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch from 297d4af to 431642b Compare May 4, 2026 15:16
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from feb1571 to 0ed0730 Compare May 4, 2026 15:37
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-image-preloader branch 2 times, most recently from 31b4d2c to 10681c4 Compare May 4, 2026 16:45
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from 0ed0730 to 04bd9a7 Compare May 4, 2026 16:45
@vegaro vegaro changed the base branch from cesar/wfl-46-workflow-image-preloader to graphite-base/3419 May 4, 2026 16:50
@vegaro vegaro force-pushed the graphite-base/3419 branch from 10681c4 to 8383c70 Compare May 4, 2026 16:51
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from 0d843fa to 86df9e7 Compare May 4, 2026 16:51
@vegaro vegaro changed the base branch from graphite-base/3419 to main May 4, 2026 16:51

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c262c686c279428e72d7854484351b824842fdd4. Configure here.

@vegaro vegaro requested a review from facumenzella May 11, 2026 07:26
vegaro and others added 5 commits May 13, 2026 10:37
…tting navigation

Without this, a dark/light mode toggle while on a non-first workflow step
would call updateState() which re-runs the full workflow setup and silently
navigates the user back to step 1.

rebuildWorkflowStepStates() clears the step cache and rebuilds from the
current step, preserving the navigator's back-stack position.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Inject useWorkflowsEndpoint into PaywallViewModelImpl so tests can
enable the workflow path without changing the BuildConfig constant.

Two tests cover the fix in #3419:
- refreshStateIfColorsChanged preserves current navigation step
- refreshStateIfColorsChanged does not trigger updateState (call count guard)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vegaro vegaro force-pushed the cesar/wfl-46-workflow-color-refresh branch from 837a3bb to 8472463 Compare May 13, 2026 10:36

@facumenzella facumenzella left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me. Haven't tested it manually though

@vegaro vegaro added this pull request to the merge queue May 13, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 13, 2026
@vegaro vegaro added this pull request to the merge queue May 13, 2026
@vegaro vegaro removed this pull request from the merge queue due to a manual request May 13, 2026
@vegaro vegaro added this pull request to the merge queue May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants