Skip to content

ui: move Llama Chat to SvelteKit 3 and its built-in service worker - #32463

Merged
allozaur merged 5 commits into
ggml-org:masterfrom
allozaur:allozaur/chore/ui-sveltekit-3-upstream
Nov 17, 2026
Merged

allozaur merged 5 commits into
ggml-org:masterfrom
allozaur:allozaur/chore/ui-sveltekit-3-upstream

Conversation

@allozaur

@allozaur allozaur commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Llama Chat moves to SvelteKit 3 (3.2.0) and replaces Workbox with SvelteKit's own service worker. Nothing changes for the user: the app looks and works the same, installs as a PWA, works offline, and asks to reload when llama-server ships a new build.

Most of the diff is a codemod: SvelteKit 3 drops the $lib alias, so every import of the app's own code becomes a #lib/... subpath import, and 657 of the 724 files change only that. The rest is a handful of renames and simple additions, plus a few changes that go further: the config, the service worker and its update flow, and two small changes in llama-server and the CMake asset check.

Additional information

Codemod, replacements and simple additions
  • Imports (codemod). $lib/X becomes #lib/X.ts, #lib/X.svelte.ts or #lib/X/index.ts, naming the file on disk, and $app/environment becomes $app/env. Import order and line wrapping follow from the longer paths. package.json maps #lib/* to ./src/lib/*.
  • Server-only names (renames). SvelteKit 3 refuses to bundle modules named server.* or folders named server/ for the browser. The server status components move to components/app/servers/, and the store and enums become llama-server.*; their exports keep their names.
  • Renamed APIs. replaceState(url) and goto(url, { replaceState }) become goto(url, { replace, shallow }), invalidateAll() becomes refreshAll(), $page from $app/stores becomes page from $app/state, and copies of the now read-only page.url come from page.url.href.
  • Base path. base from $app/paths is gone: server requests go through a small withBase() helper over asset(), and static files use asset().
  • Svelte 5 patterns, following svelte.dev's best practices: actions become attachments ({@attach}), class: directives become class arrays, the chat contexts come from createContext, and the last store and the last legacy-mode component move to runes.
  • ESLint 10, with its two new recommended rules applied: rethrown errors keep the original as cause, and two variables lose an initial value that was always overwritten.
  • Dependencies. SvelteKit 3.2.0, adapter-static 4, vite-plugin-svelte 7, Vite 8, TypeScript 6, Svelte 5.57 and Storybook 10.6; @vite-pwa/sveltekit and Workbox go. minimatch is overridden to 11.0.5 for a moderate advisory under ESLint and typescript-eslint, whose own fixes are younger than the repo's 7-day min-release-age. npm audit finds nothing.
What changes more
  • Config. svelte.config.js is gone: its options (the static adapter, the single bundle, relative paths, the hash router, mdsvex) live in sveltekit({ ... }) in vite.config.ts, as SvelteKit 3 expects. tsconfig.json extends the generated $app/tsconfig. A small Vite plugin serves and emits manifest.webmanifest, which the PWA plugin used to generate.
  • Service worker. src/service-worker/index.ts precaches the app shell, the bundle, the manifest and the static files, fetched with cache: 'reload' so a stale index.html from the HTTP cache can't land next to a new bundle. It serves only those from cache; API requests always go to the network, as before.
  • Update detection. usePwa() registers the worker and shows the refresh prompt when a new one waits. A page the worker doesn't control learns of a new build from SvelteKit's updated state, which replaces the version the app kept in localStorage. Reload activates the new worker before reloading, so one click lands on the new build either way.
  • Old installs. static/sw.js replaces the old Workbox worker for browsers that installed an earlier build: their update check fetches it, it removes itself and its caches, and the reloaded page registers service-worker.js.
  • llama-server. server-http.cpp serves service-worker.js with no-cache, like sw.js, and answers both with the self-removing worker when the built-in UI is off or replaced. scripts/ui-assets.cmake accepts service-worker.js, or workbox-*.js from older prebuilt archives.
