Skip to content

Refactor single-tab management: replace AloneDetector class with useS… #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v2-dev
Choose a base branch
from

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.
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.

Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
big-agi-open-next ❌ Failed (Inspect) Apr 29, 2025 6:19pm

@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 🚀🚀

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