Skip to content

refactor: frontend on SvelteKit 3 with adapter-static and Vite - #330

Merged
HardMax71 merged 2 commits into
mainfrom
refactor/frontend-sveltekit
Oct 11, 2026
Merged

HardMax71 merged 2 commits into
mainfrom
refactor/frontend-sveltekit

Conversation

@HardMax71

@HardMax71 HardMax71 commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #325, step 2 of #328. Closes #291.

The frontend now runs on SvelteKit 3 with adapter-static on Vite 8. That replaces the Rollup config with its hand-written HTTPS dev server and proxy, @mateothegreat/svelte5-router, main.ts and App.svelte. The app stays a client-rendered SPA: the root +layout.ts sets ssr = false, and nginx serves the 200.html fallback for every path that isn't a file.

Pages are +page.svelte files under src/routes/. The login and admin checks are load functions in (auth)/+layout.ts and admin/+layout.ts, sharing lib/auth-guard.ts, so they run before a page mounts. The admin pages no longer wrap themselves in AdminLayout, since admin/+layout.svelte is the sidebar now, and /admin redirects to /admin/events. <svelte:head> replaces utils/meta.ts, and page titles read "Page - Integr8sCode".

+error.svelte and handleError in hooks.client.ts replace the error store and main.ts's global onerror and unhandledrejection handlers. Those handlers are what swapped the whole app for the error screen after a failed API call in a click handler (#291). Now the toast is all that happens, and the error page only shows when navigating, loading or rendering fails.

SvelteKit 3 dropped the $lib alias, so imports use package.json subpath imports with explicit extensions: #lib/api/index.ts, #stores/auth.svelte.ts, #components/Header.svelte. That's a mechanical rewrite across 132 files, tests included.

The CSP changes shape. SvelteKit forbids nonces on prerendered pages, so it writes the policy into 200.html as a <meta> tag, with a sha256 hash of its one inline bootstrap script. The directives match what nginx used to send. nginx no longer rewrites **CSP_NONCE** placeholders, and it sends only frame-ancestors 'none', which a meta CSP can't carry. I served the built site through the same nginx template locally and loaded it in Chrome. Every page renders, the guards redirect, and there are no CSP violations.

Getting to zero meant switching the generated schemas to zod/mini. Classic Zod probes new Function while it builds a schema, and since #329 that has logged a blocked-eval violation on every page load. Mini never tries. It ships no message locale, so firstIssue now words type errors itself.

Also: Tailwind runs through @tailwindcss/vite and the PostCSS chain is gone, the logger reads import.meta.env.DEV, and the Dockerfile copies build/. Rollup and its plugins, svelte-preprocess, express, http-proxy, sirv-cli and the router are uninstalled.

Tests mock $app/navigation instead of the router. The AdminLayout test mocks $app/state, the meta spies became document.title checks, and the guards, the error page and the client hooks have their own tests.

Checked: npm run check, lint, Stylelint, Prettier, 1137 Vitest tests with coverage above the thresholds, vite build, mkdocs build --strict, and a byte-identical client from ./deploy.sh openapi plus npm run generate:api. I couldn't build the Docker image locally, because npm ci timed out on the network inside the build, so CI's Stack Tests run will be its first build, along with the Playwright suite.


Summary by cubic

