From fd9fc7b952657e7bc61451187b9c9ce98e9cdb46 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Mon, 16 Nov 2026 09:17:27 +0100 Subject: [PATCH 1/3] ui: let the dev proxy pass llama-server's cross-origin check llama-server refuses browser requests whose Origin does not match its own host unless --cors-origins allows it, and the Vite proxy forwarded the page's Origin (localhost:5173, or a LAN or Tailscale address). Loading a model, saving tools and /v1 calls failed with 403 under `vite dev`. The proxy now calls the server with its own Host and no Origin, WebSocket upgrades included. Sec-Fetch-Site still passes through, so requests from other sites stay refused. Assisted-by: Claude (Opus 5.5 Medium) --- ui/apps/chat/vite.config.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ui/apps/chat/vite.config.ts b/ui/apps/chat/vite.config.ts index 68493dad9656..4608938f35f0 100644 --- a/ui/apps/chat/vite.config.ts +++ b/ui/apps/chat/vite.config.ts @@ -13,7 +13,7 @@ import { playwright } from '@vitest/browser-playwright'; import { mdsvex } from 'mdsvex'; import { dirname, resolve } from 'path'; import { fileURLToPath } from 'url'; -import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite'; +import { defineConfig, loadEnv, type ProxyOptions, searchForWorkspaceRoot } from 'vite'; const __dirname = dirname(fileURLToPath(import.meta.url)); const LLAMA_VOICE_SOURCE = resolve(__dirname, '../../lib/voice/src'); @@ -38,6 +38,18 @@ const outDir = process.env.LLAMA_UI_OUT_DIR ?? './dist'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), 'VITE_PUBLIC_'); const SERVER_ORIGIN = env.VITE_PUBLIC_SERVER_ORIGIN || 'http://localhost:9931'; + // llama-server takes cross-origin browser requests only from --cors-origins, so the proxy + // calls it as its own page: the Host of the server and no Origin. Sec-Fetch-Site still + // passes through, so the server keeps refusing requests from other sites. + const toServer = (ws = false): ProxyOptions => ({ + changeOrigin: true, + configure: (proxy) => { + proxy.on('proxyReq', (req) => req.removeHeader('origin')); + proxy.on('proxyReqWs', (req) => req.removeHeader('origin')); + }, + target: SERVER_ORIGIN, + ws + }); return { build: { @@ -106,13 +118,13 @@ export default defineConfig(({ mode }) => { 'Cross-Origin-Opener-Policy': 'same-origin' }, proxy: { - '/cors-proxy': SERVER_ORIGIN, - '/models': SERVER_ORIGIN, - '/props': SERVER_ORIGIN, - '/slots': SERVER_ORIGIN, - '/tools': SERVER_ORIGIN, + '/cors-proxy': toServer(), + '/models': toServer(), + '/props': toServer(), + '/slots': toServer(), + '/tools': toServer(), // ws: realtime transcription (/v1/realtime) is a WebSocket - '/v1': { target: SERVER_ORIGIN, ws: true } + '/v1': toServer(true) } }, From f2bcb0e3725924d8bb05f44b91db5714c6848bde Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Mon, 16 Nov 2026 19:30:42 +0100 Subject: [PATCH 2/3] ui: navigate through resolve() with typed route ids ROUTES holds the app's route ids, as page.route.id reports them, in place of hash strings and the separate *_ROUTE_ID constants. Every link and goto() goes through resolve() from $app/paths, which checks the route exists and returns its URL (#/models with the hash router). RouterService resolves the routes that take params: a chat, a project, a project's chat or new chat, and an extension's page. Tab links, sidebar items and extension navigation items carry the resolved URL's type, and checks for the current page compare page.route.id instead of the hash. svelte/no-navigation-without-resolve is on again, with type information for the app's modules so a URL typed as ResolvedPathname passes. Links that leave the app say so with rel="external"; the deep-link cleanups, which change the current page's own query, are marked as such. Assisted-by: Claude (Opus 5.5 Medium) --- ui/apps/chat/eslint.config.js | 7 +++- .../ChatMessage/ChatMessage.svelte | 7 ++-- ...atMessageToolCallBlockSearchResults.svelte | 4 +-- .../app/chat/ChatScreen/ChatScreen.svelte | 2 +- .../app/chat/ChatTabs/ChatTabsItem.svelte | 3 +- .../dialogs/DialogModelNotAvailable.svelte | 1 + .../app/mcp/McpServerIdentity.svelte | 2 +- .../ModelsDiscoverDetailsHeader.svelte | 4 +-- .../SidebarNavigation.svelte | 11 ++++--- .../SidebarNavigationActions.svelte | 6 +--- .../app/servers/ServerErrorSplash.svelte | 3 +- .../app/settings/SettingsMcpServers.svelte | 1 + .../src/lib/constants/routes.constants.ts | 32 +++++++++---------- .../chat/src/lib/constants/ui.constants.ts | 8 ++--- ui/apps/chat/src/lib/services/index.ts | 2 +- .../chat/src/lib/services/router.service.ts | 11 ++++--- .../lib/stores/conversations/index.svelte.ts | 6 ++-- ui/apps/chat/src/lib/stores/tabs.svelte.ts | 9 +++--- ui/apps/chat/src/lib/stores/ui.svelte.ts | 13 ++++---- ui/apps/chat/src/lib/types/navigation.d.ts | 4 ++- ui/apps/chat/src/lib/utils/chat-tabs.ts | 10 +++--- ui/apps/chat/src/routes/(chat)/+page.svelte | 1 + .../src/routes/(chat)/chat/[id]/+page.svelte | 4 ++- ui/apps/chat/src/routes/+error.svelte | 5 +-- ui/apps/chat/src/routes/+layout.svelte | 9 +++--- ui/apps/chat/src/routes/search/+page.svelte | 3 +- .../client/nested-surfaces.svelte.test.ts | 1 - .../chat/tabs/ChatTabsItem.stories.svelte | 13 ++++++-- 28 files changed, 103 insertions(+), 79 deletions(-) diff --git a/ui/apps/chat/eslint.config.js b/ui/apps/chat/eslint.config.js index 330551d9d8d1..edbc71c487a3 100644 --- a/ui/apps/chat/eslint.config.js +++ b/ui/apps/chat/eslint.config.js @@ -266,7 +266,6 @@ export default ts.config( 'simple-import-sort/imports': ['error', { groups: [['.*']] }], 'svelte/no-at-html-tags': 'off', // This app uses hash-based routing (#/) where resolve() from $app/paths does not apply - 'svelte/no-navigation-without-resolve': 'off', // Sort HTML attributes alphabetically in the markup. The Svelte directives // (bind:/use:/animate:/style:/in:/out:/transition:/class:) sort first, @@ -321,6 +320,12 @@ export default ts.config( } } }, + { + // type information for the app's own modules too, so svelte/no-navigation-without-resolve + // accepts a URL typed as ResolvedPathname, such as RouterService.chat(id) + files: ['src/**/*.ts'], + languageOptions: { parserOptions: { projectService: true } } + }, { // Exclude generated build output and Storybook files from ESLint ignores: [ diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte index 0086107eed80..f4172daaf969 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessage.svelte @@ -30,6 +30,7 @@ import { parseFilesToMessageExtras } from '#lib/utils/browser-only.ts'; import { deriveAgenticSections } from '#lib/utils/index.ts'; import { goto } from '$app/navigation'; + import { resolve } from '$app/paths'; interface Props { class?: string; @@ -241,7 +242,7 @@ const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id); if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } return; @@ -282,7 +283,7 @@ const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id); if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } } else { chatActions.delete(message); @@ -362,7 +363,7 @@ isEditing = false; if (conversationDeleted) { - goto(ROUTES.START); + goto(resolve(ROUTES.START)); } else { focusMainChatForm(); } diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte index efbbde97446a..1a8491d3aa7d 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/ChatMessageToolCallBlockSearchResults.svelte @@ -83,7 +83,7 @@ {#if faviconUrl} @@ -108,7 +108,7 @@ {result.title} diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte index 7cf2366e304e..df28b777a86b 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte @@ -372,7 +372,7 @@ {/if}
- {#if stick.farFromBottom && page.url.hash.includes(ROUTES.CHAT) && page.params.id} + {#if stick.farFromBottom && page.route.id === ROUTES.CHAT && page.params.id} stick.scrollToBottom('smooth')} /> {/if}
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte index c01af20d6f4b..d5c5509568c2 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatTabs/ChatTabsItem.svelte @@ -10,10 +10,11 @@ TAB_SURFACE_IDLE_CLASS, UI_DATA_ATTRS } from '#lib/constants/index.ts'; + import type { ResolvedPathname } from '$app/types'; import type { Component } from 'svelte'; interface Tab { - href: string; + href: ResolvedPathname; /** Marks the new-chat tab. */ icon?: Component; id: string; diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte index 5a7a6ba4d40a..818bf5779527 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogModelNotAvailable.svelte @@ -26,6 +26,7 @@ url.searchParams.set(URL_PARAMS.MODEL, model); handleOpenChange(false); + // eslint-disable-next-line svelte/no-navigation-without-resolve -- the current page's own URL with its query changed, not a link to resolve goto(url.toString()); } diff --git a/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte b/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte index c716652b0556..256baa2dd1f4 100644 --- a/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte +++ b/ui/apps/chat/src/lib/components/app/mcp/McpServerIdentity.svelte @@ -54,7 +54,7 @@ class="shrink-0 text-muted-foreground hover:text-foreground" href={safeWebsiteUrl} onclick={(e) => e.stopPropagation()} - rel="noopener noreferrer" + rel="external noopener noreferrer" target="_blank" > diff --git a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte index 64bdbd5f62ed..26db7f7a9c7f 100644 --- a/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte +++ b/ui/apps/chat/src/lib/components/app/models/discover/ModelsDiscoverDetails/ModelsDiscoverDetailsHeader.svelte @@ -73,7 +73,7 @@ aria-label="View base model on HuggingFace" class="shrink-0 text-muted-foreground transition-colors hover:text-foreground" href={HuggingFaceService.getModelUrl(baseModels[0])} - rel="noopener noreferrer" + rel="external noopener noreferrer" target="_blank" > @@ -86,7 +86,7 @@ diff --git a/ui/apps/chat/src/routes/+layout.svelte b/ui/apps/chat/src/routes/+layout.svelte index 8fcef551be52..5f45697132d6 100644 --- a/ui/apps/chat/src/routes/+layout.svelte +++ b/ui/apps/chat/src/routes/+layout.svelte @@ -9,7 +9,6 @@ FAVICON_PATHS, FAVICON_SELECTORS, HEADERS, - MODELS_ROUTE_ID, NEW_CHAT_TAB_ID, ROUTES, SETTINGS_KEYS, @@ -173,9 +172,9 @@ untrack(() => { if ( - (page.route.id === '/(chat)' || - page.route.id === '/(chat)/chat/[id]' || - page.route.id === MODELS_ROUTE_ID) && + (page.route.id === ROUTES.START || + page.route.id === ROUTES.CHAT || + page.route.id === ROUTES.MODELS) && page.status !== 401 && page.status !== 403 ) { @@ -384,7 +383,7 @@ - {#if deviceStore.isMobile && !page.url.hash.includes(ROUTES.SEARCH) && !uiStore.isComposerExpanded} + {#if deviceStore.isMobile && page.route.id !== ROUTES.SEARCH && !uiStore.isComposerExpanded}
{ if (browser && !deviceStore.isMobile) { - goto(ROUTES.START, { replace: true }); + goto(resolve(ROUTES.START), { replace: true }); } }); diff --git a/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts b/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts index 302c1b6f35fb..dd92bca23d25 100644 --- a/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts +++ b/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts @@ -2,7 +2,6 @@ // group inset in the sidebar and a row in the group. This holds the rule app.css states for // them, on what the browser actually renders: a row's corners are concentric with its // group's, so its radius is the group's less the padding between their edges. - import '../../src/app.css'; import SidebarNavigationActions from '#lib/components/app/navigation/SidebarNavigation/SidebarNavigationActions.svelte'; import SidebarNavigationFooter from '#lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte'; diff --git a/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte b/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte index c51ee56c32fd..95a5a5b360e5 100644 --- a/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte +++ b/ui/apps/chat/tests/stories/chat/tabs/ChatTabsItem.stories.svelte @@ -2,7 +2,9 @@ import { SquarePen } from '@lucide/svelte'; import { defineMeta } from '@storybook/addon-svelte-csf'; import ChatTabsItem from '#lib/components/app/chat/ChatTabs/ChatTabsItem.svelte'; - import { NEW_CHAT_LABEL, NEW_CHAT_TAB_ID } from '#lib/constants/index.ts'; + import { NEW_CHAT_LABEL, NEW_CHAT_TAB_ID, ROUTES } from '#lib/constants/index.ts'; + import { RouterService } from '#lib/services/router.service.ts'; + import { resolve } from '$app/paths'; import StateGallery from '$llama-ui-stories/helpers/StateGallery.svelte'; import StateGalleryItem from '$llama-ui-stories/helpers/StateGalleryItem.svelte'; @@ -14,7 +16,7 @@ title: 'Llama Chat/Chat/ChatTabs/ChatTabsItem' }); - const tab = { href: '#/chat/conv-1', id: 'conv-1', name: 'Rust borrow checker' }; + const tab = { href: RouterService.chat('conv-1'), id: 'conv-1', name: 'Rust borrow checker' }; const handlers = { onActivate: (id: string) => console.log('activate', id), @@ -37,7 +39,12 @@ From 568bd48c4e49fbf7581a3cd19e8916a818496233 Mon Sep 17 00:00:00 2001 From: Aleksander Grygier Date: Tue, 24 Nov 2026 09:42:05 +0100 Subject: [PATCH 3/3] ui: make Llama Chat a plain chat unless llama-server offers agent features Llama Chat showed its tools, MCP and agentic settings and ran the agentic loop for every server. Now it does so only for a llama-server that offers its built-in tools or its proxy, which --agent turns on together; the app reads this from /props and /tools. Without them it is a plain chat: a message and its reply, with reasoning when the model gives it. The chat store sends the classic request, the tools store has no tools and the MCP store connects to no server, so the tools menu, the working folder, the MCP entry and page, and the Tools and Agentic settings are gone. Tool calls in earlier conversations still display. The Show MCP setting moves from General to the Agentic settings, with the rest of what agent mode adds. VITE_PUBLIC_AGENTIC=false builds an app that is a plain chat for every server, and leaves Llama Harness's loop out of the bundle: the harness gets a ./trace entry with the phrasing alone, and Vite resolves the package to a small stub that re-exports it. A CI job builds the variant and checks the loop is not in it. Assisted-by: Claude (Opus 5.5 Medium) --- .github/workflows/ui.yml | 32 +++++++ ui/apps/chat/.env.example | 2 + ui/apps/chat/.storybook/preview.ts | 4 + ui/apps/chat/README.md | 4 + ui/apps/chat/package.json | 1 + .../ChatFormActionAddButton.svelte | 7 +- .../ChatFormActionAddDropdown.svelte | 11 ++- .../app/dialogs/DialogSearch.svelte | 5 +- .../SidebarNavigation.svelte | 9 +- .../SidebarNavigationFooter.svelte | 5 +- .../settings/SettingsChat/SettingsChat.svelte | 22 ++--- .../chat/src/lib/constants/app.constants.ts | 9 ++ .../constants/attachment-menu.constants.ts | 5 +- .../src/lib/constants/settings.constants.ts | 25 ++++-- .../chat/src/lib/constants/ui.constants.ts | 7 ++ .../src/lib/stores/agentic-mode.svelte.ts | 35 ++++++++ .../lib/stores/agentic/harness-chat-only.ts | 10 +++ .../chat/src/lib/stores/chat/index.svelte.ts | 6 +- .../chat/src/lib/stores/mcp/index.svelte.ts | 4 + ui/apps/chat/src/lib/stores/tools.svelte.ts | 11 ++- .../chat/src/routes/mcp-servers/+page.svelte | 10 ++- ui/apps/chat/src/routes/mcp-servers/+page.ts | 10 ++- .../form/ChatScreenForm.a11y.stories.svelte | 6 +- .../chat/form/ChatScreenForm.stories.svelte | 4 +- .../chat/tests/unit/chat-only-build.test.ts | 87 +++++++++++++++++++ ui/apps/chat/tsconfig.json | 3 +- ui/apps/chat/vite.config.ts | 15 +++- ui/apps/chat/vitest-setup-client.ts | 4 + ui/lib/harness/package.json | 4 + 29 files changed, 313 insertions(+), 44 deletions(-) create mode 100644 ui/apps/chat/src/lib/stores/agentic-mode.svelte.ts create mode 100644 ui/apps/chat/src/lib/stores/agentic/harness-chat-only.ts create mode 100644 ui/apps/chat/tests/unit/chat-only-build.test.ts diff --git a/.github/workflows/ui.yml b/.github/workflows/ui.yml index bba032416bfb..3547bf4c61e5 100644 --- a/.github/workflows/ui.yml +++ b/.github/workflows/ui.yml @@ -212,6 +212,38 @@ jobs: run: npm run prepack working-directory: ui/lib/harness + chat-only-build: + name: Chat-only build + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + ref: ${{ github.event.inputs.sha || github.event.pull_request.head.sha || github.sha || github.head_ref || github.ref_name }} + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: "24" + package-manager-cache: false + + - name: Install dependencies + run: npm ci + working-directory: ui/apps/chat + + - name: Build without the agentic loop + run: npm run build + working-directory: ui/apps/chat + env: + VITE_PUBLIC_AGENTIC: "false" + + - name: Check the harness loop is not in the bundle + run: | + if grep -rlq "Tool execution was interrupted by a new user message" dist; then + echo "The chat-only bundle contains Llama Harness's loop" && exit 1 + fi + working-directory: ui/apps/chat + e2e-tests: name: E2E Tests needs: ui-build diff --git a/ui/apps/chat/.env.example b/ui/apps/chat/.env.example index 9760b0dd43fb..269e65278648 100644 --- a/ui/apps/chat/.env.example +++ b/ui/apps/chat/.env.example @@ -1,4 +1,6 @@ VITE_PUBLIC_APP_NAME='Llama Chat' +# 'false' builds a chat-only app: no tools, no MCP, no agentic loop +# VITE_PUBLIC_AGENTIC='false' VITE_DEBUG='true' VITE_PUBLIC_SERVER_ORIGIN='http://localhost:8033' diff --git a/ui/apps/chat/.storybook/preview.ts b/ui/apps/chat/.storybook/preview.ts index 22f04dd88609..47c884fd0f99 100644 --- a/ui/apps/chat/.storybook/preview.ts +++ b/ui/apps/chat/.storybook/preview.ts @@ -1,5 +1,6 @@ import '../src/app.css'; import { MEDIA_QUERIES } from '#lib/constants/pwa.constants.ts'; +import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts'; // the docs pages' styles, shared with the library's Storybook import '../../../lib/ui/.storybook/docs.css'; import { applyColorScheme } from './color-scheme'; @@ -7,6 +8,9 @@ import ModeWatcherDecorator from './decorators/ModeWatcherDecorator.svelte'; import TooltipProviderDecorator from './decorators/TooltipProviderDecorator.svelte'; import type { Preview } from '@storybook/sveltekit'; +// the stories show the app as with a llama-server started with --agent +agenticMode.serverHasTools = true; + applyColorScheme(); window.matchMedia(MEDIA_QUERIES.PREFERS_DARK).addEventListener('change', applyColorScheme); diff --git a/ui/apps/chat/README.md b/ui/apps/chat/README.md index 891fe6b2a422..6ba2e8957d10 100644 --- a/ui/apps/chat/README.md +++ b/ui/apps/chat/README.md @@ -154,6 +154,10 @@ llama-server serves the UI with `Cross-Origin-Embedder-Policy: require-corp` and llama-server embeds it: when llama-server is built, `scripts/ui-assets.cmake` takes `ui/apps/chat/dist` if it exists, runs `npm run build` if `LLAMA_BUILD_UI` is on, or downloads the release's prebuilt `dist.tar.gz` from Hugging Face, and compiles every file into the binary. The same `dist` is what `npx @ggml-org/llama-chat` serves. +**Plain chat and agent mode.** Llama Chat is a plain chat, a message and its reply with reasoning when the model gives it, unless llama-server offers the agentic features: its built-in tools or its proxy, which `llama-server --agent` turns on together. The app reads this from `/props` and `/tools`. With them it shows the tools menu, the working folder, MCP and the Tools and Agentic settings, and runs the agentic loop; without them it shows none of these and sends the classic request. Tool calls in earlier conversations still display. + +**Chat-only build.** `VITE_PUBLIC_AGENTIC=false npm run build` builds an app that is a plain chat for every server, and `npm run dev:chat-only` runs the dev server the same way. Llama Harness's loop is left out of its bundle. + ```text ui/apps/chat/ ├── src/ diff --git a/ui/apps/chat/package.json b/ui/apps/chat/package.json index bc3f0d3315d1..76146f41e5b0 100644 --- a/ui/apps/chat/package.json +++ b/ui/apps/chat/package.json @@ -43,6 +43,7 @@ "build": "npm run build-pwa-assets && vite build", "build-pwa-assets": "pwa-assets-generator --root . --config pwa-assets.config.ts && pwa-assets-generator --root . --config pwa-assets-dark.config.ts && node scripts/make-icons-circular.js", "dev": "bash scripts/dev.sh", + "dev:chat-only": "VITE_PUBLIC_AGENTIC=false bash scripts/dev.sh", "preview": "vite preview", "prepare": "svelte-kit sync || echo ''", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte index e25bcb56f72c..11c8a19544dd 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddButton.svelte @@ -2,7 +2,8 @@ import { Button } from '@ggml-org/llama-ui/ui/button'; import * as Tooltip from '@ggml-org/llama-ui/ui/tooltip'; import { Plus } from '@lucide/svelte'; - import { ATTACHMENT_TOOLTIP_TEXT, ICON_CLASS_DEFAULT } from '#lib/constants/index.ts'; + import { attachmentTooltipText, ICON_CLASS_DEFAULT } from '#lib/constants/index.ts'; + import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts'; interface Props { disabled?: boolean; @@ -21,13 +22,13 @@ type="button" variant="ghost" > - {ATTACHMENT_TOOLTIP_TEXT} + {attachmentTooltipText(agenticMode.enabled)} -

