Files
llama.cpp/ui/apps/chat/tests/client/nested-surfaces.svelte.test.ts
T
Emanuil Rusev 10f173b253 ui: hide Models and MCP behind settings, off by default (#32527)
* ui: hide Models and MCP behind settings, off by default

Two new settings in General, "Show Models" and "Show MCP", both off by default, like "Enable Discover Models". The WebUI is often the first thing people new to local models see, and most of them don't need a models manager or know what MCP is.

"Show MCP" only hides the way to manage MCP; servers already added keep working. Turning MCP off for real would mean gating every place that reads the server list (health checks, tool groups, prompts, avatars). Anyone who already has servers saved gets MCP shown, so they don't lose the way to manage them.

With Models hidden, every entry point to the manager goes: the sidebar, search, the shortcut and "Manage models" in the selector -- it opens the same full manager. The /models page still opens by its URL, which apps link to. On a single-model server the selector chip used to open the manager; with it hidden, the chip is a plain label.

* ui: keep Models shown while Discover Models is on

Discover opens only from the Models page (its header button and the manager's row actions), so with Models hidden by default, checking Discover showed nothing. Checking Discover now shows Models too and locks its checkbox, the same way it already locks the Hugging Face Hub API one; unchecking Discover leaves Models as it is. Saved configs with Discover on get Models turned on when they load, so people who use Discover don't lose it.
2026-11-18 13:26:31 +01:00

95 lines
3.8 KiB
TypeScript

// The sidebar's footer is the third of four nested surfaces: the page, the sidebar on it, a
// 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';
import {
SETTINGS_KEYS,
SIDEBAR_ACTIONS_ITEMS,
SIDEBAR_FOOTER_ITEMS
} from '#lib/constants/index.ts';
import { settingsStore } from '#lib/stores/index.ts';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { page } from 'vitest/browser';
import { render } from 'vitest-browser-svelte';
function px(value: string): number {
return parseFloat(value);
}
async function renderFooter() {
const screen = render(SidebarNavigationFooter, {});
const rows = () => [...screen.container.querySelectorAll<HTMLElement>('[data-slot="button"]')];
await vi.waitFor(() => expect(rows()).toHaveLength(SIDEBAR_FOOTER_ITEMS.length));
const group = rows()[0].parentElement?.parentElement;
if (!group) throw new Error('footer group not rendered');
return { group, rows: rows() };
}
describe('nested surfaces', () => {
// the footer is a desktop's and a tablet's: a phone lists its items with the sidebar's actions
beforeEach(async () => {
await page.viewport(1280, 900);
// Models and MCP wait behind their settings: show them, so every footer row is measured
settingsStore.updateConfig(SETTINGS_KEYS.SHOW_MODELS_MANAGER, true);
settingsStore.updateConfig(SETTINGS_KEYS.SHOW_MCP, true);
});
it('round the footer group from its tokens', async () => {
const { group } = await renderFooter();
const root = getComputedStyle(document.documentElement);
const style = getComputedStyle(group);
// the tokens resolve, so the group is not left square or unpadded
expect(px(style.borderTopLeftRadius)).toBeGreaterThan(0);
expect(px(style.paddingTop)).toBeGreaterThan(0);
expect(root.getPropertyValue('--surface-group-radius').trim()).not.toBe('');
expect(root.getPropertyValue('--surface-group-padding').trim()).not.toBe('');
});
it('keep each footer row concentric with its group', async () => {
const { group, rows } = await renderFooter();
const style = getComputedStyle(group);
const expected = px(style.borderTopLeftRadius) - px(style.paddingTop);
for (const row of rows) {
const radius = getComputedStyle(row).borderTopLeftRadius;
expect(px(radius), row.textContent ?? '').toBeCloseTo(expected, 1);
}
});
it('inset each footer row by the group padding the radius accounts for', async () => {
const { group, rows } = await renderFooter();
const style = getComputedStyle(group);
const box = group.getBoundingClientRect();
// the hairline border sits outside the padding the radius is reduced by
const inner = box.left + px(style.borderLeftWidth) + px(style.paddingLeft);
for (const row of rows) {
expect(row.getBoundingClientRect().left).toBeCloseTo(inner, 0);
}
});
it('round the top actions of the sidebar like the footer rows', async () => {
const { rows: footerRows } = await renderFooter();
const expected = getComputedStyle(footerRows[0]).borderTopLeftRadius;
const top = render(SidebarNavigationActions, { class: '' });
const rows = () => [...top.container.querySelectorAll<HTMLElement>('[data-slot="button"]')];
await vi.waitFor(() => expect(rows()).toHaveLength(SIDEBAR_ACTIONS_ITEMS.length));
for (const row of rows()) {
expect(getComputedStyle(row).borderTopLeftRadius, row.textContent ?? '').toBe(expected);
}
});
});