Testing
  • ui/apps/chat: npm ci, npm run check (0 errors), npm run lint, the 763 unit tests, the 270 client tests, the 49 Storybook tests and npm run build pass. npm audit finds 0 vulnerabilities.
  • The update path in llama-server, with the UI built into it (-DLLAMA_BUILD_UI=ON) and one browser profile on one origin, in headless Chromium:
    1. llama-server from master: the Workbox sw.js controls the page, with its workbox-precache cache.
    2. llama-server from this branch: the first load already runs the new bundle. The old worker and its cache are gone, service-worker.js is active, and it controls the page after a reload.
    3. llama-server from this branch, rebuilt with a new UI version: "Update available" shows while the old build keeps running, and one click on Reload loads the new bundle and leaves only the new cache.
  • A fresh profile on this branch's llama-server registers service-worker.js and precaches the app. Offline loads and both update paths were also checked against vite preview.
  • The build passes the CMake asset check, which embeds 70 assets. llama-server serves service-worker.js and sw.js with Cache-Control: no-cache.

Requirements

Swap the mdast stub for @types/mdast, move the katex override to 0.19.0,
and override glob, source-map and html-encoding-sniffer under
workbox-build and http-server so installs no longer pull deprecated
packages. Apply the non-breaking npm audit fixes to the lockfile.

Assisted-by: Claude (Opus 5.5 Medium)
Move to SvelteKit 3, Vite 8, TypeScript 6 and Storybook 10.6. The
SvelteKit options move from svelte.config.js into sveltekit() in
vite.config.ts, $lib imports become #lib subpath imports from
package.json, and $app/environment becomes $app/env. Modules named
server.* or living under a server/ folder are server-only in SvelteKit 3,
so the llama-server components, store and enums move to llama-server
names.

@vite-pwa/sveltekit and Workbox give way to SvelteKit's own service
worker in src/service-worker, registered by usePwa(), which precaches the
app files and leaves API requests to the network. A small plugin emits
manifest.webmanifest. static/sw.js removes the worker of older builds, and
llama-server serves a self-removing service-worker.js as well as sw.js
when the built-in UI is off or replaced.

Assisted-by: Claude (Opus 5.5 Medium)
A page the service worker doesn't control now learns of a new build
from SvelteKit itself: `updated` from $app/state checks
_app/version.json on navigation, on focus and every hour. It replaces
the version Llama Chat kept in localStorage and compared by hand.
Reload on the update prompt pulls in the new worker and activates it
before reloading, so one click lands on the new build, whether or not
a worker controlled the page.

Following Svelte's current guidance:
- usePwa keeps its state in $state rather than a store, and no effect
  checks `browser`
- nearViewport, autoResizeTextarea and the custom CSS injection are
  attachments ({@Attach}) rather than actions (use:)
- class lists use arrays rather than class: directives
- the chat contexts come from createContext, typed, in place of
  setContext/getContext with string keys
- ActionIconCopyToClipboard takes $props() rather than `export let`

Assisted-by: Claude (Opus 5.5 Medium)
ESLint 9 is out of support. Every plugin the app uses supports 10:
typescript-eslint, eslint-plugin-svelte, perfectionist,
simple-import-sort, eslint-plugin-storybook and eslint-config-prettier.
@eslint/js and @eslint/compat follow.

ESLint 10's recommended rules ask for two things the code now does:
errors rethrown from a catch keep the caught error as their `cause`,
and no variable starts with a value that every path overwrites.

Assisted-by: Claude (Opus 5.5 Medium)
ESLint 10.14, @eslint/config-array 0.23.5 and typescript-eslint 8.72
depend on minimatch 10, which GHSA-g3hv-75wg-m249 (denial of service
via globparts amplification) affects below 11.0.1. Their fixed releases
move to minimatch 11 but are all younger than the repo's 7-day
min-release-age, so an override pins minimatch 11.0.5, the newest the
rule allows. The three only call new Minimatch(), match() and
minimatch(), which minimatch 11 keeps. npm audit now finds nothing.

