Skip to content

Switch organizations from the sidebar menu - #270

Merged
tnkuehne merged 2 commits into
mainfrom
feat/org-picker-team-switcher
Nov 21, 2026
Merged

tnkuehne merged 2 commits into
mainfrom
feat/org-picker-team-switcher

Conversation

@jonathanlaib

@jonathanlaib jonathanlaib commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The organization control in the sidebar opens a menu instead of leaving the workspace for /organizations.

  • The trigger shows the organization and the person's role in it. It stays a link to /organizations, so it still works before hydration and without JavaScript.
  • The menu lists all organizations. Choosing one submits the existing selectOrganization remote form from inside the menu and reloads on /, like the chooser page. Organizations with Company SSO go through sign-in.
  • While the menu is open, the digits 1–9 pick an organization. Browsers reserve Ctrl/⌘ with digits for tab switching, so there is no global shortcut.
  • Add organization opens /organizations, which keeps creation and the full list.
  • The mobile header link to /organizations is unchanged.

Before / after

Before After
Closed before after
Opened before after

Verification

  • New browser test: switching from the menu by click and by digit key, checked against /api/v1/me.
  • organization-writes.spec.ts (16 tests) and auth.spec.ts (56 tests) pass locally, with and without JavaScript.
  • Rendered with the Vite fixture server and synthetic organizations (Chromium, 1100 px wide).
  • oxlint, oxfmt --check and svelte-check report nothing for the changed files.
  • Not checked: dark mode and the SSO path in the browser.

RetriggerView in GreptileConfidence 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.

  • The desktop sidebar opens a menu for switching organizations.

Reviews (3) · Last reviewed commit: "Keep the organization menu reachable wit..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
widefleet-docs 4213bea Nov 21 2026, 06:27 PM

@jonathanlaib
jonathanlaib force-pushed the feat/org-picker-team-switcher branch from 219ec0f to 4213bea Compare November 21, 2026 18:26
@tnkuehne
tnkuehne merged commit 3f68932 into main Nov 21, 2026
17 checks passed
@tnkuehne
tnkuehne deleted the feat/org-picker-team-switcher branch November 21, 2026 23:41
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&amp;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&amp;next=%2Fwidefleet%2Fwidefleet%2Fpull%2F275&amp;utm_source=greptile_review&amp;utm_medium=github&amp;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 -->
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.

2 participants