The frontend moves from Rollup with @mateothegreat/svelte5-router to SvelteKit 3 with adapter-static on Vite 8, closing #325 and #291 as part of #328. The app stays a client-rendered SPA, and the new error handling fixes #291: a failed API call in a click handler now shows a toast instead of replacing the whole app with the error screen.

  • Pages become +page.svelte files; auth and admin checks run as load functions in (auth)/+layout.ts and admin/+layout.ts before a page mounts; /admin redirects to /admin/events, and the guards and redirect now have tests.
  • SvelteKit 3 drops the $lib alias, so imports move to package.json subpath imports with explicit extensions (#lib/api/index.ts, #stores/auth.svelte.ts, #components/Header.svelte), and the build targets ESNext now that the tsconfig does.
  • The CSP moves from per-request nginx nonces to a <meta> tag SvelteKit hashes into 200.html; nginx now only sends frame-ancestors 'none'.
  • Generated schemas switch to zod/mini, which never probes new Function, removing the blocked-eval CSP violation on every page load; firstIssue now words type errors itself.
  • generate:api runs svelte-kit sync first, since openapi-ts reads the $app tsconfig only that command writes, which broke the Generated API job on a clean install.
  • Tailwind runs through @tailwindcss/vite; Rollup, svelte-preprocess, express, http-proxy, sirv-cli and the router are removed, and the Dockerfile copies build/.

Written for commit cd463cf. Summary will update on new commits.

View guided diff Turn on auto-fix

SvelteKit's router, layout guards, error page and svelte:head replace the
svelte5-router setup, main.ts, App.svelte, the error store and meta.ts;
Vite replaces the Rollup config and its hand-written dev server. Imports
move to package.json subpath imports since SvelteKit 3 dropped $lib. The
CSP is a meta tag Kit hashes into 200.html, so nginx stops injecting
nonces, and the generated schemas use zod/mini, which never probes eval.
Dropping the global error handlers stops a failed API call in a click
handler from replacing the app.

Closes #325
Closes #291
@HardMax71 HardMax71 added the area: frontend Svelte UI and the generated API client label Oct 11, 2026
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5db2892a-2871-428c-b482-7d0f55a44c4b

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Improvements or additions to documentation area: realtime SSE streams and notifications area: deploy Compose, deploy.sh, images, release workflow, production host labels Oct 11, 2026
@codecov-commenter

codecov-commenter commented Oct 11, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 88.64629% with 52 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
frontend/src/routes/admin/executions/+page.svelte 76.66% 4 Missing and 17 partials ⚠️
frontend/src/routes/admin/settings/+page.svelte 87.03% 6 Missing and 8 partials ⚠️
frontend/src/routes/admin/events/+page.svelte 91.75% 6 Missing and 2 partials ⚠️
frontend/src/routes/admin/sagas/+page.svelte 90.90% 3 Missing and 2 partials ⚠️
frontend/src/lib/logger.ts 0.00% 0 Missing and 1 partial ⚠️
frontend/src/routes/+error.svelte 80.00% 0 Missing and 1 partial ⚠️
frontend/src/routes/admin/+layout.svelte 92.85% 0 Missing and 1 partial ⚠️
frontend/src/routes/admin/users/+page.svelte 95.45% 0 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Flag Coverage Δ
backend-e2e 82.84% <ø> (-0.07%) ⬇️
backend-unit 72.37% <ø> (ø)
frontend-unit 87.72% <88.64%> (+1.60%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
frontend/src/components/Footer.svelte 94.11% <ø> (ø)
frontend/src/components/Header.svelte 89.71% <100.00%> (ø)
frontend/src/components/NotificationCenter.svelte 81.91% <ø> (ø)
...end/src/components/admin/AutoRefreshControl.svelte 85.00% <ø> (ø)
...c/components/admin/events/EventDetailsModal.svelte 90.47% <ø> (ø)
...nd/src/components/admin/events/EventFilters.svelte 73.80% <ø> (ø)
...src/components/admin/events/EventStatsCards.svelte 75.00% <ø> (ø)
...end/src/components/admin/events/EventsTable.svelte 76.84% <ø> (ø)
.../components/admin/events/ReplayPreviewModal.svelte 90.00% <ø> (ø)
...omponents/admin/events/ReplayProgressBanner.svelte 92.85% <ø> (ø)
... and 54 more

... and 1 file with indirect coverage changes

Components Coverage Δ
Backend 91.35% <ø> (-0.05%) ⬇️
Frontend 87.72% <88.64%> (+1.60%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…oute files

openapi-ts reads tsconfig.json, which extends the $app/tsconfig that only
svelte-kit sync writes, so the Generated API job failed on a clean install.
Also use replaceAll and .at() now that the tsconfig targets ESNext, and test
the root layout, the guard layouts and the /admin redirect.
@sonarqubecloud

Copy link
Copy Markdown

@HardMax71
HardMax71 merged commit 954fcc9 into main Oct 11, 2026
22 of 24 checks passed
@HardMax71
HardMax71 deleted the refactor/frontend-sveltekit branch October 11, 2026 16:13
HardMax71 added a commit that referenced this pull request Oct 11, 2026
…once (#332)

CodeMirror injects its theme as a <style> tag in the document head, and the meta CSP from #330 blocks it, so the editor renders with no gutter and no highlighting. 200.html now carries a nonce placeholder in style-src-elem and in a csp-nonce meta tag, nginx swaps in $request_id per response, and the editor passes it to EditorView.cspNonce, as it did before #330.

A Playwright test checks the gutter layout and fails on any CSP violation; it fails on main and passes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: deploy Compose, deploy.sh, images, release workflow, production host area: frontend Svelte UI and the generated API client area: realtime SSE streams and notifications documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: frontend on SvelteKit with adapter-static and Vite [Bug]: a failed API call in a click handler replaces the whole app with the error page

2 participants