Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(help): wrap server-version row in DropdownMenuGroup to stop Help menu crash (#5458)

Bohan Jiang449d9887b5a2
diff --git a/packages/views/layout/help-launcher.test.tsx b/packages/views/layout/help-launcher.test.tsx
index b83ca800f0..30fb527c06 100644
--- a/packages/views/layout/help-launcher.test.tsx
+++ b/packages/views/layout/help-launcher.test.tsx
@@ -24,14 +24,36 @@ vi.mock("../i18n", () => ({
// Follows the app-sidebar.test.tsx convention of flattening the Base UI
// dropdown primitives to plain children so the menu content is always in
// the DOM, instead of exercising the real portal/open-state interaction.
-vi.mock("@multica/ui/components/ui/dropdown-menu", () => ({
- DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,
- DropdownMenuContent: ({ children }: { children: ReactNode }) => <>{children}</>,
- DropdownMenuItem: ({ children }: { children: ReactNode }) => <>{children}</>,
- DropdownMenuLabel: ({ children }: { children: ReactNode }) => <div>{children}</div>,
- DropdownMenuSeparator: () => null,
- DropdownMenuTrigger: ({ children }: { children: ReactNode }) => <>{children}</>,
-}));
+//
+// The mock deliberately preserves ONE real invariant: DropdownMenuLabel wraps
+// Base UI's Menu.GroupLabel, whose useMenuGroupRootContext() throws when it has
+// no Menu.Group ancestor. A plain-<div> mock silently swallowed that contract,
+// which is exactly how MUL-4819 shipped — a version row rendered outside a
+// DropdownMenuGroup crashed the whole app (no error boundary above the sidebar)
+// the moment the Help menu opened. Mirroring the throw here keeps the guard.
+// The group context lives inside the factory so it survives vi.mock hoisting.
+vi.mock("@multica/ui/components/ui/dropdown-menu", async () => {
+ const { createContext, useContext } = await import("react");
+ const GroupContext = createContext(false);
+ return {
+ DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,
+ DropdownMenuContent: ({ children }: { children: ReactNode }) => <>{children}</>,
+ DropdownMenuItem: ({ children }: { children: ReactNode }) => <>{children}</>,
+ DropdownMenuGroup: ({ children }: { children: ReactNode }) => (
+ <GroupContext.Provider value={true}>{children}</GroupContext.Provider>
+ ),
+ DropdownMenuLabel: ({ children }: { children: ReactNode }) => {
+ if (!useContext(GroupContext)) {
+ throw new Error(
+ "Base UI: MenuGroupRootContext is missing. Menu group parts must be used within <Menu.Group>.",
+ );
+ }
+ return <div>{children}</div>;
+ },
+ DropdownMenuSeparator: () => null,
+ DropdownMenuTrigger: ({ children }: { children: ReactNode }) => <>{children}</>,
+ };
+});
afterEach(() => {
configStore.getState().setServerVersion("");
@@ -48,4 +70,14 @@ describe("HelpLauncher", () => {
render(<HelpLauncher />);
expect(screen.getByText("Server version 1.2.3")).toBeInTheDocument();
});
+
+ // MUL-4819: the version row's DropdownMenuLabel must sit inside a
+ // DropdownMenuGroup. Rendering it bare made Base UI's Menu.GroupLabel throw
+ // on open, unmounting the whole app (black screen, no error) because no error
+ // boundary sits above the sidebar. Rendering here must not throw.
+ it("renders the version row without a missing-group crash", () => {
+ configStore.getState().setServerVersion("9.9.9");
+ expect(() => render(<HelpLauncher />)).not.toThrow();
+ expect(screen.getByText("Server version 9.9.9")).toBeInTheDocument();
+ });
});
diff --git a/packages/views/layout/help-launcher.tsx b/packages/views/layout/help-launcher.tsx
index d7a19d382a..7627004052 100644
--- a/packages/views/layout/help-launcher.tsx
+++ b/packages/views/layout/help-launcher.tsx
@@ -4,6 +4,7 @@ import { ArrowUpRight, BookOpen, CircleHelp, History, MessageCircle } from "luci
import {
DropdownMenu,
DropdownMenuContent,
+ DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
@@ -75,9 +76,16 @@ export function HelpLauncher() {
{serverVersion && (
<>
<DropdownMenuSeparator />
- <DropdownMenuLabel className="font-normal">
- {t(($) => $.help.server_version, { version: serverVersion })}
- </DropdownMenuLabel>
+ {/* 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">
+ {t(($) => $.help.server_version, { version: serverVersion })}
+ </DropdownMenuLabel>
+ </DropdownMenuGroup>
</>
)}
</DropdownMenuContent>