fix(webui): toasts above sheets; drop unreachable alias helpers

Stack the toast viewport on perfect-design's --z-toast token so it sits
above Sheet overlays, and add a harness check that the toast is the
topmost element at its centre while a sheet is open.

Delete useAliasNames, lib/alias and its spec, which nothing imports
since the shadcn migration removed AliasBadge.
This commit is contained in:
2026-11-25 11:52:38 +00:00
parent ff58b03e21
commit 62817af834
5 changed files with 19 additions and 36 deletions
+18
View File
@@ -183,6 +183,24 @@ test('config change helper opens from the header and Back closes it', async ({ p
await expect(page.locator('[data-panel-kind="helper"]')).toHaveCount(0)
})
// A toast raised while the helper Sheet is open must be the topmost element at its centre, not hidden behind the overlay.
test('toast stacks above an open sheet', async ({ page }) => {
await page.setViewportSize(VIEWPORTS.desktop)
await visit(page, '#config', 'live', 'light')
await page.getByRole('button', { name: 'Change helper' }).click()
await page.getByRole('button', { name: 'New user' }).click()
await page.getByRole('button', { name: 'Generate' }).click()
const toast = page.getByText('Generated a new API key.')
await expect(toast).toBeVisible()
const topmost = await toast.evaluate((el) => {
const r = el.getBoundingClientRect()
const hit = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2)
return hit === el || el.contains(hit)
})
expect(topmost).toBe(true)
await expect(page.locator('[data-panel-kind="helper"]')).toBeVisible()
})
test('config page starts compact on desktop', async ({ page }) => {
await page.setViewportSize(VIEWPORTS.desktop)
await visit(page, '#config', 'live', 'light')
+1 -1
View File
@@ -47,7 +47,7 @@ function onDismiss(toast: Toast): void {
<template>
<div
class="pointer-events-none fixed inset-x-0 bottom-0 z-50 flex flex-col-reverse gap-2 p-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] sm:inset-x-auto sm:right-4 sm:bottom-4 sm:w-96"
class="pointer-events-none fixed inset-x-0 bottom-0 z-(--z-toast) flex flex-col-reverse gap-2 p-4 pb-[calc(env(safe-area-inset-bottom)+1rem)] sm:inset-x-auto sm:right-4 sm:bottom-4 sm:w-96"
>
<div aria-live="assertive" class="flex flex-col-reverse gap-2">
<TransitionGroup
-11
View File
@@ -1,11 +0,0 @@
import { computed } from 'vue'
import { aliasNameSet } from '@/lib/alias'
import { useDashboardStore } from '@/stores/dashboard'
/** useAliasNames exposes isAlias(id): true when id is a configured model alias (from the polled overview). */
export function useAliasNames() {
const dashboard = useDashboardStore()
const names = computed(() => aliasNameSet(dashboard.overview?.aliases))
return { isAlias: (id: string): boolean => names.value.has(id) }
}
-18
View File
@@ -1,18 +0,0 @@
import { describe, expect, it } from 'vitest'
import { aliasNameSet } from './alias'
import type { AdminAliasView } from '@/types/api'
const view = (alias: string): AdminAliasView => ({ alias, target: 'openai/gpt-5', modelMeta: {} })
describe('aliasNameSet', () => {
it.each<{ name: string; input: AdminAliasView[] | undefined; has: string[]; hasNot: string[] }>([
{ name: 'undefined', input: undefined, has: [], hasNot: ['x'] },
{ name: 'empty', input: [], has: [], hasNot: ['x'] },
{ name: 'two aliases', input: [view('fast'), view('smart')], has: ['fast', 'smart'], hasNot: ['openai/gpt-5', 'Fast', ''] },
])('$name', ({ input, has, hasNot }) => {
const set = aliasNameSet(input)
for (const h of has) expect(set.has(h)).toBe(true)
for (const h of hasNot.filter((x) => !has.includes(x))) expect(set.has(h)).toBe(false)
})
})
-6
View File
@@ -1,6 +0,0 @@
import type { AdminAliasView } from '@/types/api'
/** aliasNameSet indexes configured alias names (exact match, as a client sends them) for O(1) lookups. */
export function aliasNameSet(aliases: readonly AdminAliasView[] | undefined): Set<string> {
return new Set((aliases ?? []).map((a) => a.alias))
}