Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-6462: feat(views): add a web-only Desktop download entry to the Help menu (#7291)
Bohan Jiangbfb1320809ab
diff --git a/packages/views/layout/help-launcher.test.tsx b/packages/views/layout/help-launcher.test.tsxindex 30fb527c06..b312576d03 100644--- a/packages/views/layout/help-launcher.test.tsx+++ b/packages/views/layout/help-launcher.test.tsx@@ -1,10 +1,18 @@-import type { ReactNode } from "react";+import { cloneElement, type ReactElement, type ReactNode } from "react";import { render, screen } from "@testing-library/react";-import { afterEach, describe, expect, it, vi } from "vitest";+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { configStore } from "@multica/core/config";import enLayout from "../locales/en/layout.json";+import { isDesktopShell } from "../platform/local-directory";import { HelpLauncher } from "./help-launcher";+// The download entry is gated on the desktop-shell probe, which reads a+// preload-injected bridge that jsdom never has. Mock it so both platforms are+// reachable from the same suite.+vi.mock("../platform/local-directory", () => ({+ isDesktopShell: vi.fn(() => false),+}));+// react-i18next isn't initialised in the views test env, so resolve the// selector against the real en/layout.json to assert on actual copy.vi.mock("../i18n", () => ({@@ -38,7 +46,17 @@ vi.mock("@multica/ui/components/ui/dropdown-menu", async () => {return {DropdownMenu: ({ children }: { children: ReactNode }) => <>{children}</>,DropdownMenuContent: ({ children }: { children: ReactNode }) => <>{children}</>,- DropdownMenuItem: ({ children }: { children: ReactNode }) => <>{children}</>,+ // Base UI's `render` prop swaps in a caller-supplied element (here the+ // <a>) and adopts the item's children. Flattening it to a bare fragment —+ // as this mock originally did — would drop the anchor entirely and make an+ // href assertion silently unfalsifiable.+ DropdownMenuItem: ({+ children,+ render,+ }: {+ children: ReactNode;+ render?: ReactElement;+ }) => (render ? cloneElement(render, undefined, children) : <>{children}</>),DropdownMenuGroup: ({ children }: { children: ReactNode }) => (<GroupContext.Provider value={true}>{children}</GroupContext.Provider>),@@ -55,6 +73,10 @@ vi.mock("@multica/ui/components/ui/dropdown-menu", async () => {};});+beforeEach(() => {+ vi.mocked(isDesktopShell).mockReturnValue(false);+});+afterEach(() => {configStore.getState().setServerVersion("");});@@ -80,4 +102,23 @@ describe("HelpLauncher", () => {expect(() => render(<HelpLauncher />)).not.toThrow();expect(screen.getByText("Server version 9.9.9")).toBeInTheDocument();});++ // MUL-6462: after web onboarding the desktop download CTA was unreachable —+ // no entry anywhere in the app, so users had to remember the URL or detour+ // through the marketing site. The Help menu is the persistent home for it.+ it("links to the download page on web", () => {+ render(<HelpLauncher />);+ const link = screen.getByRole("link", { name: /Desktop app/ });+ expect(link).toHaveAttribute("href", "https://multica.ai/download");+ });++ // AppSidebar is shared: apps/desktop renders the same component tree. Without+ // this gate the desktop app would offer to download the desktop app.+ it("hides the download entry inside the desktop shell", () => {+ vi.mocked(isDesktopShell).mockReturnValue(true);+ render(<HelpLauncher />);+ expect(screen.queryByText("Desktop app")).not.toBeInTheDocument();+ // The rest of the menu is unaffected by the gate.+ expect(screen.getByText("Docs")).toBeInTheDocument();+ });});diff --git a/packages/views/layout/help-launcher.tsx b/packages/views/layout/help-launcher.tsxindex e4c82783ff..f430a9f1b3 100644--- a/packages/views/layout/help-launcher.tsx+++ b/packages/views/layout/help-launcher.tsx@@ -1,6 +1,13 @@"use client";-import { ArrowUpRight, BookOpen, CircleHelp, History, MessageCircle } from "lucide-react";+import {+ ArrowUpRight,+ BookOpen,+ CircleHelp,+ Download,+ History,+ MessageCircle,+} from "lucide-react";import {DropdownMenu,DropdownMenuContent,@@ -12,15 +19,31 @@ import {} from "@multica/ui/components/ui/dropdown-menu";import { useModalStore } from "@multica/core/modals";import { useConfigStore } from "@multica/core/config";+import { isDesktopShell } from "../platform/local-directory";import { DISCORD_URL, DiscordIcon } from "./discord";import { useT } from "../i18n";const DOCS_URL = "https://multica.ai/docs";const CHANGELOG_URL = "https://multica.ai/changelog";+// Absolute, including on self-hosted deployments: the installers we ship are+// the same binaries either way, and the desktop client can point at a+// self-hosted backend once installed. A self-host-relative /download would+// only serve a copy of this page that still has to reach our release assets.+const DOWNLOAD_URL = "https://multica.ai/download";export function HelpLauncher() {const { t } = useT("layout");const serverVersion = useConfigStore((state) => state.serverVersion);+ // Web-only: offering "download the desktop app" inside the desktop app is+ // nonsense, and this sidebar is shared — apps/desktop renders the same+ // AppSidebar as the web dashboard, so the entry has to be gated here.+ //+ // No `mounted` deferral (cf. browser-notification-setting.tsx): the desktop+ // renderer is a locally-bundled SPA with no SSR pass, and on web+ // `isDesktopShell()` is false both on the server and after hydration. The+ // markup matches either way, so the link can ship in the SSR payload instead+ // of popping in a frame late.+ const desktop = isDesktopShell();return (<DropdownMenu><DropdownMenuTrigger@@ -36,6 +59,24 @@ export function HelpLauncher() {sideOffset={8}className="min-w-40 max-w-56">+ {!desktop && (+ <>+ <DropdownMenuItem+ render={+ <a+ href={DOWNLOAD_URL}+ target="_blank"+ rel="noopener noreferrer"+ />+ }+ >+ <Download className="h-3.5 w-3.5" />+ {t(($) => $.help.download_desktop)}+ <ArrowUpRight className="size-3 translate-y-px text-faint-foreground" />+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ </>+ )}<DropdownMenuItemrender={<a href={DOCS_URL} target="_blank" rel="noopener noreferrer" />diff --git a/packages/views/locales/en/layout.json b/packages/views/locales/en/layout.jsonindex c670a3dc7b..3c185a602b 100644--- a/packages/views/locales/en/layout.json+++ b/packages/views/locales/en/layout.json@@ -29,6 +29,7 @@},"help": {"trigger": "Help",+ "download_desktop": "Desktop app","docs": "Docs","changelog": "Change log","discord": "Discord",diff --git a/packages/views/locales/ja/layout.json b/packages/views/locales/ja/layout.jsonindex a03dfbbff0..f824254f96 100644--- a/packages/views/locales/ja/layout.json+++ b/packages/views/locales/ja/layout.json@@ -29,6 +29,7 @@},"help": {"trigger": "ヘルプ",+ "download_desktop": "デスクトップ版","docs": "ドキュメント","changelog": "変更ログ","discord": "Discord",diff --git a/packages/views/locales/ko/layout.json b/packages/views/locales/ko/layout.jsonindex c089411af3..7ce0e6d1b3 100644--- a/packages/views/locales/ko/layout.json+++ b/packages/views/locales/ko/layout.json@@ -29,6 +29,7 @@},"help": {"trigger": "도움말",+ "download_desktop": "데스크톱 앱","docs": "문서","changelog": "변경 로그","discord": "Discord",diff --git a/packages/views/locales/zh-Hans/layout.json b/packages/views/locales/zh-Hans/layout.jsonindex 5aa737d1c9..55c7354b16 100644--- a/packages/views/locales/zh-Hans/layout.json+++ b/packages/views/locales/zh-Hans/layout.json@@ -29,6 +29,7 @@},"help": {"trigger": "帮助",+ "download_desktop": "桌面端","docs": "文档","changelog": "更新日志","discord": "Discord",