{ATTACHMENT_TOOLTIP_TEXT}

+

{attachmentTooltipText(agenticMode.enabled)}

diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte index 78153bfbdfbe..d86d663f3808 100644 --- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte +++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormActions/ChatFormActionAdd/ChatFormActionAddDropdown.svelte @@ -9,13 +9,14 @@ ATTACHMENT_FILE_ITEMS, ATTACHMENT_MENU_TEXT, ATTACHMENT_MODALITY_TEXT, - ATTACHMENT_TOOLTIP_TEXT, + attachmentTooltipText, ICON_CLASS_DEFAULT, MODALITY_ICONS } from '#lib/constants/index.ts'; import { getChatFormActionsContext } from '#lib/contexts/index.ts'; import { AttachmentAction, AttachmentItemEnabledWhen, ModelModality } from '#lib/enums/index.ts'; import { useAttachmentMenu } from '#lib/hooks/use-attachment-menu.svelte.ts'; + import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts'; import type { Component } from 'svelte'; interface Props { @@ -84,7 +85,7 @@ )} disabled={chatFormActions.disabled} > - {ATTACHMENT_TOOLTIP_TEXT} + {attachmentTooltipText(agenticMode.enabled)} @@ -92,7 +93,7 @@ -

{ATTACHMENT_TOOLTIP_TEXT}

