Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
14 changes: 8 additions & 6 deletions scripts/ui-assets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ function(ui_validate_assets files in_dir)
set(found_index FALSE)
set(found_manifest FALSE)
set(found_sw FALSE)
# the service worker: SvelteKit's service-worker.js, or Workbox's workbox-*.js in the
# prebuilt archives of builds before SvelteKit 3
set(found_service_worker FALSE)
set(found_build_json FALSE)
set(found_version_json FALSE)
set(found_bundle_js FALSE)
set(found_bundle_css FALSE)
set(found_workbox_js FALSE)

foreach(f ${files})
get_filename_component(base "${f}" NAME)
Expand All @@ -86,6 +88,8 @@ function(ui_validate_assets files in_dir)
set(found_manifest TRUE)
elseif(base STREQUAL "sw.js")
set(found_sw TRUE)
elseif(base STREQUAL "service-worker.js" OR base MATCHES "^workbox.*\\.js$")
set(found_service_worker TRUE)
elseif(base STREQUAL "build.json")
set(found_build_json TRUE)
elseif(base STREQUAL "version.json")
Expand All @@ -94,8 +98,6 @@ function(ui_validate_assets files in_dir)
set(found_bundle_js TRUE)
elseif(base MATCHES "^bundle.*\\.css$")
set(found_bundle_css TRUE)
elseif(base MATCHES "^workbox.*\\.js$")
set(found_workbox_js TRUE)
endif()
endforeach()

Expand All @@ -109,6 +111,9 @@ function(ui_validate_assets files in_dir)
if(NOT found_sw)
list(APPEND missing "sw.js")
endif()
if(NOT found_service_worker)
list(APPEND missing "service-worker.js (or workbox[hash].js in an older build)")
endif()
if(NOT found_build_json)
list(APPEND missing "build.json")
endif()
Expand All @@ -121,9 +126,6 @@ function(ui_validate_assets files in_dir)
if(NOT found_bundle_css)
list(APPEND missing "bundle[hash].css")
endif()
if(NOT found_workbox_js)
list(APPEND missing "workbox[hash].js")
endif()

if(missing)
set(listing "")
Expand Down
12 changes: 8 additions & 4 deletions tools/server/server-http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,10 @@ bool server_http_context::init_listener(const common_params & params) {
srv->Get(params.api_prefix + "/index.html", serve_asset_cached("index.html", true, cache_revalidate));

// All remaining assets registered directly from the embedded asset table.
// PWA revalidation files (sw.js, manifest, version.json) use no-cache;
// PWA revalidation files (service workers, manifest, version.json) use no-cache;
// everything else is immutable.
static const std::unordered_set<std::string> no_cache_names = {
"service-worker.js",
"sw.js",
"manifest.webmanifest",
"_app/version.json",
Expand All @@ -588,9 +589,10 @@ bool server_http_context::init_listener(const common_params & params) {
}

// a browser that used the built-in UI keeps its service worker, so it shows the old UI even after the UI is replaced or disabled
// answer the worker's update check with a worker that removes itself; a sw.js in public_path is served first
// answer the worker's update check with a worker that removes itself; a worker file in public_path is served first
// sw.js is the worker path of older UI builds, service-worker.js the current one
if (!params.ui || !params.public_path.empty()) {
srv->Get(params.api_prefix + "/sw.js", [](const httplib::Request &, httplib::Response & res) {
const auto serve_sw_remove = [](const httplib::Request &, httplib::Response & res) {
static constexpr const char * sw_remove_js = R"(
self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('activate', (e) => e.waitUntil((async () => {
Expand All @@ -601,7 +603,9 @@ self.addEventListener('activate', (e) => e.waitUntil((async () => {
)";
res.set_header("Cache-Control", "no-cache");
res.set_content(sw_remove_js, "application/javascript");
});
};
srv->Get(params.api_prefix + "/sw.js", serve_sw_remove);
srv->Get(params.api_prefix + "/service-worker.js", serve_sw_remove);
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/apps/chat/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Preview } from '@storybook/sveltekit';
import '../src/app.css';
import ModeWatcherDecorator from './decorators/ModeWatcherDecorator.svelte';
import TooltipProviderDecorator from './decorators/TooltipProviderDecorator.svelte';
import type { Preview } from '@storybook/sveltekit';

const preview: Preview = {
parameters: {
Expand Down
4 changes: 2 additions & 2 deletions ui/apps/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ ui/apps/chat/ → build → build/ui/apps/chat/dist/
### SvelteKit Configuration

```javascript
// svelte.config.js
// vite.config.ts - options passed to sveltekit({ ... })
adapter: adapter({
pages: '../../../build/ui/apps/chat/dist', // Output directory
assets: '../../../build/ui/apps/chat/dist', // Static assets
Expand Down Expand Up @@ -363,7 +363,7 @@ Components are organized in `app/` (application-specific) and `ui/` (shadcn-svel
| `DialogConfirmation` | Generic confirmation for destructive actions |
| `DialogConversationRename` | Edit conversation title |

**Server/Model Components** (`app/server/`, `app/models/`):
**Server/Model Components** (`app/servers/`, `app/models/`):

| Component | Responsibility |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------- |
Expand Down
3 changes: 2 additions & 1 deletion ui/apps/chat/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
import svelteConfig from './svelte.config.js';
import { includeIgnoreFile } from '@eslint/compat';
import js from '@eslint/js';
import { loadConfig } from '@sveltejs/load-config';
import prettier from 'eslint-config-prettier';
import perfectionist from 'eslint-plugin-perfectionist';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
Expand All @@ -11,6 +11,7 @@ import globals from 'globals';
import { fileURLToPath } from 'node:url';
import ts from 'typescript-eslint';

const svelteConfig = (await loadConfig('./', { traverse: false }))?.config;
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
// Require a blank line between sibling element-like nodes in a Svelte template
// (elements, components, and the {#if} / {#each} / {#await} / {#snippet} /
Expand Down
Loading
Loading