Skip to content

feat: Switch between multiple accounts & self-hosted backends#999

Open
Pecacheu wants to merge 33 commits intostoatchat:mainfrom
Pecacheu:multiuser
Open

feat: Switch between multiple accounts & self-hosted backends#999
Pecacheu wants to merge 33 commits intostoatchat:mainfrom
Pecacheu:multiuser

Conversation

@Pecacheu
Copy link
Copy Markdown
Contributor

@Pecacheu Pecacheu commented Mar 6, 2026

Related Discussions

https://github.com/orgs/stoatchat/discussions/1073#discussioncomment-15783714
https://github.com/orgs/stoatchat/discussions/1310
stoatchat/self-hosted#141
stoatchat/for-desktop#43
stoatchat/for-desktop#55
#851

Current UI concept

Test live at https://forestfire.net:420

Feel free to give it a test if you've got a self-hosted instance and let me know how it goes!

@Pecacheu Pecacheu changed the title feat: Switch between multiple users & self-hosted backends feat: Switch between multiple accounts & self-hosted backends Mar 6, 2026
@Gtoasted
Copy link
Copy Markdown

Gtoasted commented Mar 7, 2026

I'm currently working on a similar feature, but instead of making an account switcher, I'm trying to make adding servers from other instances to the sidebar possible. I've done some preliminary work here, but I'm still far from finished.

I've actually been struggling to come up with a good way of managing things like user settings that are instance-specific but not server-specific, so maybe we can coordinate to make both features work together.

@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Mar 7, 2026

I'm currently working on a similar feature, but instead of making an account switcher, I'm trying to make adding servers from other instances to the sidebar possible. I've done some preliminary work here, but I'm still far from finished.

I've actually been struggling to come up with a good way of managing things like user settings that are instance-specific but not server-specific, so maybe we can coordinate to make both features work together.

Interesting- I could see both of those features working together, yes. I think the way I'm handling swapping between user tokens could be extended to apply to other stored user settings too.

@github-actions github-actions bot force-pushed the multiuser branch 2 times, most recently from d14c2fb to ab62f3b Compare March 7, 2026 03:28
@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Mar 13, 2026

Aight so @Gtoasted is now using an API call to fetch all the other endpoint URLs, so I can make a big improvement here UI-wise.

Old vs new:

Still experimenting with how to redirect all navigation though.

@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Mar 15, 2026

Eureka, it actually works now! (Mostly)

@insertish
Copy link
Copy Markdown
Contributor

This looks promising, I would update the wording to match:
image

This should also be accessible as a dialog/modal from a button, I'd say in the footer, rather than chucking it into the form (this also makes it look weird).

@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Mar 21, 2026

This should also be accessible as a dialog/modal from a button, I'd say in the footer, rather than chucking it into the form (this also makes it look weird).

True. I was inspired by the collapsable UI found in some other login screens, but the text would probably fit much better inside a modal in this case. I'll give that a go.

This looks promising, I would update the wording to match

I like the proxy wording and used that, but personally I think the "on-prem" wording feels a bit too corporate. Not that we can't acknowledge corporate use, it is definitely a common use-case for on-premise hosting, I just feel it shouldn't be worded as if that's the only people who use it, confusing some poor guy just trying to sign into some self-hosted Minecraft server chat instance.

How about something like:

Use this option to connect to a self-hosted on-premise instance. This is useful for private communities or access-controlled corporate environments.

It's also still a good idea to have some sort of content hosting warning like above. It disavows any liability to certain types of content (you know which kind I mean) being discovered on some mega-creep's instance. #notalawyer but my pleb understanding is that in many jurisdictions, a clear warning needs to be shown to the user for this type of thing, i.e. a notice buried in some license policy doesn't count, it has to be something you click "OK" or "Accept" to. (Then again, clearly the "Here's a link to this 500 page ToS you obviously won't read, do you accept?" approach counts.) But please do reword it, again not an expert.

@Pecacheu
Copy link
Copy Markdown
Contributor Author

This is pretty much ready and mostly tested now (though more testing is def appreciated!) so I'll go ahead and take it out of draft.

Also here is what the advanced options look like now as a modal:

@Pecacheu Pecacheu marked this pull request as ready for review March 31, 2026 18:26
@Pecacheu Pecacheu requested review from a team as code owners March 31, 2026 18:26
@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Apr 5, 2026

Known issue: There seems to be some overriding behavior happening with the settings stores- They write to the correct instance's store, but read still seems to pull from the base store. I suspect that the keys are being overwritten during the hydration phase.

Pecacheu and others added 10 commits April 11, 2026 23:41
- "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 privalage to fetch them from the API

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- Currently does nothing, but it looks cool don't it?
- Fix auth flow adjusting to screen width on mobile

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
The purpose of this context is to hold information about a single instance of stoat (information that is currently stored in global configuration)

Signed-off-by: Gtoasted <git@gtoasted.de>
…A_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
…Y_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
…BOX_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
…TCHA_SITEKEY

Signed-off-by: Gtoasted <git@gtoasted.de>
Gtoasted and others added 23 commits April 11, 2026 23:43
Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
- Added InstanceManager to allow switching instances in the same context
- Advanced fields at login now change out the instance, but this data is not yet stored on refresh

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- Fix smDown in wrong place in FlowBase
- Change route from /instance/ to /i/ to keep links shorter sonce it will be prepended to everything
- Rename hostname to host because it could also contain a port number
- Add navigate and setNext to instance

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- Also add a back button to the auth page that only appears when in "add an account" mode and not on first login

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>
- Relative path is redirected to instance-specific path
- Remove unused Instance.navigate, add relPath and switchTo
- Async API endpoint fetch, currently showing any error in alert() prompt because modals don't work at root level
- Use Dynamic element to force reload of context when instance changes

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- All links now use `https://stoat.chat/i/host` prefix, allowing easy and uniform detection when cross-posting links- Eg. clicking a link from another instance redirects client to that instance.
- instance.href method now generates full URL by default
- Use instance.href instead of location.origin to ensure consistency in app hosted on different domain to the instance's API domain

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>
- Add global stores and make 'auth' store global
- Store host param in session data
- Auto-switch instance if current session doesn't match
- Replace "Advanced" dropdown with modal
- Delete session on "OK" if invalid session error
- Fix buttons not highlighting in Home sidebar on alt instance

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
- Support cross-instance channel/server/invite links (Builds on work in stoatchat#1037)
- Auto-redirect to appropriate instance as needed, logging into most recent saved account on instance
- Fix regex for paramsFromPathname to support instance prefix
- Fix annoying draft console logging

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>
…astActivePath to get set to wrong value

- Fix non-reactivity warn on app routes
- Improve error handling and display during login/auth flows

Signed-off-by: Pecacheu <3608878+Pecacheu@users.noreply.github.com>
@Taureon
Copy link
Copy Markdown

Taureon commented Apr 16, 2026

hey @Pecacheu are there any issues here that need resolving?
i wanna check if i can help here

@Pecacheu
Copy link
Copy Markdown
Contributor Author

Pecacheu commented Apr 17, 2026

hey @Pecacheu are there any issues here that need resolving? i wanna check if i can help here

There is the one known issue above, tho it might be hard to solve without being familiar with the code already. I was planning to address it next time I have some time to work on Stoat stuff. Overall though this is looking pretty solid/stable, it has come a long way.

You can always help by simply testing it out and seeing if you run into any other issues, though!

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.

4 participants