+

{attachmentTooltipText(agenticMode.enabled)}

@@ -160,7 +161,9 @@ {/if} - + {#if agenticMode.enabled} + + {/if}
diff --git a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte index 9a241af2835b..80d0cb5fdc6f 100644 --- a/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte +++ b/ui/apps/chat/src/lib/components/app/dialogs/DialogSearch.svelte @@ -22,7 +22,7 @@ ICON_CLASS_SM, ICON_CLASS_XS, SIDEBAR_ACTIONS_ITEMS, - SIDEBAR_FOOTER_ITEMS + sidebarFooterItems } from '#lib/constants/index.ts'; import { KeyboardKey, SidebarAction } from '#lib/enums/index.ts'; import { useDebouncedSearch } from '#lib/hooks/use-debounced-search.svelte.ts'; @@ -32,6 +32,7 @@ HuggingFaceService } from '#lib/services/index.ts'; import { RouterService } from '#lib/services/router.service.ts'; + import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts'; import { conversationsStore, deviceStore, @@ -248,7 +249,7 @@ const actionEntries = $derived.by((): SearchEntry[] => // every sidebar action the sidebar shows but Search itself, which is what opened this // dialog, and the models manager on a phone, which picks its models in the selector - [...SIDEBAR_ACTIONS_ITEMS, ...SIDEBAR_FOOTER_ITEMS] + [...SIDEBAR_ACTIONS_ITEMS, ...sidebarFooterItems(agenticMode.enabled)] .filter( (item) => item.action && diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte index f216fd4e2884..5cfb763992c3 100644 --- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte +++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigation.svelte @@ -22,18 +22,19 @@ SIDEBAR_COLLAPSE_WIDTH, SIDEBAR_COLLAPSED_WIDTH, SIDEBAR_CONTENT_FADE_MS, - SIDEBAR_FOOTER_ITEMS, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH, SIDEBAR_OVERSTRETCH_PX, SIDEBAR_REVEAL_ACTION_DELAY_MS, SIDEBAR_SETTLE_MS, - SIDEBAR_TOGGLE_MS + SIDEBAR_TOGGLE_MS, + sidebarFooterItems } from '#lib/constants/index.ts'; import { SidebarAction, TooltipSide } from '#lib/enums/index.ts'; import { useKeyboardShortcuts } from '#lib/hooks/use-keyboard-shortcuts.svelte.ts'; import { useMarqueeSelection } from '#lib/hooks/use-marquee-selection.svelte.ts'; import { RouterService } from '#lib/services/router.service.ts'; + import { agenticMode } from '#lib/stores/agentic-mode.svelte.ts'; import { chatStore, conversationsStore, @@ -669,7 +670,9 @@ diff --git a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte index b236dc3db653..714d0f64627d 100644 --- a/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte +++ b/ui/apps/chat/src/lib/components/app/navigation/SidebarNavigation/SidebarNavigationFooter.svelte @@ -1,7 +1,8 @@ diff --git a/ui/apps/chat/src/routes/mcp-servers/+page.ts b/ui/apps/chat/src/routes/mcp-servers/+page.ts index 3c3deac5178a..2b6ea49440a6 100644 --- a/ui/apps/chat/src/routes/mcp-servers/+page.ts +++ b/ui/apps/chat/src/routes/mcp-servers/+page.ts @@ -1,4 +1,12 @@ import type { PageLoad } from './$types'; +import { redirect } from '@sveltejs/kit'; +import { AGENTIC_ENABLED, ROUTES } from '#lib/constants/index.ts'; import { loadAppRoute } from '#lib/stores/init.ts'; +import { resolve } from '$app/paths'; -export const load: PageLoad = ({ fetch }) => loadAppRoute(fetch); +export const load: PageLoad = ({ fetch }) => { + // a chat-only build has no MCP + if (!AGENTIC_ENABLED) redirect(307, resolve(ROUTES.START)); + + return loadAppRoute(fetch); +}; diff --git a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte index b1058822af45..ad443f61ccdf 100644 --- a/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte +++ b/ui/apps/chat/tests/stories/chat/form/ChatScreenForm.a11y.stories.svelte @@ -1,7 +1,7 @@