feat(webui): improve model and provider settings UX (#6145)

* feat(webui): improve model and provider settings UX

* refactor(webui): organize provider forms and model picker interactions

* fix(webui): separate OAuth credentials from provider configuration

* fix(webui): stabilize shared combobox navigation

* refactor(config): store provider connections as sparse entries

* fix(webui): preserve provider validation and isolate catalog tests

* refactor(config): manage explicit provider connections

* refactor(webui): decouple settings UX from provider removal

* fix(webui): select current combobox options during rapid input

* feat(webui): refine model preset and provider management

* style(webui): refine preset footer actions

* fix(webui): align model settings with responsive layout rules

* refactor(webui): finalize preset dialogs and simplify provider state

* fix(webui): keep fallback heading stable while sorting presets

Animate card dimensions without changing layout height and keep the section heading outside sortable cards. Remove proxy normalization from this PR.

* docs: update WebUI model and provider setup instructions

* docs: start model setup from new preset

* docs: remove duplicate WebUI model setup instructions
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-11 04:30:43 +08:00
1 parent 8080ea843a
commit 9261e731ce
88 files changed
+2854 -1734

No files matched your search

+34 -15
View File
@@ -14,6 +14,11 @@ interface ComboboxNavigationOptions {
onClose: () => void;
}
interface ActiveOption {
value: string | null;
source: "initial" | "keyboard" | "pointer";
}
export function useComboboxNavigation({
open,
values,
@@ -22,17 +27,23 @@ export function useComboboxNavigation({
onClose,
}: ComboboxNavigationOptions) {
const listboxId = React.useId();
const [activeValue, setActiveValue] = React.useState<string | null>(null);
const [activeOption, setActiveOption] = React.useState<ActiveOption>({ value: null, source: "initial" });
const activeValue = !open || (activeOption.source === "pointer" && activeOption.value === null)
? null
: activeOption.value && values.includes(activeOption.value)
? activeOption.value
: selectedValue && values.includes(selectedValue)
? selectedValue
: values[0] ?? null;
React.useEffect(() => {
if (!open) {
setActiveValue(null);
return;
}
setActiveValue((current) => {
if (current && values.includes(current)) return current;
if (selectedValue && values.includes(selectedValue)) return selectedValue;
return values[0] ?? null;
setActiveOption((current) => {
if (open && current.value && values.includes(current.value)) return current;
const value = open
? selectedValue && values.includes(selectedValue) ? selectedValue : values[0] ?? null
: null;
return current.value === value && current.source === "initial"
? current : { value, source: "initial" };
});
}, [open, selectedValue, values]);
@@ -40,17 +51,17 @@ export function useComboboxNavigation({
const activeOptionId = activeIndex >= 0 ? `${listboxId}-option-${activeIndex}` : undefined;
React.useEffect(() => {
if (!activeOptionId) return;
if (!activeOptionId || activeOption.source !== "keyboard") return;
const option = document.getElementById(activeOptionId);
option?.scrollIntoView?.({ block: "nearest" });
}, [activeOptionId]);
}, [activeOptionId, activeOption.source]);
const move = (offset: number) => {
if (!values.length) return;
const nextIndex = activeIndex < 0
? offset > 0 ? 0 : values.length - 1
: (activeIndex + offset + values.length) % values.length;
setActiveValue(values[nextIndex]);
setActiveOption({ value: values[nextIndex], source: "keyboard" });
};
const onInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
@@ -102,9 +113,17 @@ export function useComboboxNavigation({
id: `${listboxId}-option-${index}`,
role: "option" as const,
"aria-selected": value === activeValue,
"data-highlighted": value === activeValue ? "" : undefined,
"data-highlighted": value === activeValue && activeOption.source === "keyboard" ? "" : undefined,
tabIndex: -1,
onPointerMove: () => setActiveValue(value),
onPointerMove: (event: React.PointerEvent<HTMLButtonElement>) => {
if (event.pointerType === "touch") return;
setActiveOption((current) => current.value === value && current.source === "pointer"
? current : { value, source: "pointer" });
},
onPointerLeave: () => {
setActiveOption((current) => current.source === "pointer" && current.value === value
? { value: null, source: "pointer" } : current);
},
onClick: () => onSelect(value),
};
};
@@ -122,7 +141,7 @@ const ComboboxOption = React.forwardRef<
className={cn(
floatingItemClassName,
floatingItemFocusClassName,
"w-full cursor-default text-left data-[highlighted]:bg-muted/85 data-[highlighted]:text-foreground",
"w-full cursor-default text-left settings-hover data-[highlighted]:bg-[var(--control-hover-fill)] data-[highlighted]:text-foreground",
className,
)}
{...props}
+2 -2
View File
@@ -10,10 +10,10 @@ export const modalOverlayClassName =
"fixed inset-0 z-50 bg-black/25 backdrop-blur-[8px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:fill-mode-forwards data-[state=open]:fade-in-0";
export const modalSurfaceClassName =
"bg-background text-foreground shadow-[0_12px_36px_rgba(15,23,42,0.12)] dark:bg-popover dark:shadow-[0_18px_44px_rgba(0,0,0,0.32)]";
"outline-none bg-background text-foreground shadow-[0_12px_36px_rgba(15,23,42,0.12)] dark:bg-popover dark:shadow-[0_18px_44px_rgba(0,0,0,0.32)]";
export const floatingSurfaceClassName =
`${floatingSurfaceVisualClassName} z-50 overflow-x-hidden overflow-y-auto overscroll-contain scrollbar-thin scrollbar-track-transparent`;
`${floatingSurfaceVisualClassName} z-50 overflow-x-hidden overflow-y-auto overscroll-contain scrollbar-thin`;
export const floatingSurfaceMotionClassName =
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0";
+28
View File
@@ -0,0 +1,28 @@
import * as React from "react";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip-primitives";
import { cn } from "@/lib/utils";
export function HoverHint({ content, children, enabled = true, side = "top", align = "center", sideOffset, contentClassName }: {
content: React.ReactNode;
children: React.ReactElement;
enabled?: boolean;
side?: React.ComponentPropsWithoutRef<typeof TooltipContent>["side"];
align?: React.ComponentPropsWithoutRef<typeof TooltipContent>["align"];
sideOffset?: number;
contentClassName?: string;
}) {
const [open, setOpen] = React.useState(false);
return (
<TooltipProvider>
<Tooltip open={enabled && open} onOpenChange={(next) => setOpen(enabled && next)}>
<TooltipTrigger asChild>{children}</TooltipTrigger>
<TooltipContent side={side} align={align} sideOffset={sideOffset}
className={cn("max-w-[min(28rem,calc(100vw-2rem))] whitespace-pre-wrap break-words", contentClassName)}>
{content}
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
}
+12 -4
View File
@@ -3,16 +3,19 @@ import * as React from "react";
import { formControlFocusClassName } from "@/components/ui/form-control";
import { cn } from "@/lib/utils";
type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
variant?: "default" | "search";
};
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
({ className, type, variant = "default", ...props }, ref) => {
return (
<input
type={type}
className={cn(
"touch-text-input flex h-10 w-full rounded-full border border-input bg-background px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
formControlFocusClassName,
variant === "search" || type === "search"
? "focus:outline-none" : formControlFocusClassName,
className,
)}
ref={ref}
@@ -23,4 +26,9 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
);
Input.displayName = "Input";
export { Input };
const SearchInput = React.forwardRef<HTMLInputElement, Omit<InputProps, "variant">>(
(props, ref) => <Input {...props} ref={ref} variant="search" />,
);
SearchInput.displayName = "SearchInput";
export { Input, SearchInput };
+2
View File
@@ -9,6 +9,7 @@ import { cn } from "@/lib/utils";
import { useFloatingPortal } from "@/components/ui/floating-portal";
const Popover = PopoverPrimitive.Root;
const PopoverAnchor = PopoverPrimitive.Anchor;
const PopoverTrigger = PopoverPrimitive.Trigger;
interface PopoverContentProps
@@ -41,6 +42,7 @@ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
export {
Popover,
PopoverAnchor,
PopoverContent,
PopoverTrigger,
};
+2 -1
View File
@@ -9,6 +9,7 @@ import { ControlChevron } from "@/components/ui/control-chevron";
export const Select = SelectPrimitive.Root;
export const SelectValue = SelectPrimitive.Value;
export const SelectSeparator = SelectPrimitive.Separator;
export const SelectTrigger = React.forwardRef<
React.ElementRef<typeof SelectPrimitive.Trigger>,
@@ -24,7 +25,7 @@ SelectTrigger.displayName = "SelectTrigger";
export function SelectContent({ children, ...props }: Pick<
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>,
"children" | "onPointerUpCapture" | "onPointerDownOutside" | "onKeyDownCapture" | "onEscapeKeyDown"
"children" | "onPointerUpCapture" | "onPointerDownOutside" | "onKeyDownCapture" | "onEscapeKeyDown" | "onCloseAutoFocus"
>) {
const container = useFloatingPortal();
return (
+2 -2
View File
@@ -29,7 +29,7 @@ const SheetOverlay = React.forwardRef<
SheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
const sheetVariants = cva(
"fixed z-50 flex flex-col gap-4 bg-background transition ease-in-out",
"fixed z-50 flex flex-col gap-4 bg-background outline-none transition ease-in-out",
{
variants: {
side: {
@@ -99,7 +99,7 @@ const SheetContent = React.forwardRef<
{showCloseButton ? (
<DialogPrimitive.Close
className={cn(
"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity",
"absolute right-4 top-4 rounded-mark opacity-70 ring-offset-background transition-opacity",
"hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
"disabled:pointer-events-none",
closeButtonClassName,
@@ -0,0 +1,32 @@
import * as React from "react";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { floatingSurfaceElevationClassName } from "@/components/ui/floating-surface";
import { cn } from "@/lib/utils";
function TooltipProvider(props: Omit<React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>, "delayDuration" | "skipDelayDuration">) {
return <TooltipPrimitive.Provider {...props} delayDuration={500} skipDelayDuration={0} />;
}
const Tooltip = TooltipPrimitive.Root;
const TooltipTrigger = TooltipPrimitive.Trigger;
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
floatingSurfaceElevationClassName,
"z-50 overflow-hidden rounded-control px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95",
className,
)}
{...props}
/>
</TooltipPrimitive.Portal>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
+3 -32
View File
@@ -1,32 +1,3 @@
import * as React from "react";
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { floatingSurfaceElevationClassName } from "@/components/ui/floating-surface";
import { cn } from "@/lib/utils";
function TooltipProvider(props: Omit<React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>, "delayDuration" | "skipDelayDuration">) {
return <TooltipPrimitive.Provider {...props} delayDuration={500} skipDelayDuration={0} />;
}
const Tooltip = TooltipPrimitive.Root;
const TooltipTrigger = TooltipPrimitive.Trigger;
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
floatingSurfaceElevationClassName,
"z-50 overflow-hidden rounded-control px-3 py-1.5 text-xs animate-in fade-in-0 zoom-in-95",
className,
)}
{...props}
/>
</TooltipPrimitive.Portal>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip-primitives";
export { HoverHint } from "@/components/ui/hover-hint";
export { TruncatedTextTooltip } from "@/components/ui/truncated-text-tooltip";
@@ -0,0 +1,30 @@
import * as React from "react";
import { HoverHint } from "@/components/ui/hover-hint";
import { cn } from "@/lib/utils";
export function TruncatedTextTooltip({ text, className, ...props }: {
text: string;
} & Omit<React.ComponentPropsWithoutRef<"span">, "children" | "title">) {
const ref = React.useRef<HTMLSpanElement>(null);
const [truncated, setTruncated] = React.useState(false);
React.useLayoutEffect(() => {
const element = ref.current;
if (!element) return;
const measure = () => setTruncated(element.scrollWidth > element.clientWidth);
measure();
const observer = new ResizeObserver(measure);
observer.observe(element);
let mounted = true;
void document.fonts.ready.then(() => { if (mounted) measure(); });
return () => { mounted = false; observer.disconnect(); };
}, [text]);
return (
<HoverHint content={text} enabled={truncated}>
<span {...props} ref={ref} className={cn("min-w-0 truncate", className)}>{text}</span>
</HoverHint>
);
}