Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8045370
ui: let the dev proxy pass llama-server's cross-origin check
allozaur Nov 16, 2026
04ef3dd
ui: bring the Storybook changes over from the design system PR
allozaur Nov 17, 2026
898303a
ui: a Storybook for Llama UI and Llama Chat
allozaur Nov 9, 2026
0b9336d
ui: the Storybook's pages take the base components from @ggml-org/lla…
allozaur Nov 12, 2026
87434df
ui: Storybook's docs place Llama UI in ui/lib/ui and Llama Chat in ui…
allozaur Nov 12, 2026
2fb7c14
ui: bring Storybook up to date with the storybook-overhaul branch
allozaur Nov 12, 2026
ae9e57c
ui: call the app Llama Chat in the Storybook brand pages
allozaur Nov 16, 2026
ca57f19
ui: the brand and communications pages move to llama-brand
allozaur Nov 16, 2026
fde46ea
ui: let the ChatScreen story store its reply before the next one starts
allozaur Nov 12, 2026
b2e4714
ui: name the Storybook's color modes and surface themes instead of sp…
allozaur Nov 17, 2026
a5c8ac4
ui: Scrapbook › UI › Composer keys, the options for the chat form's keys
allozaur Nov 17, 2026
2543995
ui: Storybook's guides no longer send brand work to pages that moved …
allozaur Nov 17, 2026
5c66972
ui: file Safe areas, GlassKey and ChatForm single row under the Story…
allozaur Nov 17, 2026
03add03
ui: the Storybook takes its logos from @ggml-org/llama-brand
allozaur Nov 17, 2026
45b59b5
ui: give the library's Storybook addons version ranges instead of latest
allozaur Nov 17, 2026
c9b79da
ui: take the Scrapbook out of the Storybook
allozaur Nov 17, 2026
2477a19
ui: move the Philosophy section out of the Storybook PR
allozaur Nov 17, 2026
c48a097
ui: publish the Storybook to its Hugging Face Space on every UI change
allozaur Nov 17, 2026
879b602
ui: move the Architecture section out of the Storybook PR
allozaur Nov 17, 2026
3d7b498
ui: give Llama UI and Llama Chat their own Storybook sections, each s…
allozaur Nov 17, 2026
123137a
ui: run the library's tests, its stories among them, in CI
allozaur Nov 17, 2026
2858836
ui: draw a floating panel's rim on its border, so its edge is one line
allozaur Nov 17, 2026
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
81 changes: 81 additions & 0 deletions .github/workflows/ui-storybook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: UI Storybook

# Builds Llama UI and Llama Chat's Storybook (ui/apps/chat) and publishes it to its Hugging Face Space
# whenever the UI changes on master, so the Space always shows the latest build.

on:
workflow_dispatch:
push:
branches:
- master
paths: [
'.github/workflows/ui-storybook.yml',
'ui/apps/chat/**',
'ui/lib/ui/**'
]

cache-mode: none
permissions:
contents: read

# only the newest build matters: a newer push replaces a deploy still in progress
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true

jobs:
deploy:
name: Deploy to Hugging Face Spaces
if: github.repository == 'ggml-org/llama.cpp'
runs-on: ubuntu-24.04

env:
HF_SPACE: ${{ vars.HF_SPACE_UI_STORYBOOK || 'ggml-org/llama-ui-storybook' }}

steps:
- name: Checkout code
uses: actions/checkout@v6

- 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 Storybook
run: npm run build-storybook
working-directory: ui/apps/chat

- name: Write the Space card
run: |
cat > ui/apps/chat/storybook-static/README.md << EOF
---
title: Llama UI Storybook
emoji: 🦙
colorFrom: gray
colorTo: gray
sdk: static
pinned: false
---
The Storybook of Llama UI and Llama Chat, built from [ggml-org/llama.cpp](https://github.com/ggml-org/llama.cpp) (\`ui/apps/chat\`) at ${GITHUB_SHA}.
EOF
- name: Install Hugging Face Hub CLI
run: |
python3 -m venv .venv-hf
.venv-hf/bin/pip install -U huggingface_hub==1.28.0
- name: Upload to the Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN_UI_STATIC_OUTPUT }}
run: |
# --delete '*' removes files the new build no longer has; the Space's .gitattributes is always kept
.venv-hf/bin/hf upload "$HF_SPACE" ui/apps/chat/storybook-static . \
--repo-type space \
--delete '*' \
--commit-message "Storybook from ggml-org/llama.cpp@${GITHUB_SHA::10}"
9 changes: 9 additions & 0 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,15 @@ jobs:
run: npm run check
working-directory: ui/lib/ui

- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
working-directory: ui/lib/ui

# the unit tests and the Storybook stories (ui/lib/ui/tests/stories), which run as tests in Chromium
- name: Run tests
run: npm test
working-directory: ui/lib/ui

- name: Build the package
run: npm run prepack
working-directory: ui/lib/ui
Expand Down
24 changes: 24 additions & 0 deletions ui/apps/chat/.storybook/color-scheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MEDIA_QUERIES } from '#lib/constants/pwa.constants.ts';
import { ColorMode } from '#lib/enums/ui.enums.ts';
import { modeStorageKey } from 'mode-watcher';