Assisted-by: Claude (Opus 5.5 Medium)
@github-actions github-actions Bot added documentation Improvements or additions to documentation server server/ui labels Nov 17, 2026
@allozaur
allozaur marked this pull request as ready for review November 17, 2026 10:31
@allozaur
allozaur requested review from a team as code owners November 17, 2026 10:31
@allozaur
allozaur merged commit 67cf896 into ggml-org:master Nov 17, 2026
33 of 36 checks passed
gabe-l-hart added a commit to gabe-l-hart/llama.cpp that referenced this pull request Nov 17, 2026
* origin/master: (138 commits)
qwen4exp : fix graph reallocation from the n-gram table scale (ggml-org#32483)
server : return 400 when grammar and ignore_eos are on (ggml-org#32377)
ggml-cuda: disable quantized matvec fusion on all Pascal GPUs (ggml-org#32239)
Title: CUDA: few-row MMQ for MUL_MAT_ID (ggml-org#32065)
ui: turn the live markdown preview off by default (ggml-org#32469)
CUDA: use block reductions for whole-row pool_1d (ggml-org#31855)
ggml : decode F8_E4M3 to fp32 without ldexpf (ggml-org#32477)
llama : keep the k-pool layout prefix on sequence edits (ggml-org#32137)
vocab : speed up PLaMo-2/3 tokenizer table build (ggml-org#32249)
convert : fix FP8 qwen4exp checkpoints (n-gram table scale, block-scaled FP8) (ggml-org#32476)
ui: Llama UI design system: tokens, surfaces and fonts (ggml-org#32468)
mtmd: support Minimax-Music3 (ggml-org#32435)
chat: add tts_dict for kokoro G2P template (ggml-org#32397)
Rotate K/V read order for better L2 cache hit rates (ggml-org#32407)
ui: turn conversation tabs off by default (ggml-org#32402)
ui: move Llama Chat to SvelteKit 3 and its built-in service worker (ggml-org#32463)
qwen3next : apply output projection weight scale (ggml-org#32393)
cuda : raise shared mem limit only for the launched kernel (ggml-org#32392)
nix: expose a SYCL package (ggml-org#31066)
vulkan: disable flip Flash Attention shader on AMD Windows due to a driver bug (ggml-org#32415)
...
Cinderella-Man added a commit to Cinderella-Man/miner-llama that referenced this pull request Nov 17, 2026
…1525)

73 upstream commits after b12410, among them the server's slot scheduler (ggml-org#32154, b12411), the warp-primitive
wrappers (ggml-org#31617, b12414), kv-cells' indexed sequence removal (ggml-org#32380) and the web UI's move to ui/apps/chat
(ggml-org#32032, ggml-org#32463). 8 files conflicted in 9 hunks; every fork switch keeps its default (off) and v4.0's presets
mean the same; upstream's changes are taken except where noted:
- ggml-org#32154 moves server_prompt, server_prompt_cache and slot selection into server-slot-sched.{h,cpp}, the reuse
  of a slot's cells into server_prompt::get_reuse(). The fork's checkpoint sharing (--ctx-checkpoints-share:
  the checkpoint aliases, server_prompt_checkpoints_copy, clone(share), server_prompt_cache::share_checkpoints
  and alloc's copy) moves with them. get_reuse takes the fork's two sliding-window rules as arguments, false by
  default (upstream's rule): ring_past (a ring checkpoint past the divergence may serve it,
  LLAMA_SERVER_CKPT_RING_PAST) and resume_next (resume one past the checkpoint's pos_max,
  LLAMA_SERVER_CKPT_RESUME_NEXT), both given only with ckpt_trim, as before; it returns its pos_min threshold
  for the log. The caller keeps the fork's restore log, timing and cache statistics (cache_src, n_ckpt_pos,
  t_restore_us) and the reset log, with the same values as before.
- ggml-org#32380 adds llama_kv_cells::seq_rm(seq_id, p0, p1), a walk of the sequence's position index. The fork's
  llama_kv_cache::seq_rm stays: by default the scan of every cell (v4.0), with LLAMA_KV_SEQ_RM_BOUND the same
  walk in cell order, both marking the KQ cells and keeping LLAMA_KV_HEAD_EMPTY/_TAIL's head rules (v4.0's
  Flint and Flash-Next lines set LLAMA_KV_SEQ_RM_BOUND=1). The new cells method is unused here.
- ggml-org#32392 raises the shared memory limit only for the launched mul_mat_q: taken, with the fork's kq_fp32
  template argument; ggml-org#31599's row-innermost grid is HIP only.
- ggml-org#31617 replaces WARP_SIZE and the _sync primitives by warp_size and ggml_cuda_shfl*/ballot: taken in
  topk-moe.cu (the fork's MoE-tail path keeps its own __shfl_sync calls, the same instructions on a 32-wide
  warp) and in common.cuh, where ggml-common.h moves below the vendor headers and the fork's profile-light.h and
  graph-patch.h stay where they were.
- ggml-org#31327 (GDN mma kernel on CDNA): upstream's renamed locals, with the fork's state_ids row (soff_in).
The other 32 files both sides change merged without conflict and hold each side's changed lines exactly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dzannotti added a commit to halo-box/strix-llama.cpp that referenced this pull request Nov 17, 2026
Upstream: ggml-org/llama.cpp 8f647f1..67cf896 (4 commits)

Conflicts:
- ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte: kept the fork ExternalLink import (server dashboard link) with upstream ggml-org#32463's #lib/.../index.ts aliases; upstream now imports goto and page itself, so the fork copies are dropped.
- ui/apps/chat/src/lib/constants/ui.constants.ts: kept the fork Gauge icon and SERVER_DASHBOARD_URL imports with upstream's #lib aliases.

Assisted-by: Claude Opus 5.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YKmjzcT1LTvKtbw9EzBVGE
wanghqc added a commit to qualcomm/llama.cpp that referenced this pull request Nov 19, 2026
Backport of the build part of upstream 67cf896 (ggml-org#32463). The prebuilt UI
bundle now ships service-worker.js in place of workbox[hash].js, so the asset
check failed every build that includes llama-server. Accept either file, and
have llama-server answer service-worker.js with the self-removing worker too.
fencerJP added a commit to fencerJP/llama-apu that referenced this pull request Nov 21, 2026
fencerJP added a commit to fencerJP/llama-apu that referenced this pull request Nov 21, 2026
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
…gml-org#32463)

* ui: replace deprecated packages and fix npm audit findings

Swap the mdast stub for @types/mdast, move the katex override to 0.19.0,
and override glob, source-map and html-encoding-sniffer under
workbox-build and http-server so installs no longer pull deprecated
packages. Apply the non-breaking npm audit fixes to the lockfile.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: migrate Llama Chat to SvelteKit 3 and its built-in service worker

Move to SvelteKit 3, Vite 8, TypeScript 6 and Storybook 10.6. The
SvelteKit options move from svelte.config.js into sveltekit() in
vite.config.ts, $lib imports become #lib subpath imports from
package.json, and $app/environment becomes $app/env. Modules named
server.* or living under a server/ folder are server-only in SvelteKit 3,
so the llama-server components, store and enums move to llama-server
names.

@vite-pwa/sveltekit and Workbox give way to SvelteKit's own service
worker in src/service-worker, registered by usePwa(), which precaches the
app files and leaves API requests to the network. A small plugin emits
manifest.webmanifest. static/sw.js removes the worker of older builds, and
llama-server serves a self-removing service-worker.js as well as sw.js
when the built-in UI is off or replaced.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: use SvelteKit 3's update detection and Svelte 5's current patterns

A page the service worker doesn't control now learns of a new build
from SvelteKit itself: `updated` from $app/state checks
_app/version.json on navigation, on focus and every hour. It replaces
the version Llama Chat kept in localStorage and compared by hand.
Reload on the update prompt pulls in the new worker and activates it
before reloading, so one click lands on the new build, whether or not
a worker controlled the page.

Following Svelte's current guidance:
- usePwa keeps its state in $state rather than a store, and no effect
  checks `browser`
- nearViewport, autoResizeTextarea and the custom CSS injection are
  attachments ({@Attach}) rather than actions (use:)
- class lists use arrays rather than class: directives
- the chat contexts come from createContext, typed, in place of
  setContext/getContext with string keys
- ActionIconCopyToClipboard takes $props() rather than `export let`

Assisted-by: Claude (Opus 5.5 Medium)

* ui: move to ESLint 10

ESLint 9 is out of support. Every plugin the app uses supports 10:
typescript-eslint, eslint-plugin-svelte, perfectionist,
simple-import-sort, eslint-plugin-storybook and eslint-config-prettier.
@eslint/js and @eslint/compat follow.

ESLint 10's recommended rules ask for two things the code now does:
errors rethrown from a catch keep the caught error as their `cause`,
and no variable starts with a value that every path overwrites.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: override minimatch to clear npm audit's last finding

ESLint 10.14, @eslint/config-array 0.23.5 and typescript-eslint 8.72
depend on minimatch 10, which GHSA-g3hv-75wg-m249 (denial of service
via globparts amplification) affects below 11.0.1. Their fixed releases
move to minimatch 11 but are all younger than the repo's 7-day
min-release-age, so an override pins minimatch 11.0.5, the newest the
rule allows. The three only call new Minimatch(), match() and
minimatch(), which minimatch 11 keeps. npm audit now finds nothing.

Assisted-by: Claude (Opus 5.5 Medium)
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
…gml-org#32463)

* ui: replace deprecated packages and fix npm audit findings

Swap the mdast stub for @types/mdast, move the katex override to 0.19.0,
and override glob, source-map and html-encoding-sniffer under
workbox-build and http-server so installs no longer pull deprecated
packages. Apply the non-breaking npm audit fixes to the lockfile.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: migrate Llama Chat to SvelteKit 3 and its built-in service worker

Move to SvelteKit 3, Vite 8, TypeScript 6 and Storybook 10.6. The
SvelteKit options move from svelte.config.js into sveltekit() in
vite.config.ts, $lib imports become #lib subpath imports from
package.json, and $app/environment becomes $app/env. Modules named
server.* or living under a server/ folder are server-only in SvelteKit 3,
so the llama-server components, store and enums move to llama-server
names.

@vite-pwa/sveltekit and Workbox give way to SvelteKit's own service
worker in src/service-worker, registered by usePwa(), which precaches the
app files and leaves API requests to the network. A small plugin emits
manifest.webmanifest. static/sw.js removes the worker of older builds, and
llama-server serves a self-removing service-worker.js as well as sw.js
when the built-in UI is off or replaced.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: use SvelteKit 3's update detection and Svelte 5's current patterns

A page the service worker doesn't control now learns of a new build
from SvelteKit itself: `updated` from $app/state checks
_app/version.json on navigation, on focus and every hour. It replaces
the version Llama Chat kept in localStorage and compared by hand.
Reload on the update prompt pulls in the new worker and activates it
before reloading, so one click lands on the new build, whether or not
a worker controlled the page.

Following Svelte's current guidance:
- usePwa keeps its state in $state rather than a store, and no effect
  checks `browser`
- nearViewport, autoResizeTextarea and the custom CSS injection are
  attachments ({@Attach}) rather than actions (use:)
- class lists use arrays rather than class: directives
- the chat contexts come from createContext, typed, in place of
  setContext/getContext with string keys
- ActionIconCopyToClipboard takes $props() rather than `export let`

Assisted-by: Claude (Opus 5.5 Medium)

* ui: move to ESLint 10

ESLint 9 is out of support. Every plugin the app uses supports 10:
typescript-eslint, eslint-plugin-svelte, perfectionist,
simple-import-sort, eslint-plugin-storybook and eslint-config-prettier.
@eslint/js and @eslint/compat follow.

ESLint 10's recommended rules ask for two things the code now does:
errors rethrown from a catch keep the caught error as their `cause`,
and no variable starts with a value that every path overwrites.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: override minimatch to clear npm audit's last finding

ESLint 10.14, @eslint/config-array 0.23.5 and typescript-eslint 8.72
depend on minimatch 10, which GHSA-g3hv-75wg-m249 (denial of service
via globparts amplification) affects below 11.0.1. Their fixed releases
move to minimatch 11 but are all younger than the repo's 7-day
min-release-age, so an override pins minimatch 11.0.5, the newest the
rule allows. The three only call new Minimatch(), match() and
minimatch(), which minimatch 11 keeps. npm audit now finds nothing.

Assisted-by: Claude (Opus 5.5 Medium)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation server/ui server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants