Skip to content

Auto-close wallet handoff tab after successful extension flow #272

@macterra

Description

@macterra

Summary

After the React wallet hands a request off to the browser extension, the original wallet tab should be able to close automatically when the extension flow completes successfully.

Right now the wallet shows a good confirmation screen:

  • "Opened in Archon Wallet extension"
  • with Continue in Web Wallet and Close Tab

That is a solid fallback, but the remaining UX papercut is that users are left with an extra tab after the extension successfully completes the login/accept flow.

Goal

When a wallet request is handed off from the React wallet web page to the browser extension, the extension should close the original handoff tab automatically after a confirmed successful completion.

This should apply to:

  • auth challenge flows
  • credential accept flows
  • alias accept flows

Why the extension should do it

A normal web page cannot reliably close an arbitrary tab opened by the user.
The browser extension can, because it has tab access and already receives the request from a specific source tab.

Proposed design

1. Add a handoff session id

When React wallet hands off a request to the extension:

  • generate a handoffId
  • include it in the page-to-extension message
  • keep it associated with the source page state

2. Record the source tab in background

In the extension background script:

  • store { handoffId, tabId, action, createdAt }
  • keyed by the handoff session id

3. Close only on confirmed success

When the extension completes the auth/accept flow successfully:

  • send a success message to background with handoffId
  • background looks up the original source tab
  • before closing, verify the tab still matches the expected wallet handoff URL/state if possible
  • then call chrome.tabs.remove(tabId)

Safety checks

Only auto-close when:

  • the extension flow succeeded
  • the user did not cancel
  • the original tab still appears to be the handoff page
  • the handoff record has not expired

Do not auto-close when:

  • the flow fails
  • the flow is canceled
  • the tab has navigated elsewhere
  • the tab record is stale or missing

Open questions

  • What is the best handoff id format and storage lifetime?
  • Should the wallet tab include the handoff id in the URL, memory state, or both?
  • What success event is the right trigger for auth vs credential vs alias acceptance?
  • Should there be a user setting to disable auto-close?

Acceptance criteria

  • After successful extension auth, the original wallet handoff tab closes automatically
  • After successful credential accept, the original wallet handoff tab closes automatically
  • After successful alias accept, the original wallet handoff tab closes automatically
  • No auto-close happens on failure or cancel
  • The feature is implemented by the extension/background, not by the web page alone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions