Skip to content

Single-tab management: switch to localStorage-based#802

Open
mnm-matin wants to merge 1 commit intoenricoros:mainfrom
mnm-matin:use-here-tab
Open

Single-tab management: switch to localStorage-based#802
mnm-matin wants to merge 1 commit intoenricoros:mainfrom
mnm-matin:use-here-tab

Conversation

@mnm-matin
Copy link

Switch to LocalStorage-based single tab management

Problem:
Current multi-tab detection forces users to close the original tab when opening the app in a new tab, leading to poor UX as users must manually hunt down and close tabs.

Solution:
Replace the BroadcastChannel implementation with a simpler LocalStorage-based approach, inspired by WhatsApp Web's tab management:

  • New tabs automatically become active
  • Existing tabs show "Use here" prompt instead of forcing closure
  • Simplified code with fewer dependencies and edge cases

Changes:

  • Rewrote useSingleTabEnforcer to use localStorage and the storage event
  • Updated ProviderSingleTab to show a WhatsApp-style "Use here" button
  • Eliminated complex state management, timers, and race condition handling

Testing:

  • Open multiple tabs - verify only one is active
  • Click "Use here" - verify tab becomes active and others show prompt
  • Close active tab - verify another can claim ownership

…ingleTabEnforcer hook for improved tab ownership handling. Update ProviderSingleTab to utilize new hook structure, enhancing clarity and functionality.
@vercel
Copy link

vercel bot commented Apr 29, 2025

@mnm-matin is attempting to deploy a commit to the Token Fabrics Pro Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
big-agi-open-next Error Error Sep 12, 2025 10:11pm
open-v2-dev Error Error Sep 12, 2025 10:11pm

@enricoros
Copy link
Owner

Thanks for the pr @mnm-matin very smart solution!

I'd merge it right away, but need to take some time to merge this because it's on the critical path for the new boot sequence that will be present in the upcoming version (and needs careful initialization and dependency between components, including this). So I'll have to revisit this once I release the very large change I'm working on.

Thanks for submitting!

@mnm-matin
Copy link
Author

np, happy to contribute to a great project with super responsive devs 🚀🚀

@enricoros enricoros changed the title Refactor single-tab management: replace AloneDetector class with useS… Single-tab management: switch to localStorage-based Sep 12, 2025
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