Skip to content

Conversation

@shobhitagarwal1612
Copy link
Member

@shobhitagarwal1612 shobhitagarwal1612 commented Jan 23, 2026

Towards #1795

Migrates the logic related to handling sign-in errors from MainViewModel to SignInScreen.

@andreia-ferreira PTAL?

The `PermissionDeniedDialog` is now managed within the `SignInScreen` based on the sign-in state, rather than being handled globally via `MainUiState` in `MainActivity`.
The `onUserSignInError` method and associated logic have been removed from `MainViewModel`, as sign-in error handling is now managed within the `SignInScreen`. The fallback behavior on error remains a sign-out state with a placeholder for future error dialog improvements.
@auto-assign auto-assign bot requested a review from sufyanAbbasi January 23, 2026 16:26
@gemini-code-assist
Copy link

Summary of Changes

Hello @shobhitagarwal1612, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the application's sign-in error state management. By migrating error handling and the display of related UI components directly into the SignInScreen Composable, the change centralizes the sign-in flow's error presentation. This improves the separation of concerns, making the MainActivity and MainViewModel leaner and the sign-in module more self-contained and easier to maintain.

Highlights

  • Refactored Sign-in Error Handling: The logic for handling sign-in error states, including permission denied and user cancellation, has been moved from MainActivity and MainViewModel to the SignInScreen Composable.
  • Centralized Error UI: The PermissionDeniedDialog and generic error messages are now displayed directly within the SignInScreen using a new SignInErrorUi Composable, improving modularity and keeping sign-in related UI concerns together.
  • Removed Redundant Logic: Imports and code related to MainUiState.OnPermissionDenied, showPermissionDeniedDialog, and specific sign-in error checks (isPermissionDeniedException, isSignInCancelledException) have been removed from MainActivity and MainViewModel.
  • Enhanced SignInScreen Functionality: The SignInScreen and its SignInContent Composable now accept onExitClick and onSignOutClick callbacks, allowing the screen to manage its own exit and sign-out actions in response to errors.
  • Added SignOut Functionality to ViewModel: A new onSignOutButtonClick function has been added to SignInViewModel to explicitly handle user sign-out actions from the sign-in screen.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the sign-in error handling by moving the logic from MainActivity and MainViewModel to the SignInScreen composable. This is a good architectural improvement, making the sign-in flow more self-contained. The changes include removing the error handling from MainViewModel, deleting MainUiState.OnPermissionDenied, and implementing a new SignInErrorUi composable to display different error states like permission denied, user cancellation, or unknown errors.

My main feedback is regarding a regression in error handling for issues that occur after a successful authentication but during the user session setup (e.g., in onUserSignedIn). These errors are now handled generically by signing the user out without any explanation, whereas previously specific errors like permission denied would show an informative dialog. Please see my detailed comment.

Comment on lines 123 to 127
} catch (e: Throwable) {
onUserSignInError(e)
Timber.e(e)
// TODO: Display some error dialog to the user with a helpful user-readable message.
onUserSignedOut()
}

Choose a reason for hiding this comment

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

high

This catch block now handles all exceptions by signing the user out. This is a regression from the previous behavior where onUserSignInError would specifically handle PermissionDeniedException and show a dialog to the user. Now, if an error like permission denied occurs after sign-in (e.g., during userRepository.saveUserDetails), the user is returned to the sign-in screen without any explanation.

While the sign-in error handling has been moved to SignInScreen, that screen only handles SignInState.Error, which is for failures during the authentication process itself. Errors happening after successful authentication but during user session setup are now handled poorly.

Please consider restoring specific error handling here. One approach could be to check for isPermissionDeniedException within this catch block and then find a way to signal this specific error to the UI, so the user can be properly informed.

@shobhitagarwal1612 shobhitagarwal1612 marked this pull request as draft January 23, 2026 16:28
@shobhitagarwal1612 shobhitagarwal1612 changed the title Signin error states Move sign-in error handling to SignInScreen Jan 23, 2026
Tests have been added to verify:
- Display of permission denied dialog on Firestore permission denied errors.
- Application exit and sign-out actions within the permission denied dialog.
- Suppression of error UI when sign-in is cancelled by the user.
- Display of a snackbar for unknown sign-in errors.
The test case verifying that sign-in errors redirect to a signed-out state has been removed from `MainViewModelTest`.
@shobhitagarwal1612 shobhitagarwal1612 marked this pull request as ready for review January 23, 2026 16:59
@auto-assign auto-assign bot requested a review from gino-m January 23, 2026 16:59
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 32.35294% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.77%. Comparing base (117d5bb) to head (220643a).

Files with missing lines Patch % Lines
...g/groundplatform/android/ui/signin/SignInScreen.kt 29.23% 41 Missing and 5 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3473      +/-   ##
============================================
- Coverage     70.02%   69.77%   -0.25%     
+ Complexity     1604     1599       -5     
============================================
  Files           322      322              
  Lines          8646     8678      +32     
  Branches        949      950       +1     
============================================
+ Hits           6054     6055       +1     
- Misses         2017     2049      +32     
+ Partials        575      574       -1     
Files with missing lines Coverage Δ
...org/groundplatform/android/ui/main/MainActivity.kt 41.41% <ø> (-3.04%) ⬇️
.../org/groundplatform/android/ui/main/MainUiState.kt 100.00% <ø> (ø)
...rg/groundplatform/android/ui/main/MainViewModel.kt 64.17% <100.00%> (+1.51%) ⬆️
...groundplatform/android/ui/signin/SignInFragment.kt 71.42% <100.00%> (ø)
...g/groundplatform/android/ui/signin/SignInScreen.kt 66.01% <29.23%> (-22.29%) ⬇️

... and 2 files with indirect coverage changes

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

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