* feat(dashboard): nous-blue theme, bulk sessions, schedule picker
Batch of related dashboard improvements gathered on
austin/fix/dashboard-changes:
* Nous Blue theme — faithful port of the LENS_5I overlay system onto
the existing DashboardTheme. Lifts the foreground inversion layer to
z-index 200 to fix the long-standing hover / loading visual artifact,
adds an explicit swatchColors slot so the theme picker shows the
post-inversion preview, and migrates the legacy "lens-5i" theme key
from localStorage / API to "nous-blue" on first read.
* Theme-aware series colors: new --series-input-token /
--series-output-token CSS vars consumed by Analytics + Models
charts; ToolCall + ModelInfoCard switched to semantic
--color-success for diff lines and the Tools capability badge.
* Analytics + Models headers: consolidate period selector + refresh
next to the page title and drop the redundant period badge.
* Bulk session management — "Delete empty (N)" button + per-row
checkboxes with shift-click range select and a bulk-delete action
bar. Backed by SessionDB.delete_sessions() /
delete_empty_sessions() plus POST /api/sessions/bulk-delete and
DELETE /api/sessions/empty (registered before the templated
/api/sessions/{session_id} family so they don't get shadowed).
Hard cap of 500 IDs per bulk request. Full pytest coverage.
* Cron page — human-readable schedule picker (every-interval / daily
/ weekly / monthly / once / custom) replaces the raw cron
expression input; the job list now renders "Weekly on Mon, Wed,
Fri at 14:30" instead of "30 14 * * 1,3,5". English-only ordinals
for monthly schedules so non-English locales don't get incorrect
suffixes.
* example-dashboard plugin moved from plugins/ to tests/fixtures/ so
stock installs no longer ship the demo. Tests install it
dynamically via a pytest fixture that also reorders the FastAPI
routes.
* i18n: 40+ new keys for the bulk-select UI and schedule
picker/describer translated across all 16 locales.
Co-authored-by: Cursor <cursoragent@cursor.com>
* refactor(dashboard): dedupe memory provider picker
The memory provider <Select> lived on both /system and /plugins,
writing the same config.yaml field through two different endpoints
with no cross-page refresh. Remove the picker from /system in favor
of a read-only status row + link to /plugins, where it pairs with
the context-engine picker under "Plugin providers".
/system retains the destructive admin controls (file sizes, Reset
MEMORY.md / USER.md / all). The api.setMemoryProvider client and
PUT /api/memory/provider backend endpoint are left in place for
CLI / script callers.
Co-authored-by: Cursor <cursoragent@cursor.com>
* docs(dashboard): address Copilot review on PR #37383
- Backdrop layer-stack comment claimed LENS_5I-style themes override
--component-backdrop-bg-blend-mode to multiply, but our only
LENS_5I-style theme (nous-blue) keeps the default difference.
Reword to describe what the code actually does and present the
var as a forward-looking extension hook.
- /api/sessions/bulk-delete docstring promised the response would
echo back the list of deleted IDs, but the implementation only
returns {ok, deleted}. Tighten the docstring to match the wire
format; the client already knows what it asked to delete, so the
IDs aren't needed.
Co-authored-by: Cursor <cursoragent@cursor.com>
* fix(dashboard): address copilot review on cron describe + bulk-select checkbox
- schedule.ts: restrict `describeCronExpression` to strictly 5-field cron
expressions. The backend `parse_schedule` also accepts the 6-field
`min hour dom month dow year` form, and humanising those by
destructuring only the first five fields would silently drop the year
(e.g. ``0 9 * * * 2099`` rendered as "Daily at 09:00"). 6+ field
expressions now fall through to the raw-string fallback so the user
sees what's actually scheduled.
- SessionsPage.tsx (SessionRow): wire the bulk-select Checkbox's
``onClick`` directly instead of attaching it to a parent ``<span>``
with a no-op ``onCheckedChange``. Radix forwards onClick to the
underlying ``<button role=checkbox>``, so the same handler now drives
both mouse clicks (preserving shift-key state for range select) and
keyboard activation (Space on the focused checkbox, which the browser
synthesises as a click on the <button>). Improves a11y / keyboard UX
without changing the controlled-selection model.
- SessionsPage.tsx: also extend ``SessionRowProps`` with the new
``onRename`` / ``onExport`` props introduced on main so the row's
destructured prop types resolve after the merge.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
254 lines
8.3 KiB
TypeScript
254 lines
8.3 KiB
TypeScript
import { useCallback, useEffect, useRef, useState } from "react";
|
|
import { createPortal } from "react-dom";
|
|
import { Palette, Check } from "lucide-react";
|
|
import { Button } from "@nous-research/ui/ui/components/button";
|
|
import { ListItem } from "@nous-research/ui/ui/components/list-item";
|
|
import { BottomSheet } from "@nous-research/ui/ui/components/bottom-sheet";
|
|
import { Typography } from "@nous-research/ui/ui/components/typography/index";
|
|
import { useBelowBreakpoint } from "@nous-research/ui/hooks/use-below-breakpoint";
|
|
import { BUILTIN_THEMES, useTheme } from "@/themes";
|
|
import type { DashboardTheme, ThemeListEntry } from "@/themes";
|
|
import { useI18n } from "@/i18n";
|
|
import { cn } from "@/lib/utils";
|
|
|
|
/**
|
|
* Compact theme picker mounted next to the language switcher in the header.
|
|
* Each dropdown row shows a 3-stop swatch (background / midground / warm
|
|
* glow) so users can preview the palette before committing. User-defined
|
|
* themes from `~/.hermes/dashboard-themes/*.yaml` use their API-provided
|
|
* definitions so they show real palette swatches just like built-ins.
|
|
*
|
|
* When placed at the bottom of a container (e.g. the sidebar rail), pass
|
|
* `dropUp` so the menu opens above the trigger instead of clipping below
|
|
* the viewport. On viewports below the `sm` breakpoint, `dropUp` uses a
|
|
* bottom sheet portaled to `document.body` so the picker is not clipped by
|
|
* the sidebar (same idea as a responsive Drawer).
|
|
*/
|
|
export function ThemeSwitcher({ collapsed = false, dropUp = false }: ThemeSwitcherProps) {
|
|
const { themeName, availableThemes, setTheme } = useTheme();
|
|
const { t } = useI18n();
|
|
const [open, setOpen] = useState(false);
|
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
const narrowViewport = useBelowBreakpoint(640);
|
|
const useMobileSheet = Boolean(dropUp && narrowViewport);
|
|
|
|
const close = useCallback(() => setOpen(false), []);
|
|
|
|
useEffect(() => {
|
|
if (!open) return;
|
|
const onKey = (e: KeyboardEvent) => {
|
|
if (e.key === "Escape") close();
|
|
};
|
|
document.addEventListener("keydown", onKey);
|
|
return () => document.removeEventListener("keydown", onKey);
|
|
}, [open, close]);
|
|
|
|
useEffect(() => {
|
|
if (!open || useMobileSheet) return;
|
|
const onMouseDown = (e: MouseEvent) => {
|
|
const target = e.target as Node;
|
|
if (wrapperRef.current?.contains(target)) return;
|
|
if (dropdownRef.current?.contains(target)) return;
|
|
close();
|
|
};
|
|
document.addEventListener("mousedown", onMouseDown);
|
|
return () => document.removeEventListener("mousedown", onMouseDown);
|
|
}, [open, close, useMobileSheet]);
|
|
|
|
const current = availableThemes.find((th) => th.name === themeName);
|
|
const label = current?.label ?? themeName;
|
|
const sheetTitle = t.theme?.title ?? "Theme";
|
|
|
|
return (
|
|
<div ref={wrapperRef} className="relative">
|
|
<Button
|
|
ghost
|
|
size={collapsed ? "icon" : undefined}
|
|
onClick={() => setOpen((o) => !o)}
|
|
className={cn(
|
|
collapsed
|
|
? "text-text-secondary hover:text-foreground hover:bg-transparent"
|
|
: "px-2 py-1 normal-case tracking-normal font-normal text-xs text-text-secondary hover:text-foreground",
|
|
)}
|
|
title={`${t.theme?.switchTheme ?? "Switch theme"}: ${label}`}
|
|
aria-label={t.theme?.switchTheme ?? "Switch theme"}
|
|
aria-expanded={open}
|
|
aria-haspopup="listbox"
|
|
>
|
|
<span className="inline-flex items-center gap-1.5">
|
|
<Palette className="h-3.5 w-3.5" />
|
|
|
|
{!collapsed && (
|
|
<Typography
|
|
mondwest
|
|
className="hidden sm:inline text-display tracking-wide text-xs"
|
|
>
|
|
{label}
|
|
</Typography>
|
|
)}
|
|
</span>
|
|
</Button>
|
|
|
|
{useMobileSheet && (
|
|
<BottomSheet
|
|
backdropDismissLabel={t.common.close}
|
|
onClose={close}
|
|
open={open}
|
|
title={sheetTitle}
|
|
>
|
|
<div aria-label={sheetTitle} role="listbox">
|
|
<ThemeSwitcherOptions
|
|
availableThemes={availableThemes}
|
|
close={close}
|
|
setTheme={setTheme}
|
|
themeName={themeName}
|
|
/>
|
|
</div>
|
|
</BottomSheet>
|
|
)}
|
|
|
|
{open && !useMobileSheet && (() => {
|
|
const rect = wrapperRef.current?.getBoundingClientRect();
|
|
const dropdown = (
|
|
<div
|
|
ref={dropdownRef}
|
|
aria-label={sheetTitle}
|
|
className={cn(
|
|
"min-w-[240px] max-h-[70dvh] overflow-y-auto",
|
|
"border border-current/20 bg-background-base/95 backdrop-blur-sm",
|
|
"shadow-[0_12px_32px_-8px_rgba(0,0,0,0.6)]",
|
|
dropUp ? "fixed z-[100]" : "absolute z-50 right-0 top-full mt-1",
|
|
)}
|
|
role="listbox"
|
|
style={
|
|
dropUp && rect
|
|
? { bottom: window.innerHeight - rect.top + 4, left: rect.left }
|
|
: undefined
|
|
}
|
|
>
|
|
<div className="border-b border-current/20 px-3 py-2">
|
|
<Typography
|
|
mondwest
|
|
className="text-display text-xs tracking-[0.12em] text-text-tertiary"
|
|
>
|
|
{sheetTitle}
|
|
</Typography>
|
|
</div>
|
|
|
|
<ThemeSwitcherOptions
|
|
availableThemes={availableThemes}
|
|
close={close}
|
|
setTheme={setTheme}
|
|
themeName={themeName}
|
|
/>
|
|
</div>
|
|
);
|
|
return dropUp ? createPortal(dropdown, document.body) : dropdown;
|
|
})()}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ThemeSwitcherOptions({
|
|
availableThemes,
|
|
close,
|
|
setTheme,
|
|
themeName,
|
|
}: ThemeSwitcherOptionsProps) {
|
|
return (
|
|
<>
|
|
{availableThemes.map((th) => {
|
|
const isActive = th.name === themeName;
|
|
const paletteTheme = BUILTIN_THEMES[th.name] ?? th.definition;
|
|
|
|
return (
|
|
<ListItem
|
|
active={isActive}
|
|
aria-selected={isActive}
|
|
className="gap-3"
|
|
key={th.name}
|
|
onClick={() => {
|
|
setTheme(th.name);
|
|
close();
|
|
}}
|
|
role="option"
|
|
>
|
|
{paletteTheme ? (
|
|
<ThemeSwatch theme={paletteTheme} />
|
|
) : (
|
|
<PlaceholderSwatch />
|
|
)}
|
|
|
|
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
|
<Typography
|
|
mondwest
|
|
className="truncate text-display text-xs tracking-wide"
|
|
>
|
|
{th.label}
|
|
</Typography>
|
|
{th.description && (
|
|
<Typography className="truncate text-xs tracking-normal text-text-tertiary">
|
|
{th.description}
|
|
</Typography>
|
|
)}
|
|
</div>
|
|
|
|
<Check
|
|
className={cn(
|
|
"h-3 w-3 shrink-0 text-midground",
|
|
isActive ? "opacity-100" : "opacity-0",
|
|
)}
|
|
/>
|
|
</ListItem>
|
|
);
|
|
})}
|
|
</>
|
|
);
|
|
}
|
|
|
|
function ThemeSwatch({ theme }: { theme: DashboardTheme }) {
|
|
// Inverted themes (Nous Blue / future lens themes) author their palette
|
|
// pre-inversion — `#FFAC02` reads as `#0053FD` blue once the foreground-
|
|
// difference layer flips the page. The picker can't replay that math
|
|
// cheaply, so themes opt-in to an explicit `swatchColors` triplet that
|
|
// mirrors the on-screen result. Falls back to the raw palette hexes for
|
|
// every other theme so existing dark-theme swatches are untouched.
|
|
const [c1, c2, c3] = theme.swatchColors ?? [
|
|
theme.palette.background.hex,
|
|
theme.palette.midground.hex,
|
|
theme.palette.warmGlow,
|
|
];
|
|
return (
|
|
<div
|
|
aria-hidden
|
|
className="flex h-4 w-9 shrink-0 overflow-hidden border border-current/20"
|
|
>
|
|
<span className="flex-1" style={{ background: c1 }} />
|
|
<span className="flex-1" style={{ background: c2 }} />
|
|
<span className="flex-1" style={{ background: c3 }} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function PlaceholderSwatch() {
|
|
return (
|
|
<div
|
|
aria-hidden
|
|
className="h-4 w-9 shrink-0 border border-dashed border-current/20"
|
|
/>
|
|
);
|
|
}
|
|
|
|
interface ThemeSwitcherOptionsProps {
|
|
availableThemes: ThemeListEntry[];
|
|
close: () => void;
|
|
setTheme: (name: string) => void;
|
|
themeName: string;
|
|
}
|
|
|
|
interface ThemeSwitcherProps {
|
|
collapsed?: boolean;
|
|
dropUp?: boolean;
|
|
}
|