Skip to content

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

Go

MUL-9327: feat(dev-toolbar): replace the Prompts panel with a general Actions panel (#10667)

Jiayuan Zhang3947299f5bbd
diff --git a/packages/core/dev-actions/index.ts b/packages/core/dev-actions/index.ts
new file mode 100644
index 0000000000..9680c69aa0
--- /dev/null
+++ b/packages/core/dev-actions/index.ts
@@ -0,0 +1,47 @@
+"use client";
+
+import { create } from "zustand";
+import { createJSONStorage, persist } from "zustand/middleware";
+import { defaultStorage } from "../platform/storage";
+
+const MAX_RECENT = 8;
+
+interface DevActionsStore {
+ /** Commands pinned to the dev toolbar, in the order they were pinned. */
+ pinned: string[];
+ /** Commands most recently run, newest first. */
+ recent: string[];
+ /** The Actions panel section last open, so it reopens there. */
+ section: string | null;
+ togglePin: (command: string) => void;
+ recordRun: (command: string) => void;
+ setSection: (section: string) => void;
+}
+
+/**
+ * What the dev toolbar's Actions panel remembers on this client. Commands are
+ * opaque keys the toolbar builds from its action registry; a key whose action
+ * is gone is ignored by the reader, not cleaned up here.
+ */
+export const useDevActionsStore = create<DevActionsStore>()(
+ persist(
+ (set) => ({
+ pinned: [],
+ recent: [],
+ section: null,
+ togglePin: (command) =>
+ set((s) => ({
+ pinned: s.pinned.includes(command) ? s.pinned.filter((k) => k !== command) : [...s.pinned, command],
+ })),
+ recordRun: (command) =>
+ set((s) => ({ recent: [command, ...s.recent.filter((k) => k !== command)].slice(0, MAX_RECENT) })),
+ setSection: (section) => set({ section }),
+ }),
+ {
+ name: "multica_dev_actions",
+ storage: createJSONStorage(() => defaultStorage),
+ partialize: ({ pinned, recent, section }) => ({ pinned, recent, section }),
+ version: 1,
+ },
+ ),
+);
diff --git a/packages/core/package.json b/packages/core/package.json
index ca18cc270d..25fc1219d6 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -193,6 +193,7 @@
"./voice": "./voice/index.ts",
"./analytics": "./analytics/index.ts",
"./diagnostics": "./diagnostics/index.ts",
+ "./dev-actions": "./dev-actions/index.ts",
"./client-usage": "./client-usage/index.ts",
"./i18n": "./i18n/index.ts",
"./i18n/react": "./i18n/react.ts",
diff --git a/packages/views/dev-toolbar/actions-panel.test.tsx b/packages/views/dev-toolbar/actions-panel.test.tsx
new file mode 100644
index 0000000000..6df9cfb550
--- /dev/null
+++ b/packages/views/dev-toolbar/actions-panel.test.tsx
@@ -0,0 +1,169 @@
+import type { ReactNode } from "react";
+import { act, fireEvent, render, screen, within } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import { useDevActionsStore } from "@multica/core/dev-actions";
+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";
+import { configureShortcutPlatform } from "@multica/core/shortcuts";
+import type { User } from "@multica/core/types";
+import { ActionsPanel, DevActions } from "./actions-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,
+ },
+ });
+}
+
+function wrap(node: ReactNode) {
+ return render(<QueryClientProvider client={new QueryClient()}>{node}</QueryClientProvider>);
+}
+
+const feature = (title: string) => within(screen.getByRole("region", { name: title }));
+const row = (title: string, label: string) => feature(title).getByText(label).nextElementSibling;
+const status = (title: string) => feature(title).getByText(title).nextElementSibling;
+const search = () => screen.getByRole("textbox", { name: "Search actions" });
+
+beforeEach(() => {
+ useSessionPromptStore.setState({ prompted: false, deckDealt: false, surveyPending: false, corner: null });
+ useDevPromptStore.setState({ request: null });
+ useDevActionsStore.setState({ pinned: [], recent: [], section: null });
+ stores.chat.setState({ isOpen: false });
+ signIn();
+});
+
+afterEach(() => configureShortcutPlatform(null));
+
+describe("ActionsPanel", () => {
+ it("opens on the Prompts group and says why the deck has nothing to deal", () => {
+ wrap(<ActionsPanel wsId="ws-1" onClose={vi.fn()} />);
+ expect(screen.getByRole("button", { name: /Prompts/ })).toHaveAttribute("aria-current", "true");
+ act(() => search().blur());
+
+ expect(status("What's new deck")).toHaveTextContent("nothing unread");
+ fireEvent.change(screen.getByRole("combobox", { name: "Set seen version" }), { target: { value: "0.8.2" } });
+ expect(stores.auth.getState().user?.whats_new_seen_version).toBe("0.8.2");
+ expect(row("What's new deck", "Unread")).toHaveTextContent("0.9.0");
+ expect(row("What's new deck", "Cards to deal")).toHaveTextContent("3");
+ expect(status("What's new deck")).toHaveTextContent("deals at the next check");
+
+ act(() => useSessionPromptStore.setState({ surveyPending: true }));
+ expect(status("What's new deck")).toHaveTextContent("waiting · source survey open or deciding");
+ act(() => {
+ useSessionPromptStore.setState({ surveyPending: false });
+ stores.chat.setState({ isOpen: true });
+ });
+ expect(status("What's new deck")).toHaveTextContent("waiting · chat window open");
+ });
+
+ it("asks each prompt to show itself, and remembers what ran", () => {
+ wrap(<ActionsPanel wsId="ws-1" onClose={vi.fn()} />);
+ for (const [title, 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: `Run ${title}` }));
+ expect(useDevPromptStore.getState().request?.kind).toBe(kind);
+ }
+ expect(useDevActionsStore.getState().recent).toEqual([
+ "source-survey/open",
+ "star-card/show",
+ "whats-new-deck/check",
+ "whats-new-deck/show",
+ ]);
+
+ fireEvent.click(screen.getByRole("button", { name: /Recent/ }));
+ expect(screen.getByRole("button", { name: "Run Open survey" })).toBeInTheDocument();
+ expect(screen.queryByRole("region", { name: "What's new deck" })).not.toBeInTheDocument();
+ });
+
+ it("starts the prompt session over", () => {
+ useSessionPromptStore.setState({ prompted: true, deckDealt: true, corner: "star" });
+ wrap(<ActionsPanel wsId="ws-1" onClose={vi.fn()} />);
+ expect(status("Prompt session")).toHaveTextContent("star holds the corner");
+ fireEvent.click(screen.getByRole("button", { name: "Run Reset session" }));
+ expect(useSessionPromptStore.getState()).toMatchObject({ prompted: false, deckDealt: false, corner: "star" });
+ });
+
+ it("disables workspace actions outside a workspace and says why", () => {
+ wrap(<ActionsPanel wsId={null} onClose={vi.fn()} />);
+ expect(screen.getByRole("button", { name: "Run Show deck" })).toBeDisabled();
+ expect(screen.getByRole("button", { name: "Run Open survey" })).toBeDisabled();
+ expect(feature("Star card").getByText("needs a workspace")).toBeInTheDocument();
+ expect(status("What's new deck")).toHaveTextContent("no workspace open");
+ });
+
+ it("searches every group, and runs the highlighted match on Enter", () => {
+ const onClose = vi.fn();
+ wrap(<ActionsPanel wsId="ws-1" onClose={onClose} />);
+ fireEvent.change(search(), { target: { value: "seen 0.8.2" } });
+ const results = within(screen.getByLabelText("Matching actions"));
+ expect(results.getAllByRole("button", { name: /^Run / }).map((b) => b.getAttribute("aria-label"))).toEqual([
+ "Run Set seen version → 0.8.2",
+ ]);
+ fireEvent.keyDown(search(), { key: "Enter" });
+ expect(stores.auth.getState().user?.whats_new_seen_version).toBe("0.8.2");
+ expect(onClose).toHaveBeenCalled();
+ expect(useDevActionsStore.getState().recent).toEqual(["whats-new-deck/seen-version=0.8.2"]);
+ });
+
+ it("moves the highlight with the arrow keys", () => {
+ wrap(<ActionsPanel wsId="ws-1" onClose={vi.fn()} />);
+ fireEvent.change(search(), { target: { value: "show" } });
+ fireEvent.keyDown(search(), { key: "ArrowDown" });
+ fireEvent.keyDown(search(), { key: "Enter" });
+ expect(useDevPromptStore.getState().request?.kind).toBe("star");
+ });
+
+ it("lists another group's features", () => {
+ wrap(<ActionsPanel wsId="ws-1" onClose={vi.fn()} />);
+ fireEvent.click(screen.getByRole("button", { name: /Errors/ }));
+ expect(screen.getByRole("region", { name: "Error capture" })).toBeInTheDocument();
+ expect(useDevActionsStore.getState().section).toBe("Errors");
+ });
+});
+
+describe("DevActions", () => {
+ it("puts pinned actions on the toolbar", () => {
+ wrap(<DevActions wsId="ws-1" />);
+ fireEvent.click(screen.getByTestId("dev-toolbar-actions"));
+ fireEvent.click(screen.getByRole("button", { name: "Pin Show star card" }));
+ expect(useDevActionsStore.getState().pinned).toEqual(["star-card/show"]);
+
+ fireEvent.click(screen.getByRole("button", { name: "Show star card" }));
+ expect(useDevPromptStore.getState().request?.kind).toBe("star");
+ });
+
+ it("toggles the panel with the shortcut", () => {
+ configureShortcutPlatform("macos");
+ wrap(<DevActions wsId="ws-1" />);
+ expect(screen.queryByRole("textbox", { name: "Search actions" })).not.toBeInTheDocument();
+ fireEvent.keyDown(window, { key: "k", code: "KeyK", metaKey: true, shiftKey: true });
+ expect(search()).toBeInTheDocument();
+ });
+});
diff --git a/packages/views/dev-toolbar/actions-panel.tsx b/packages/views/dev-toolbar/actions-panel.tsx
new file mode 100644
index 0000000000..601e781aa9
--- /dev/null
+++ b/packages/views/dev-toolbar/actions-panel.tsx
@@ -0,0 +1,427 @@
+"use client";
+
+import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
+import { useQueryClient } from "@tanstack/react-query";
+import { toast } from "sonner";
+import { useAuthStore } from "@multica/core/auth";
+import { useDevActionsStore } from "@multica/core/dev-actions";
+import { createShortcutChord, formatShortcut, shortcutMatchesEvent } from "@multica/core/shortcuts";
+import { Popover, PopoverContent, PopoverTrigger } from "@multica/ui/components/ui/popover";
+import { History, Pin, Play, Search, Zap } from "@multica/ui/icons";
+import { cn } from "@multica/ui/lib/utils";
+import {
+ blockedReason,
+ commandTitle,
+ searchCommands,
+ type DevAction,
+ type DevActionContext,
+ type DevCommand,
+ type DevFeature,
+ type DevFeatureState,
+} from "./actions";
+import { TONE_CLASS } from "./panels";
+import { DEV_COMMANDS, DEV_FEATURES, DEV_GROUPS } from "./registry";
+
+const OPEN_SHORTCUT = createShortcutChord("K", { primary: true, shift: true });
+const ACTION_COUNT = DEV_FEATURES.reduce((n, f) => n + f.actions.length, 0);
+const PINNED = "Pinned";
+const RECENT = "Recent";
+
+const COMMAND_BY_KEY = new Map(DEV_COMMANDS.map((c) => [c.key, c]));
+const commandsFor = (keys: readonly string[]) => keys.flatMap((key) => COMMAND_BY_KEY.get(key) ?? []);
+
+function useDevActionContext(wsId: string | null): DevActionContext {
+ const user = useAuthStore((s) => s.user);
+ const queryClient = useQueryClient();
+ return { wsId, user, queryClient };
+}
+
+function runCommand(command: DevCommand, ctx: DevActionContext) {
+ if (blockedReason(command.action, ctx)) return;
+ try {
+ command.action.run(ctx, command.choice?.value);
+ } catch (error) {
+ console.error(error);
+ toast.error(`${commandTitle(command)} failed`, {
+ description: error instanceof Error ? error.message : String(error),
+ });
+ return;
+ }
+ useDevActionsStore.getState().recordRun(command.key);
+}
+
+function RunButton({ title, disabled, onClick }: { title: string; disabled: boolean; onClick: () => void }) {
+ return (
+ <button
+ type="button"
+ aria-label={`Run ${title}`}
+ onClick={onClick}
+ disabled={disabled}
+ className="flex h-6 shrink-0 items-center rounded-md border border-border px-2 text-micro text-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-50"
+ >
+ Run
+ </button>
+ );
+}
+
+function PinButton({ command }: { command: DevCommand }) {
+ const pinned = useDevActionsStore((s) => s.pinned.includes(command.key));
+ const title = commandTitle(command);
+ return (
+ <button
+ type="button"
+ aria-label={pinned ? `Unpin ${title}` : `Pin ${title}`}
+ aria-pressed={pinned}
+ title={pinned ? "Unpin from the toolbar" : "Pin to the toolbar"}
+ onClick={() => useDevActionsStore.getState().togglePin(command.key)}
+ className={cn(
+ "flex size-6 shrink-0 items-center justify-center rounded-md hover:bg-accent",
+ pinned ? "text-brand" : "text-faint-foreground hover:text-foreground",
+ )}
+ >
+ <Pin className="size-3" />
+ </button>
+ );
+}
+
+function ActionText({ action, title, crumb, blocked }: { action: DevAction; title: string; crumb?: string; blocked: string | null }) {
+ return (
+ <div className="flex min-w-0 flex-1 items-baseline gap-2">
+ <span className="shrink-0 text-foreground">{title}</span>
+ {crumb && <span className="shrink-0 text-micro text-muted-foreground">{crumb}</span>}
+ <span
+ className={cn("min-w-0 truncate text-micro", blocked || action.caution ? "text-warning" : "text-muted-foreground")}
+ title={blocked ?? action.caution ?? action.description}
+ >
+ {blocked ?? action.caution ?? action.description}
+ </span>
+ </div>
+ );
+}
+
+function CommandRow({
+ command,
+ ctx,
+ crumb,
+ highlighted,
+ onHover,
+ onRun,
+}: {
+ command: DevCommand;
+ ctx: DevActionContext;
+ crumb?: boolean;
+ highlighted?: boolean;
+ onHover?: () => void;
+ onRun: () => void;
+}) {
+ const blocked = blockedReason(command.action, ctx);
+ const title = commandTitle(command);
+ return (
+ <div
+ data-highlighted={highlighted || undefined}
+ onMouseMove={onHover}
+ className="group flex items-center gap-2 px-3 py-1 hover:bg-accent/50 data-[highlighted]:bg-accent"
+ >
+ <Play className="size-3 shrink-0 text-muted-foreground" />
+ <ActionText action={command.action} title={title} crumb={crumb ? command.feature.title : undefined} blocked={blocked} />
+ <PinButton command={command} />
+ <RunButton title={title} disabled={blocked !== null} onClick={onRun} />
+ </div>
+ );
+}
+
+/** An action that runs with a value: picking one runs it. */
+function ChoiceRow({ action, commands, ctx }: { action: DevAction; commands: DevCommand[]; ctx: DevActionContext }) {
+ const blocked = blockedReason(action, ctx);
+ return (
+ <div className="flex items-center gap-2 px-3 py-1 hover:bg-accent/50">
+ <Play className="size-3 shrink-0 text-muted-foreground" />
+ <ActionText action={action} title={action.title} blocked={blocked} />
+ <select
+ aria-label={action.title}
+ value=""
+ disabled={blocked !== null}
+ onChange={(e) => {
+ const command = commands.find((c) => c.choice?.value === e.target.value);
+ if (command) runCommand(command, ctx);
+ }}
+ className="h-6 shrink-0 rounded-md border border-border bg-background px-1 font-mono text-micro disabled:opacity-50"
+ >
+ <option value="" disabled>
+ Run with…
+ </option>
+ {commands.map((c) => (
+ <option key={c.key} value={c.choice!.value}>
+ {c.choice!.label}
+ </option>
+ ))}
+ </select>
+ </div>
+ );
+}
+
+function FeatureBlock({ feature, ctx }: { feature: DevFeature; ctx: DevActionContext }) {
+ const state = (feature.useDevState ?? noState)(ctx);
+ return (
+ <section aria-label={feature.title} className="border-b border-border py-2 last:border-b-0">
+ <div className="flex items-center gap-2 px-3 pb-1">
+ <span className="font-medium text-foreground">{feature.title}</span>
+ {state.status && (
+ <span className={cn("ml-auto min-w-0 truncate font-mono text-micro", TONE_CLASS[state.status.tone ?? "normal"])}>
+ {state.status.text}
+ </span>
+ )}
+ </div>
+ {state.rows && state.rows.length > 0 && (
+ <div className="mx-3 mb-1 rounded-md bg-muted/50 px-2 py-1">
+ {state.rows.map((row) => (
+ <div key={row.label} className="flex min-h-5 items-center gap-3">
+ <span className="w-28 shrink-0 text-muted-foreground">{row.label}</span>
+ <span className={cn("min-w-0 flex-1 truncate font-mono tabular-nums", TONE_CLASS[row.tone ?? "normal"])}>
+ {row.value}
+ </span>
+ </div>
+ ))}
+ </div>
+ )}
+ {state.note && <div className="px-3 pb-1 text-micro text-muted-foreground">{state.note}</div>}
+ {feature.actions.map((action) => {
+ const commands = DEV_COMMANDS.filter((c) => c.feature === feature && c.action === action);
+ return action.choices ? (
+ <ChoiceRow key={action.id} action={action} commands={commands} ctx={ctx} />
+ ) : (
+ <CommandRow key={action.id} command={commands[0]!} ctx={ctx} onRun={() => runCommand(commands[0]!, ctx)} />
+ );
+ })}
+ </section>
+ );
+}
+
+const noState = (): DevFeatureState => ({});
+
+function NavItem({ label, count, icon, active, onClick }: { label: string; count: number; icon?: ReactNode; active: boolean; onClick: () => void }) {
+ return (
+ <button
+ type="button"
+ aria-current={active || undefined}
+ onClick={onClick}
+ className={cn(
+ "flex h-7 w-full items-center gap-2 rounded-md px-2 text-left hover:bg-accent hover:text-foreground",
+ active ? "bg-accent text-foreground" : "text-muted-foreground",
+ )}
+ >
+ {icon}
+ <span className="min-w-0 flex-1 truncate">{label}</span>
+ <span className="font-mono text-micro tabular-nums text-muted-foreground">{count}</span>
+ </button>
+ );
+}
+
+function Empty({ children }: { children: ReactNode }) {
+ return <div className="px-3 py-8 text-center text-muted-foreground">{children}</div>;
+}
+
+function SearchResults({
+ query,
+ results,
+ active,
+ ctx,
+ onHighlight,
+ onRun,
+}: {
+ query: string;
+ results: DevCommand[];
+ active: number;
+ ctx: DevActionContext;
+ onHighlight: (index: number) => void;
+ onRun: (command: DevCommand) => void;
+}) {
+ const listRef = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ listRef.current?.querySelector("[data-highlighted]")?.scrollIntoView?.({ block: "nearest" });
+ }, [active]);
+
+ if (results.length === 0) return <Empty>{`No action matches “${query}”.`}</Empty>;
+ return (
+ <div ref={listRef} aria-label="Matching actions" className="min-h-0 flex-1 overflow-y-auto py-1">
+ {results.map((command, i) => (
+ <CommandRow
+ key={command.key}
+ command={command}
+ ctx={ctx}
+ crumb
+ highlighted={i === active}
+ onHover={() => onHighlight(i)}
+ onRun={() => onRun(command)}
+ />
+ ))}
+ </div>
+ );
+}
+
+/**
+ * Every feature's dev actions, grouped, with the state that decides what they
+ * do. Typing searches them all; Enter runs the highlighted one and closes.
+ */
+export function ActionsPanel({ wsId, onClose }: { wsId: string | null; onClose: () => void }) {
+ const ctx = useDevActionContext(wsId);
+ const [query, setQuery] = useState("");
+ const [highlight, setHighlight] = useState(0);
+ const results = searchCommands(DEV_COMMANDS, query);
+ const active = Math.min(highlight, Math.max(0, results.length - 1));
+ const runAndClose = (command: DevCommand) => {
+ runCommand(command, ctx);
+ onClose();
+ };
+ const onSearchKey = (e: ReactKeyboardEvent) => {
+ if (results.length === 0) return;
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
+ e.preventDefault();
+ setHighlight(Math.min(Math.max(0, active + (e.key === "ArrowDown" ? 1 : -1)), results.length - 1));
+ } else if (e.key === "Enter" && !blockedReason(results[active]!.action, ctx)) {
+ e.preventDefault();
+ runAndClose(results[active]!);
+ }
+ };
+ const pinned = commandsFor(useDevActionsStore((s) => s.pinned));
+ const recent = commandsFor(useDevActionsStore((s) => s.recent));
+ const stored = useDevActionsStore((s) => s.section);
+ const section = stored === PINNED || stored === RECENT || DEV_GROUPS.includes(stored ?? "") ? stored! : DEV_GROUPS[0]!;
+ const setSection = useDevActionsStore((s) => s.setSection);
+
+ const list = (commands: DevCommand[], empty: string) =>
+ commands.length === 0 ? (
+ <Empty>{empty}</Empty>
+ ) : (
+ <div className="py-1">
+ {commands.map((command) => (
+ <CommandRow key={command.key} command={command} ctx={ctx} crumb onRun={() => runCommand(command, ctx)} />
+ ))}
+ </div>
+ );
+
+ return (
+ <div className="flex min-h-0 flex-1 flex-col">
+ <div className="flex h-10 shrink-0 items-center gap-2 border-b border-border px-3">
+ <Search className="size-3.5 shrink-0 text-muted-foreground" />
+ <input
+ autoFocus
+ aria-label="Search actions"
+ placeholder={`Search ${ACTION_COUNT} actions…`}
+ value={query}
+ onChange={(e) => {
+ setQuery(e.target.value);
+ setHighlight(0);
+ }}
+ onKeyDown={onSearchKey}
+ className="min-w-0 flex-1 bg-transparent text-body text-foreground outline-none placeholder:text-muted-foreground"
+ />
+ <kbd className="shrink-0 font-mono text-micro text-muted-foreground">{formatShortcut(OPEN_SHORTCUT)}</kbd>
+ </div>
+ {query.trim() ? (
+ <SearchResults
+ query={query}
+ results={results}
+ active={active}
+ ctx={ctx}
+ onHighlight={setHighlight}
+ onRun={runAndClose}
+ />
+ ) : (
+ <div className="flex min-h-0 flex-1">
+ <nav aria-label="Action groups" className="flex w-44 shrink-0 flex-col gap-0.5 overflow-y-auto border-r border-border p-1.5">
+ <NavItem
+ label={PINNED}
+ count={pinned.length}
+ icon={<Pin className="size-3" />}
+ active={section === PINNED}
+ onClick={() => setSection(PINNED)}
+ />
+ <NavItem
+ label={RECENT}
+ count={recent.length}
+ icon={<History className="size-3" />}
+ active={section === RECENT}
+ onClick={() => setSection(RECENT)}
+ />
+ <div className="my-1 border-t border-border" />
+ {DEV_GROUPS.map((group) => (
+ <NavItem
+ key={group}
+ label={group}
+ count={DEV_FEATURES.filter((f) => f.group === group).reduce((n, f) => n + f.actions.length, 0)}
+ active={section === group}
+ onClick={() => setSection(group)}
+ />
+ ))}
+ </nav>
+ <div className="min-w-0 flex-1 overflow-y-auto">
+ {section === PINNED
+ ? list(pinned, "Pin an action to keep it here and on the toolbar.")
+ : section === RECENT
+ ? list(recent, "Actions you run show up here.")
+ : DEV_FEATURES.filter((f) => f.group === section).map((feature) => (
+ <FeatureBlock key={feature.id} feature={feature} ctx={ctx} />
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ );
+}
+
+/**
+ * The toolbar's Actions entry: pinned actions as one-click chips, then the
+ * button that opens the panel, which ⌘⇧K (Ctrl+Shift+K) also toggles from
+ * anywhere in the app.
+ */
+export function DevActions({ wsId }: { wsId: string | null }) {
+ const [open, setOpen] = useState(false);
+ const ctx = useDevActionContext(wsId);
+ const pinned = commandsFor(useDevActionsStore((s) => s.pinned));
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (!shortcutMatchesEvent(OPEN_SHORTCUT, e)) return;
+ e.preventDefault();
+ setOpen((o) => !o);
+ };
+ window.addEventListener("keydown", onKey, true);
+ return () => window.removeEventListener("keydown", onKey, true);
+ }, []);
+
+ return (
+ <>
+ {pinned.map((command) => {
+ const blocked = blockedReason(command.action, ctx);
+ return (
+ <button
+ key={command.key}
+ type="button"
+ disabled={blocked !== null}
+ title={blocked ?? `${command.feature.title} · ${command.action.description ?? commandTitle(command)}`}
+ onClick={() => runCommand(command, ctx)}
+ className="flex h-5 items-center gap-1 whitespace-nowrap rounded-md px-1 hover:bg-accent hover:text-foreground disabled:opacity-50"
+ >
+ <Play className="size-2.5 text-brand" />
+ {commandTitle(command)}
+ </button>
+ );
+ })}
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger
+ data-testid="dev-toolbar-actions"
+ className="flex h-5 items-center gap-1 whitespace-nowrap rounded-md px-1 hover:bg-accent hover:text-foreground data-[popup-open]:bg-accent data-[popup-open]:text-foreground"
+ >
+ <Zap className="size-3" />
+ <span>Actions</span>
+ <span className="tabular-nums text-foreground">{ACTION_COUNT}</span>
+ </PopoverTrigger>
+ <PopoverContent side="top" align="end" sideOffset={6} className="h-[520px] w-[720px] gap-0 overflow-hidden p-0 text-caption">
+ <ActionsPanel wsId={wsId} onClose={() => setOpen(false)} />
+ </PopoverContent>
+ </Popover>
+ </>
+ );
+}
diff --git a/packages/views/dev-toolbar/actions.test.ts b/packages/views/dev-toolbar/actions.test.ts
new file mode 100644
index 0000000000..f7baca0a85
--- /dev/null
+++ b/packages/views/dev-toolbar/actions.test.ts
@@ -0,0 +1,73 @@
+import { QueryClient } from "@tanstack/react-query";
+import { describe, expect, it } from "vitest";
+import { blockedReason, commandTitle, devCommands, searchCommands, type DevFeature } from "./actions";
+import { DEV_COMMANDS, DEV_FEATURES } from "./registry";
+
+const noop = () => {};
+const features: DevFeature[] = [
+ {
+ id: "deck",
+ group: "Prompts",
+ title: "What's new deck",
+ actions: [
+ { id: "show", title: "Show deck", run: noop },
+ {
+ id: "seen",
+ title: "Set seen version",
+ choices: [
+ { value: "", label: "none" },
+ { value: "0.9.0", label: "0.9.0" },
+ ],
+ run: noop,
+ },
+ ],
+ },
+ { id: "errors", group: "Errors", title: "Error capture", actions: [{ id: "log", title: "Log a deck error", run: noop }] },
+];
+
+describe("devCommands", () => {
+ it("makes each choice a command of its own", () => {
+ expect(devCommands(features).map((c) => [c.key, commandTitle(c)])).toEqual([
+ ["deck/show", "Show deck"],
+ ["deck/seen=", "Set seen version → none"],
+ ["deck/seen=0.9.0", "Set seen version → 0.9.0"],
+ ["errors/log", "Log a deck error"],
+ ]);
+ });
+});
+
+describe("searchCommands", () => {
+ const commands = devCommands(features);
+ const keys = (query: string) => searchCommands(commands, query).map((c) => c.key);
+
+ it("needs every word, anywhere in the command", () => {
+ expect(keys("seen 0.9")).toEqual(["deck/seen=0.9.0"]);
+ expect(keys("errors")).toEqual(["errors/log"]);
+ expect(keys("prompts show")).toEqual(["deck/show"]);
+ expect(keys("nothing like this")).toEqual([]);
+ expect(keys(" ")).toEqual([]);
+ });
+
+ it("puts titles that start with the query first", () => {
+ expect(keys("deck")).toEqual(["deck/show", "errors/log", "deck/seen=", "deck/seen=0.9.0"]);
+ expect(keys("log")).toEqual(["errors/log"]);
+ });
+});
+
+describe("blockedReason", () => {
+ const ctx = { wsId: null, user: null, queryClient: new QueryClient() };
+ it("says what an action still needs", () => {
+ expect(blockedReason({ id: "a", title: "A", needs: "workspace", run: noop }, ctx)).toBe("needs a workspace");
+ expect(blockedReason({ id: "a", title: "A", needs: "user", run: noop }, ctx)).toBe("needs a signed-in user");
+ expect(blockedReason({ id: "a", title: "A", run: noop }, ctx)).toBeNull();
+ });
+});
+
+describe("registry", () => {
+ it("gives every feature and command its own key", () => {
+ const featureIds = DEV_FEATURES.map((f) => f.id);
+ expect(new Set(featureIds).size).toBe(featureIds.length);
+ const keys = DEV_COMMANDS.map((c) => c.key);
+ expect(new Set(keys).size).toBe(keys.length);
+ });
+});
diff --git a/packages/views/dev-toolbar/actions.ts b/packages/views/dev-toolbar/actions.ts
new file mode 100644
index 0000000000..750e9d3fb3
--- /dev/null
+++ b/packages/views/dev-toolbar/actions.ts
@@ -0,0 +1,100 @@
+import type { QueryClient } from "@tanstack/react-query";
+import type { User } from "@multica/core/types";
+import type { MetricTone } from "./metrics";
+
+/** What an action can read and act on when it runs. */
+export interface DevActionContext {
+ wsId: string | null;
+ user: User | null;
+ queryClient: QueryClient;
+}
+
+export interface DevActionChoice {
+ value: string;
+ label: string;
+}
+
+export interface DevAction {
+ id: string;
+ title: string;
+ description?: string;
+ /** Runs only with a workspace open, or only signed in. */
+ needs?: "workspace" | "user";
+ /** Shown as a warning, for actions that touch real data. */
+ caution?: string;
+ /** Values the action runs with; each one is a command of its own. */
+ choices?: readonly DevActionChoice[];
+ run: (ctx: DevActionContext, choice?: string) => void;
+}
+
+export interface DevFeatureState {
+ status?: { text: string; tone?: MetricTone };
+ rows?: readonly { label: string; value: string; tone?: MetricTone }[];
+ note?: string;
+}
+
+/**
+ * A feature's dev actions, declared next to the feature's own code. The
+ * toolbar lists every feature in `registry.ts` and imports nothing else from
+ * it, so production bundles, which never load the toolbar, leave these out.
+ */
+export interface DevFeature {
+ id: string;
+ /** Section of the Actions panel, shared by related features. */
+ group: string;
+ title: string;
+ /** Live state, read with hooks; the panel calls it on every render of the feature. */
+ useDevState?: (ctx: DevActionContext) => DevFeatureState;
+ actions: readonly DevAction[];
+}
+
+/** One runnable thing: an action, or one of its choices. */
+export interface DevCommand {
+ key: string;
+ feature: DevFeature;
+ action: DevAction;
+ choice?: DevActionChoice;
+}
+
+export function devCommands(features: readonly DevFeature[]): DevCommand[] {
+ return features.flatMap((feature) =>
+ feature.actions.flatMap((action) => {
+ const key = `${feature.id}/${action.id}`;
+ if (!action.choices) return [{ key, feature, action }];
+ return action.choices.map((choice) => ({ key: `${key}=${choice.value}`, feature, action, choice }));
+ }),
+ );
+}
+
+export const commandTitle = (command: DevCommand) =>
+ command.choice ? `${command.action.title} → ${command.choice.label}` : command.action.title;
+
+export function blockedReason(action: DevAction, ctx: DevActionContext): string | null {
+ if (action.needs === "workspace" && !ctx.wsId) return "needs a workspace";
+ if (action.needs === "user" && !ctx.user) return "needs a signed-in user";
+ return null;
+}
+
+/**
+ * Commands whose words contain every word of `query`, those whose title
+ * starts with it first. Words match anywhere in the group, feature, title,
+ * choice or description.
+ */
+export function searchCommands(commands: readonly DevCommand[], query: string): DevCommand[] {
+ const words = query.toLowerCase().split(/\s+/).filter(Boolean);
+ if (words.length === 0) return [];
+ const q = words.join(" ");
+ return commands
+ .map((command, index) => {
+ const title = commandTitle(command).toLowerCase();
+ const haystack = [command.feature.group, command.feature.title, title, command.action.description ?? ""]
+ .join(" ")
+ .toLowerCase();
+ if (!words.every((word) => haystack.includes(word))) return null;
+ const rank = title.startsWith(q) ? 0 : title.includes(q) ? 1 : 2;
+ return { command, rank, index };
+ })
+ .filter((hit) => hit !== null)
+ .sort((a, b) => a.rank - b.rank || a.index - b.index)
+ .map((hit) => hit.command);
+}
diff --git a/packages/views/dev-toolbar/dev-toolbar.tsx b/packages/views/dev-toolbar/dev-toolbar.tsx
index 84ab200e3e..4f9d6f6f04 100644
--- a/packages/views/dev-toolbar/dev-toolbar.tsx
+++ b/packages/views/dev-toolbar/dev-toolbar.tsx
@@ -11,7 +11,6 @@ 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";
@@ -28,6 +27,7 @@ import {
requestFailed,
type MetricTone,
} from "./metrics";
+import { DevActions } from "./actions-panel";
import {
ErrorsPanel,
LongTaskPanel,
@@ -37,7 +37,6 @@ 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";
@@ -149,7 +148,6 @@ export function DevToolbar({ build, apiUrl, route, onNavigate }: DevToolbarProps
const 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 = (
@@ -265,12 +263,10 @@ 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>
+ <DevActions wsId={wsId} />
<button
type="button"
onClick={() => setMinimized(true)}
diff --git a/packages/views/dev-toolbar/diagnostics-dev-actions.ts b/packages/views/dev-toolbar/diagnostics-dev-actions.ts
new file mode 100644
index 0000000000..c736a1343f
--- /dev/null
+++ b/packages/views/dev-toolbar/diagnostics-dev-actions.ts
@@ -0,0 +1,53 @@
+import { clearDevErrors, clearDevRequests } from "@multica/core/diagnostics";
+import type { DevFeature } from "./actions";
+
+export const queryCacheDevFeature: DevFeature = {
+ id: "query-cache",
+ group: "Data",
+ title: "Query cache",
+ actions: [
+ {
+ id: "invalidate",
+ title: "Invalidate all queries",
+ description: "Marks everything stale; what is on screen refetches now",
+ run: ({ queryClient }) => void queryClient.invalidateQueries(),
+ },
+ {
+ id: "reset",
+ title: "Reset all queries",
+ description: "Drops cached data, so screens show their loading state",
+ run: ({ queryClient }) => void queryClient.resetQueries(),
+ },
+ ],
+};
+
+export const errorsDevFeature: DevFeature = {
+ id: "errors",
+ group: "Errors",
+ title: "Error capture",
+ actions: [
+ {
+ id: "console-error",
+ title: "Log a console error",
+ run: () => console.error(new Error("Dev toolbar test error")),
+ },
+ {
+ id: "throw",
+ title: "Throw an uncaught error",
+ description: "Thrown outside React, as a failed event handler would",
+ run: () => {
+ setTimeout(() => {
+ throw new Error("Dev toolbar uncaught test error");
+ });
+ },
+ },
+ {
+ id: "reject",
+ title: "Reject a promise",
+ description: "Leaves the rejection unhandled",
+ run: () => void Promise.reject(new Error("Dev toolbar unhandled rejection")),
+ },
+ { id: "clear-errors", title: "Clear recorded errors", run: clearDevErrors },
+ { id: "clear-requests", title: "Clear recorded requests", run: clearDevRequests },
+ ],
+};
diff --git a/packages/views/dev-toolbar/prompts-panel.test.tsx b/packages/views/dev-toolbar/prompts-panel.test.tsx
deleted file mode 100644
index 697ccb9ed2..0000000000
--- a/packages/views/dev-toolbar/prompts-panel.test.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-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.tsx
deleted file mode 100644
index 0c518055d0..0000000000
--- a/packages/views/dev-toolbar/prompts-panel.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-"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&apos;s issue moves to done. Show star card skips the server&apos;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/dev-toolbar/registry.ts b/packages/views/dev-toolbar/registry.ts
new file mode 100644
index 0000000000..044a7c1616
--- /dev/null
+++ b/packages/views/dev-toolbar/registry.ts
@@ -0,0 +1,24 @@
+import { sourceSurveyDevFeature } from "../onboarding/dev-actions";
+import { starPromptDevFeature } from "../star-prompt/dev-actions";
+import { whatsNewDevFeature } from "../whats-new/dev-actions";
+import { devCommands, type DevFeature } from "./actions";
+import { errorsDevFeature, queryCacheDevFeature } from "./diagnostics-dev-actions";
+import { sessionPromptDevFeature } from "./session-prompt-dev-actions";
+
+/**
+ * Every feature with dev actions, in panel order; groups appear in the order
+ * their first feature does. A feature declares its actions in a
+ * `dev-actions.ts` next to its own code and is listed here to show up.
+ */
+export const DEV_FEATURES: readonly DevFeature[] = [
+ sessionPromptDevFeature,
+ whatsNewDevFeature,
+ starPromptDevFeature,
+ sourceSurveyDevFeature,
+ queryCacheDevFeature,
+ errorsDevFeature,
+];
+
+export const DEV_COMMANDS = devCommands(DEV_FEATURES);
+
+export const DEV_GROUPS = [...new Set(DEV_FEATURES.map((f) => f.group))];
diff --git a/packages/views/dev-toolbar/session-prompt-dev-actions.ts b/packages/views/dev-toolbar/session-prompt-dev-actions.ts
new file mode 100644
index 0000000000..4417dfb6be
--- /dev/null
+++ b/packages/views/dev-toolbar/session-prompt-dev-actions.ts
@@ -0,0 +1,26 @@
+import { useSessionPromptStore } from "@multica/core/session-prompt";
+import type { DevFeature } from "./actions";
+
+export const sessionPromptDevFeature: DevFeature = {
+ id: "prompt-session",
+ group: "Prompts",
+ title: "Prompt session",
+ useDevState: () => {
+ const { prompted, deckDealt, corner } = useSessionPromptStore();
+ return {
+ status: { text: corner ? `${corner} holds the corner` : "corner empty" },
+ rows: [
+ { label: "Prompt budget", value: prompted ? "used by survey or star card" : "free", tone: prompted ? "warn" : "normal" },
+ { label: "Deck dealt", value: deckDealt ? "yes" : "no" },
+ ],
+ };
+ },
+ actions: [
+ {
+ id: "reset",
+ title: "Reset session",
+ description: "Forgets what this session has shown, as a reload would",
+ run: () => useSessionPromptStore.getState().reset(),
+ },
+ ],
+};
diff --git a/packages/views/eslint.config.mjs b/packages/views/eslint.config.mjs
index b211166112..af5a9718fa 100644
--- a/packages/views/eslint.config.mjs
+++ b/packages/views/eslint.config.mjs
@@ -60,8 +60,9 @@ export default [
},
{
// The dev toolbar only exists in development builds and speaks to the
- // people building Multica, so its copy is not translated.
- files: ["dev-toolbar/**/*.{ts,tsx}"],
+ // people building Multica, so its copy is not translated. Features declare
+ // their toolbar actions in a `dev-actions.ts` beside their own code.
+ files: ["dev-toolbar/**/*.{ts,tsx}", "**/dev-actions.ts"],
rules: {
"i18next/no-literal-string": "off",
"no-restricted-syntax": ["error", NO_ROUND_CONTROLS, NO_FULL_PAGE_NAVIGATION],
diff --git a/packages/views/onboarding/dev-actions.ts b/packages/views/onboarding/dev-actions.ts
new file mode 100644
index 0000000000..4687cbfaeb
--- /dev/null
+++ b/packages/views/onboarding/dev-actions.ts
@@ -0,0 +1,35 @@
+import { needsSourceBackfill, SOURCE_BACKFILL_MAX_DISMISSALS } from "@multica/core/onboarding";
+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";
+import type { DevFeature } from "../dev-toolbar/actions";
+import { resetSourceBackfillDismissCount, useSourceBackfillDismissCount } from "./source-backfill-dismiss";
+
+export const sourceSurveyDevFeature: DevFeature = {
+ id: "source-survey",
+ group: "Prompts",
+ title: "Source survey",
+ useDevState: ({ user }) => {
+ const pending = useSessionPromptStore((s) => s.surveyPending);
+ const [dismissals] = useSourceBackfillDismissCount(user?.id);
+ const owes = needsSourceBackfill(user, dismissals);
+ return {
+ status: pending ? { text: "open or deciding" } : owes ? { text: "owes an answer" } : { text: "settled" },
+ rows: [{ label: "Dismissals", value: `${dismissals}/${SOURCE_BACKFILL_MAX_DISMISSALS}` }],
+ };
+ },
+ actions: [
+ {
+ id: "open",
+ title: "Open survey",
+ needs: "workspace",
+ caution: "Submitting or skipping saves your answer to the server",
+ run: () => useDevPromptStore.getState().trigger("survey"),
+ },
+ {
+ id: "reset-dismissals",
+ title: "Reset dismissals",
+ description: "This browser only",
+ needs: "user",
+ run: ({ user }) => user && resetSourceBackfillDismissCount(user.id),
+ },
+ ],
+};
diff --git a/packages/views/star-prompt/dev-actions.ts b/packages/views/star-prompt/dev-actions.ts
new file mode 100644
index 0000000000..2591a5580d
--- /dev/null
+++ b/packages/views/star-prompt/dev-actions.ts
@@ -0,0 +1,36 @@
+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";
+import { STAR_PROMPT_MAX_SHOWINGS, starPromptDue } from "@multica/core/star-prompt";
+import type { DevFeature } from "../dev-toolbar/actions";
+
+const day = (iso: string | null | undefined) => (iso ? iso.slice(0, 10) : "—");
+
+export const starPromptDevFeature: DevFeature = {
+ id: "star-card",
+ group: "Prompts",
+ title: "Star card",
+ useDevState: ({ user }) => {
+ const corner = useSessionPromptStore((s) => s.corner);
+ const due = starPromptDue(user, Date.now());
+ const 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)}`;
+ return {
+ status: corner === "star" ? { text: "on screen" } : due ? { text: "due" } : { text: "not due", tone: "warn" },
+ rows: [
+ { label: "Showings", value: showings },
+ { label: "Starred", value: day(user?.star_prompt_starred_at) },
+ ],
+ note: "Shows when an agent's issue moves to done.",
+ };
+ },
+ actions: [
+ {
+ id: "show",
+ title: "Show star card",
+ description: "Skips the server's showing count",
+ needs: "workspace",
+ run: () => useDevPromptStore.getState().trigger("star"),
+ },
+ ],
+};
diff --git a/packages/views/whats-new/dev-actions.ts b/packages/views/whats-new/dev-actions.ts
new file mode 100644
index 0000000000..57e9c6901e
--- /dev/null
+++ b/packages/views/whats-new/dev-actions.ts
@@ -0,0 +1,92 @@
+import { useAuthStore } from "@multica/core/auth";
+import { useChatStore } from "@multica/core/chat";
+import { useConfigStore } from "@multica/core/config";
+import { useDevPromptStore, useSessionPromptStore } from "@multica/core/session-prompt";
+import type { DevFeature, DevFeatureState } from "../dev-toolbar/actions";
+import { WHATS_NEW_RELEASES } from "./releases";
+import { useWhatsNew } from "./use-whats-new";
+import { deckBlocker, deckCards, type DeckBlocker } from "./whats-new-deck";
+
+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: "an input has focus, a dialog is open, or the tab is hidden",
+};
+
+const day = (iso: string | null | undefined) => (iso ? iso.slice(0, 10) : "—");
+
+export const whatsNewDevFeature: DevFeature = {
+ id: "whats-new-deck",
+ group: "Prompts",
+ title: "What's new deck",
+ useDevState: ({ wsId, user }): DevFeatureState => {
+ const serverVersion = useConfigStore((s) => s.serverVersion);
+ // `deckBlocker` reads these stores without subscribing; reading them here
+ // keeps the status current as they change.
+ const { corner } = useSessionPromptStore();
+ useChatStore((s) => s.isOpen);
+ const { visible, unread } = useWhatsNew();
+ const cards = deckCards(unread).length;
+ const blocker = deckBlocker();
+ const status: NonNullable<DevFeatureState["status"]> =
+ corner === "whats-new"
+ ? { text: "on screen" }
+ : !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" };
+ const seen = user?.whats_new_seen_version;
+ return {
+ status,
+ rows: [
+ { label: "Server version", value: serverVersion || "unknown · no cap" },
+ {
+ label: "Seen version",
+ value: seen === undefined ? "server cannot store it" : (seen ?? "none · count since signup"),
+ tone: seen === undefined ? "bad" : "normal",
+ },
+ { label: "Signed up", value: day(user?.created_at) },
+ { label: "Visible", value: visible.map((r) => r.version).join(", ") || "—" },
+ { label: "Unread", value: unread.map((r) => r.version).join(", ") || "—" },
+ { label: "Cards to deal", value: String(cards) },
+ ],
+ };
+ },
+ actions: [
+ {
+ id: "show",
+ title: "Show deck",
+ description: "Deals every card with hero art, read or not",
+ needs: "workspace",
+ run: () => useDevPromptStore.getState().trigger("whats-new"),
+ },
+ {
+ id: "check",
+ title: "Run check now",
+ description: "The real gates, without the start-up delay",
+ needs: "workspace",
+ run: () => useDevPromptStore.getState().trigger("whats-new-check"),
+ },
+ {
+ id: "seen-version",
+ title: "Set seen version",
+ description: "This client only, until the next reload",
+ needs: "user",
+ choices: [
+ { value: "", label: "none" },
+ ...WHATS_NEW_RELEASES.map((r) => ({ value: r.version, label: r.version })),
+ ],
+ run: (_ctx, version) => {
+ const current = useAuthStore.getState().user;
+ if (current) useAuthStore.getState().setUser({ ...current, whats_new_seen_version: version || null });
+ },
+ },
+ ],
+};