Role switching without page reloading #1741
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Refactors role switching in the UI to eliminate the page refresh. Closes #1512, closes #1312. This PR is a proof of concept and the necessary changes have only been made on the plan, plans, and tags pages. If the direction is approved then all pages will receive the same refactoring.
Key Changes:
+layout.sveltelevel and pass the store down to child pages using the svelte context API. Loosely based off of this blog post https://dev.to/brendanmatkin/safe-sveltekit-stores-for-ssr-5a0h but there is a lot of discussion out there about the best ways to avoid data leakage in sveltekit SSR while still storing the server-provided state.changeRoleroute to recompute the user'spermissibleQueriesandrolePermissionsbased on the new role and return the updated user to the client.ActiveRoleheader on client -> server requests to override the requested active role in order to recompute the user cookie when changing role.Navto directly access and updateuserstore from svelte context in order to avoid boilerplate user update event handling in all pages to support role switching.subscribableto add/remove/update itself in a new subscription manager store, allowing for restarting of all active subscriptions when the user changes in order to refresh the connection with new user role