Repository navigation
Switch organizations from the sidebar menu - #270
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 4213bea | Nov 21 2026, 06:27 PM |
jonathanlaib
force-pushed
the
feat/org-picker-team-switcher
branch
from
November 21, 2026 18:26
219ec0f to
4213bea
Compare
tnkuehne
added a commit
that referenced
this pull request
Nov 22, 2026
…275) The workspace layout loaded the principal and organization list on every navigation (`depends(url.href)`), and page guards read them through `await parent()`. The [load docs](https://svelte.dev/docs/kit/load#Implications-for-authentication) note that layout loads do not run on every request and recommend protecting routes in `handle` or in `+page.server.js`. The [auth docs](https://svelte.dev/docs/kit/auth) and [remote functions docs](https://svelte.dev/docs/kit/remote-functions#Implications-for-authentication) add that remote functions must run their own checks, redirecting from queries and forms and returning an error from commands. Changes: - **Request hook:** For workspace page and data requests, `handleSession` now checks the organization selection and company SSO after reading the session and before any load runs. Its redirects keep the page as the return path. Form posts without JavaScript return to their page without the action parameter. Remote requests are excluded because remote functions authorize themselves. - **Remote functions:** `remoteContext` (queries and forms) redirects a caller without access. An ended session goes to sign-in, a required company sign-in to that organization's sign-in, and an unavailable organization selection to the organization chooser. The new `commandContext` (settings commands and `manageWorkflow`) returns the same denial as an error, because commands cannot redirect. - **Page guards:** `settings/agents`, `welcome` and `apps/new` call `pagePrincipal()` instead of `await parent()`. The legacy `/catalog` redirect no longer waits for a parent load. - **Workspace navigation:** `(workspace)/+layout.server.ts` is removed. The layout awaits a new `getWorkspace` query for the principal and organizations. `setMemberRole` refreshes it in the same response, and other form submissions invalidate it by default. Analytics identification moves from the root layout into `Workspace.svelte`. - **Open tabs:** Tabs share one session. When a tab becomes visible, `Workspace.svelte` refreshes `getWorkspace`. If another tab switched the organization, the page reloads, which also resets unfinished forms so they cannot submit to the new organization. Behavior changes: - A page whose data comes only from queries does not reach the hook on client-side navigation. If the session ended or the organization selection became unavailable, its query redirects to sign-in or the chooser. A query request does not name its page, so that redirect has no return path. Full page loads and data requests keep it. - Another member's change to your role appears when your tab becomes visible again, on reload or after a form submission, instead of on your next click. Authorization is unaffected: remote functions and page loads check the current role on every request. Tests: the remote endpoint tests now expect a redirect to sign-in or the organization chooser instead of a 401 or 403 error, and still check that no data is returned. Session expiry and an unavailable selection during client navigation expect the redirect without a return path in the JavaScript variant. The role change test reloads the page. New coverage: an open tab reloads with an empty form after another tab switches organizations. No visible UI change: the error page is unchanged from `main`. Validation: - `pnpm check` (typecheck, `oxfmt --check`, `oxlint --type-aware --deny-warnings`) - Browser suite (`test:e2e --grep-invert cli-login.spec.ts`) after rebasing on #270: 86 passed, 1 skipped - `handled-errors.integration.test.ts`: 14 passed Stacked on #273. <!-- greptile_comment --> <!-- greptile_summary --> <h2><a href="https://app.greptile.com/api/retrigger?id=115298142&sig=f9d9ac6ee3a218ef3e5737ee5d74742eca2af31f289d8101103cbc9db198089d"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/-/switch-tenant?tenant=mendra&next=%2Fwidefleet%2Fwidefleet%2Fpull%2F275&utm_source=greptile_review&utm_medium=github&utm_campaign=view_in_greptile"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 5/5</h2> <!-- greptile-impact-verdict --> The PR appears safe to merge; no new actionable issue was established. <details open><summary><h3>Summary</h3></summary> Workspace access checks move from the server layout into the request hook. Queries and forms redirect callers who need to sign in or choose an organization; commands return errors. - Workspace pages check access before their loads run. - Remote requests send denied members to the right sign-in or chooser page. - Workspace navigation refreshes when roles or organization selections change. </details> <details open><summary><h3>Diagram</h3></summary> ```mermaid %%{init: {'theme': 'neutral'}}%% flowchart TD A[Request] --> B[Read session] B --> C{Remote request?} C -- No, workspace page --> D[Check workspace access] D --> E[Run page loads] C -- Yes --> F{Remote function type} F -- Query or form --> G[Check access; redirect on denial] F -- Command --> H[Check access; return error on denial] E --> I[getWorkspace supplies sidebar data] ``` </details> <!-- greptile_confidence_score:5 --> <sub>Reviews (5) · Last reviewed commit: ["Redirect signed-out remote calls instead..."](05a5fc6) · [Reviewed by Greptile](https://www.greptile.com/?utm_source=greptile_review&utm_medium=github&utm_campaign=review_public&utm_content=widefleet/widefleet)</sub> <!-- /greptile_comment -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The organization control in the sidebar opens a menu instead of leaving the workspace for
/organizations./organizations, so it still works before hydration and without JavaScript.selectOrganizationremote form from inside the menu and reloads on/, like the chooser page. Organizations with Company SSO go through sign-in./organizations, which keeps creation and the full list./organizationsis unchanged.Before / after
Verification
/api/v1/me.organization-writes.spec.ts(16 tests) andauth.spec.ts(56 tests) pass locally, with and without JavaScript.oxlint,oxfmt --checkandsvelte-checkreport nothing for the changed files.

Confidence Score: 5/5
The PR appears safe to merge; no new actionable issues were found.Summary
The sidebar now lets people switch organizations without visiting the chooser page.
Reviews (3) · Last reviewed commit: "Keep the organization menu reachable wit..." · Reviewed by Greptile