From f2cfb9bfc742707da21b7757ba16c9fd88e085ff Mon Sep 17 00:00:00 2001 From: LHaghfoss Date: Wed, 25 Nov 2026 23:06:12 +0100 Subject: [PATCH] feat(desktop): stack dashboard cards and mark models with their maker Cards can be stacked in one place and take turns every 8 seconds, with a dot indicator that counts down each turn. The Models card shows each maker's mark, the Harnesses legend each harness's, DeepSeek ids read as DeepSeek V4.1 Flash, and Running now shows a live pill. --- apps/desktop/src/acp/types.ts | 6 +- apps/desktop/src/index.css | 32 +++++ apps/desktop/src/lib/modelNames.test.ts | 7 +- apps/desktop/src/lib/modelNames.ts | 9 +- apps/desktop/src/state/widgetLayout.test.ts | 34 +++++ apps/desktop/src/state/widgetLayout.ts | 50 +++++++- apps/desktop/src/state/widgets.test.ts | 5 +- apps/desktop/src/state/widgets.ts | 3 +- apps/desktop/src/ui/DashboardCard.tsx | 21 +++- apps/desktop/src/ui/DashboardCards.tsx | 15 ++- apps/desktop/src/ui/DashboardWidgets.tsx | 8 +- apps/desktop/src/ui/ModelIcon.test.ts | 15 +++ apps/desktop/src/ui/ModelIcon.tsx | 32 +++++ apps/desktop/src/ui/WidgetGrid.tsx | 130 +++++++++++++++++--- apps/desktop/src/ui/WidgetStack.tsx | 73 +++++++++++ 15 files changed, 402 insertions(+), 38 deletions(-) create mode 100644 apps/desktop/src/ui/ModelIcon.test.ts create mode 100644 apps/desktop/src/ui/ModelIcon.tsx create mode 100644 apps/desktop/src/ui/WidgetStack.tsx diff --git a/apps/desktop/src/acp/types.ts b/apps/desktop/src/acp/types.ts index fddda0317..f61bf392b 100644 --- a/apps/desktop/src/acp/types.ts +++ b/apps/desktop/src/acp/types.ts @@ -2,7 +2,7 @@ // SwiftUI app's RustCodeKit (ACPTypes.swift, FileDiff.swift, SessionUsage.swift). import { isMcpApp, type McpApp, toolCallApp } from "../lib/mcpApp"; -import { modelTitle } from "../lib/modelNames"; +import { MODEL_ALIASES, modelTitle } from "../lib/modelNames"; import { basename, shortenHome } from "../lib/paths"; import { stripOutputFence } from "../lib/toolOutput"; import { arr, bool, type Json, type JsonObject, num, obj, rustcodeMeta, str } from "./jsonrpc"; @@ -393,9 +393,9 @@ export function projectName(cwd: string): string { return cwd ? basename(plain) || cwd : ""; } -/** `provider/model` reads as just the model, and a Claude id or alias as `Opus 5.5`. */ +/** `provider/model` reads as just the model (an alias such as `deepseek/flash` first stands for its model), and a Claude id or alias as `Opus 5.5`. */ export function modelName(model: string | undefined): string | undefined { - const name = model?.split("/").pop(); + const name = (model && (MODEL_ALIASES[model.toLowerCase()] ?? model))?.split("/").pop(); return name ? modelTitle(name) : name; } diff --git a/apps/desktop/src/index.css b/apps/desktop/src/index.css index 22e34ead3..99cf76894 100644 --- a/apps/desktop/src/index.css +++ b/apps/desktop/src/index.css @@ -1009,6 +1009,38 @@ .rc-dash-still .rc-dash-bar { animation: none; } +@keyframes rc-stack-turn { + from { + opacity: 0; + transform: translateY(10px) scale(0.985); + } +} +@keyframes rc-stack-fade { + from { + opacity: 0; + } +} +.rc-overview-card.rc-stack-turn > .rc-overview-body { + animation: rc-stack-turn 320ms var(--ease-snappy); +} +@keyframes rc-stack-progress { + from { + height: 0; + } + to { + height: 100%; + } +} +.rc-stack-progress { + animation-name: rc-stack-progress; + animation-timing-function: linear; + animation-fill-mode: forwards; +} +@media (prefers-reduced-motion: reduce) { + .rc-overview-card.rc-stack-turn > .rc-overview-body { + animation: rc-stack-fade 200ms ease-out; + } +} @media (prefers-reduced-motion: reduce) { .rc-dash-bar { animation: none; diff --git a/apps/desktop/src/lib/modelNames.test.ts b/apps/desktop/src/lib/modelNames.test.ts index bdbdbb4ce..fa6a7a2f8 100644 --- a/apps/desktop/src/lib/modelNames.test.ts +++ b/apps/desktop/src/lib/modelNames.test.ts @@ -35,9 +35,14 @@ describe("modelTitle", () => { expect(catalogModelTitle(undefined, harness)).toBeUndefined(); }); + test("names DeepSeek ids with the family's casing", () => { + expect(modelTitle("deepseek-v4.1-flash")).toBe("DeepSeek V4.1 Flash"); + expect(modelTitle("deepseek-flash")).toBe("DeepSeek Flash"); + expect(modelTitle("deepseek-chat")).toBe("DeepSeek Chat"); + }); + test("keeps other names and meaningful hyphens", () => { expect(modelTitle("gpt-oss-120b")).toBe("gpt-oss-120b"); - expect(modelTitle("deepseek-v4.1-flash")).toBe("deepseek-v4.1-flash"); expect(modelTitle("default")).toBe("default"); }); }); diff --git a/apps/desktop/src/lib/modelNames.ts b/apps/desktop/src/lib/modelNames.ts index e3040e224..99b6fc56a 100644 --- a/apps/desktop/src/lib/modelNames.ts +++ b/apps/desktop/src/lib/modelNames.ts @@ -20,7 +20,7 @@ const FAMILIES = new Set(["opus", "sonnet", "haiku", "fable"]); /** * A model as people read it: a Claude id or alias as `Opus 5.5` (`claude-opus-5-5`, `opus`, * `claude-sonnet-5.5`, `claude-opus-4-8-20260101`), with a `[1m]` context suffix kept as - * ` 1M`. Known GPT and Gemini ids use their family casing and a readable version. + * ` 1M`. Known GPT, Gemini and DeepSeek ids use their family casing and a readable version. * Unknown ids and catalog names keep their spelling. */ export function modelTitle(model: string): string { @@ -40,6 +40,13 @@ export function modelTitle(model: string): string { return `Gemini ${gemini[1]} ${variant}`; } + const deepseek = /^deepseek[- ](?:v(\d+(?:\.\d+)?)(?:[- ]|$))?([a-z]+(?:[- ][a-z]+)*)?$/i.exec(model); + if (deepseek && (deepseek[1] || deepseek[2])) { + const version = deepseek[1] ? ` V${deepseek[1]}` : ""; + const variant = deepseek[2] ? ` ${deepseek[2].split(/[- ]+/).map(titleWord).join(" ")}` : ""; + return `DeepSeek${version}${variant}`; + } + const context = /\[(\d+)m\]$/i.exec(model); const bare = context ? model.slice(0, context.index) : model; const id = MODEL_ALIASES[bare.toLowerCase()] ?? bare; diff --git a/apps/desktop/src/state/widgetLayout.test.ts b/apps/desktop/src/state/widgetLayout.test.ts index 312b5756b..e6a651aa5 100644 --- a/apps/desktop/src/state/widgetLayout.test.ts +++ b/apps/desktop/src/state/widgetLayout.test.ts @@ -15,6 +15,7 @@ import { removeWidget, resizeWidget, sameLayout, + stackWidget, } from "./widgetLayout"; const ids = (layout: { id: string }[]) => layout.map((slot) => slot.id); @@ -101,6 +102,39 @@ describe("arranging", () => { }); }); +describe("stacks", () => { + test("stack a card into another's place, taking it from where it was", () => { + const stacked = stackWidget(DEFAULT_LAYOUT, "needs", "running"); + expect(ids(stacked)).not.toContain("running"); + expect(stacked.find((slot) => slot.id === "needs")?.stack).toEqual(["running"]); + expect(hiddenWidgets(stacked)).toEqual(["spend"]); + expect(addWidget(stacked, "running")).toHaveLength(stacked.length); + expect(sameLayout(stacked, DEFAULT_LAYOUT)).toBe(false); + }); + + test("a stack's own card hands its place to the next, and the last one leaves a plain card", () => { + const stacked = stackWidget(stackWidget(DEFAULT_LAYOUT, "needs", "running"), "needs", "spend"); + const handed = removeWidget(stacked, "needs"); + expect(handed.find((slot) => slot.id === "running")).toEqual({ + id: "running", + w: 1, + h: 1, + stack: ["spend"], + }); + expect(removeWidget(handed, "spend").find((slot) => slot.id === "running")).toEqual({ + id: "running", + w: 1, + h: 1, + }); + }); + + test("keeps a stored stack and drops its unknown or repeated cards", () => { + const layout = stored([{ id: "needs", w: 1, h: 1, stack: ["running", "nope", "needs", "running"] }]); + expect(layout).toEqual([{ id: "needs", w: 1, h: 1, stack: ["running"] }]); + expect(parseLayout(JSON.stringify(layout))).toEqual(layout); + }); +}); + describe("packing", () => { test("the default fills four rows of four with no hole", () => { expect(packLayout(DEFAULT_LAYOUT)).toEqual({ diff --git a/apps/desktop/src/state/widgetLayout.ts b/apps/desktop/src/state/widgetLayout.ts index a125146a7..568130e88 100644 --- a/apps/desktop/src/state/widgetLayout.ts +++ b/apps/desktop/src/state/widgetLayout.ts @@ -29,6 +29,16 @@ export interface WidgetSlot { id: WidgetId; w: WidgetExtent; h: WidgetExtent; + /** The other cards stacked in this place, which take turns with `id` (a stack, as on iOS). */ + stack?: WidgetId[]; +} + +/** How long a stack shows one card before it turns to the next, in milliseconds. */ +export const STACK_INTERVAL_MS = 8000; + +/** The cards a place holds, its own first. */ +export function stackMembers(slot: WidgetSlot): WidgetId[] { + return [slot.id, ...(slot.stack ?? [])]; } export const WIDGET_NAMES: Record = { @@ -101,8 +111,15 @@ export function parseLayout(raw: string | null): WidgetSlot[] { const id = typeof stored === "string" ? (RENAMED[stored] ?? stored) : stored; if (!isWidgetId(id) || seen.has(id)) continue; seen.add(id); - const { w, h } = item as { w?: unknown; h?: unknown }; - slots.push(isExtent(w) && isExtent(h) && id === stored ? { id, w, h } : slotOf(id)); + const { w, h, stack } = item as { w?: unknown; h?: unknown; stack?: unknown }; + const slot = isExtent(w) && isExtent(h) && id === stored ? { id, w, h } : slotOf(id); + const members: WidgetId[] = []; + for (const member of Array.isArray(stack) ? stack : []) { + if (!isWidgetId(member) || seen.has(member)) continue; + seen.add(member); + members.push(member); + } + slots.push(members.length ? { ...slot, stack: members } : slot); } return slots; } catch { @@ -120,12 +137,27 @@ export function moveWidget(layout: readonly WidgetSlot[], id: WidgetId, index: n return rest; } +/** The layout without `id`: a stacked card leaves its stack, and a stack's own card hands the place to the next. */ export function removeWidget(layout: readonly WidgetSlot[], id: WidgetId): WidgetSlot[] { - return layout.filter((slot) => slot.id !== id); + return layout.flatMap((slot) => { + const members = stackMembers(slot); + if (!members.includes(id)) return [slot]; + const [first, ...rest] = members.filter((member) => member !== id); + if (!first) return []; + return [rest.length ? { ...slot, id: first, stack: rest } : { id: first, w: slot.w, h: slot.h }]; + }); +} + +/** The layout with `id` stacked into the place `target` holds, taken from wherever it was. */ +export function stackWidget(layout: readonly WidgetSlot[], target: WidgetId, id: WidgetId): WidgetSlot[] { + if (target === id) return [...layout]; + const without = removeWidget(layout, id); + if (!without.some((slot) => slot.id === target)) return [...layout]; + return without.map((slot) => (slot.id === target ? { ...slot, stack: [...(slot.stack ?? []), id] } : slot)); } export function addWidget(layout: readonly WidgetSlot[], id: WidgetId): WidgetSlot[] { - if (layout.some((slot) => slot.id === id)) return [...layout]; + if (layout.some((slot) => stackMembers(slot).includes(id))) return [...layout]; return [...layout, slotOf(id)]; } @@ -148,13 +180,19 @@ export function resizeWidget(layout: readonly WidgetSlot[], id: WidgetId): Widge /** The cards the layout leaves out, in the catalogue's order, for the add tray. */ export function hiddenWidgets(layout: readonly WidgetSlot[]): WidgetId[] { - return WIDGET_IDS.filter((id) => !layout.some((slot) => slot.id === id)); + return WIDGET_IDS.filter((id) => !layout.some((slot) => stackMembers(slot).includes(id))); } export function sameLayout(one: readonly WidgetSlot[], other: readonly WidgetSlot[]): boolean { return ( one.length === other.length && - one.every((slot, i) => slot.id === other[i]?.id && slot.w === other[i]?.w && slot.h === other[i]?.h) + one.every( + (slot, i) => + slot.id === other[i]?.id && + slot.w === other[i]?.w && + slot.h === other[i]?.h && + (slot.stack ?? []).join() === (other[i]?.stack ?? []).join(), + ) ); } diff --git a/apps/desktop/src/state/widgets.test.ts b/apps/desktop/src/state/widgets.test.ts index dcd541075..0931d5831 100644 --- a/apps/desktop/src/state/widgets.test.ts +++ b/apps/desktop/src/state/widgets.test.ts @@ -239,6 +239,8 @@ describe("the dashboard's splits", () => { row({ day: "2026-11-21", harness: "claude-code", model: undefined, turns: 3 }), row({ day: "2026-11-22", harness: "claude-code", model: "claude-opus-5-5", turns: 2 }), row({ day: "2026-11-23", harness: "claude-code", model: "opus", turns: 2 }), + row({ day: "2026-11-05", harness: "pi", model: "default", turns: 2 }), + row({ day: "2026-11-05", harness: "pi", model: "deepseek/flash", turns: 1 }), ]; expect(sharesBy(rows, "harness", "2026-11-10")).toEqual([ { key: "claude-code", turns: 7, tokens: 0, part: 0.875 }, @@ -246,8 +248,9 @@ describe("the dashboard's splits", () => { ]); expect(sharesBy(rows, "model").map((share) => [share.key, share.turns])).toEqual([ ["GPT 6 Luna", 10], + ["Default model", 5], ["Opus 5.5", 4], - ["Default model", 3], + ["DeepSeek V4.1 Flash", 1], ]); }); diff --git a/apps/desktop/src/state/widgets.ts b/apps/desktop/src/state/widgets.ts index 80032ac3f..196a83654 100644 --- a/apps/desktop/src/state/widgets.ts +++ b/apps/desktop/src/state/widgets.ts @@ -201,7 +201,8 @@ export interface Share { */ /** The name a row's model is counted under: ids and aliases of one model share it (`opus`, `claude-opus-5-5`). */ export function modelGroup(row: UsageRow): string { - return modelName(row.model) || "Default model"; + const name = modelName(row.model); + return name && name.toLowerCase() !== "default" ? name : "Default model"; } export function sharesBy(rows: readonly UsageRow[], key: "harness" | "model", since = ""): Share[] { diff --git a/apps/desktop/src/ui/DashboardCard.tsx b/apps/desktop/src/ui/DashboardCard.tsx index 3afc262ec..3bacf7cb6 100644 --- a/apps/desktop/src/ui/DashboardCard.tsx +++ b/apps/desktop/src/ui/DashboardCard.tsx @@ -14,6 +14,7 @@ import { useWidgetPlacement, WidgetChrome, } from "./WidgetGrid"; +import { StackDots, useWidgetStack } from "./WidgetStack"; /** A list row's height, one line or two, and what a card spends on its padding, label row and the gap under it. */ export const ROW_HEIGHT = 24; @@ -51,14 +52,16 @@ export function Card({ }) { const placement = useWidgetPlacement(); const editClass = useWidgetEditClass(); + const stack = useWidgetStack(); return (
@@ -71,6 +74,7 @@ export function Card({
{children} +
); } @@ -172,3 +176,18 @@ export function CardRow({ export function CardList({ children }: { children: ReactNode }) { return
{children}
; } + +/** A small floating pill for what is happening now: a dot that pings, and how many. */ +export function LivePill({ count, title }: { count: number; title: string }) { + return ( + + + + + + + {count} live + + + ); +} diff --git a/apps/desktop/src/ui/DashboardCards.tsx b/apps/desktop/src/ui/DashboardCards.tsx index ef6892a56..c0d48a20f 100644 --- a/apps/desktop/src/ui/DashboardCards.tsx +++ b/apps/desktop/src/ui/DashboardCards.tsx @@ -6,7 +6,7 @@ * and as many rows as its height holds. */ -import { useMemo } from "react"; +import { type ReactNode, useMemo } from "react"; import type { UsageRow } from "../acp/rustcode"; import { count } from "../lib/plural"; import { useInboxItems } from "../state/inboxRead"; @@ -26,7 +26,9 @@ import { } from "../state/widgets"; import { Card, Nothing, useShownRows } from "./DashboardCard"; import { ColumnsSkeleton, FigureTileSkeleton, SharesSkeleton, SplitSkeleton } from "./DashboardSkeletons"; +import { HarnessIcon } from "./HarnessIcon"; import { Bot, CalendarDays, Layers, Sun } from "./icons"; +import { ModelIcon } from "./ModelIcon"; import { cx, Tooltip } from "./primitives"; import { shareShade, Tile, TrendPill } from "./StatisticsCharts"; import { useCardHeight, useWidgetColumns } from "./WidgetGrid"; @@ -256,16 +258,21 @@ function ShareRow({ part, value, shade, + mark, }: { name: string; part: number; value: string; shade: string; + mark?: ReactNode; }) { return (
-
- {name} +
+ + {mark} + {name} + {value}
@@ -318,6 +325,7 @@ export function ModelsCard({ month }: { month?: UsageRow[] }) {
} part={share.part} shade={shareShade(index)} value={`${sharePercent(share.part)}${priced}`} @@ -367,6 +375,7 @@ export function HarnessesCard({ month }: { month?: UsageRow[] }) { {shares.slice(0, legend).map((share, index) => (
  • + {names.get(share.key) ?? share.key} {sharePercent(share.part)} diff --git a/apps/desktop/src/ui/DashboardWidgets.tsx b/apps/desktop/src/ui/DashboardWidgets.tsx index 7e3d997ca..ed91a95c2 100644 --- a/apps/desktop/src/ui/DashboardWidgets.tsx +++ b/apps/desktop/src/ui/DashboardWidgets.tsx @@ -60,6 +60,7 @@ import { CardList, CardRow, LabelNote, + LivePill, Nothing, ROW_HEIGHT, TWO_LINE_ROW_HEIGHT, @@ -566,8 +567,11 @@ function RunningCard() { label="Running now" icon={Play} aside={ - more > 0 ? ( - +{more} + threads.length > 0 ? ( + 0 ? `${count(more, "more thread", "more threads")} running` : "Turns running now"} + /> ) : undefined } > diff --git a/apps/desktop/src/ui/ModelIcon.test.ts b/apps/desktop/src/ui/ModelIcon.test.ts new file mode 100644 index 000000000..8260c2eeb --- /dev/null +++ b/apps/desktop/src/ui/ModelIcon.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, test } from "bun:test"; +import { modelMaker } from "./ModelIcon"; + +describe("a model's maker", () => { + test("follows the family in its display name", () => { + expect(modelMaker("Opus 5.5")).toBe("claude"); + expect(modelMaker("Sonnet 5")).toBe("claude"); + expect(modelMaker("GPT 6.1 Sol")).toBe("codex"); + expect(modelMaker("Gemini 3 Pro")).toBe("gemini"); + }); + + test("leaves other models to their own letter", () => { + expect(modelMaker("DeepSeek V4.1 Flash")).toBe("deepseek v4.1 flash"); + }); +}); diff --git a/apps/desktop/src/ui/ModelIcon.tsx b/apps/desktop/src/ui/ModelIcon.tsx new file mode 100644 index 000000000..365e21ea1 --- /dev/null +++ b/apps/desktop/src/ui/ModelIcon.tsx @@ -0,0 +1,32 @@ +/** + * The mark beside a model's name: its maker's, drawn by `HarnessIcon` (Claude models the Claude + * mark, GPT and o-series models OpenAI's, Gemini models Gemini's), a letter in a square for any + * other model, and a sparkle for a harness's default model. + */ + +import { HarnessIcon } from "./HarnessIcon"; +import { Sparkles } from "./icons"; +import { cx } from "./primitives"; + +/** The harness id whose mark a model's maker shares, or the model itself for a letter. */ +export function modelMaker(name: string): string { + const key = name.toLowerCase(); + if (/\b(claude|opus|sonnet|haiku|fable)\b/.test(key)) return "claude"; + if (/\b(gpt|o\d|codex|chatgpt|openai)\b/.test(key)) return "codex"; + if (key.includes("gemini")) return "gemini"; + return key; +} + +export function ModelIcon({ + name, + size = 14, + className, +}: { + name: string; + size?: number; + className?: string; +}) { + if (name === "Default model") + return ; + return ; +} diff --git a/apps/desktop/src/ui/WidgetGrid.tsx b/apps/desktop/src/ui/WidgetGrid.tsx index c4e31e937..f1ecf253b 100644 --- a/apps/desktop/src/ui/WidgetGrid.tsx +++ b/apps/desktop/src/ui/WidgetGrid.tsx @@ -4,6 +4,7 @@ * added back from a gallery of the removed cards. The arrangement lives in `state/widgetLayout.ts`. */ +import { DropdownMenu } from "radix-ui"; import { type CSSProperties, createContext, @@ -31,6 +32,8 @@ import { resizeWidget, sameLayout, setWidgetLayout, + stackMembers, + stackWidget, useWidgetLayout, WIDGET_BLURBS, WIDGET_NAMES, @@ -38,8 +41,9 @@ import { type WidgetId, type WidgetSlot, } from "../state/widgetLayout"; -import { GripVertical, Plus, RotateCcw, SlidersHorizontal, X } from "./icons"; -import { cx, Pill, Tooltip } from "./primitives"; +import { GripVertical, Layers, Plus, RotateCcw, SlidersHorizontal, X } from "./icons"; +import { cx, MenuContent, menuItem, menuLabel, Pill, Tooltip } from "./primitives"; +import { StackContext, type StackState } from "./WidgetStack"; /** The grid's columns for its width: four on a wide window, two on a narrow one, one on a sliver. */ export function columnsFor(width: number): number { @@ -70,6 +74,8 @@ export function useWidgetsEditing(): boolean { interface Frame { slot: WidgetSlot; + /** The card the place shows now: its own, or one of its stack's. */ + shown: WidgetId; columns: number; index: number; editing: boolean; @@ -170,9 +176,11 @@ export function useWidgetEditClass(): string | undefined { export function WidgetChrome({ fallback }: { fallback?: ReactNode }) { const frame = useContext(FrameContext); if (!frame?.editing) return <>{fallback}; - const name = WIDGET_NAMES[frame.slot.id]; + const name = WIDGET_NAMES[frame.shown]; + const stacked = stackMembers(frame.slot).length > 1; return ( + - + + + + +
    Stack with {name}
    + {hidden.map((id) => ( + setWidgetLayout(stackWidget(getWidgetLayout(), slot.id, id))} + > + + {WIDGET_NAMES[id]} + {WIDGET_BLURBS[id]} + + + ))} +
    + + ); +} + +/** + * One place in the grid: a card, or a stack of cards that take turns. A stack turns to its next + * card when its indicator's countdown ends (`StackDots`), and holds still while the pointer or the + * focus is on it and in edit mode. + */ +function StackPlace({ + slot, + editing, + children, +}: { + slot: WidgetSlot; + editing: boolean; + children: (shown: WidgetId) => ReactNode; +}) { + const members = stackMembers(slot); + const [picked, setPicked] = useState<{ at: number; turned: boolean }>({ at: 0, turned: false }); + const [held, setHeld] = useState(false); + const at = picked.at % members.length; + const shown = members[at] ?? slot.id; + if (members.length < 2) return <>{children(shown)}; + const stack: StackState = { + members, + at, + turned: picked.turned, + paused: held || editing, + select: (index) => setPicked({ at: index, turned: true }), + advance: () => setPicked((was) => ({ at: (was.at + 1) % members.length, turned: true })), + }; + return ( +
    setHeld(true)} + onMouseLeave={() => setHeld(false)} + onFocus={() => setHeld(true)} + onBlur={(event) => { + if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setHeld(false); + }} + > + {children(shown)} +
    + ); +} + /** Moves cards that changed place from where they were, so a reorder slides instead of jumping. */ function useSlideOnReorder(order: string) { const grid = useRef(null); @@ -353,20 +440,25 @@ export function WidgetGrid({ aria-label="Activity, usage and recent work" > {layout.map((slot, index) => ( - - {render(slot.id)} - + + {(shown) => ( + + {render(shown)} + + )} + ))} {!isEditing && layout.length === 0 && (
    diff --git a/apps/desktop/src/ui/WidgetStack.tsx b/apps/desktop/src/ui/WidgetStack.tsx new file mode 100644 index 000000000..e83d674e3 --- /dev/null +++ b/apps/desktop/src/ui/WidgetStack.tsx @@ -0,0 +1,73 @@ +/** + * A dashboard stack's state and its floating indicator: a column of small dots at the card's + * right edge, one per card, the shown one a pill that fills as its turn runs out. A dot shows its + * card; the fill pauses while the stack is held (pointer, focus, edit mode). + */ + +import { createContext, useContext } from "react"; +import { STACK_INTERVAL_MS, WIDGET_NAMES, type WidgetId } from "../state/widgetLayout"; +import { cx, Tooltip } from "./primitives"; + +export interface StackState { + members: WidgetId[]; + at: number; + /** The stack has turned at least once, so the shown card arrives with the turn's motion. */ + turned: boolean; + paused: boolean; + select: (index: number) => void; + advance: () => void; +} + +export const StackContext = createContext(undefined); + +export function useWidgetStack(): StackState | undefined { + return useContext(StackContext); +} + +export function StackDots() { + const stack = useWidgetStack(); + if (!stack) return null; + return ( +
    + {stack.members.map((id, index) => { + const current = index === stack.at; + return ( + + + + ); + })} +
    + ); +}