Skip to content

Move workspace page checks from server loads into queries - #282

Merged
tnkuehne merged 1 commit into
mainfrom
drop-workspace-server-loads
Nov 22, 2026
Merged

tnkuehne merged 1 commit into
mainfrom
drop-workspace-server-loads

Conversation

@tnkuehne

@tnkuehne tnkuehne commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

On client-side navigation, a page with a server load first fetches __data.json. Its component starts its queries only after that response arrives, so each click waited for two server requests in a row. Most workspace pages had a server load that only set a header, read URL parameters, checked a permission or returned a 404. This moves that work into the queries the pages already call, following the remote functions docs (getPost with error(404), redirect in queries, form.result instead of a redirect).

Changes

  • Cache header in the request hook: handle sets cache-control: private, no-store on every HTML response. Before, only pages with a load sent it, and only because each load set it. Without it, the browser's Back button shows a private page again after sign-out (RFC 9111, section 6). SvelteKit already sends no-store on __data.json and remote function responses. A new browser test signs out and goes Back. Without the hook header, it fails.
  • Loads removed: Home, My apps, My connections, connection requests, administration, agents and company sign-in. Pages read q, filter, page and error from page.url, and route parameters from params.
  • Checks moved into queries:
    • getAgents returns 403 to non-administrators. The API still lists agents for app creators.
    • New queries carry the old load checks:
      • getAppCreation: creator check and preview original
      • getServiceListApp
      • getServiceAvailability: administrator check and 404
      • getServiceConnection
      • getConnectionResult
      • getConnectionRequest
      • checkSsoSetup: redirect when SSO is active
      • getWelcome: administrator redirect
  • App route: [appId] became [appId=identifier]. A matcher in src/params.ts replaces the load's 404 for an ID that is not a UUID. Such a URL no longer matches a route, so it gets the root 404 page, as an unknown organization slug already does.
  • Rollback request ID: getAppDetails returns a fresh requestId. The value is serialized with the query result, so the server-rendered form and the hydrated page share it. As before, the layout keeps the submitted ID until a rollback succeeds, so a retry is recognized as the same request.
  • Saved notices: setting a member role, inviting, app access, access management and API availability return a result instead of redirecting to ?saved=1, ?accessSaved=1 or ?invited=1. Without JavaScript, SvelteKit renders the page with the form's result. Inviting and setting availability always redirected before, even with JavaScript.
  • API list: the three queries start together instead of one after another.

Remaining workspace loads:

  • [organization]/+layout.server.ts: its 404 runs again only when the organization changes.
  • The /settings redirect.

Trade-offs without JavaScript

These apply only when a form is submitted without JavaScript.

  • After a native form post, the page shows the result at the form's URL. Reloading it asks to resend the form, and the page no longer jumps to the #access or #app-access section.
  • Access management: after revoking someone who then appears in neither list, no "App access saved" notice is shown. The list itself shows the change.

Measurements

Client navigation with 250 ms of added latency per server data request, median of rounds two and three, main vs. this branch:

Click main This branch
Home 562 ms (__data.json, then getCatalog) 302 ms (getCatalog)
My apps 579 ms (__data.json, then getApps) 299 ms (getApps)
New app 570 ms (__data.json, then getApps) 286 ms (getAppCreation)
App access 424 ms (__data.json, then getAppAccess) 142 ms (getAppAccess)
Access management, app overview, agents about 300 ms (__data.json) no request (cached query)
APIs 810 ms (__data.json, then two queries one after another) 300 ms (three queries together)
Members 556 ms (__data.json, then getMembers) 304 ms (getMembers)
Company sign-in 558 ms (__data.json, then getSettings) 314 ms (getSettings)
My connections 564 ms (__data.json, then getUserConnections) 275 ms (getUserConnections)

Validation

  • pnpm check
  • Browser tests: 93 passed, 1 skipped. The CLI login suite did not run locally because the CLI binary was not built.
  • New browser tests:
    • Agents: an app creator gets 403 on the agents page, both on a full request and after client navigation.
    • Back after sign-out: the test signs out and goes Back. With the hook header removed, it fails.

RetriggerView in GreptileConfidence Score: 4/5

Preserve working Home addresses for existing organizations with reserved slugs before merging.

Summary

The PR removes page loads and moves workspace addresses and queries to an explicit organization.

  • Workspace pages use organization-specific addresses and queries.
  • Workspace pages load their data without an extra server round trip.
  • Private workspace pages stay private without relying on page loads.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["Workspace URL with organization slug"] --> B["Request hook checks membership"]
  B --> C["Workspace query resolves organization"]
  C --> D["Page queries receive organization ID"]
  D --> E["Remote function checks membership"]
  E --> F["Server operation checks resource access"]
Loading

Reviews (3) · Last reviewed commit: "Move workspace page checks from server l..." · Reviewed by Greptile

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 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 92f660b Nov 22 2026, 11:17 AM

@tnkuehne
tnkuehne force-pushed the drop-workspace-server-loads branch from f43aa40 to 1630b08 Compare November 22, 2026 09:19
@tnkuehne
tnkuehne changed the base branch from main to skip-refresh-before-org-reload November 22, 2026 09:19
@tnkuehne
tnkuehne added this pull request to stack #285 November 22, 2026 09:19
@tnkuehne tnkuehne changed the title Remove server loads that only set a cache header or read the URL Remove server loads that only set a cache header, read the URL or check a permission Nov 22, 2026
@tnkuehne
tnkuehne marked this pull request as draft November 22, 2026 09:43
A server load makes every client navigation fetch __data.json before the
page's queries start. Workspace pages used loads only to set the cache
header, read URL parameters, check permissions, return 404s and redirect.

The request hook now sets private, no-store on every HTML response, so
Back after sign-out asks the server again. Checks and redirects run in the
queries, saved notices come from form results, an app path matches only a
UUID, and getAppDetails provides the rollback request ID.
@tnkuehne
tnkuehne removed this pull request from stack #285 November 22, 2026 11:16
@tnkuehne
tnkuehne force-pushed the drop-workspace-server-loads branch from 1630b08 to 92f660b Compare November 22, 2026 11:16
@tnkuehne
tnkuehne changed the base branch from skip-refresh-before-org-reload to main November 22, 2026 11:17
@tnkuehne
tnkuehne marked this pull request as ready for review November 22, 2026 11:17
@tnkuehne tnkuehne changed the title Remove server loads that only set a cache header, read the URL or check a permission Move workspace page checks from server loads into queries Nov 22, 2026
@greptile-apps

greptile-apps Bot commented Nov 22, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Existing Home links break packages/contracts/src/organizations.ts:43 ▶

    Existing organizations can already have slugs such as setup; the old creation rules allowed them. Their Home link now points to /setup, which opens the public setup page instead of the organization. After installation, that page redirects to /sign-in.

    The new check in createOrganizationInput only protects new organizations. Preserve a working address for existing organizations with these names, or migrate their slugs before switching the routes.

@tnkuehne

Copy link
Copy Markdown
Contributor Author

The reserved slugs and the routes they collide with come from #283; this PR does not change them. Handling existing organizations with such slugs is out of scope here and will be decided separately.

@tnkuehne
tnkuehne merged commit ded27a3 into main Nov 22, 2026
2 checks passed
@tnkuehne
tnkuehne deleted the drop-workspace-server-loads branch November 22, 2026 11:29
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.

1 participant