/** The class on `<html>` that turns the dark theme on, as mode-watcher sets it. */
export const DARK_CLASS = ColorMode.DARK;

/** Turns the dark theme on or off. */
export function setDarkClass(isDark: boolean) {
document.documentElement.classList.toggle(DARK_CLASS, isDark);
}

/**
* Sets the dark class from the saved mode-watcher mode, or the system preference
* when there is none. Docs pages render no story, so preview.ts calls this too.
*/
export function applyColorScheme() {
const mode = localStorage.getItem(modeStorageKey.current) || ColorMode.SYSTEM;
const isDark =
mode === ColorMode.DARK ||
(mode === ColorMode.SYSTEM && window.matchMedia(MEDIA_QUERIES.PREFERS_DARK).matches);

setDarkClass(isDark);
}
25 changes: 8 additions & 17 deletions ui/apps/chat/.storybook/decorators/ModeWatcherDecorator.svelte
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
<script lang="ts">
import { ModeWatcher } from 'mode-watcher';
import { onMount } from 'svelte';
import { ColorMode } from '#lib/enums/ui.enums.ts';
import { applyColorScheme, setDarkClass } from '../color-scheme';

interface Props {
children?: any;
/** a mode the story is always shown in, rather than the viewer's */
forced?: ColorMode.DARK | ColorMode.LIGHT;
}

let { children }: Props = $props();
let { children, forced }: Props = $props();

onMount(() => {
const root = document.documentElement;
const theme = localStorage.getItem('mode-watcher-mode') || 'system';

if (theme === 'dark') {
root.classList.add('dark');
} else if (theme === 'light') {
root.classList.remove('dark');
} else {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (prefersDark) {
root.classList.add('dark');
} else {
root.classList.remove('dark');
}
}
if (forced) setDarkClass(forced === ColorMode.DARK);
else applyColorScheme();
});
</script>

