Skip to content

Fix feature flags silent failure and profile page infinite loading#3679

Merged
Baalmart merged 3 commits into
stagingfrom
fix/feature-flags-fresh-login
Jun 25, 2026
Merged

Fix feature flags silent failure and profile page infinite loading#3679
Baalmart merged 3 commits into
stagingfrom
fix/feature-flags-fresh-login

Conversation

@Mozart299

@Mozart299 Mozart299 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor
  • Add ?? false to isFeatureEnabled() call to prevent TypeError when PostHog returns null on fresh login with no local cache, which was silently disabling all feature flags for the entire session
  • Call reloadFlags() at startup after PostHog init so flags load for unauthenticated/guest users from first launch
  • Dispatch LoadUser in ProfilePage initState to retry if user data isn't already loaded, and add Retry button on UserLoadingError state

Summary by CodeRabbit

  • New Features
    • Feature flags are refreshed automatically during app startup for more up-to-date experiences.
    • The profile screen now offers a Retry button when user data fails to load.
  • Bug Fixes
    • Improved profile behavior: user data now re-fetches when the screen opens in a non-loaded state.
    • Made feature flag handling more reliable by treating unavailable flag results as false.

- Add ?? false to isFeatureEnabled() call to prevent TypeError when
  PostHog returns null on fresh login with no local cache, which was
  silently disabling all feature flags for the entire session
- Call reloadFlags() at startup after PostHog init so flags load for
  unauthenticated/guest users from first launch
- Dispatch LoadUser in ProfilePage initState to retry if user data
  isn't already loaded, and add Retry button on UserLoadingError state
@coderabbitai

coderabbitai Bot commented Jun 24, 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: d9ccee20-b739-4c9d-aa87-4a1ec766b694

📥 Commits

Reviewing files that changed from the base of the PR and between 66d26e2 and e20f10a.

📒 Files selected for processing (1)
  • src/mobile/lib/src/app/profile/pages/profile_page.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/mobile/lib/src/app/profile/pages/profile_page.dart

📝 Walkthrough

Walkthrough

The app now reloads feature flags during startup after PostHog setup, normalizes null flag checks to false, and updates the profile page to load user data on entry and retry from the error state.

Changes

Startup and profile flow updates

Layer / File(s) Summary
Feature flags reload after setup
src/mobile/lib/main.dart, src/mobile/lib/src/app/shared/services/feature_flag_service.dart
main.dart imports FeatureFlagService and awaits reloadFlags() after PostHog setup. reloadFlags() now stores false when the SDK returns null.
Profile user load and retry
src/mobile/lib/src/app/profile/pages/profile_page.dart
initState dispatches LoadUser() when the bloc is not already loaded or loading, and the error UI now includes a Retry button that dispatches LoadUser().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Baalmart

Poem

🚩 PostHog wakes, the flags roll in,
Null turns false, and state stays thin.
Profile loads, and if it sighs,
Retry clicks bring better skies.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main fixes: feature flag initialization and the profile page loading issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/feature-flags-fresh-login

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/mobile/lib/src/app/profile/pages/profile_page.dart`:
- Around line 22-30: Avoid triggering a duplicate user fetch from
profile_page.dart’s initState in ProfilePage: the current state check only
excludes UserLoaded, so UserLoading still falls through and dispatches
LoadUser() again. Update the condition to also skip dispatch when the UserBloc
state is already loading, using the existing UserBloc/UserLoaded/UserLoading
flow in initState so only one load can be enqueued at a time.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 65312af2-7390-4ddc-bddf-ea14fab78fb0

📥 Commits

Reviewing files that changed from the base of the PR and between a84056e and 66d26e2.

⛔ Files ignored due to path filters (1)
  • src/mobile/pubspec.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • src/mobile/lib/main.dart
  • src/mobile/lib/src/app/profile/pages/profile_page.dart
  • src/mobile/lib/src/app/shared/services/feature_flag_service.dart

Comment thread src/mobile/lib/src/app/profile/pages/profile_page.dart

Copilot AI 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.

Pull request overview

This PR improves reliability of PostHog feature flags on fresh installs/logins and prevents the Profile page from getting stuck in a non-loaded state by proactively triggering user-load and offering a retry action.

Changes:

  • Make feature-flag evaluation resilient to null results from PostHog and trigger a flags refresh right after PostHog initialization.
  • On ProfilePage, dispatch LoadUser during initState when the user state isn’t already loading/loaded.
  • Add a Retry button to the profile error UI.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/mobile/pubspec.lock Updates dependency resolution; also bumps the lockfile’s minimum Dart/Flutter SDK versions.
src/mobile/lib/src/app/shared/services/feature_flag_service.dart Defaults feature flags to false when PostHog returns null.
src/mobile/lib/main.dart Reloads feature flags immediately after PostHog setup.
src/mobile/lib/src/app/profile/pages/profile_page.dart Triggers user reload on page init and adds Retry UI on load failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mobile/lib/src/app/profile/pages/profile_page.dart Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Baalmart
Baalmart merged commit 47af504 into staging Jun 25, 2026
25 of 27 checks passed
@Baalmart
Baalmart deleted the fix/feature-flags-fresh-login branch June 25, 2026 06:15
@Baalmart Baalmart mentioned this pull request Jun 25, 2026
3 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jul 8, 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.

3 participants