fix: return to app after Android OAuth callback#509
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates OAuthRedirectActivity to explicitly route the user back to MainActivity after handling the OAuth callback, preventing them from being stranded on the Custom Tab surface. Feedback suggests disabling transition animations with overridePendingTransition(0, 0) to avoid jarring visual effects, and removing the FLAG_ACTIVITY_CLEAR_TOP flag to preserve user context by not destroying other activities on top of MainActivity.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| private fun routeBackToApp() { | ||
| val launchIntent = buildReturnToAppIntent() | ||
| try { | ||
| startActivity(launchIntent) |
There was a problem hiding this comment.
| addFlags( | ||
| Intent.FLAG_ACTIVITY_NEW_TASK or | ||
| Intent.FLAG_ACTIVITY_CLEAR_TOP or | ||
| Intent.FLAG_ACTIVITY_SINGLE_TOP, | ||
| ) |
There was a problem hiding this comment.
Using Intent.FLAG_ACTIVITY_CLEAR_TOP will clear any activities on top of MainActivity when bringing the task to the front. If the app is ever expanded to use multiple activities, this flag would destroy those activities and force the user back to the root MainActivity, losing their current context (e.g., if they initiated the OAuth flow from a settings or profile sub-activity).
Since Intent.FLAG_ACTIVITY_NEW_TASK combined with Intent.FLAG_ACTIVITY_SINGLE_TOP is sufficient to bring the existing task to the front and safely reuse the MainActivity instance (or resume the top-most activity of the task), we can remove FLAG_ACTIVITY_CLEAR_TOP to preserve user context and make the task routing more future-proof.
addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or
Intent.FLAG_ACTIVITY_SINGLE_TOP,
)|
Addressed automated review feedback in 36e3ff7: replaced CLEAR_TOP with REORDER_TO_FRONT to preserve the existing app stack/link-account context, and suppressed transition animation after routing back to MainActivity. |
Code Review Roast 🔥Verdict: No Issues Found | Recommendation: Merge Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything. The author fixed the exact UX problem you'd expect from the issue description: users getting stranded on Custom Tab after OAuth. The Still surprised to see a PR this tight on the first swing. Usually there's at least one 📊 Overall: Like finding a well-commented Android task management solution — mythical, but real. Files Reviewed (1 file)
Reviewed by laguna-m.1-20260312:free · 384,902 tokens |
Summary
MainActivityafter callback delivery/cancellation.AndroidOAuthBridgehandoff and OAuth token/provider logic.RCA summary
Android OAuth linking succeeds in the data path, but
OAuthRedirectActivityonly delivered the callback and finished. Because the Custom Tab flow is launched withFLAG_ACTIVITY_NEW_TASKand the redirect activity uses its own transient task, Android could leave users on the browser/loading surface even though the account was linked.Tests / verification
git diff --check✅./gradlew :androidApp:compileDebugKotlin -Pskip.supabase.check=true --no-daemonbut the cron host has no Java runtime installed (Unable to locate a Java Runtime), so Gradle compilation could not run in this environment.Manual QA recommended
Fixes #508
User retains final merge approval; this automation will not merge.