Repository navigation
Load page data once per control-plane navigation - #273
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | cd61a5e | Nov 22 2026, 12:02 AM |
Workspace server loads awaited remote queries only to warm them and then discarded the results. SvelteKit serializes remote query results into the HTML of a full page render, but not into __data.json. On client-side navigation the server therefore ran each query inside the data request, and the page component then requested the same query again. Every navigation waited for two sequential Worker requests and repeated the database work. The components already await these queries, which renders them on the server for full page loads and returns their 404 and other errors with the matching status. Remove the discarded prefetches from the home, apps, app, agents, connections, members, services, API requests and settings loads. The app layout no longer depends on the full URL to recheck access on each section navigation. That recheck only came from the removed prefetch; the section queries and the five-second app refresh authorize their own data.
tnkuehne
force-pushed
the
remote-queries-outside-loads
branch
from
November 22, 2026 00:01
8dd5c50 to
cd61a5e
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.
Workspace server loads awaited remote queries only to warm them and then discarded the results. SvelteKit serializes remote query results into the HTML of a full page render, but not into
__data.json. On client-side navigation the server ran each query inside the data request, and the page component then requested the same query again, so every navigation waited for two sequential requests and repeated the database work.The remote functions docs await queries in components. The components here already do that, which renders the data on the server for full page loads. Errors thrown by a query during rendering, such as the 404 from
getAppDetails, set the response status and render+error.svelte.Changes:
Loads that use a query result for a 404, a redirect or returned data (
apps/new,services/[service]/*,services/requests/[requestId],settings/company-sign-in/setup, the selected app onservices) are unchanged here.Validation:
pnpm checkequivalents: control-plane typecheck,oxfmt --check,oxlint --type-aware --deny-warnings.setup.spec.tsfailed. It failed again when rerun alone (the first attempt hitEADDRINUSEfrom another local process on port 25430). It passed in the next full run with this change and on unchangedmain.

Confidence Score: 5/5
The PR appears safe to merge; no blocking failures were found.Summary
Removes discarded remote-query reads from server loads so client navigation does not fetch the same data twice.
Diagram
Reviews (6) · Last reviewed commit: "Load page data once per control-plane na..." · Reviewed by Greptile