- docker-proxy service (tecnativa/docker-socket-proxy) in both compose files; worker uses it via DOCKER_HOST with a dependency-free client. - runtimes table with presets (llama.cpp CPU, vLLM CPU) and custom images; validation of image refs, env, args, devices (/dev/dri, /dev/kfd). - Worker reports Docker/CPU/memory facts and detects its network and models mount; pulls images with progress; image state per runtime. - Settings -> Runtimes page with host card, list, editor, pull/update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
102 lines
4.0 KiB
TypeScript
102 lines
4.0 KiB
TypeScript
"use client";
|
|
|
|
import { BoxesIcon, LogOutIcon, MonitorIcon, MoonIcon, SunIcon, TagIcon, TagsIcon } from "lucide-react";
|
|
import Link from "next/link";
|
|
import { useTheme } from "next-themes";
|
|
import { useTransition } from "react";
|
|
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuRadioGroup,
|
|
DropdownMenuRadioItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
|
|
export type MenuUser = { name: string | null; email: string | null; image: string | null };
|
|
|
|
function initials(user: MenuUser): string {
|
|
const source = user.name || user.email || "?";
|
|
const parts = source.split(/[\s@._-]+/).filter(Boolean);
|
|
return ((parts[0]?.[0] ?? "?") + (parts.length > 1 ? parts[1][0] : "")).toUpperCase();
|
|
}
|
|
|
|
function UserAvatar({ user, size }: { user: MenuUser; size?: "sm" | "default" | "lg" }) {
|
|
return (
|
|
<Avatar size={size}>
|
|
{user.image && <AvatarImage src={user.image} alt="" referrerPolicy="no-referrer" />}
|
|
<AvatarFallback className="text-xs font-medium">{initials(user)}</AvatarFallback>
|
|
</Avatar>
|
|
);
|
|
}
|
|
|
|
/** Avatar from the OIDC profile; opens a menu with account info, settings, theme and sign out. */
|
|
export function UserMenu({ user, signOutAction }: { user: MenuUser; signOutAction: () => Promise<void> }) {
|
|
const { theme, setTheme } = useTheme();
|
|
const [signingOut, startSignOut] = useTransition();
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger
|
|
aria-label="Account menu"
|
|
className="flex items-center gap-2 rounded-full p-0.5 outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 sm:pr-3"
|
|
>
|
|
<UserAvatar user={user} />
|
|
<span className="hidden max-w-40 truncate text-sm sm:inline">{user.name ?? user.email}</span>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" className="w-64">
|
|
<div className="flex items-center gap-3 px-1.5 py-2">
|
|
<UserAvatar user={user} size="lg" />
|
|
<div className="flex min-w-0 flex-col">
|
|
<span className="truncate text-sm font-medium">{user.name ?? "Signed in"}</span>
|
|
{user.email && <span className="truncate text-xs text-muted-foreground">{user.email}</span>}
|
|
</div>
|
|
</div>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuLabel>Settings</DropdownMenuLabel>
|
|
<DropdownMenuItem render={<Link href="/settings/labels" />}>
|
|
<TagIcon />
|
|
File labels
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem render={<Link href="/settings/tags" />}>
|
|
<TagsIcon />
|
|
Tags
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem render={<Link href="/settings/runtimes" />}>
|
|
<BoxesIcon />
|
|
Runtimes
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuLabel>Theme</DropdownMenuLabel>
|
|
<DropdownMenuRadioGroup value={theme ?? "system"} onValueChange={(v) => setTheme(v as string)}>
|
|
<DropdownMenuRadioItem value="system" closeOnClick={false}>
|
|
<MonitorIcon />
|
|
System
|
|
</DropdownMenuRadioItem>
|
|
<DropdownMenuRadioItem value="light" closeOnClick={false}>
|
|
<SunIcon />
|
|
Light
|
|
</DropdownMenuRadioItem>
|
|
<DropdownMenuRadioItem value="dark" closeOnClick={false}>
|
|
<MoonIcon />
|
|
Dark
|
|
</DropdownMenuRadioItem>
|
|
</DropdownMenuRadioGroup>
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem variant="destructive" disabled={signingOut} onClick={() => startSignOut(() => signOutAction())}>
|
|
<LogOutIcon />
|
|
{signingOut ? "Signing out…" : "Sign out"}
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|