<ModeWatcher />
{#if !forced}<ModeWatcher />{/if}

{#if children}
{@const Component = children}
Expand Down
91 changes: 91 additions & 0 deletions ui/apps/chat/.storybook/docs.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
@reference '../src/app.css';

/*
* MDX pages that wrap their content in <Unstyled><div className="ds-docs"> drop
* Storybook's docs theme and take colours, font and type roles from the design system.
*/
.sbdocs-wrapper:has(.ds-docs) {
background: var(--surface-page);
}

.ds-docs {
@apply mx-auto max-w-3xl font-sans text-body text-fg-default;

& :where(h1) {
@apply mb-4 text-heading;
}

& :where(h2) {
@apply mt-10 mb-3 border-b border-line-default pb-2 text-title;
}

& :where(h3) {
@apply mt-6 mb-2 text-body font-semibold;
}

& :where(h4, h5, h6) {
@apply mt-4 mb-2 text-label;
}

& :where(p, ul, ol, blockquote, table, pre) {
@apply my-3;
}

& :where(ul) {
@apply list-disc pl-6;
}

& :where(ol) {
@apply list-decimal pl-6;
}

& :where(li) {
@apply my-1;
}

& :where(strong) {
@apply font-semibold;
}

& :where(a) {
@apply underline underline-offset-2 hover:text-fg-muted;
}

& :where(blockquote) {
@apply border-l-2 border-line-default pl-4 text-fg-muted;
}

/* a note that stands out from the running text: a quiet panel with the accent on its edge */
& :where(.callout) {
@apply my-6 rounded-panel border-l-2 border-(--art-cinder) bg-surface-muted px-5 py-4;

& > :where(p) {
@apply my-0;
}
}

& :where(hr) {
@apply my-8 border-line-default;
}

/* inline code only, with a selector that outranks the code the Markdown block renders */
& :not(pre) > code {
@apply rounded-control border-0 bg-surface-code px-1 py-0.5 font-mono text-[0.875em] text-(--fg-code);
}

& :where(pre) {
@apply overflow-x-auto rounded-panel bg-surface-code p-4 text-body-sm;
}

& :where(table) {
@apply w-full border-collapse text-body-sm;
}

& :where(th, td) {
@apply border-b border-line-default px-3 py-2 text-left align-top;
}

& :where(th) {
@apply text-label;
}
}
26 changes: 24 additions & 2 deletions ui/apps/chat/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

// Llama UI's stories live with the library (ui/lib/ui/tests/stories), which runs and tests them in its own
// Storybook; this one shows them too, under Llama UI, next to Llama Chat's own. The library's front page stays its own.
const LLAMA_UI_STORIES = resolve(__dirname, '../../../lib/ui/tests/stories');

const config: StorybookConfig = {
stories: ['../tests/stories/**/*.mdx', '../tests/stories/**/*.stories.@(js|ts|svelte)'],
stories: [
'../tests/stories/**/*.mdx',
'../tests/stories/**/*.stories.@(js|ts|svelte)',
{
directory: '../../../lib/ui/tests/stories',
files: '{foundations,components,app,models,mockups}/**/*.stories.svelte'
}
],
addons: [
'@storybook/addon-svelte-csf',
'@chromatic-com/storybook',
Expand All @@ -18,7 +29,18 @@ const config: StorybookConfig = {
viteFinal: async (config) => {
config.server = config.server || {};
config.server.fs = config.server.fs || {};
config.server.fs.allow = [...(config.server.fs.allow || []), resolve(__dirname, '../tests')];
config.server.fs.allow = [
...(config.server.fs.allow || []),
resolve(__dirname, '../tests'),
LLAMA_UI_STORIES
];
// the library's stories import Storybook from where they live, where only this app's packages are installed
config.resolve = config.resolve || {};
config.resolve.dedupe = [
...(config.resolve.dedupe || []),
'@storybook/addon-svelte-csf',
'storybook'
];
return config;
}
};
Expand Down
86 changes: 86 additions & 0 deletions ui/apps/chat/.storybook/manager-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<!--
Old links keep working: stories that moved redirect to where they are now (the brand pages that became Llama UI's
foundations, and the old UI section, which became Llama UI for the library and Llama Chat for the app), and a link
to a story that no longer exists opens Storybook's start page instead of the "Couldn't find story" error.
-->
<script>
(function () {
var match = location.search.match(/[?&]path=\/(story|docs)\/([^&]+)/);

if (!match) return;

var id = decodeURIComponent(match[2]);

// moved stories, old id: new id
var moved = {
'brand-colors-primitives--primitives': 'llama-ui-foundations-colors--primitives',
'brand-logo-app-icons--splash-screens': 'llama-chat-foundations-brand--splash-screens',
'brand-logo-usage--splash-screens': 'llama-chat-foundations-brand--splash-screens',
'introduction-design-guidelines--docs': 'agents-design-guidelines--docs'
};

// renamed groups, old id prefix: new id prefix, the first that matches wins (the UI section, split in two)
var renamed = [
[
'ui-blocks-chat-chatscreen-chatscreenform-accessibility',
'llama-chat-chat-chatform-chatscreenform-accessibility'
],
[
'ui-blocks-chat-chatmessagestatistics-accessibility',
'llama-chat-chat-chatmessages-chatmessagestatistics-accessibility'
],
['ui-blocks-chat-chatscreen-chatattachments-', 'llama-chat-chat-chatattachments-'],
['ui-blocks-chat-chatscreen-chatform-', 'llama-chat-chat-chatform-'],
['ui-blocks-chat-chatscreen-chatmessages-', 'llama-chat-chat-chatmessages-'],
['ui-blocks-chat-chatscreen-chattabs-', 'llama-chat-chat-chattabs-'],
['ui-blocks-chat-chatscreen-', 'llama-chat-chat-chatscreen-'],
['ui-blocks-content-syntaxhighlightedcode', 'llama-ui-app-components-syntaxhighlightedcode'],
['ui-blocks-app-pwarefreshalert', 'llama-chat-pwa-pwarefreshalert'],
['ui-blocks-app-serversplash', 'llama-chat-servers-serversplash'],
['ui-blocks-app-scrollcarousel', 'llama-chat-misc-scrollcarousel'],
['ui-blocks-', 'llama-chat-'],
['ui-actions-actionicon', 'llama-ui-app-components-actionicon'],
['ui-actions-', 'llama-ui-components-actions-'],
['ui-display-', 'llama-ui-components-display-'],
['ui-forms-', 'llama-ui-components-forms-'],
['ui-navigation-', 'llama-ui-components-navigation-'],
['ui-overlays-', 'llama-ui-components-overlays-'],
['ui-foundations-brand', 'llama-chat-foundations-brand'],
['ui-foundations-safe-areas', 'llama-chat-foundations-safe-areas'],
['ui-foundations-', 'llama-ui-foundations-'],
['ui-patterns-actionicon', 'llama-ui-app-components-actionicon'],
['ui-patterns-searchinput', 'llama-ui-app-components-searchinput'],
['ui-patterns-glasskey', 'llama-chat-actions-glasskey'],
['ui-patterns-infobadges', 'llama-chat-badges-infobadges'],
['ui-patterns-dialogconfirmation', 'llama-chat-dialogs-dialogconfirmation'],
['ui-patterns-inputwithsuggestions', 'llama-chat-forms-inputwithsuggestions'],
['ui-patterns-keyvaluepairs', 'llama-chat-forms-keyvaluepairs'],
['ui-patterns-', 'llama-chat-misc-']
];

function go(to) {
var url =
location.pathname +
(to ? '?path=/' + (/--docs$/.test(to) ? 'docs' : 'story') + '/' + to : '');

if (url !== location.pathname + location.search) location.replace(url);
}

if (moved[id]) return go(moved[id]);

for (var i = 0; i < renamed.length; i++) {
if (id.indexOf(renamed[i][0]) === 0)
return go(renamed[i][1] + id.slice(renamed[i][0].length));
}

// any other id: open the start page if the story is gone
fetch('./index.json')
.then(function (response) {
return response.json();
})
.then(function (index) {
if (!index.entries || !index.entries[id]) go('');
})
.catch(function () {});
})();
</script>
Loading
Loading