Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
chore: add more dashboard cmdk actions (#2422)
Maximilian Kaske1b11553f1539
diff --git a/apps/dashboard/src/components/command-menu/command-menu.tsx b/apps/dashboard/src/components/command-menu/command-menu.tsxindex eddb7b085..bd544cf72 100644--- a/apps/dashboard/src/components/command-menu/command-menu.tsx+++ b/apps/dashboard/src/components/command-menu/command-menu.tsx@@ -1,11 +1,9 @@"use client";-import { Close, Dark, Light, Search } from "@openstatus/icons";+import { Close, Search } from "@openstatus/icons";import {Command,CommandEmpty,- CommandGroup,- CommandItem,CommandList,CommandLoading,} from "@openstatus/ui/components/ui/command";@@ -14,94 +12,61 @@ import {DialogContent,DialogTitle,} from "@openstatus/ui/components/ui/dialog";-import { useQuery } from "@tanstack/react-query";import { Command as CommandPrimitive } from "cmdk";import { useTheme } from "next-themes";import { useRouter } from "next/navigation";import * as React from "react";import { FormSheetMaintenanceCreate } from "@/components/forms/maintenance/sheet-create";+import { FormSheetStatusReportUpdateCreate } from "@/components/forms/status-report-update/sheet-create";import { FormSheetStatusReportCreate } from "@/components/forms/status-report/sheet-create";import { FormDialogSupportContact } from "@/components/forms/support-contact/dialog";import { scrollToHash, useScrollToHash } from "@/hooks/use-scroll-to-hash";-import { useTRPC } from "@/lib/trpc/client";import { switchWorkspace } from "@/lib/workspace-cookie";+import { GroupView } from "./group-view";import {- type CommandLink,- type CommandPage,- type CommandSheetAction,- CREATE_ACTIONS,- CREATE_LINKS,- HELP_LINK_ITEMS,- HELP_SUPPORT_ACTION,- MONITOR_ACTIONS,- NAVIGATION,- SETTINGS,- STATUS_PAGE_ACTIONS,-} from "./config";+ maintenancesGroup,+ monitorsGroup,+ statusPagesGroup,+ statusReportsGroup,+ workspacesGroup,+} from "./groups/entities";+import { monitorScopeGroups } from "./groups/monitor-scope";+import {+ createGroup,+ helpGroup,+ navigationGroup,+ settingsGroup,+ themeGroup,+} from "./groups/static";+import { statusPageScopeGroups } from "./groups/status-page-scope";import { useCommandMenu } from "./provider";--type ActiveSheet = CommandSheetAction["sheet"] | null;--const IDLE_CAP = 5;--function LinkItem({- item,- onSelect,-}: {- item: CommandLink;- onSelect: (item: CommandLink) => void;-}) {- return (- <CommandItem- value={item.label}- keywords={item.keywords}- onSelect={() => onSelect(item)}- >- <item.icon />- <span>{item.label}</span>- </CommandItem>- );-}--function ActionItem({- action,- onSelect,-}: {- action: CommandSheetAction;- onSelect: () => void;-}) {- return (- <CommandItem- value={action.label}- keywords={action.keywords}- onSelect={onSelect}- >- <action.icon />- <span>{action.label}</span>- </CommandItem>- );-}+import type {+ CommandAction,+ CommandMenuGroup,+ CommandPage,+ CommandSheet,+} from "./types";+import { pageLabel } from "./types";+import { useCommandMenuData } from "./use-command-menu-data";export function CommandMenu() {const { open, setOpen } = useCommandMenu();const [search, setSearch] = React.useState("");const [pages, setPages] = React.useState<CommandPage[]>([]);- const [activeSheet, setActiveSheet] = React.useState<ActiveSheet>(null);+ const [activeSheet, setActiveSheet] = React.useState<CommandSheet | null>(+ null,+ );const [mounted, setMounted] = React.useState(false);const inputRef = React.useRef<HTMLInputElement>(null);const router = useRouter();const { resolvedTheme, setTheme } = useTheme();- const trpc = useTRPC();useScrollToHash();- const { data: monitors } = useQuery(trpc.monitor.list.queryOptions());- const { data: statusPages } = useQuery(trpc.page.list.queryOptions());- const { data: workspaces } = useQuery(trpc.workspace.list.queryOptions());- const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());+ const data = useCommandMenuData({ open });const page = pages.length > 0 ? pages[pages.length - 1] : null;@@ -143,27 +108,60 @@ export function CommandMenu() {if (hashIndex !== -1) scrollToHash(href.slice(hashIndex + 1));};- const selectLink = (item: CommandLink) => {- if (item.external) {- window.open(item.href, "_blank", "noreferrer");- setOpen(false);- return;- }- navigate(item.href);- };-- const openSheet = (sheet: Exclude<ActiveSheet, null>) => {+ const openSheet = (next: CommandSheet) => {setOpen(false);// Defer so the palette Dialog releases focus + scroll lock before the// sheet/dialog claims them — otherwise Radix layers fight during overlap.- setTimeout(() => setActiveSheet(sheet), 0);+ setTimeout(() => setActiveSheet(next), 0);};- const idleCap = <T,>(items: T[]) =>- search ? items : items.slice(0, IDLE_CAP);+ const dispatch = (action: CommandAction) => {+ switch (action.type) {+ case "navigate":+ navigate(action.href);+ break;+ case "external":+ window.open(action.href, "_blank", "noreferrer");+ setOpen(false);+ break;+ case "sheet":+ openSheet(action.sheet);+ break;+ case "push":+ pushPage(action.page);+ break;+ case "run":+ // Intentionally leaves the palette open (theme toggle, workspace switch).+ action.run();+ break;+ }+ };- const otherWorkspaces =- workspaces?.filter((w) => w.slug !== workspace?.slug) ?? [];+ const groups: CommandMenuGroup[] = page+ ? page.type === "monitor"+ ? monitorScopeGroups(page)+ : statusPageScopeGroups({+ page,+ statusReports: data.sortedStatusReports,+ maintenances: data.sortedMaintenances,+ })+ : [+ monitorsGroup(data.monitors),+ statusPagesGroup(data.statusPages),+ statusReportsGroup(data.sortedStatusReports),+ maintenancesGroup(data.sortedMaintenances, data.pageTitleById),+ navigationGroup(),+ createGroup(),+ settingsGroup(),+ workspacesGroup(data.otherWorkspaces, switchWorkspace),+ helpGroup(),+ ...(mounted ? [themeGroup(resolvedTheme, setTheme)] : []),+ ].filter((g): g is CommandMenuGroup => g !== null);++ const reportForUpdate =+ activeSheet?.sheet === "status-report-update"+ ? data.statusReports?.find((r) => r.id === activeSheet.reportId)+ : undefined;return (<>@@ -191,7 +189,7 @@ export function CommandMenu() {<Search className="size-4 shrink-0 opacity-50" />{page ? (<span className="bg-muted text-muted-foreground inline-flex shrink-0 items-center gap-1 rounded border px-1.5 py-0.5 text-xs">- {page.type === "monitor" ? page.name : page.title}+ {pageLabel(page)}<buttontype="button"aria-label="Clear scope"@@ -212,195 +210,60 @@ export function CommandMenu() {className="placeholder:text-muted-foreground flex h-10 w-full bg-transparent py-3 text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50"/></div>- <CommandList>+ {/* inline style: twMerge drops the ui default max-h when a class+ overrides it, and a missed JIT class would leave the list+ unbounded — the style prop can't silently fail */}+ <CommandList style={{ maxHeight: "min(400px, 65vh)" }}><CommandEmpty>No results found.</CommandEmpty>-- {page ? (- <CommandGroup- heading={page.type === "monitor" ? page.name : page.title}- >- {(page.type === "monitor"- ? MONITOR_ACTIONS(page.id)- : STATUS_PAGE_ACTIONS(page.id)- ).map((item) => (- <CommandItem- key={item.href}- value={item.label}- keywords={item.keywords}- onSelect={() => navigate(item.href)}- >- <item.icon />- <span>{item.label}</span>- </CommandItem>- ))}- </CommandGroup>- ) : (- <>- {monitors === undefined ? (- <CommandLoading>Loading…</CommandLoading>- ) : null}-- {monitors && monitors.length > 0 ? (- <CommandGroup heading="Monitors">- {idleCap(monitors).map((m) => (- <CommandItem- key={m.id}- value={`monitor-${m.id}`}- keywords={[m.name, m.url]}- onSelect={() =>- pushPage({- type: "monitor",- id: m.id,- name: m.name,- })- }- >- <div className="grid min-w-0">- <span className="truncate">{m.name}</span>- <span className="text-muted-foreground truncate text-xs">- {m.url}- </span>- </div>- </CommandItem>- ))}- </CommandGroup>- ) : null}-- {statusPages && statusPages.length > 0 ? (- <CommandGroup heading="Status Pages">- {idleCap(statusPages).map((p) => (- <CommandItem- key={p.id}- value={`status-page-${p.id}`}- keywords={[p.title, p.slug, p.customDomain].filter(- Boolean,- )}- onSelect={() =>- pushPage({- type: "status-page",- id: p.id,- title: p.title,- })- }- >- <div className="grid min-w-0">- <span className="truncate">{p.title}</span>- <span className="text-muted-foreground truncate text-xs">- {p.slug}- </span>- </div>- </CommandItem>- ))}- </CommandGroup>- ) : null}-- <CommandGroup heading="Navigation">- {NAVIGATION.map((item) => (- <LinkItem- key={item.href}- item={item}- onSelect={selectLink}- />- ))}- </CommandGroup>-- <CommandGroup heading="Create">- {CREATE_LINKS.map((item) => (- <LinkItem- key={item.href}- item={item}- onSelect={selectLink}- />- ))}- {CREATE_ACTIONS.map((action) => (- <ActionItem- key={action.sheet}- action={action}- onSelect={() => openSheet(action.sheet)}- />- ))}- </CommandGroup>-- <CommandGroup heading="Settings">- {SETTINGS.map((item) => (- <LinkItem- key={item.href}- item={item}- onSelect={selectLink}- />- ))}- </CommandGroup>-- {otherWorkspaces.length > 0 ? (- <CommandGroup heading="Workspace">- {otherWorkspaces.map((w) => (- <CommandItem- key={w.id}- value={`workspace-${w.id}`}- keywords={[w.name || "Untitled Workspace", w.slug]}- onSelect={() => switchWorkspace(w.slug)}- >- <span className="truncate">- {w.name || "Untitled Workspace"}- </span>- <span className="text-muted-foreground truncate font-mono text-xs">- {w.slug}- </span>- </CommandItem>- ))}- </CommandGroup>- ) : null}-- <CommandGroup heading="Get Help">- <ActionItem- action={HELP_SUPPORT_ACTION}- onSelect={() => openSheet("support")}- />- {HELP_LINK_ITEMS.map((item) => (- <LinkItem- key={item.href}- item={item}- onSelect={selectLink}- />- ))}- </CommandGroup>-- {mounted ? (- <CommandGroup heading="Theme">- <CommandItem- value="toggle-theme"- keywords={["dark", "light", "appearance"]}- onSelect={() =>- setTheme(resolvedTheme === "dark" ? "light" : "dark")- }- >- {resolvedTheme === "dark" ? <Light /> : <Dark />}- <span>- Switch to{" "}- {resolvedTheme === "dark" ? "light" : "dark"} theme- </span>- </CommandItem>- </CommandGroup>- ) : null}- </>- )}+ {!page && data.monitors === undefined ? (+ <CommandLoading>Loading…</CommandLoading>+ ) : null}+ {groups.map((group) => (+ <GroupView+ key={group.heading}+ group={group}+ search={search}+ onAction={dispatch}+ />+ ))}</CommandList></Command></DialogContent></Dialog><FormSheetStatusReportCreate- open={activeSheet === "status-report"}- onOpenChange={(o) => setActiveSheet(o ? "status-report" : null)}+ open={activeSheet?.sheet === "status-report"}+ onOpenChange={(o) =>+ setActiveSheet(o ? { sheet: "status-report" } : null)+ }+ defaultPageId={+ activeSheet?.sheet === "status-report"+ ? activeSheet.pageId+ : undefined+ }/><FormSheetMaintenanceCreate- open={activeSheet === "maintenance"}- onOpenChange={(o) => setActiveSheet(o ? "maintenance" : null)}+ open={activeSheet?.sheet === "maintenance"}+ onOpenChange={(o) =>+ setActiveSheet(o ? { sheet: "maintenance" } : null)+ }+ defaultPageId={+ activeSheet?.sheet === "maintenance" ? activeSheet.pageId : undefined+ }/><FormDialogSupportContact- open={activeSheet === "support"}- onOpenChange={(o) => setActiveSheet(o ? "support" : null)}+ open={activeSheet?.sheet === "support"}+ onOpenChange={(o) => setActiveSheet(o ? { sheet: "support" } : null)}/>+ {reportForUpdate ? (+ <FormSheetStatusReportUpdateCreate+ report={reportForUpdate}+ open={activeSheet?.sheet === "status-report-update"}+ onOpenChange={(o) => {+ if (!o) setActiveSheet(null);+ }}+ />+ ) : null}</>);}diff --git a/apps/dashboard/src/components/command-menu/config.ts b/apps/dashboard/src/components/command-menu/config.tsdeleted file mode 100644index 199e0819b..000000000--- a/apps/dashboard/src/components/command-menu/config.ts+++ /dev/null@@ -1,141 +0,0 @@-import { AtSign, KeyRound, Palette, Pencil, Plus, Users } from "lucide-react";-import type * as React from "react";--import { MONITOR_TABS } from "@/app/(dashboard)/monitors/[id]/constants";-import { STATUS_PAGE_TABS } from "@/app/(dashboard)/status-pages/[id]/constants";-import { HELP_LINKS, HELP_SUPPORT } from "@/config/help";-import { NAV_MENU_ITEMS } from "@/config/nav";-import { SETTINGS_TABS } from "@/config/settings";--// Lucide icons and the custom brand icons both accept svg props.-export type CommandIcon = React.ComponentType<React.ComponentProps<"svg">>;--export type CommandLink = {- label: string;- href: string;- icon: CommandIcon;- keywords?: string[];- external?: boolean;-};--export type CommandSheetAction = {- label: string;- icon: CommandIcon;- keywords?: string[];- sheet: "status-report" | "maintenance" | "support";-};--export type CommandPage =- | { type: "monitor"; id: number; name: string }- | { type: "status-page"; id: number; title: string };--export const NAVIGATION: CommandLink[] = NAV_MENU_ITEMS.map((item) => ({- label: item.label,- href: item.href,- icon: item.icon,- keywords: item.keywords,-}));--export const CREATE_LINKS: CommandLink[] = [- {- label: "Create Monitor",- href: "/monitors/create",- icon: Plus,- keywords: ["new monitor"],- },- {- label: "Create Status Page",- href: "/status-pages/create",- icon: Plus,- keywords: ["new page"],- },-];--export const CREATE_ACTIONS: CommandSheetAction[] = [- {- label: "Create Status Report",- icon: Plus,- keywords: ["incident", "announce", "publish"],- sheet: "status-report",- },- {- label: "Create Maintenance",- icon: Plus,- keywords: ["downtime", "window", "schedule"],- sheet: "maintenance",- },-];--const SETTINGS_TAB_LINKS: CommandLink[] = SETTINGS_TABS.map((tab) => ({- label: tab.label,- href: tab.href,- icon: tab.icon,- keywords: tab.keywords,-}));--// Deep-links into settings cards via anchor ids. Icons are only used here, so-// they live with the command menu rather than a shared config.-const SETTINGS_ANCHORS: CommandLink[] = [- {- label: "API Keys",- href: "/settings/general#api-keys",- icon: KeyRound,- keywords: ["token", "key"],- },- {- label: "Team Members",- href: "/settings/general#team-members",- icon: Users,- keywords: ["invite", "member"],- },- {- label: "Workspace Slug",- href: "/settings/general#workspace-slug",- icon: AtSign,- },- {- label: "Workspace Name",- href: "/settings/general#workspace-name",- icon: Pencil,- keywords: ["rename"],- },- {- label: "Appearance",- href: "/settings/account#appearance",- icon: Palette,- keywords: ["theme", "dark mode"],- },-];--export const SETTINGS: CommandLink[] = [- ...SETTINGS_TAB_LINKS,- ...SETTINGS_ANCHORS,-];--export const HELP_SUPPORT_ACTION: CommandSheetAction = {- label: HELP_SUPPORT.label,- icon: HELP_SUPPORT.icon,- keywords: HELP_SUPPORT.keywords,- sheet: "support",-};--export const HELP_LINK_ITEMS: CommandLink[] = HELP_LINKS.map((link) => ({- ...link,- external: true,-}));--export function MONITOR_ACTIONS(id: number): CommandLink[] {- return MONITOR_TABS.map((tab) => ({- label: tab.label,- href: `/monitors/${id}/${tab.value}`,- icon: tab.icon,- }));-}--export function STATUS_PAGE_ACTIONS(id: number): CommandLink[] {- return STATUS_PAGE_TABS.map((tab) => ({- label: tab.label,- href: `/status-pages/${id}/${tab.value}`,- icon: tab.icon,- }));-}diff --git a/apps/dashboard/src/components/command-menu/group-view.tsx b/apps/dashboard/src/components/command-menu/group-view.tsxnew file mode 100644index 000000000..f4265d8c8--- /dev/null+++ b/apps/dashboard/src/components/command-menu/group-view.tsx@@ -0,0 +1,48 @@+"use client";++import {+ CommandGroup,+ CommandItem,+} from "@openstatus/ui/components/ui/command";++import type { CommandAction, CommandMenuGroup } from "./types";++export function GroupView({+ group,+ search,+ onAction,+}: {+ group: CommandMenuGroup;+ search: string;+ onAction: (action: CommandAction) => void;+}) {+ if (group.items.length === 0) return null;+ const items =+ !search && group.idleLimit+ ? group.items.slice(0, group.idleLimit)+ : group.items;+ return (+ <CommandGroup heading={group.heading}>+ {items.map((item) => (+ <CommandItem+ key={item.value}+ value={item.value}+ keywords={item.keywords}+ onSelect={() => onAction(item.action)}+ >+ {item.icon ? <item.icon /> : null}+ {item.description ? (+ <div className="grid min-w-0">+ <span className="truncate">{item.label}</span>+ <span className="text-muted-foreground font-commit-mono truncate text-xs">+ {item.description}+ </span>+ </div>+ ) : (+ <span>{item.label}</span>+ )}+ </CommandItem>+ ))}+ </CommandGroup>+ );+}diff --git a/apps/dashboard/src/components/command-menu/groups/entities.ts b/apps/dashboard/src/components/command-menu/groups/entities.tsnew file mode 100644index 000000000..54decf185--- /dev/null+++ b/apps/dashboard/src/components/command-menu/groups/entities.ts@@ -0,0 +1,109 @@+import type { RouterOutputs } from "@openstatus/api";++import type { CommandMenuGroup } from "../types";++type Monitor = RouterOutputs["monitor"]["list"][number];+type StatusPage = RouterOutputs["page"]["list"][number];+type StatusReport = RouterOutputs["statusReport"]["list"][number];+type Maintenance = RouterOutputs["maintenance"]["list"][number];+type Workspace = RouterOutputs["workspace"]["list"][number];++export function monitorsGroup(+ monitors: Monitor[] | undefined,+): CommandMenuGroup | null {+ if (!monitors || monitors.length === 0) return null;+ return {+ heading: "Monitors",+ idleLimit: 5,+ items: monitors.map((m) => ({+ value: `monitor-${m.id}`,+ label: m.name,+ description: m.url,+ keywords: [m.name, m.url],+ action: {+ type: "push",+ page: { type: "monitor", id: m.id, name: m.name },+ },+ })),+ };+}++export function statusPagesGroup(+ statusPages: StatusPage[] | undefined,+): CommandMenuGroup | null {+ if (!statusPages || statusPages.length === 0) return null;+ return {+ heading: "Status Pages",+ idleLimit: 5,+ items: statusPages.map((p) => ({+ value: `status-page-${p.id}`,+ label: p.title,+ description: p.slug,+ keywords: [p.title, p.slug, p.customDomain].filter(Boolean) as string[],+ action: {+ type: "push",+ page: { type: "status-page", id: p.id, title: p.title },+ },+ })),+ };+}++export function statusReportsGroup(+ sortedStatusReports: StatusReport[] | undefined,+): CommandMenuGroup | null {+ if (!sortedStatusReports || sortedStatusReports.length === 0) return null;+ return {+ heading: "Status Reports",+ idleLimit: 5,+ items: sortedStatusReports.map((r) => ({+ value: `status-report-${r.id}`,+ label: r.title,+ description: `${r.status} · ${r.page.title}`,+ keywords: [r.title, r.status, r.page.title],+ action: {+ type: "navigate",+ href: `/status-pages/${r.pageId}/status-reports/${r.id}`,+ },+ })),+ };+}++export function maintenancesGroup(+ sortedMaintenances: Maintenance[] | undefined,+ pageTitleById: Map<number, string>,+): CommandMenuGroup | null {+ if (!sortedMaintenances || sortedMaintenances.length === 0) return null;+ return {+ heading: "Maintenances",+ idleLimit: 5,+ items: sortedMaintenances.map((m) => ({+ value: `maintenance-${m.id}`,+ label: m.title,+ description: m.from.toLocaleString(),+ keywords: [m.title, pageTitleById.get(m.pageId ?? -1) ?? ""].filter(+ Boolean,+ ),+ action: {+ type: "navigate",+ href: `/status-pages/${m.pageId}/maintenances`,+ },+ })),+ };+}++export function workspacesGroup(+ otherWorkspaces: Workspace[],+ switchWorkspace: (slug: string) => void,+): CommandMenuGroup | null {+ if (otherWorkspaces.length === 0) return null;+ return {+ heading: "Workspace",+ items: otherWorkspaces.map((w) => ({+ value: `workspace-${w.id}`,+ label: w.name || "Untitled Workspace",+ description: w.slug,+ keywords: [w.name || "Untitled Workspace", w.slug],+ action: { type: "run", run: () => switchWorkspace(w.slug) },+ })),+ };+}diff --git a/apps/dashboard/src/components/command-menu/groups/monitor-scope.ts b/apps/dashboard/src/components/command-menu/groups/monitor-scope.tsnew file mode 100644index 000000000..9575c2b7d--- /dev/null+++ b/apps/dashboard/src/components/command-menu/groups/monitor-scope.ts@@ -0,0 +1,19 @@+import { MONITOR_TABS } from "@/app/(dashboard)/monitors/[id]/constants";++import type { CommandMenuGroup, CommandPage } from "../types";++export function monitorScopeGroups(+ page: Extract<CommandPage, { type: "monitor" }>,+): CommandMenuGroup[] {+ return [+ {+ heading: page.name,+ items: MONITOR_TABS.map((tab) => ({+ value: tab.label,+ label: tab.label,+ icon: tab.icon,+ action: { type: "navigate", href: `/monitors/${page.id}/${tab.value}` },+ })),+ },+ ];+}diff --git a/apps/dashboard/src/components/command-menu/groups/static.ts b/apps/dashboard/src/components/command-menu/groups/static.tsnew file mode 100644index 000000000..a8c8e36cf--- /dev/null+++ b/apps/dashboard/src/components/command-menu/groups/static.ts@@ -0,0 +1,161 @@+import { Dark, Light } from "@openstatus/icons";+import { AtSign, KeyRound, Palette, Pencil, Plus, Users } from "lucide-react";++import { HELP_LINKS, HELP_SUPPORT } from "@/config/help";+import { NAV_MENU_ITEMS } from "@/config/nav";+import { SETTINGS_TABS } from "@/config/settings";++import type { CommandMenuGroup, CommandMenuItem } from "../types";++export function navigationGroup(): CommandMenuGroup {+ return {+ heading: "Navigation",+ items: NAV_MENU_ITEMS.map((item) => ({+ value: item.label,+ label: item.label,+ icon: item.icon,+ keywords: item.keywords,+ action: { type: "navigate", href: item.href },+ })),+ };+}++export function createStatusReportItem(pageId?: number): CommandMenuItem {+ return {+ value: pageId ? "create-status-report" : "Create Status Report",+ label: "Create Status Report",+ icon: Plus,+ keywords: ["incident", "announce", "publish"],+ action: { type: "sheet", sheet: { sheet: "status-report", pageId } },+ };+}++export function createMaintenanceItem(pageId?: number): CommandMenuItem {+ return {+ value: pageId ? "create-maintenance" : "Create Maintenance",+ label: "Create Maintenance",+ icon: Plus,+ keywords: ["downtime", "window", "schedule"],+ action: { type: "sheet", sheet: { sheet: "maintenance", pageId } },+ };+}++export function createGroup(): CommandMenuGroup {+ return {+ heading: "Create",+ items: [+ {+ value: "Create Monitor",+ label: "Create Monitor",+ icon: Plus,+ keywords: ["new monitor"],+ action: { type: "navigate", href: "/monitors/create" },+ },+ {+ value: "Create Status Page",+ label: "Create Status Page",+ icon: Plus,+ keywords: ["new page"],+ action: { type: "navigate", href: "/status-pages/create" },+ },+ createStatusReportItem(),+ createMaintenanceItem(),+ ],+ };+}++// Deep-links into settings cards via anchor ids. Icons are only used here, so+// they live with the command menu rather than a shared config.+const SETTINGS_ANCHORS: CommandMenuItem[] = [+ {+ value: "API Keys",+ label: "API Keys",+ icon: KeyRound,+ keywords: ["token", "key"],+ action: { type: "navigate", href: "/settings/general#api-keys" },+ },+ {+ value: "Team Members",+ label: "Team Members",+ icon: Users,+ keywords: ["invite", "member"],+ action: { type: "navigate", href: "/settings/general#team-members" },+ },+ {+ value: "Workspace Slug",+ label: "Workspace Slug",+ icon: AtSign,+ action: { type: "navigate", href: "/settings/general#workspace-slug" },+ },+ {+ value: "Workspace Name",+ label: "Workspace Name",+ icon: Pencil,+ keywords: ["rename"],+ action: { type: "navigate", href: "/settings/general#workspace-name" },+ },+ {+ value: "Appearance",+ label: "Appearance",+ icon: Palette,+ keywords: ["theme", "dark mode"],+ action: { type: "navigate", href: "/settings/account#appearance" },+ },+];++export function settingsGroup(): CommandMenuGroup {+ return {+ heading: "Settings",+ items: [+ ...SETTINGS_TABS.map((tab) => ({+ value: tab.label,+ label: tab.label,+ icon: tab.icon,+ keywords: tab.keywords,+ action: { type: "navigate" as const, href: tab.href },+ })),+ ...SETTINGS_ANCHORS,+ ],+ };+}++export function helpGroup(): CommandMenuGroup {+ return {+ heading: "Get Help",+ items: [+ {+ value: HELP_SUPPORT.label,+ label: HELP_SUPPORT.label,+ icon: HELP_SUPPORT.icon,+ keywords: HELP_SUPPORT.keywords,+ action: { type: "sheet", sheet: { sheet: "support" } },+ },+ ...HELP_LINKS.map((link) => ({+ value: link.label,+ label: link.label,+ icon: link.icon,+ keywords: link.keywords,+ action: { type: "external" as const, href: link.href },+ })),+ ],+ };+}++export function themeGroup(+ resolvedTheme: string | undefined,+ setTheme: (t: string) => void,+): CommandMenuGroup {+ const target = resolvedTheme === "dark" ? "light" : "dark";+ return {+ heading: "Theme",+ items: [+ {+ value: "toggle-theme",+ label: `Switch to ${target} theme`,+ icon: resolvedTheme === "dark" ? Light : Dark,+ keywords: ["dark", "light", "appearance"],+ action: { type: "run", run: () => setTheme(target) },+ },+ ],+ };+}diff --git a/apps/dashboard/src/components/command-menu/groups/status-page-scope.ts b/apps/dashboard/src/components/command-menu/groups/status-page-scope.tsnew file mode 100644index 000000000..47974f6ec--- /dev/null+++ b/apps/dashboard/src/components/command-menu/groups/status-page-scope.ts@@ -0,0 +1,82 @@+import type { RouterOutputs } from "@openstatus/api";+import { Plus } from "lucide-react";++import { STATUS_PAGE_TABS } from "@/app/(dashboard)/status-pages/[id]/constants";++import type { CommandMenuGroup, CommandMenuItem, CommandPage } from "../types";+import { createMaintenanceItem, createStatusReportItem } from "./static";++type StatusReport = RouterOutputs["statusReport"]["list"][number];+type Maintenance = RouterOutputs["maintenance"]["list"][number];++export function statusPageScopeGroups({+ page,+ statusReports,+ maintenances,+}: {+ page: Extract<CommandPage, { type: "status-page" }>;+ statusReports: StatusReport[] | undefined;+ maintenances: Maintenance[] | undefined;+}): CommandMenuGroup[] {+ const pageReports = statusReports?.filter((r) => r.pageId === page.id) ?? [];+ const unresolvedReports = pageReports.filter((r) => r.status !== "resolved");+ const pageMaintenances =+ maintenances?.filter((m) => m.pageId === page.id) ?? [];++ const actionItems: CommandMenuItem[] = [+ createStatusReportItem(page.id),+ createMaintenanceItem(page.id),+ ...unresolvedReports.map((report) => ({+ value: `add-update-${report.id}`,+ label: `Add Update to ${report.title}`,+ icon: Plus,+ keywords: ["update", "status report update", report.title],+ action: {+ type: "sheet" as const,+ sheet: { sheet: "status-report-update" as const, reportId: report.id },+ },+ })),+ ];++ return [+ { heading: "Actions", items: actionItems },+ {+ heading: "Status Reports",+ items: pageReports.map((report) => ({+ value: `status-report-${report.id}`,+ label: report.title,+ description: report.status,+ keywords: [report.title, report.status],+ action: {+ type: "navigate",+ href: `/status-pages/${page.id}/status-reports/${report.id}`,+ },+ })),+ },+ {+ heading: "Maintenances",+ items: pageMaintenances.map((m) => ({+ value: `maintenance-${m.id}`,+ label: m.title,+ description: m.from.toLocaleString(),+ keywords: [m.title],+ action: {+ type: "navigate",+ href: `/status-pages/${page.id}/maintenances`,+ },+ })),+ },+ {+ heading: "Pages",+ items: STATUS_PAGE_TABS.map((tab) => ({+ value: tab.label,+ label: tab.label,+ icon: tab.icon,+ action: {+ type: "navigate",+ href: `/status-pages/${page.id}/${tab.value}`,+ },+ })),+ },+ ];+}diff --git a/apps/dashboard/src/components/command-menu/types.ts b/apps/dashboard/src/components/command-menu/types.tsnew file mode 100644index 000000000..df779a496--- /dev/null+++ b/apps/dashboard/src/components/command-menu/types.ts@@ -0,0 +1,48 @@+import type { IconType } from "@openstatus/icons";++// Shared across lucide + brand icons; keep in sync with the rest of the dashboard.+export type CommandIcon = IconType;++// Context each sheet needs when opened from the palette. Adding a sheet here+// extends both `CommandSheet` and the palette's ActiveSheet handling.+type CommandSheetContext = {+ "status-report": { pageId?: number };+ maintenance: { pageId?: number };+ support: Record<never, never>;+ "status-report-update": { reportId: number };+};++export type CommandSheet = {+ [K in keyof CommandSheetContext]: { sheet: K } & CommandSheetContext[K];+}[keyof CommandSheetContext];++export type CommandPage =+ | { type: "monitor"; id: number; name: string }+ | { type: "status-page"; id: number; title: string };++export function pageLabel(page: CommandPage): string {+ return page.type === "monitor" ? page.name : page.title;+}++export type CommandAction =+ | { type: "navigate"; href: string }+ | { type: "external"; href: string }+ | { type: "sheet"; sheet: CommandSheet }+ | { type: "push"; page: CommandPage }+ | { type: "run"; run: () => void };++export type CommandMenuItem = {+ value: string; // cmdk identity — must stay stable across renders+ label: string;+ description?: string; // muted mono second line+ icon?: CommandIcon;+ keywords?: string[];+ action: CommandAction;+};++export type CommandMenuGroup = {+ heading: string;+ items: CommandMenuItem[];+ // Cap shown items while the search input is empty (root entity groups).+ idleLimit?: number;+};diff --git a/apps/dashboard/src/components/command-menu/use-command-menu-data.ts b/apps/dashboard/src/components/command-menu/use-command-menu-data.tsnew file mode 100644index 000000000..7296f31ef--- /dev/null+++ b/apps/dashboard/src/components/command-menu/use-command-menu-data.ts@@ -0,0 +1,66 @@+"use client";++import { useQuery } from "@tanstack/react-query";++import { useTRPC } from "@/lib/trpc/client";++export function useCommandMenuData({ open }: { open: boolean }) {+ const trpc = useTRPC();++ // `enabled: open` keeps the always-mounted palette from fetching on every+ // dashboard load; data stays cached once fetched.+ const { data: monitors } = useQuery(+ trpc.monitor.list.queryOptions(undefined, { enabled: open }),+ );+ const { data: statusPages } = useQuery(+ trpc.page.list.queryOptions(undefined, { enabled: open }),+ );+ const { data: workspaces } = useQuery(+ trpc.workspace.list.queryOptions(undefined, { enabled: open }),+ );+ const { data: workspace } = useQuery(+ trpc.workspace.get.queryOptions(undefined, { enabled: open }),+ );+ // Inputs match the overview/create-sheet queries so create mutations+ // invalidate this cache entry too.+ const { data: statusReports } = useQuery(+ trpc.statusReport.list.queryOptions({}, { enabled: open }),+ );+ const { data: maintenances } = useQuery(+ trpc.maintenance.list.queryOptions(undefined, { enabled: open }),+ );++ const otherWorkspaces =+ workspaces?.filter((w) => w.slug !== workspace?.slug) ?? [];++ // Unresolved reports first; within each partition keep server order (desc).+ const sortedStatusReports = statusReports+ ? [+ ...statusReports.filter((r) => r.status !== "resolved"),+ ...statusReports.filter((r) => r.status === "resolved"),+ ]+ : undefined;++ // Upcoming/active maintenances first, then past (server order desc).+ // Orphans without a page are skipped — no route to navigate to.+ const now = Date.now();+ const withPage = maintenances?.filter((m) => m.pageId !== null);+ const sortedMaintenances = withPage+ ? [+ ...withPage.filter((m) => m.to.getTime() >= now),+ ...withPage.filter((m) => m.to.getTime() < now),+ ]+ : undefined;++ const pageTitleById = new Map(statusPages?.map((p) => [p.id, p.title]) ?? []);++ return {+ monitors,+ statusPages,+ statusReports,+ sortedStatusReports,+ sortedMaintenances,+ otherWorkspaces,+ pageTitleById,+ };+}diff --git a/apps/dashboard/src/components/forms/maintenance/sheet-create.tsx b/apps/dashboard/src/components/forms/maintenance/sheet-create.tsxindex b5135bfe4..e425f1567 100644--- a/apps/dashboard/src/components/forms/maintenance/sheet-create.tsx+++ b/apps/dashboard/src/components/forms/maintenance/sheet-create.tsx@@ -39,10 +39,13 @@ export function FormSheetMaintenanceCreate({children,open: controlledOpen,onOpenChange,+ defaultPageId,}: {children?: React.ReactNode;open?: boolean;onOpenChange?: (open: boolean) => void;+ /** Pre-scopes the sheet to a page and hides the selector. */+ defaultPageId?: number;}) {const [internalOpen, setInternalOpen] = useState(false);const open = controlledOpen ?? internalOpen;@@ -53,7 +56,8 @@ export function FormSheetMaintenanceCreate({const { data: pages } = useQuery(trpc.page.list.queryOptions());const pageId =- pages?.length === 1 ? pages[0].id : (selectedPageId ?? undefined);+ defaultPageId ??+ (pages?.length === 1 ? pages[0].id : (selectedPageId ?? undefined));const { data: page } = useQuery(trpc.page.get.queryOptions(@@ -91,7 +95,7 @@ export function FormSheetMaintenanceCreate({Configure and update the maintenance.</FormSheetDescription></FormSheetHeader>- {pages && pages.length > 1 ? (+ {defaultPageId === undefined && pages && pages.length > 1 ? (<><div className="grid gap-1.5 px-4 py-4"><Label htmlFor="maintenance-page-select">Status Page</Label>diff --git a/apps/dashboard/src/components/forms/status-report-update/sheet-create.tsx b/apps/dashboard/src/components/forms/status-report-update/sheet-create.tsxindex f1e11c6ff..6eaf03632 100644--- a/apps/dashboard/src/components/forms/status-report-update/sheet-create.tsx+++ b/apps/dashboard/src/components/forms/status-report-update/sheet-create.tsx@@ -14,9 +14,13 @@ type StatusReport = RouterOutputs["statusReport"]["list"][number];export function FormSheetStatusReportUpdateCreate({report,children,+ open,+ onOpenChange,}: {report: StatusReport;- children: React.ReactNode;+ children?: React.ReactNode;+ open?: boolean;+ onOpenChange?: (open: boolean) => void;}) {const trpc = useTRPC();const queryClient = useQueryClient();@@ -49,6 +53,8 @@ export function FormSheetStatusReportUpdateCreate({return (<FormSheetStatusReportUpdate+ open={open}+ onOpenChange={onOpenChange}defaultValues={{status: nextStatus,componentImpacts: reportComponents.map((c) => ({diff --git a/apps/dashboard/src/components/forms/status-report-update/sheet.tsx b/apps/dashboard/src/components/forms/status-report-update/sheet.tsxindex 9e10e3601..6c0d104be 100644--- a/apps/dashboard/src/components/forms/status-report-update/sheet.tsx+++ b/apps/dashboard/src/components/forms/status-report-update/sheet.tsx@@ -24,16 +24,24 @@ export function FormSheetStatusReportUpdate({onSubmit,components,allowUnsetImpacts,+ open: controlledOpen,+ onOpenChange,}: Omit<React.ComponentProps<typeof FormSheetTrigger>, "onSubmit"> & {defaultValues?: Partial<FormValues>;onSubmit: (values: FormValues) => Promise<void>;components?: { id: number; name: string }[];allowUnsetImpacts?: boolean;+ open?: boolean;+ onOpenChange?: (open: boolean) => void;}) {- const [open, setOpen] = useState(false);+ const [internalOpen, setInternalOpen] = useState(false);+ const open = controlledOpen ?? internalOpen;+ const setOpen = onOpenChange ?? setInternalOpen;return (<FormSheetWithDirtyProtection open={open} onOpenChange={setOpen}>- <FormSheetTrigger asChild>{children}</FormSheetTrigger>+ {children ? (+ <FormSheetTrigger asChild>{children}</FormSheetTrigger>+ ) : null}<FormSheetContent className="sm:max-w-lg"><FormSheetHeader><FormSheetTitle>Status Report Update</FormSheetTitle>diff --git a/apps/dashboard/src/components/forms/status-report/sheet-create.tsx b/apps/dashboard/src/components/forms/status-report/sheet-create.tsxindex 86be18f41..f23318cfe 100644--- a/apps/dashboard/src/components/forms/status-report/sheet-create.tsx+++ b/apps/dashboard/src/components/forms/status-report/sheet-create.tsx@@ -39,10 +39,13 @@ export function FormSheetStatusReportCreate({children,open: controlledOpen,onOpenChange,+ defaultPageId,}: {children?: React.ReactNode;open?: boolean;onOpenChange?: (open: boolean) => void;+ /** Pre-scopes the sheet to a page and hides the selector. */+ defaultPageId?: number;}) {const [internalOpen, setInternalOpen] = useState(false);const open = controlledOpen ?? internalOpen;@@ -56,7 +59,8 @@ export function FormSheetStatusReportCreate({);const pageId =- pages?.length === 1 ? pages[0].id : (selectedPageId ?? undefined);+ defaultPageId ??+ (pages?.length === 1 ? pages[0].id : (selectedPageId ?? undefined));const { data: page } = useQuery(trpc.page.get.queryOptions(@@ -104,7 +108,7 @@ export function FormSheetStatusReportCreate({Configure and update the status of your report.</FormSheetDescription></FormSheetHeader>- {pages && pages.length > 1 ? (+ {defaultPageId === undefined && pages && pages.length > 1 ? (<><div className="grid gap-1.5 px-4 py-4"><Label htmlFor="status-page-select">Status Page</Label>