Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8576: feat(whats-new): move the read entry into the Help menu, swap the gift icon (#9908)
Jiayuan Zhang2a3e4aa61436
diff --git a/packages/ui/components/ui/popover.tsx b/packages/ui/components/ui/popover.tsxindex 8d1f34f31a..3016eb91e9 100644--- a/packages/ui/components/ui/popover.tsx+++ b/packages/ui/components/ui/popover.tsx@@ -19,12 +19,13 @@ function PopoverContent({alignOffset = 0,side = "bottom",sideOffset = 4,+ anchor,keepMounted,...props}: PopoverPrimitive.Popup.Props &Pick<PopoverPrimitive.Positioner.Props,- "align" | "alignOffset" | "side" | "sideOffset"+ "align" | "alignOffset" | "side" | "sideOffset" | "anchor"> &// Keep the popup in the DOM while closed. Needed when the content hosts a// modal (confirm dialog / transcript) that opens on click: without it the@@ -38,6 +39,7 @@ function PopoverContent({alignOffset={alignOffset}side={side}sideOffset={sideOffset}+ anchor={anchor}className="isolate z-50"><PopoverPrimitive.Popupdiff --git a/packages/views/layout/help-launcher.test.tsx b/packages/views/layout/help-launcher.test.tsxindex 025669eeb2..ed1bb06bd4 100644--- a/packages/views/layout/help-launcher.test.tsx+++ b/packages/views/layout/help-launcher.test.tsx@@ -13,6 +13,12 @@ vi.mock("../platform/local-directory", () => ({isDesktopShell: vi.fn(() => false),}));+// The What's new entry is covered with the real menu in whats-new-launcher.test.tsx.+vi.mock("../whats-new/whats-new-launcher", () => ({+ useWhatsNewMenuPanel: () => ({ available: false }),+ WhatsNewMenuPanel: () => null,+}));+// The UI language the mocked i18n instance reports; drives locale-aware links.const i18nState = vi.hoisted(() => ({ language: "en" }));diff --git a/packages/views/layout/help-launcher.tsx b/packages/views/layout/help-launcher.tsxindex 05d93dc8f9..90c3990991 100644--- a/packages/views/layout/help-launcher.tsx+++ b/packages/views/layout/help-launcher.tsx@@ -1,11 +1,13 @@"use client";+import { useRef } from "react";import {ArrowUpRight,BookOpen,CircleHelp,Download,History,+ Megaphone,MessageCircle,} from "@multica/ui/icons";import {@@ -26,6 +28,7 @@ import { useT } from "../i18n";import { docsLocalePrefix } from "../common/docs-locale";import { RAIL_ICON_BUTTON_CLASS } from "./rail-styles";import { CHANGELOG_URL, DOCS_URL, DOWNLOAD_URL } from "./help-links";+import { useWhatsNewMenuPanel, WhatsNewMenuPanel } from "../whats-new/whats-new-launcher";export function HelpLauncher() {@@ -41,97 +44,109 @@ export function HelpLauncher() {// markup matches either way, so the link can ship in the SSR payload instead// of popping in a frame late.const desktop = isDesktopShell();+ const triggerRef = useRef<HTMLButtonElement>(null);+ const whatsNew = useWhatsNewMenuPanel();return (- <DropdownMenu>- <TooltipHint label={t(($) => $.help.trigger)} side="right">- <DropdownMenuTrigger- aria-label={t(($) => $.help.trigger)}- className={RAIL_ICON_BUTTON_CLASS}+ <>+ <DropdownMenu>+ <TooltipHint label={t(($) => $.help.trigger)} side="right">+ <DropdownMenuTrigger+ ref={triggerRef}+ aria-label={t(($) => $.help.trigger)}+ className={RAIL_ICON_BUTTON_CLASS}+ >+ <CircleHelp />+ </DropdownMenuTrigger>+ </TooltipHint>+ <DropdownMenuContent+ align="end"+ side="right"+ sideOffset={8}+ className="min-w-40 max-w-56">- <CircleHelp />- </DropdownMenuTrigger>- </TooltipHint>- <DropdownMenuContent- align="end"- side="right"- 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" />+ {!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 />+ </>+ )}+ <DropdownMenuItem+ render={+ <a+ href={`${DOCS_URL}${docsLocalePrefix(i18n.language)}`}+ target="_blank"+ rel="noopener noreferrer"+ />+ }+ >+ <BookOpen className="h-3.5 w-3.5" />+ {t(($) => $.help.docs)}+ <ArrowUpRight className="size-3 translate-y-px text-faint-foreground" />+ </DropdownMenuItem>+ {whatsNew.available && (+ <DropdownMenuItem onClick={whatsNew.show}>+ <Megaphone className="h-3.5 w-3.5" />+ {t(($) => $.whats_new.trigger)}</DropdownMenuItem>- <DropdownMenuSeparator />- </>- )}- <DropdownMenuItem- render={- <a- href={`${DOCS_URL}${docsLocalePrefix(i18n.language)}`}- target="_blank"- rel="noopener noreferrer"- />- }- >- <BookOpen className="h-3.5 w-3.5" />- {t(($) => $.help.docs)}- <ArrowUpRight className="size-3 translate-y-px text-faint-foreground" />- </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-faint-foreground" />- </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-faint-foreground" />- </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 rail). */}- <DropdownMenuGroup>- <DropdownMenuLabel className="font-normal break-words">- {t(($) => $.help.server_version, { version: serverVersion })}- </DropdownMenuLabel>- </DropdownMenuGroup>- </>- )}- </DropdownMenuContent>- </DropdownMenu>+ )}+ <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-faint-foreground" />+ </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-faint-foreground" />+ </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 rail). */}+ <DropdownMenuGroup>+ <DropdownMenuLabel className="font-normal break-words">+ {t(($) => $.help.server_version, { version: serverVersion })}+ </DropdownMenuLabel>+ </DropdownMenuGroup>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ <WhatsNewMenuPanel panel={whatsNew} anchor={triggerRef} />+ </>);}diff --git a/packages/views/whats-new/whats-new-launcher.test.tsx b/packages/views/whats-new/whats-new-launcher.test.tsxindex 181a9da697..a8323f419d 100644--- a/packages/views/whats-new/whats-new-launcher.test.tsx+++ b/packages/views/whats-new/whats-new-launcher.test.tsx@@ -5,6 +5,7 @@ import { configStore } from "@multica/core/config";import { Command, Globe, Terminal } from "@multica/ui/icons";import type { User } from "@multica/core/types";import enLayout from "../locales/en/layout.json";+import { HelpLauncher } from "../layout/help-launcher";import { useSearchStore } from "../search/search-store";import type { WhatsNewRelease } from "./releases";import { useWhatsNewSessionStore } from "./session-store";@@ -125,8 +126,20 @@ function renderLauncher() {}const trigger = () => screen.getByRole("button", { name: "What's new" });+const railTrigger = () => screen.queryByRole("button", { name: "What's new" });const dot = () => document.querySelector('[data-slot="whats-new-dot"]');+function openFromHelpMenu() {+ fireEvent.click(screen.getByRole("button", { name: "Help" }));+ act(() => {+ vi.runAllTimers();+ });+ fireEvent.click(screen.getByRole("menuitem", { name: "What's new" }));+ act(() => {+ vi.runAllTimers();+ });+}+beforeEach(() => {vi.useFakeTimers();i18nState.language = "en";@@ -205,13 +218,63 @@ describe("WhatsNewLauncher", () => {it("stays quiet against a server that cannot record dismissals", () => {signIn({});- renderLauncher();+ render(+ <>+ <WhatsNewLauncher />+ <HelpLauncher />+ </>,+ );+ act(() => {+ vi.advanceTimersByTime(AUTO_OPEN_DELAY_MS);+ });- expect(dot()).not.toBeInTheDocument();+ expect(railTrigger()).not.toBeInTheDocument();expect(screen.queryByText(/since your last visit/)).not.toBeInTheDocument();+ openFromHelpMenu();+ expect(screen.getByRole("heading", { name: "What's new" })).toBeInTheDocument();+ expect(mocks.markWhatsNewSeen).not.toHaveBeenCalled();+ });++ it("leaves the rail once the update is acknowledged", () => {+ signIn({ whats_new_seen_version: "0.1.0" });+ renderLauncher();++ fireEvent.click(screen.getByRole("button", { name: "Got it" }));+ act(() => {+ vi.runAllTimers();+ });+ expect(railTrigger()).not.toBeInTheDocument();+ });++ it("keeps the rail button while the panel opened from it is up", () => {+ signIn({ whats_new_seen_version: "0.2.0" });+ render(<WhatsNewLauncher />);+fireEvent.click(trigger());expect(screen.getByRole("heading", { name: "What's new" })).toBeInTheDocument();+ expect(railTrigger()).toBeInTheDocument();++ fireEvent.click(screen.getByRole("button", { name: "Close" }));+ act(() => {+ vi.runAllTimers();+ });+ expect(railTrigger()).not.toBeInTheDocument();+ });++ it("opens the history from the Help menu once everything is read", () => {+ signIn({ whats_new_seen_version: "0.3.0" });+ render(+ <>+ <WhatsNewLauncher />+ <HelpLauncher />+ </>,+ );+ expect(railTrigger()).not.toBeInTheDocument();++ openFromHelpMenu();+ expect(screen.getByRole("heading", { name: "What's new" })).toBeInTheDocument();+ expect(screen.getByRole("region", { name: "v0.3.0" })).not.toHaveTextContent("New");expect(mocks.markWhatsNewSeen).not.toHaveBeenCalled();});diff --git a/packages/views/whats-new/whats-new-launcher.tsx b/packages/views/whats-new/whats-new-launcher.tsxindex 6a0fad0f1c..96936b62d6 100644--- a/packages/views/whats-new/whats-new-launcher.tsx+++ b/packages/views/whats-new/whats-new-launcher.tsx@@ -1,7 +1,7 @@"use client";-import { useEffect, useRef, useState } from "react";-import { Gift } from "@multica/ui/icons";+import { useCallback, useEffect, useRef, useState, type RefObject } from "react";+import { Megaphone } from "@multica/ui/icons";import { Popover, PopoverContent, PopoverTrigger } from "@multica/ui/components/ui/popover";import { TooltipHint } from "@multica/ui/components/common/tooltip-hint";import { cn } from "@multica/ui/lib/utils";@@ -16,6 +16,9 @@ import { WhatsNewPanel } from "./whats-new-panel";/** Lets the workspace settle before the card slides in. */export const AUTO_OPEN_DELAY_MS = 1200;+const POPUP_CLASS = "gap-0 overflow-hidden rounded-xl p-0";+const EMPTY_VERSIONS: ReadonlySet<string> = new Set();+type View =| { kind: "card"; releases: WhatsNewRelease[] }| { kind: "panel"; unreadVersions: ReadonlySet<string> };@@ -27,19 +30,22 @@ function isRendered(el: HTMLElement | null): boolean {}/**- * Rail entry for release highlights. After an update the card opens by+ * Rail entry for unread release highlights. After an update the card opens by* itself once per page session, from whichever launcher is on screen;* dismissing it (or opening the panel) records the* newest release as seen. Clicking away only hides the card, so the dot- * stays until the user acknowledges it.+ * stays until the user acknowledges it. Once nothing is unread the button+ * leaves the rail; the history stays one click away in the Help menu.*/export function WhatsNewLauncher() {const { t } = useT("layout");const { visible, unread, markSeen } = useWhatsNew();const [open, setOpen] = useState(false);- // Snapshotted on open: marking seen empties `unread` while the popup is- // still visible and animating out.- const [view, setView] = useState<View>({ kind: "panel", unreadVersions: new Set() });+ // Keeps the trigger in the rail while its popup animates out: marking seen+ // empties `unread` while the popup is still visible.+ const [popupMounted, setPopupMounted] = useState(false);+ // Snapshotted on open, for the same reason.+ const [view, setView] = useState<View>({ kind: "panel", unreadVersions: EMPTY_VERSIONS });const triggerRef = useRef<HTMLButtonElement>(null);const hasUnread = unread.length > 0;@@ -50,15 +56,17 @@ export function WhatsNewLauncher() {if (session.autoShown || !isRendered(triggerRef.current)) return;session.markAutoShown();setView({ kind: "card", releases: unread });+ setPopupMounted(true);setOpen(true);}, AUTO_OPEN_DELAY_MS);return () => window.clearTimeout(timer);}, [unread]);- if (visible.length === 0) return null;+ if (visible.length === 0 || (!hasUnread && !popupMounted)) return null;const openPanel = () => {setView({ kind: "panel", unreadVersions: new Set(unread.map((r) => r.version)) });+ setPopupMounted(true);setOpen(true);markSeen();};@@ -77,6 +85,9 @@ export function WhatsNewLauncher() {if (next || (view.kind === "card" && details.reason === "trigger-press")) openPanel();else setOpen(false);}}+ onOpenChangeComplete={(next) => {+ if (!next) setPopupMounted(false);+ }}><TooltipHint label={label} side="right"><PopoverTrigger@@ -85,7 +96,7 @@ export function WhatsNewLauncher() {data-unread={hasUnread || undefined}className={RAIL_ICON_BUTTON_CLASS}>- <Gift />+ <Megaphone />{hasUnread && (<spanaria-hidden@@ -101,7 +112,7 @@ export function WhatsNewLauncher() {sideOffset={8}// An unprompted card must not pull focus out of whatever the user is typing in.initialFocus={view.kind === "panel"}- className={cn("gap-0 overflow-hidden rounded-xl p-0", view.kind === "card" ? "w-[380px]" : "w-[400px]")}+ className={cn(POPUP_CLASS, view.kind === "card" ? "w-[380px]" : "w-[400px]")}>{view.kind === "card" ? (<WhatsNewCard releases={view.releases} onDismiss={dismiss} onViewDetails={openPanel} />@@ -112,3 +123,33 @@ export function WhatsNewLauncher() {</Popover>);}++/** The release history opened from a menu rather than the rail button. */+export function useWhatsNewMenuPanel() {+ const { visible, unread, markSeen } = useWhatsNew();+ const [open, setOpen] = useState(false);+ const [unreadVersions, setUnreadVersions] = useState(EMPTY_VERSIONS);+ const show = useCallback(() => {+ setUnreadVersions(new Set(unread.map((r) => r.version)));+ setOpen(true);+ markSeen();+ }, [unread, markSeen]);+ return { available: visible.length > 0, releases: visible, open, setOpen, unreadVersions, show };+}++export function WhatsNewMenuPanel({+ panel,+ anchor,+}: {+ panel: ReturnType<typeof useWhatsNewMenuPanel>;+ /** The menu's trigger: the menu itself is gone by the time the panel opens. */+ anchor: RefObject<HTMLElement | null>;+}) {+ return (+ <Popover open={panel.open} onOpenChange={panel.setOpen}>+ <PopoverContent anchor={anchor} side="right" align="end" sideOffset={8} className={cn(POPUP_CLASS, "w-[400px]")}>+ <WhatsNewPanel releases={panel.releases} unreadVersions={panel.unreadVersions} onClose={() => panel.setOpen(false)} />+ </PopoverContent>+ </Popover>+ );+}