Skip to content

Conversation

@AaronPlave
Copy link
Contributor

@AaronPlave AaronPlave commented Aug 11, 2025

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:

  • Refactor user variable into a user store at the +layout.svelte level 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.
  • Refactor changeRole route to recompute the user's permissibleQueries and rolePermissions based on the new role and return the updated user to the client.
  • Use ActiveRole header on client -> server requests to override the requested active role in order to recompute the user cookie when changing role.
  • Refactor Nav to directly access and update user store from svelte context in order to avoid boilerplate user update event handling in all pages to support role switching.
  • Refactor subscribable to 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
  • Add a derived store and hidden div to indicate when all web socket connections are finished loading, will be used for test purposes as another gate to determine when the page is loaded.

…n to pages via context API. Implemented on a few pages as proof of concept. Modify changeRole route to return updated user and make Nav component set user store with updated user.
@AaronPlave AaronPlave changed the title Refactor user prop to be a store in +layout.svelte that is passed dow… Role switching without page reloading Aug 11, 2025
… active role header so that the active role cookie can be regenerated when hitting changeRole
… manager. Additionally track loading and error states within gql subscribable + subscription manager.
@sonarqubecloud
Copy link

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.

UI resets when you change roles View customizations are lost on page automatic page refresh

2 participants