Files
multica/packages/views/layout/help-launcher.tsx
Bohan Jiang fa17e5c168 fix(views): stop server version from stretching the help menu (#5472)
Cap the Help menu width (max-w-56) and let the server version label
wrap (break-words) so a long version string no longer widens the whole
popup. The menu still keeps its min-w-40 floor when no version is shown.

MUL-4828

Co-authored-by: Bohan-J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-07-15 18:41:16 +08:00

95 lines
3.3 KiB
TypeScript

"use client";
import { ArrowUpRight, BookOpen, CircleHelp, History, MessageCircle } from "lucide-react";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@multica/ui/components/ui/dropdown-menu";
import { useModalStore } from "@multica/core/modals";
import { useConfigStore } from "@multica/core/config";
import { DISCORD_URL, DiscordIcon } from "./discord";
import { useT } from "../i18n";
const DOCS_URL = "https://multica.ai/docs";
const CHANGELOG_URL = "https://multica.ai/changelog";
export function HelpLauncher() {
const { t } = useT("layout");
const serverVersion = useConfigStore((state) => state.serverVersion);
return (
<DropdownMenu>
<DropdownMenuTrigger
aria-label={t(($) => $.help.trigger)}
title={t(($) => $.help.trigger)}
className="inline-flex size-7 items-center justify-center rounded-full text-muted-foreground transition-colors cursor-pointer hover:bg-accent hover:text-foreground data-popup-open:bg-accent data-popup-open:text-foreground"
>
<CircleHelp className="size-4" />
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
side="top"
sideOffset={8}
className="min-w-40 max-w-56"
>
<DropdownMenuItem
render={
<a href={DOCS_URL} target="_blank" rel="noopener noreferrer" />
}
>
<BookOpen className="h-3.5 w-3.5" />
{t(($) => $.help.docs)}
<ArrowUpRight className="size-3 translate-y-px text-muted-foreground/50" />
</DropdownMenuItem>
<DropdownMenuItem
render={
<a
href={CHANGELOG_URL}
target="_blank"
rel="noopener noreferrer"
/>
}
>
<History className="h-3.5 w-3.5" />
{t(($) => $.help.changelog)}
<ArrowUpRight className="size-3 translate-y-px text-muted-foreground/50" />
</DropdownMenuItem>
<DropdownMenuItem
render={
<a href={DISCORD_URL} target="_blank" rel="noopener noreferrer" />
}
>
<DiscordIcon className="h-3.5 w-3.5" />
{t(($) => $.help.discord)}
<ArrowUpRight className="size-3 translate-y-px text-muted-foreground/50" />
</DropdownMenuItem>
<DropdownMenuItem
onClick={() => useModalStore.getState().open("feedback")}
>
<MessageCircle className="h-3.5 w-3.5" />
{t(($) => $.help.feedback)}
</DropdownMenuItem>
{serverVersion && (
<>
<DropdownMenuSeparator />
{/* DropdownMenuLabel renders Base UI's Menu.GroupLabel, which reads
a Menu.Group context and throws if it has no Group ancestor. It
must always be wrapped in a DropdownMenuGroup — without it the
Help menu crashes the whole app on open (no error boundary sits
above the sidebar). */}
<DropdownMenuGroup>
<DropdownMenuLabel className="font-normal break-words">
{t(($) => $.help.server_version, { version: serverVersion })}
</DropdownMenuLabel>
</DropdownMenuGroup>
</>
)}
</DropdownMenuContent>
</DropdownMenu>
);
}