Skip to content

Conversation

@catalinradoiu
Copy link
Contributor

@catalinradoiu catalinradoiu commented Dec 19, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1211724162604201/task/1206984821130536?focus=true

Description

Custom tabs were not properly handling window closure during single sign-on flows. When an SSO flow opened a new window (which adds a fragment to the backstack), the window.close() callback from the OAuth provider would attempt to use regular browser tab logic (removing from tab repository and updating tab selection). This approach failed in custom tabs because they don't use the tab repository concept - they manage navigation through fragment backstack transactions. As a result, the SSO window remained open and prevented the login callback code from executing on the previous fragment, breaking the authentication flow.

Solution
Added custom tab-specific handling for window closure. When closeCurrentTab() is called in a custom tab context, it now triggers a fragment backstack pop operation instead of attempting repository-based tab removal. This properly closes the SSO fragment and returns to the calling fragment, allowing the authentication callback to execute correctly. Regular browser tabs continue to use the existing repository-based logic, ensuring no regression in standard tab behavior.

Steps to test this PR

Check steps in the attached task.

UI changes

No UI changes, only behavior changes.


Note

Introduce NavigateBackInCustomTab so closing in custom tabs pops the fragment back stack rather than deleting a tab; wire it in ViewModel/Fragment and add tests.

  • Behavior change (Custom Tabs):
    • Add Command.NavigateBackInCustomTab.
    • Update BrowserTabViewModel.closeCurrentTab() to emit NavigateBackInCustomTab when isCustomTabScreen is true; otherwise keep deleting the tab from repository.
    • Handle NavigateBackInCustomTab in BrowserTabFragment by popping the fragment back stack when active custom tab.
  • Tests:
    • Adjust/expand tests to cover non-custom-tab deletion path and custom tab back navigation command emission.

Written by Cursor Bugbot for commit 32d48b3. This will update automatically on new commits. Configure here.

…nCloseWindow window callback of the BrowserChromeClient is triggered
Copy link
Contributor Author

@catalinradoiu catalinradoiu marked this pull request as ready for review December 19, 2025 16:03
isActiveTab = it.tabId == tabId
if (wasActive && !isActiveTab) {
logcat { "Tab $tabId is newly inactive" }
logcat(tag = "RadoiuC") { "Tab $tabId is newly inactive" }
Copy link

Choose a reason for hiding this comment

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

Bug: Personal debug tag accidentally committed in log statement

The logcat call was changed from using the default tag to a personal debug tag "RadoiuC" (matching the author's name). This appears to be a debugging artifact that was unintentionally included. The log statement previously used the default class-based tag, which is more appropriate for production code.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

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.

1 participant