Skip to content

feat: Multi-user account switching - #1217

Open
Pecacheu wants to merge 19 commits into
stoatchat:mainfrom
Pecacheu:multiuser-accounts
Open

feat: Multi-user account switching#1217
Pecacheu wants to merge 19 commits into
stoatchat:mainfrom
Pecacheu:multiuser-accounts

Conversation

@Pecacheu

@Pecacheu Pecacheu commented May 30, 2026

Copy link
Copy Markdown
Contributor

Split off from and baseline for multi-instance switching in:

Requires:

How was this PR tested?

At least a dozen furries daily-driving PR 999 for months :3

This has been briefly tested to ensure that extraction from the above didn't break it.

Screenshots & Screencasts (if appropriate)

Back button appears on auth page only when adding an additional account, not on first login. Matches styling of the light/dark mode button.

Checklist:

  • I have carefully read the contributing guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR
  • I have confirmed that any new dependencies are strictly necessary
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code

Please declare, if any, LLM usage involved in creating this PR

80% Raichu powered, 20% V8 Energy drink at 2 AM powered

@Pecacheu
Pecacheu requested review from a team as code owners May 30, 2026 06:16
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 3 times, most recently from 4db64ed to 9d93080 Compare June 1, 2026 01:06
@chrishultin chrishultin added the ux review This needs UX review label Jun 1, 2026
@Pecacheu Pecacheu mentioned this pull request Jun 1, 2026
7 tasks

@Dadadah Dadadah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not bad, I would appreciate if you could go in to detail about how the state store works now, perhaps we should update the developer documentation?

This PR is large, are you sure there aren't any more relevant screenshots or videos for ui/ux review?

Comment thread packages/client/components/auth/src/AuthPage.tsx
Comment thread packages/client/components/client/Controller.ts Outdated
Comment thread packages/client/components/client/Controller.ts Outdated
Comment thread packages/client/components/auth/src/flows/Flow.tsx Outdated
Comment thread packages/client/components/state/stores/Auth.ts Outdated
@Pecacheu

Pecacheu commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

This PR is large, are you sure there aren't any more relevant screenshots or videos for ui/ux review?

Just added one more screenshot- But aside from that, this PR is more backend changes than UI so that's that's changed UI-wise. Eg. several of the changed JSX files was just to pass the onClose listener to the add account button so that it closes the settings UI when pressed.

Not bad, I would appreciate if you could go in to detail about how the state store works now, perhaps we should update the developer documentation?

Sure, updated documentation for the State/Store changes might make sense. Long story short, now instead of having only one database (currently named "localforage" in main, as that's what the library defaults to), we treat the old one as the 'global' DB that holds any store with the global flag set to true- namely the auth store at the moment. All other stores are instead loaded from and written to the appropriate store with the name instanceHost@userId - Since only default instance is supported at the moment, the former is blank, i.e. it is just @userId.

For forward compatibility, I made the multi-instance PR behave like this too, so that none of your settings for existing main-instance logins are lost in the void. In other words, he default instance (as set by CONFIGURATION) is always replaced with a blank string (even if you explicitly type in stoat.chat in the instance field) so that there is no instance prefix. And your first logged-in account stores everything in "localforage" instead, again so that existing settings are not lost.

One thing I didn't yet implement that should probably be added is garbage collection for unused DBs, i.e. after logout of a secondary account the data just sits there. The databases known to localforage should be double-checked against the list of saved sessions in the global auth store.

@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 4 times, most recently from db88bba to e5a5fc2 Compare June 20, 2026 17:23
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 4 times, most recently from 7dae0be to da50c8f Compare June 25, 2026 04:20
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 2 times, most recently from f9c38bd to 6979ea8 Compare June 29, 2026 15:59
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 2 times, most recently from f8be6b8 to 06cf37e Compare July 2, 2026 15:18
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 3 times, most recently from 5e5a4d5 to b9811d4 Compare July 21, 2026 02:53
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch 2 times, most recently from 752dbf1 to a11e8c1 Compare July 25, 2026 15:43
Gtoasted and others added 11 commits July 28, 2026 09:56
refactor: use Instance.apiUrl instead of CONFIGURATION.DEFAULT_API_URL
refactor: use Instance.wsUrl instead of CONFIGURATION.DEFAULT_WS_URL
refactor: use Instance.mediaUrl instead of CONFIGURATION.DEFAULT_MEDIA_URL
refactor: use Instance.proxyUrl instead of CONFIGURATION.DEFAULT_PROXY_URL
refactor: use Instance.gifboxUrl instead of CONFIGURATION.DEFAULT_GIFBOX_URL
refactor: use Instance.isStoat instead of CONFIGURATION.IS_STOAT
refactor: use Instance.hcaptcha_sitekey instead of CONFIGURATION.HCAPTCHA_SITEKEY
refactor: use Instance.maxEmoji instead of CONFIGURATION.MAX_EMOJI
refactor: use Instance.enableVideo instead of CONFIGURATION.ENABLE_VIDEO
chore: take note of remaining variables to be implemented in instance.ts
chore: fix formatting
feat: add hostname to Instance.ts
feat: modify routes to allow access to other instances

Signed-off-by: Gtoasted <git@gtoasted.de>
refactor: Move client init from Lifecycle into Instance so that the configuration is only pulled once
fix: Use instance prop for server emoji limit
fix: Use relPath for path in HomeSidebar
fix: Pull captcha key from backend
refactor: Move loading screen so export can be used in other files
fix: Use new loading screen
fix: Revert StateContext route change
fix: Default to non-reactive location in relPath to avoid error due to usage outside of Router
fix: Lingui string variable issue
fix: Handle undefined instance during login, fix comments

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
fix: Reliable endpoint dev overrides via Stoat.js update

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
… instance link stripping

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch from a11e8c1 to 6af835c Compare July 28, 2026 14:07
Pecacheu added 8 commits July 28, 2026 10:24
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- "Add an account" button in Settings -> My Account
- "Switch Accounts" button in user context menu, if multiple accounts are stored
- "Log out" button only logs out the current account, switches to next stored one if present
- Account tokens stored via modified schema for 'auth' key in Auth manager
- Last known name and pfp are cached, because alt accounts might not have privilege to fetch them from the API

fix: Apply patches from multiuser
fix: TS error caused by rebase

fix: Move unused host var to multi-instance PR
- Define class var at top
- Remove debug lines

refactor: Use new breakpoints on login screen
fix: Lifecycle transitions slightly borked by PR 1197, causing random logouts
fix: Separate logout wo/ delSes

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- Fix using wrong lingui macro
- Add loading screen to cli sync and login wait

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
@Pecacheu
Pecacheu force-pushed the multiuser-accounts branch from 6af835c to ee5927c Compare July 31, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ux review This needs UX review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants