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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ui/apps/chat/.env.example
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 4 additions & 0 deletions ui/apps/chat/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
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';
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);

Expand Down
4 changes: 4 additions & 0 deletions ui/apps/chat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
7 changes: 6 additions & 1 deletion ui/apps/chat/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions ui/apps/chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,13 +22,13 @@
type="button"
variant="ghost"
>
<span class="sr-only">{ATTACHMENT_TOOLTIP_TEXT}</span>
<span class="sr-only">{attachmentTooltipText(agenticMode.enabled)}</span>

<Plus class={ICON_CLASS_DEFAULT} />
</Button>
</Tooltip.Trigger>

<Tooltip.Content>
<p>{ATTACHMENT_TOOLTIP_TEXT}</p>
<p>{attachmentTooltipText(agenticMode.enabled)}</p>
</Tooltip.Content>
</Tooltip.Root>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -84,15 +85,15 @@
)}
disabled={chatFormActions.disabled}
>
<span class="sr-only">{ATTACHMENT_TOOLTIP_TEXT}</span>
<span class="sr-only">{attachmentTooltipText(agenticMode.enabled)}</span>

<Plus class={ICON_CLASS_DEFAULT} />
</DropdownMenu.Trigger>
{/snippet}
</Tooltip.Trigger>

<Tooltip.Content>
<p>{ATTACHMENT_TOOLTIP_TEXT}</p>
<p>{attachmentTooltipText(agenticMode.enabled)}</p>
</Tooltip.Content>
</Tooltip.Root>

Expand Down Expand Up @@ -160,7 +161,9 @@
</DropdownMenu.Item>
{/if}

<ChatFormActionAddToolsSubmenu />
{#if agenticMode.enabled}
<ChatFormActionAddToolsSubmenu />
{/if}
</DropdownMenu.Content>
</DropdownMenu.Root>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -241,7 +242,7 @@
const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id);

if (conversationDeleted) {
goto(ROUTES.START);
goto(resolve(ROUTES.START));
}

return;
Expand Down Expand Up @@ -282,7 +283,7 @@
const conversationDeleted = await chatStore.removeSystemPromptPlaceholder(message.id);

if (conversationDeleted) {
goto(ROUTES.START);
goto(resolve(ROUTES.START));
}
} else {
chatActions.delete(message);
Expand Down Expand Up @@ -362,7 +363,7 @@
isEditing = false;

if (conversationDeleted) {
goto(ROUTES.START);
goto(resolve(ROUTES.START));
} else {
focusMainChatForm();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<HoverCard.Trigger
class="hover:bg-muted/80 focus-visible:ring-ring inline-flex max-w-full items-center gap-1.5 rounded-full border bg-muted px-2.5 py-1 text-caption transition-colors outline-none focus-visible:ring-2"
href={safeUrl}
rel="noopener noreferrer"
rel="external noopener noreferrer"
target="_blank"
>
{#if faviconUrl}
Expand All @@ -108,7 +108,7 @@
<a
class="line-clamp-3 text-label leading-snug hover:underline"
href={safeUrl}
rel="noopener noreferrer"
rel="external noopener noreferrer"
target="_blank">{result.title}</a
>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
{/if}

<div class="pointer-events-none flex flex-col gap-6 items-center w-full">
{#if stick.farFromBottom && page.url.hash.includes(ROUTES.CHAT) && page.params.id}
{#if stick.farFromBottom && page.route.id === ROUTES.CHAT && page.params.id}
<ChatScreenActionScrollDown onclick={() => stick.scrollToBottom('smooth')} />
{/if}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<ExternalLink class="size-icon-xs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<ExternalLink class="size-icon-xs" />
Expand All @@ -86,7 +86,7 @@
<Button
class="h-auto gap-1.5 px-2.5 py-1.5 text-caption"
href={HuggingFaceService.getModelUrl(modelId)}
rel="noopener noreferrer"
rel="external noopener noreferrer"
size="sm"
target="_blank"
variant="secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -43,6 +44,7 @@
} from '#lib/stores/index.ts';
import { buildConversationTree, remToPx } from '#lib/utils/index.ts';
import { goto } from '$app/navigation';
import { resolve } from '$app/paths';
import { page } from '$app/state';
import { tick } from 'svelte';
import { SvelteSet } from 'svelte/reactivity';
Expand Down Expand Up @@ -155,7 +157,7 @@
});

$effect(() => {
if (deviceStore.isMobile && page.url.hash.includes(ROUTES.SEARCH)) {
if (deviceStore.isMobile && page.route.id === ROUTES.SEARCH) {
uiStore.isSidebarExpanded = false;
}
});
Expand Down Expand Up @@ -544,12 +546,12 @@
break;
// dialogs on a desktop or tablet; on a phone, pages of their own
case SidebarAction.MCP:
if (isOnMobile) navigateBehind(() => goto(ROUTES.MCP_SERVERS));
if (isOnMobile) navigateBehind(() => goto(resolve(ROUTES.MCP_SERVERS)));
else openDialog(() => (mcpDialogOpen = true));

break;
case SidebarAction.SETTINGS:
if (isOnMobile) navigateBehind(() => goto(ROUTES.SETTINGS));
if (isOnMobile) navigateBehind(() => goto(resolve(ROUTES.SETTINGS)));
else openDialog(() => (settingsDialogOpen = true));

break;
Expand All @@ -559,7 +561,7 @@

<svelte:window bind:innerWidth onkeydown={handleKeydown} />

{#if innerWidth > 768 || !page.url.hash.includes(ROUTES.SEARCH)}
{#if innerWidth > 768 || page.route.id !== ROUTES.SEARCH}
<!-- svelte-ignore a11y_no_static_element_interactions -->
<aside
bind:this={asideEl}
Expand Down Expand Up @@ -622,7 +624,7 @@
class="pointer-events-auto size-10 rounded-full! md:size-9 {isStripHidden
? 'bg-transparent! hover:bg-transparent!'
: 'matte-key bg-card! hover:bg-card! dark:bg-muted-foreground/15! dark:hover:bg-muted-foreground/15!'}"
href={uiStore.isSidebarExpanded && !isLogoToggle ? ROUTES.START : undefined}
href={uiStore.isSidebarExpanded && !isLogoToggle ? resolve(ROUTES.START) : undefined}
icon={isLogoToggle && logoHovered
? uiStore.isSidebarExpanded
? PanelLeftClose
Expand Down Expand Up @@ -668,7 +670,9 @@
<!-- a phone has no footer: its items join these -->
<SidebarNavigationActions
class="px-2 md:my-3"
items={isOnMobile ? [...SIDEBAR_ACTIONS_ITEMS, ...SIDEBAR_FOOTER_ITEMS] : undefined}
items={isOnMobile
? [...SIDEBAR_ACTIONS_ITEMS, ...sidebarFooterItems(agenticMode.enabled)]
: undefined}
onAction={handleSidebarAction}
onNavigate={navigateBehind}
/>
Expand Down
Loading
Loading