Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(whats-new): reach every user with the deck, and add a Prompts panel to the dev toolbar (MUL-9327) (#10664)
Jiayuan Zhang0972864b8b01
diff --git a/packages/core/session-prompt/index.ts b/packages/core/session-prompt/index.tsindex 03fd2e2fe1..03e6145401 100644--- a/packages/core/session-prompt/index.ts+++ b/packages/core/session-prompt/index.ts@@ -2,18 +2,80 @@import { create } from "zustand";+/** Cards that slide into the bottom-right corner, which holds one at a time. */+export type CornerCard = "whats-new" | "star";+interface SessionPromptStore {- /** A prompt that asks something of the user has been shown this app session. */+ /**+ * A prompt that asks something of the user has been shown this app session.+ * Shared by the source survey and the GitHub star prompt; the What's new+ * deck only informs, so it neither spends nor respects this.+ */prompted: boolean;+ /** The What's new deck has been dealt this app session. */+ deckDealt: boolean;+ /** The source survey is open, or has yet to decide whether to open. */+ surveyPending: boolean;+ corner: CornerCard | null;markPrompted: () => void;+ markDeckDealt: () => void;+ setSurveyPending: (pending: boolean) => void;+ /** True when the corner is now `card`'s, false when another card holds it. */+ claimCorner: (card: CornerCard) => boolean;+ releaseCorner: (card: CornerCard) => void;+ /** Forgets what this session has shown, as a reload would; what is on screen keeps its hold. */+ reset: () => void;}/**- * The one interruption an app session allows, shared by the source survey,- * the GitHub star prompt and the What's new deck so a user who just dealt with- * one never meets another.+ * Keeps the app's own prompts from piling onto each other within an app+ * session: who has interrupted already, whether the survey is about to, and+ * which card holds the corner.*/-export const useSessionPromptStore = create<SessionPromptStore>((set) => ({+export const useSessionPromptStore = create<SessionPromptStore>((set, get) => ({prompted: false,+ deckDealt: false,+ surveyPending: false,+ corner: null,markPrompted: () => set({ prompted: true }),+ markDeckDealt: () => set({ deckDealt: true }),+ setSurveyPending: (pending) => set({ surveyPending: pending }),+ claimCorner: (card) => {+ const { corner } = get();+ if (corner !== null && corner !== card) return false;+ if (corner !== card) set({ corner: card });+ return true;+ },+ releaseCorner: (card) => {+ if (get().corner === card) set({ corner: null });+ },+ reset: () => set({ prompted: false, deckDealt: false }),+}));++/** A prompt the dev toolbar asked to show, bypassing its gates. */+export type DevPromptKind = "whats-new" | "whats-new-check" | "star" | "survey";++interface DevPromptRequest {+ kind: DevPromptKind;+ id: number;+}++interface DevPromptStore {+ request: DevPromptRequest | null;+ trigger: (kind: DevPromptKind) => void;+ /** Takes the pending request when it is of `kind`, so a remount does not replay it. */+ take: (kind: DevPromptKind) => boolean;+}++let nextRequestId = 0;++/** Dev toolbar → prompt components. Nothing triggers it outside development. */+export const useDevPromptStore = create<DevPromptStore>((set, get) => ({+ request: null,+ trigger: (kind) => set({ request: { kind, id: ++nextRequestId } }),+ take: (kind) => {+ if (get().request?.kind !== kind) return false;+ set({ request: null });+ return true;+ },}));diff --git a/packages/views/dev-toolbar/dev-toolbar.tsx b/packages/views/dev-toolbar/dev-toolbar.tsxindex 62bea8efb4..84ab200e3e 100644--- a/packages/views/dev-toolbar/dev-toolbar.tsx+++ b/packages/views/dev-toolbar/dev-toolbar.tsx@@ -11,6 +11,7 @@ import {subscribeToCurrentSlug,} from "@multica/core/platform";import { useWSStatus, type WSStatus } from "@multica/core/realtime";+import { useSessionPromptStore } from "@multica/core/session-prompt";import { runtimeListOptions } from "@multica/core/runtimes/queries";import { memberListOptions } from "@multica/core/workspace/queries";import { Popover, PopoverContent, PopoverTrigger } from "@multica/ui/components/ui/popover";@@ -36,6 +37,7 @@ import {SyncPanel,TONE_CLASS,} from "./panels";+import { PromptsPanel } from "./prompts-panel";import { CachePanel, EventsPanel, RuntimesPanel, TasksPanel } from "./realtime-panels";import { useDevRecorder, useMainThreadBlocked, useNavDuration, useNow } from "./use-dev-metrics";@@ -147,6 +149,7 @@ export function DevToolbar({ build, apiUrl, route, onNavigate }: DevToolbarPropsconst fetching = useIsFetching();const online = runtimes?.filter((r) => r.status === "online").length ?? 0;const running = activeTasks(tasks ?? []).filter((t) => t.status === "running").length;+ const corner = useSessionPromptStore((s) => s.corner);const openIssue = slug ? (issueId: string) => onNavigate(paths.workspace(slug).issueDetail(issueId)) : null;const syncDot = (@@ -262,6 +265,9 @@ export function DevToolbar({ build, apiUrl, route, onNavigate }: DevToolbarProps</Metric></>)}+ <Metric label="Prompts" value={corner ?? "idle"}>+ <PromptsPanel wsId={wsId} now={now} />+ </Metric><Metric label="Errors" value={String(errors)} tone={errors > 0 ? "bad" : "normal"}><ErrorsPanel recording={recording} /></Metric>diff --git a/packages/views/dev-toolbar/prompts-panel.test.tsx b/packages/views/dev-toolbar/prompts-panel.test.tsxnew file mode 100644index 0000000000..697ccb9ed2--- /dev/null+++ b/packages/views/dev-toolbar/prompts-panel.test.tsx@@ -0,0 +1,92 @@+import { act, fireEvent, render, screen } from "@testing-library/react";+import { beforeEach, describe, expect, it, vi } from "vitest";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";+import type { User } from "@multica/core/types";+import { PromptsPanel } from "./prompts-panel";++const stores = vi.hoisted(() => {+ // eslint-disable-next-line @typescript-eslint/no-require-imports+ const { create } = require("zustand") as typeof import("zustand");+ const auth = create<{ user: Partial<User> | null; setUser: (user: Partial<User>) => void }>((set) => ({+ user: null,+ setUser: (user) => set({ user }),+ }));+ const chat = create<{ isOpen: boolean }>(() => ({ isOpen: false }));+ return { auth, chat };+});++vi.mock("@multica/core/auth", () => ({ useAuthStore: stores.auth }));+vi.mock("@multica/core/chat", () => ({ useChatStore: stores.chat }));++function signIn(user: Partial<User> = {}) {+ stores.auth.setState({+ user: {+ id: "u1",+ created_at: "2026-11-14T08:00:00Z",+ whats_new_seen_version: "0.9.0",+ onboarded_at: "2026-11-14T08:00:00Z",+ onboarding_questionnaire: { source: ["friend"] },+ star_prompt_shown_count: 0,+ star_prompt_last_shown_at: null,+ star_prompt_starred_at: null,+ ...user,+ },+ });+}++const field = (label: string) => screen.getByText(label).nextElementSibling;++beforeEach(() => {+ useSessionPromptStore.setState({ prompted: false, deckDealt: false, surveyPending: false, corner: null });+ useDevPromptStore.setState({ request: null });+ stores.chat.setState({ isOpen: false });+ signIn();+});++describe("PromptsPanel", () => {+ it("says why the deck has nothing to deal, and deals once the seen version moves back", () => {+ render(<PromptsPanel wsId="ws-1" now={0} />);+ expect(field("Status")).toHaveTextContent("nothing unread");++ fireEvent.change(screen.getByRole("combobox", { name: "Seen version" }), { target: { value: "0.8.2" } });+ expect(stores.auth.getState().user?.whats_new_seen_version).toBe("0.8.2");+ expect(field("Unread")).toHaveTextContent("0.9.0");+ expect(field("Cards to deal")).toHaveTextContent("3");+ expect(field("Status")).toHaveTextContent("deals at the next check");++ act(() => useSessionPromptStore.setState({ surveyPending: true }));+ expect(field("Status")).toHaveTextContent("waiting: source survey open or deciding");+ act(() => {+ useSessionPromptStore.setState({ surveyPending: false });+ stores.chat.setState({ isOpen: true });+ });+ expect(field("Status")).toHaveTextContent("waiting: chat window open");+ });++ it("asks each prompt to show itself", () => {+ render(<PromptsPanel wsId="ws-1" now={0} />);+ for (const [button, kind] of [+ ["Show deck", "whats-new"],+ ["Run check now", "whats-new-check"],+ ["Show star card", "star"],+ ["Open survey", "survey"],+ ] as const) {+ fireEvent.click(screen.getByRole("button", { name: button }));+ expect(useDevPromptStore.getState().request?.kind).toBe(kind);+ }+ });++ it("starts the session over", () => {+ useSessionPromptStore.setState({ prompted: true, deckDealt: true, corner: "star" });+ render(<PromptsPanel wsId="ws-1" now={0} />);+ fireEvent.click(screen.getByRole("button", { name: "Reset session" }));+ expect(useSessionPromptStore.getState()).toMatchObject({ prompted: false, deckDealt: false, corner: "star" });+ });++ it("disables the workspace prompts outside a workspace", () => {+ render(<PromptsPanel wsId={null} now={0} />);+ expect(screen.getByRole("button", { name: "Show deck" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Open survey" })).toBeDisabled();+ expect(field("Status")).toHaveTextContent("no workspace open");+ });+});diff --git a/packages/views/dev-toolbar/prompts-panel.tsx b/packages/views/dev-toolbar/prompts-panel.tsxnew file mode 100644index 0000000000..0c518055d0--- /dev/null+++ b/packages/views/dev-toolbar/prompts-panel.tsx@@ -0,0 +1,179 @@+"use client";++import type { ReactNode } from "react";+import { useAuthStore } from "@multica/core/auth";+import { useConfigStore } from "@multica/core/config";+import { needsSourceBackfill, SOURCE_BACKFILL_MAX_DISMISSALS } from "@multica/core/onboarding";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";+import { STAR_PROMPT_MAX_SHOWINGS, starPromptDue } from "@multica/core/star-prompt";+import { cn } from "@multica/ui/lib/utils";+import {+ resetSourceBackfillDismissCount,+ useSourceBackfillDismissCount,+} from "../onboarding/source-backfill-dismiss";+import { WHATS_NEW_RELEASES } from "../whats-new/releases";+import { useWhatsNew } from "../whats-new/use-whats-new";+import { deckBlocker, deckCards, type DeckBlocker } from "../whats-new/whats-new-deck";+import type { MetricTone } from "./metrics";+import { PanelHeader, SmallButton, TONE_CLASS } from "./panels";++const BLOCKER_LABEL: Record<DeckBlocker, string> = {+ dealt: "already dealt this session",+ survey: "source survey open or deciding",+ corner: "star card holds the corner",+ chat: "chat window open",+ busy: "typing, a dialog open, or tab hidden",+};++function Section({ title, note, actions, children }: { title: string; note?: string; actions?: ReactNode; children: ReactNode }) {+ return (+ <div className="border-b border-border last:border-b-0">+ <div className="flex items-center gap-2 px-3 pt-2 pb-1">+ <span className="font-medium text-foreground">{title}</span>+ {note && <span className="text-micro text-muted-foreground">{note}</span>}+ <div className="ml-auto flex items-center gap-1">{actions}</div>+ </div>+ <div className="pb-2">{children}</div>+ </div>+ );+}++function Field({ label, tone = "normal", children }: { label: string; tone?: MetricTone; children: ReactNode }) {+ return (+ <div className="flex min-h-5 items-center gap-3 px-3">+ <span className="w-32 shrink-0 text-muted-foreground">{label}</span>+ <span className={cn("min-w-0 flex-1 truncate font-mono tabular-nums", TONE_CLASS[tone])}>{children}</span>+ </div>+ );+}++const yesNo = (value: boolean) => (value ? "yes" : "no");+const day = (iso: string | null | undefined) => (iso ? iso.slice(0, 10) : "—");++/**+ * Every gate behind the app's own prompts — the What's new deck, the GitHub+ * star card and the source survey — with buttons that show each one on demand.+ * `now` re-renders the panel so DOM-dependent gates stay current.+ */+export function PromptsPanel({ wsId }: { wsId: string | null; now: number }) {+ const user = useAuthStore((s) => s.user);+ const serverVersion = useConfigStore((s) => s.serverVersion);+ const session = useSessionPromptStore();+ const trigger = useDevPromptStore((s) => s.trigger);+ const { visible, unread } = useWhatsNew();+ const [dismissCount] = useSourceBackfillDismissCount(user?.id);++ const cards = deckCards(unread).length;+ const blocker = deckBlocker();+ const deck: { text: string; tone: MetricTone } =+ session.corner === "whats-new"+ ? { text: "on screen", tone: "normal" }+ : !wsId+ ? { text: "no workspace open", tone: "warn" }+ : unread.length === 0+ ? { text: "nothing unread", tone: "warn" }+ : cards === 0+ ? { text: "no unread highlight has hero art", tone: "bad" }+ : blocker+ ? { text: `waiting: ${BLOCKER_LABEL[blocker]}`, tone: blocker === "dealt" ? "warn" : "normal" }+ : { text: "deals at the next check", tone: "normal" };++ const seenSupported = user?.whats_new_seen_version !== undefined;+ const setSeen = (version: string) => {+ const current = useAuthStore.getState().user;+ if (current) useAuthStore.getState().setUser({ ...current, whats_new_seen_version: version || null });+ };++ return (+ <>+ <PanelHeader title="Prompts" note="this app session">+ <SmallButton onClick={() => session.reset()}>Reset session</SmallButton>+ </PanelHeader>+ <Section title="Session">+ <Field label="Prompt budget" tone={session.prompted ? "warn" : "normal"}>+ {session.prompted ? "used by survey or star card" : "free"}+ </Field>+ <Field label="Corner">{session.corner ?? "empty"}</Field>+ </Section>+ <Section+ title="What's new deck"+ actions={+ <>+ <SmallButton onClick={() => trigger("whats-new-check")} disabled={!wsId}>+ Run check now+ </SmallButton>+ <SmallButton onClick={() => trigger("whats-new")} disabled={!wsId}>+ Show deck+ </SmallButton>+ </>+ }+ >+ <Field label="Status" tone={deck.tone}>+ {deck.text}+ </Field>+ <Field label="Server version">{serverVersion || "unknown · no cap"}</Field>+ <Field label="Seen version" tone={seenSupported ? "normal" : "bad"}>+ {seenSupported ? (+ <select+ aria-label="Seen version"+ value={user?.whats_new_seen_version ?? ""}+ onChange={(e) => setSeen(e.target.value)}+ className="h-5 rounded-sm border border-border bg-background px-1 font-mono text-micro"+ >+ <option value="">none · count since signup</option>+ {WHATS_NEW_RELEASES.map((r) => (+ <option key={r.version} value={r.version}>+ {r.version}+ </option>+ ))}+ </select>+ ) : (+ "server cannot store it"+ )}+ </Field>+ <Field label="Signed up">{day(user?.created_at)}</Field>+ <Field label="Visible">{visible.map((r) => r.version).join(", ") || "—"}</Field>+ <Field label="Unread">{unread.map((r) => r.version).join(", ") || "—"}</Field>+ <Field label="Cards to deal">{String(cards)}</Field>+ <div className="px-3 pt-1 text-micro text-muted-foreground">+ Seen version changes stay on this client until the next reload. Show deck deals every card with hero art,+ read or not.+ </div>+ </Section>+ <Section title="Star card" actions={<SmallButton onClick={() => trigger("star")} disabled={!wsId}>Show star card</SmallButton>}>+ <Field label="Due" tone={starPromptDue(user, Date.now()) ? "normal" : "warn"}>+ {yesNo(starPromptDue(user, Date.now()))}+ </Field>+ <Field label="Showings">+ {user?.star_prompt_shown_count === undefined+ ? "server cannot count them"+ : `${user.star_prompt_shown_count}/${STAR_PROMPT_MAX_SHOWINGS} · last ${day(user.star_prompt_last_shown_at)}`}+ </Field>+ <Field label="Starred">{day(user?.star_prompt_starred_at)}</Field>+ <div className="px-3 pt-1 text-micro text-muted-foreground">+ Shows when an agent's issue moves to done. Show star card skips the server's showing count.+ </div>+ </Section>+ <Section+ title="Source survey"+ actions={+ <>+ <SmallButton onClick={() => user && resetSourceBackfillDismissCount(user.id)} disabled={dismissCount === 0}>+ Reset dismissals+ </SmallButton>+ <SmallButton onClick={() => trigger("survey")} disabled={!user || !wsId}>+ Open survey+ </SmallButton>+ </>+ }+ >+ <Field label="Owes an answer">{yesNo(needsSourceBackfill(user, dismissCount))}</Field>+ <Field label="Dismissals">{`${dismissCount}/${SOURCE_BACKFILL_MAX_DISMISSALS}`}</Field>+ <Field label="Open or deciding">{yesNo(session.surveyPending)}</Field>+ <div className="px-3 pt-1 text-micro text-muted-foreground">+ Submitting or skipping the survey saves your answer to the server.+ </div>+ </Section>+ </>+ );+}diff --git a/packages/views/onboarding/source-backfill-dismiss.ts b/packages/views/onboarding/source-backfill-dismiss.tsindex e805ec67fc..fdf614279d 100644--- a/packages/views/onboarding/source-backfill-dismiss.ts+++ b/packages/views/onboarding/source-backfill-dismiss.ts@@ -87,6 +87,16 @@ export function useSourceBackfillDismissCount(return [count, bump] as const;}+/** Forgets one user's dismissals, for the dev toolbar. */+export function resetSourceBackfillDismissCount(userId: string): void {+ try {+ window.localStorage.removeItem(storageKey(userId));+ } catch {+ // Same private-mode caveat as `bump`.+ }+ notify();+}+/** Test helper — not exported from the package index. */export function _resetSourceBackfillDismissCountForTests(): void {if (typeof window === "undefined") return;diff --git a/packages/views/onboarding/source-backfill-modal.test.tsx b/packages/views/onboarding/source-backfill-modal.test.tsxindex 945dc2a886..f479a5d213 100644--- a/packages/views/onboarding/source-backfill-modal.test.tsx+++ b/packages/views/onboarding/source-backfill-modal.test.tsx@@ -3,6 +3,7 @@ import userEvent from "@testing-library/user-event";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { I18nProvider } from "@multica/core/i18n/react";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import enCommon from "../locales/en/common.json";import enOnboarding from "../locales/en/onboarding.json";@@ -363,3 +364,50 @@ describe("SourceBackfillModal", () => {expect(mockListIssues).not.toHaveBeenCalled();});});++describe("SourceBackfillModal and the other prompts", () => {+ const pending = () => useSessionPromptStore.getState().surveyPending;+ const owesSurvey = {+ id: "u1",+ onboarded_at: "2026-01-01T00:00:00Z",+ onboarding_questionnaire: { source: [] },+ };++ beforeEach(() => {+ useSessionPromptStore.setState({ prompted: false, surveyPending: false });+ useDevPromptStore.setState({ request: null });+ });++ it("holds the others back while it decides and while it is open, then lets them go", async () => {+ let answer: (total: number) => void = () => {};+ mockListIssues.mockImplementation(+ () => new Promise((resolve) => (answer = (total) => resolve({ issues: [], total }))),+ );+ setUser(owesSurvey);+ renderModal();+ expect(pending()).toBe(true);++ await act(async () => answer(3));+ await screen.findByText(/How did you hear about Multica/i);+ expect(pending()).toBe(true);++ await userEvent.setup().click(screen.getByRole("button", { name: "Close" }));+ await waitFor(() => expect(pending()).toBe(false));+ });++ it("lets the others go when the workspace has not reached the threshold", async () => {+ mockAgentDoneTotal.value = 1;+ setUser(owesSurvey);+ renderModal();+ await waitFor(() => expect(mockListIssues).toHaveBeenCalled());+ await waitFor(() => expect(pending()).toBe(false));+ expect(screen.queryByText(/How did you hear about Multica/i)).not.toBeInTheDocument();+ });++ it("opens on demand from the dev toolbar, even for a user who already answered", async () => {+ setUser({ id: "u1", onboarded_at: "2026-01-01T00:00:00Z", onboarding_questionnaire: { source: ["search"] } });+ renderModal();+ act(() => useDevPromptStore.getState().trigger("survey"));+ expect(await screen.findByText(/How did you hear about Multica/i)).toBeInTheDocument();+ });+});diff --git a/packages/views/onboarding/source-backfill-modal.tsx b/packages/views/onboarding/source-backfill-modal.tsxindex 6640bd1a74..88748853ee 100644--- a/packages/views/onboarding/source-backfill-modal.tsx+++ b/packages/views/onboarding/source-backfill-modal.tsx@@ -23,7 +23,7 @@ import {type Source,} from "@multica/core/onboarding";import { useCurrentWorkspace } from "@multica/core/paths";-import { useSessionPromptStore } from "@multica/core/session-prompt";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import { Button } from "@multica/ui/components/ui/button";import {Dialog,@@ -75,13 +75,14 @@ export function SourceBackfillModal() {// owes an answer and we know which workspace to count in.const userEligible = needsSourceBackfill(user, dismissCount);const wsId = useCurrentWorkspace()?.id ?? null;- const { data: agentDoneCount } = useQuery({+ const { data: agentDoneCount, status: agentDoneStatus } = useQuery({...agentCompletedIssueCountOptions(wsId ?? ""),enabled: userEligible && wsId !== null,});const shouldPrompt =userEligible &&(agentDoneCount ?? 0) >= SOURCE_BACKFILL_MIN_AGENT_DONE_ISSUES;+ const deciding = userEligible && wsId !== null && agentDoneStatus === "pending";// Decide once per (user, gate delta) whether the prompt should// open. After it opens we stop reconsulting the predicate so a@@ -128,6 +129,24 @@ export function SourceBackfillModal() {if (open) useSessionPromptStore.getState().markPrompted();}, [open]);+ // Other prompts wait while the survey is open or about to be.+ useEffect(() => {+ const aboutToOpen = shouldPrompt && openedForUserRef.current !== userId;+ useSessionPromptStore.getState().setSurveyPending(open || deciding || aboutToOpen);+ }, [open, deciding, shouldPrompt, userId]);+ useEffect(() => () => useSessionPromptStore.getState().setSurveyPending(false), []);++ useEffect(() => {+ if (!userId) return;+ const answer = () => {+ if (!useDevPromptStore.getState().take("survey")) return;+ openedForUserRef.current = userId;+ setOpen(true);+ };+ answer();+ return useDevPromptStore.subscribe(answer);+ }, [userId]);+return (<Dialogopen={open}diff --git a/packages/views/star-prompt/star-prompt.test.tsx b/packages/views/star-prompt/star-prompt.test.tsxindex de83b43ad8..33a7b62bbe 100644--- a/packages/views/star-prompt/star-prompt.test.tsx+++ b/packages/views/star-prompt/star-prompt.test.tsx@@ -4,7 +4,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { setApiInstance, type ApiClient } from "@multica/core/api";import { I18nProvider } from "@multica/core/i18n/react";-import { useSessionPromptStore } from "@multica/core/session-prompt";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import {claimStarPromptShowing,markStarPromptStarred,@@ -117,7 +117,8 @@ beforeEach(() => {stores.auth.setState({ user: eligibleUser() });stores.chat.setState({ isOpen: false });useStarPromptStore.setState({ moment: null });- useSessionPromptStore.setState({ prompted: false });+ useSessionPromptStore.setState({ prompted: false, deckDealt: false, surveyPending: false, corner: null });+ useDevPromptStore.setState({ request: null });workspace.current = { id: "ws-1", slug: "acme" };});@@ -211,6 +212,34 @@ describe("StarPrompt", () => {expect(listIssues).not.toHaveBeenCalled();});+ it("holds the corner while it shows and gives it back on close", async () => {+ renderPrompt();+ await agentFinishesIssue();+ await screen.findByText("Lambda has completed 4 issues");+ expect(useSessionPromptStore.getState().corner).toBe("star");++ fireEvent.click(screen.getByRole("button", { name: "Not now" }));+ expect(useSessionPromptStore.getState().corner).toBeNull();+ });++ it("skips the moment while the What's new deck holds the corner", async () => {+ useSessionPromptStore.setState({ corner: "whats-new" });+ renderPrompt();+ await agentFinishesIssue();++ expect(listIssues).not.toHaveBeenCalled();+ expect(claimStarPromptShowing).not.toHaveBeenCalled();+ });++ it("shows on demand from the dev toolbar without spending a showing", async () => {+ useSessionPromptStore.setState({ prompted: true });+ renderPrompt();+ act(() => useDevPromptStore.getState().trigger("star"));++ expect(await screen.findByText("Dev agent has completed 3 issues")).toBeInTheDocument();+ expect(claimStarPromptShowing).not.toHaveBeenCalled();+ });+it("waits quietly while the workspace is still resolving", async () => {workspace.current = null;renderPrompt();@@ -294,7 +323,7 @@ describe("StarPrompt for a workspace that finishes work in custom done statuses"first.unmount();// A new app session: fresh module state and caches, same signed-in user.- useSessionPromptStore.setState({ prompted: false });+ useSessionPromptStore.setState({ prompted: false, deckDealt: false, surveyPending: false, corner: null });qc.clear();renderSession();await agentFinishesIssue();diff --git a/packages/views/star-prompt/star-prompt.tsx b/packages/views/star-prompt/star-prompt.tsxindex eb1d46e848..5466d7d878 100644--- a/packages/views/star-prompt/star-prompt.tsx+++ b/packages/views/star-prompt/star-prompt.tsx@@ -11,7 +11,7 @@ import { formatStarCount, githubStarsOptions, MULTICA_GITHUB_URL } from "@multicimport { createLogger } from "@multica/core/logger";import { needsSourceBackfill } from "@multica/core/onboarding";import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";-import { useSessionPromptStore } from "@multica/core/session-prompt";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import {agentDoneIssueCountOptions,claimStarPromptShowing,@@ -80,6 +80,8 @@ export function StarPrompt() {// The attribution survey owns this session's one interruption.if (needsSourceBackfill(user, readSourceBackfillDismissCount(user?.id))) return;if (!isQuietMoment()) return;+ // The What's new deck holds the corner; the next finished issue tries again.+ if (useSessionPromptStore.getState().corner !== null) return;const [doneCount, agents] = await Promise.all([qc.fetchQuery(agentDoneIssueCountOptions(workspaceId, m.agentId)),@@ -88,8 +90,9 @@ export function StarPrompt() {const agent = agents.find((a) => a.id === m.agentId);if (!agent || doneCount < STAR_PROMPT_MIN_AGENT_DONE_ISSUES) return;if (!mountedRef.current || !(await claimStarPromptShowing())) return;+ if (!mountedRef.current || !useSessionPromptStore.getState().claimCorner("star")) return;useSessionPromptStore.getState().markPrompted();- if (mountedRef.current) setShowing({ agentName: agent.name, doneCount });+ setShowing({ agentName: agent.name, doneCount });};const timer = window.setTimeout(() => {@@ -99,10 +102,26 @@ export function StarPrompt() {return () => window.clearTimeout(timer);}, [moment, wsId, qc]);+ useEffect(() => {+ if (!wsId) return;+ const answer = () => {+ if (!useDevPromptStore.getState().take("star")) return;+ useSessionPromptStore.getState().claimCorner("star");+ setShowing({ agentName: "Dev agent", doneCount: STAR_PROMPT_MIN_AGENT_DONE_ISSUES });+ };+ answer();+ return useDevPromptStore.subscribe(answer);+ }, [wsId]);++ useEffect(() => () => useSessionPromptStore.getState().releaseCorner("star"), []);+// The chat window covers this corner while it is open.if (!showing || chatOpen) return null;- const close = () => setShowing(null);+ const close = () => {+ setShowing(null);+ useSessionPromptStore.getState().releaseCorner("star");+ };const star = () => {close();markStarPromptStarred().catch((err) => logger.warn("failed to record star click", err));diff --git a/packages/views/whats-new/releases.test.ts b/packages/views/whats-new/releases.test.tsnew file mode 100644index 0000000000..c4a7f13e50--- /dev/null+++ b/packages/views/whats-new/releases.test.ts@@ -0,0 +1,13 @@+import { describe, expect, it } from "vitest";+import { compareVersions, parseVersion } from "@multica/core/whats-new";+import { WHATS_NEW_DECK_SINCE, WHATS_NEW_RELEASES } from "./releases";++describe("WHATS_NEW_RELEASES", () => {+ it("gives every release since the deck at least one highlight with hero art", () => {+ const since = parseVersion(WHATS_NEW_DECK_SINCE)!;+ const missing = WHATS_NEW_RELEASES.filter(+ (r) => compareVersions(parseVersion(r.version)!, since) >= 0 && !r.highlights.some((h) => h.hero),+ ).map((r) => r.version);+ expect(missing).toEqual([]);+ });+});diff --git a/packages/views/whats-new/releases.ts b/packages/views/whats-new/releases.tsindex cbf541da3e..aa0345785c 100644--- a/packages/views/whats-new/releases.ts+++ b/packages/views/whats-new/releases.ts@@ -30,12 +30,19 @@ export interface WhatsNewRelease extends ReleaseStamp {highlights: WhatsNewHighlight[];}+/** The first release dealt as a corner deck; see WHATS_NEW_RELEASES. */+export const WHATS_NEW_DECK_SINCE = "0.9.0";+/*** In-app highlights per release, newest first. Not the changelog: only* user-visible changes worth discovering, 0–3 per release, with copy that* says how to use the feature. Fix-only releases get no entry, so they are* never marked as new in the panel. Versions and dates must* match the changelog entry the highlights come from.+ *+ * From WHATS_NEW_DECK_SINCE on, every entry needs at least one highlight with+ * hero art: only those reach the corner deck, and an entry without one would+ * reach users only through the Help menu.*/export const WHATS_NEW_RELEASES: WhatsNewRelease[] = [{diff --git a/packages/views/whats-new/whats-new-deck.test.tsx b/packages/views/whats-new/whats-new-deck.test.tsxindex 1ece68b372..96d1c06f2c 100644--- a/packages/views/whats-new/whats-new-deck.test.tsx+++ b/packages/views/whats-new/whats-new-deck.test.tsx@@ -1,7 +1,7 @@import { act, fireEvent, render, screen, within } from "@testing-library/react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { I18nProvider } from "@multica/core/i18n/react";-import { useSessionPromptStore } from "@multica/core/session-prompt";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import type { User } from "@multica/core/types";import { Command, Globe, Terminal } from "@multica/ui/icons";import enCommon from "../locales/en/common.json";@@ -119,7 +119,8 @@ beforeEach(() => {vi.useFakeTimers({ shouldAdvanceTime: true });mocks.markWhatsNewSeen.mockResolvedValue(undefined);stores.chat.setState({ isOpen: false });- useSessionPromptStore.setState({ prompted: false });+ useSessionPromptStore.setState({ prompted: false, deckDealt: false, surveyPending: false, corner: null });+ useDevPromptStore.setState({ request: null });signIn();});@@ -140,7 +141,7 @@ describe("WhatsNewDeck", () => {expect(within(screen.getByRole("group", { name: "Palette title" })).getByText("v0.3.0 · Mar 1")).toBeInTheDocument();// 0.1.0 shipped before the account existed.expect(screen.getAllByRole("button", { name: /^Update \d of 3$/ })).toHaveLength(3);- expect(useSessionPromptStore.getState().prompted).toBe(true);+ expect(useSessionPromptStore.getState()).toMatchObject({ deckDealt: true, corner: "whats-new", prompted: false });});it("walks the deck with Next and marks the newest release seen on Got it", async () => {@@ -177,6 +178,7 @@ describe("WhatsNewDeck", () => {expect(mocks.markWhatsNewSeen).toHaveBeenCalledWith("0.3.0");await wait(300);expect(screen.queryByRole("region", { name: "What's new" })).not.toBeInTheDocument();+ expect(useSessionPromptStore.getState().corner).toBeNull();});it("follows a card's action and puts the deck away", async () => {@@ -211,7 +213,7 @@ describe("WhatsNewDeck", () => {renderDeck();await wait(WHATS_NEW_DECK_DELAY_MS);expect(title("Palette title")).not.toBeInTheDocument();- expect(useSessionPromptStore.getState().prompted).toBe(false);+ expect(useSessionPromptStore.getState().deckDealt).toBe(false);act(() => stores.chat.setState({ isOpen: false }));await wait(WHATS_NEW_DECK_RETRY_MS);@@ -229,19 +231,69 @@ describe("WhatsNewDeck", () => {expect(title("Runtimes title")).toBeInTheDocument();});- it("stays away once the session has had its interruption", async () => {+ it("deals even after another prompt has shown this session", async () => {useSessionPromptStore.setState({ prompted: true });renderDeck();+ await wait(WHATS_NEW_DECK_DELAY_MS);+ expect(title("Palette title")).toBeInTheDocument();+ });++ it("deals for a user who still owes the source survey", async () => {+ signIn({ onboarding_questionnaire: undefined });+ renderDeck();+ await wait(WHATS_NEW_DECK_DELAY_MS);+ expect(title("Palette title")).toBeInTheDocument();+ });++ it("deals only once per session", async () => {+ useSessionPromptStore.setState({ deckDealt: true });+ renderDeck();await wait(WHATS_NEW_DECK_DELAY_MS + WHATS_NEW_DECK_RETRY_MS);expect(title("Palette title")).not.toBeInTheDocument();});- it("leaves the session to the source survey when it is due", async () => {- signIn({ onboarding_questionnaire: undefined });+ it("waits for the source survey to open and close first", async () => {+ useSessionPromptStore.setState({ surveyPending: true });renderDeck();await wait(WHATS_NEW_DECK_DELAY_MS);expect(title("Palette title")).not.toBeInTheDocument();- expect(useSessionPromptStore.getState().prompted).toBe(false);++ act(() => useSessionPromptStore.setState({ surveyPending: false }));+ await wait(WHATS_NEW_DECK_RETRY_MS);+ expect(title("Palette title")).toBeInTheDocument();+ });++ it("waits for the star card to leave the corner", async () => {+ useSessionPromptStore.setState({ corner: "star" });+ renderDeck();+ await wait(WHATS_NEW_DECK_DELAY_MS);+ expect(title("Palette title")).not.toBeInTheDocument();++ act(() => useSessionPromptStore.setState({ corner: null }));+ await wait(WHATS_NEW_DECK_RETRY_MS);+ expect(title("Palette title")).toBeInTheDocument();+ expect(useSessionPromptStore.getState().corner).toBe("whats-new");+ });++ it("runs its check at once when the dev toolbar asks", async () => {+ renderDeck();+ act(() => useDevPromptStore.getState().trigger("whats-new-check"));+ await wait(0);+ expect(title("Palette title")).toBeInTheDocument();+ });++ it("shows every card with hero art on demand from the dev toolbar, read or not", async () => {+ signIn({ whats_new_seen_version: "0.3.0" });+ useSessionPromptStore.setState({ deckDealt: true });+ renderDeck();+ act(() => useDevPromptStore.getState().trigger("whats-new"));+ expect(title("Palette title")).toBeInTheDocument();+ expect(screen.getAllByTestId("hero-art")).toHaveLength(3);++ fireEvent.click(screen.getByRole("button", { name: "Close" }));+ await wait(300);+ expect(screen.queryByRole("region", { name: "What's new" })).not.toBeInTheDocument();+ expect(useSessionPromptStore.getState().corner).toBeNull();});it("leaves highlights without hero art to the What's new panel", async () => {@@ -258,7 +310,7 @@ describe("WhatsNewDeck", () => {renderDeck();await wait(WHATS_NEW_DECK_DELAY_MS);expect(screen.queryByRole("region", { name: "What's new" })).not.toBeInTheDocument();- expect(useSessionPromptStore.getState().prompted).toBe(false);+ expect(useSessionPromptStore.getState().deckDealt).toBe(false);} finally {RELEASES[0]!.highlights[0]!.hero = ART;RELEASES[0]!.highlights[1]!.hero = ART;@@ -270,7 +322,7 @@ describe("WhatsNewDeck", () => {renderDeck();await wait(WHATS_NEW_DECK_DELAY_MS);expect(screen.queryByRole("region", { name: "What's new" })).not.toBeInTheDocument();- expect(useSessionPromptStore.getState().prompted).toBe(false);+ expect(useSessionPromptStore.getState().deckDealt).toBe(false);});it("goes away when the release is marked seen elsewhere", async () => {@@ -280,5 +332,6 @@ describe("WhatsNewDeck", () => {act(() => signIn({ whats_new_seen_version: "0.3.0" }));expect(title("Palette title")).not.toBeInTheDocument();+ expect(useSessionPromptStore.getState().corner).toBeNull();});});diff --git a/packages/views/whats-new/whats-new-deck.tsx b/packages/views/whats-new/whats-new-deck.tsxindex c9ea9adeb8..58cac4c70c 100644--- a/packages/views/whats-new/whats-new-deck.tsx+++ b/packages/views/whats-new/whats-new-deck.tsx@@ -13,25 +13,22 @@ import {import { ArrowRight, X } from "@multica/ui/icons";import { Button } from "@multica/ui/components/ui/button";import { cn } from "@multica/ui/lib/utils";-import { useAuthStore } from "@multica/core/auth";import { useChatStore } from "@multica/core/chat";-import { needsSourceBackfill } from "@multica/core/onboarding";import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";-import { useSessionPromptStore } from "@multica/core/session-prompt";+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";import { isFloatingChatRouteSuppressed } from "../chat/floating-chat-visibility";import { isQuietMoment } from "../common/quiet-moment";import { useT } from "../i18n";import { useNavigation } from "../navigation";-import { readSourceBackfillDismissCount } from "../onboarding/source-backfill-dismiss";import { HighlightActionButton } from "./highlight-action";import { HeroFrame, type WhatsNewHero } from "./heroes";-import { highlightCopy, type WhatsNewHighlight, type WhatsNewRelease } from "./releases";+import { highlightCopy, WHATS_NEW_RELEASES, type WhatsNewHighlight, type WhatsNewRelease } from "./releases";import { useWhatsNew } from "./use-whats-new";import { formatReleaseDate, versionLabel } from "./whats-new-panel";-/** Long enough for the workspace to render and for the source survey (700ms) to claim the session first. */+/** Long enough for the workspace to render and for the source survey (700ms) to open first. */export const WHATS_NEW_DECK_DELAY_MS = 3000;-/** How often a busy moment (typing, a dialog, the chat window) is checked again. */+/** How often a busy moment (the survey, another card, typing, the chat window) is checked again. */export const WHATS_NEW_DECK_RETRY_MS = 5000;export const WHATS_NEW_DECK_MAX_CARDS = 5;@@ -45,23 +42,39 @@ interface DeckCard {}/** Only highlights with hero art are dealt; the rest stay in the What's new panel. */-function deckCards(unread: readonly WhatsNewRelease[]): DeckCard[] {- return unread+export function deckCards(releases: readonly WhatsNewRelease[]): DeckCard[] {+ return releases.flatMap((release) =>release.highlights.flatMap((highlight) => (highlight.hero ? [{ release, highlight, hero: highlight.hero }] : [])),).slice(0, WHATS_NEW_DECK_MAX_CARDS);}+/** What the deck is waiting on. `dealt` is final for the session; the rest pass. */+export type DeckBlocker = "dealt" | "survey" | "corner" | "chat" | "busy";++/** Why the deck would hold its cards back right now, or null when it would deal them. */+export function deckBlocker(): DeckBlocker | null {+ const session = useSessionPromptStore.getState();+ if (session.deckDealt) return "dealt";+ if (session.surveyPending) return "survey";+ if (session.corner !== null && session.corner !== "whats-new") return "corner";+ if (useChatStore.getState().isOpen) return "chat";+ if (!isQuietMoment()) return "busy";+ return null;+}+/**- * Unread release highlights as a deck of cards in the star prompt's corner.- * Opens once per app session when nothing else is happening; closing it marks- * the release seen, and the highlights stay in What's new in the Help menu.+ * Unread release highlights as a deck of cards in the bottom-right corner.+ * Deals once per app session, after the source survey and when nothing else+ * is happening. It only informs, so other prompts having shown does not keep+ * it away. Closing it marks the release seen; the highlights stay in What's+ * new in the Help menu.*/export function WhatsNewDeck() {// Shells mount this while the workspace slug is still resolving.const wsId = useCurrentWorkspace()?.id ?? null;- const { unread, markSeen } = useWhatsNew();+ const { visible, unread, markSeen } = useWhatsNew();const chatOpen = useChatStore((s) => s.isOpen);const floatingChatEnabled = useChatStore((s) => s.floatingChatEnabled);const { pathname } = useNavigation();@@ -69,44 +82,74 @@ export function WhatsNewDeck() {const launcherVisible =floatingChatEnabled && !chatOpen && !isFloatingChatRouteSuppressed(pathname, chatPath);const [cards, setCards] = useState<DeckCard[] | null>(null);+ // Dealt from the dev toolbar: shown whether or not anything is unread.+ const [forced, setForced] = useState(false);const [leaving, setLeaving] = useState(false);+ const [checkNow, setCheckNow] = useState(0);const hasUnread = unread.length > 0;const dealable = useMemo(() => deckCards(unread), [unread]);const dealableRef = useRef(dealable);dealableRef.current = dealable;+ const visibleRef = useRef(visible);+ visibleRef.current = visible;const hasDealable = dealable.length > 0;useEffect(() => {if (cards || !wsId || !hasDealable) return;let timer: number | undefined;const consider = () => {- if (useSessionPromptStore.getState().prompted) return;- const user = useAuthStore.getState().user;- // The attribution survey owns this session's one interruption.- if (needsSourceBackfill(user, readSourceBackfillDismissCount(user?.id))) return;- if (useChatStore.getState().isOpen || !isQuietMoment()) {+ const blocker = deckBlocker();+ if (blocker === "dealt") return;+ if (blocker || !useSessionPromptStore.getState().claimCorner("whats-new")) {timer = window.setTimeout(consider, WHATS_NEW_DECK_RETRY_MS);return;}- useSessionPromptStore.getState().markPrompted();+ useSessionPromptStore.getState().markDeckDealt();setCards(dealableRef.current);};- timer = window.setTimeout(consider, WHATS_NEW_DECK_DELAY_MS);+ timer = window.setTimeout(consider, checkNow > 0 ? 0 : WHATS_NEW_DECK_DELAY_MS);return () => window.clearTimeout(timer);- }, [cards, wsId, hasDealable]);+ }, [cards, wsId, hasDealable, checkNow]);++ useEffect(() => {+ if (!wsId) return;+ const answer = () => {+ const devPrompts = useDevPromptStore.getState();+ if (devPrompts.take("whats-new-check")) setCheckNow((n) => n + 1);+ if (devPrompts.take("whats-new")) {+ const fromVisible = deckCards(visibleRef.current);+ const preview = fromVisible.length > 0 ? fromVisible : deckCards(WHATS_NEW_RELEASES);+ if (preview.length === 0) return;+ useSessionPromptStore.getState().claimCorner("whats-new");+ useSessionPromptStore.getState().markDeckDealt();+ setLeaving(false);+ setForced(true);+ setCards(preview);+ }+ };+ answer();+ return useDevPromptStore.subscribe(answer);+ }, [wsId]);useEffect(() => {if (!leaving) return;const timer = window.setTimeout(() => {setCards(null);+ setForced(false);setLeaving(false);}, LEAVE_MS);return () => window.clearTimeout(timer);}, [leaving]);// Opening What's new from the Help menu also marks the release seen.- if (!cards || (!hasUnread && !leaving)) return null;+ const onScreen = cards !== null && (hasUnread || leaving || forced);+ useEffect(() => {+ if (!onScreen) useSessionPromptStore.getState().releaseCorner("whats-new");+ }, [onScreen]);+ useEffect(() => () => useSessionPromptStore.getState().releaseCorner("whats-new"), []);++ if (!cards || !onScreen) return null;const finish = () => {markSeen();@@ -115,6 +158,8 @@ export function WhatsNewDeck() {return (<Deck+ // A fresh deal from the dev toolbar starts again from the first card.+ key={cards.map((c) => `${c.release.version}:${c.highlight.id}`).join()}cards={cards}leaving={leaving}// The chat window covers this corner while it is open; the deck keeps its place behind it.