Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/desktop/src/acp/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}

Expand Down
32 changes: 32 additions & 0 deletions apps/desktop/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion apps/desktop/src/lib/modelNames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
9 changes: 8 additions & 1 deletion apps/desktop/src/lib/modelNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions apps/desktop/src/state/widgetLayout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
removeWidget,
resizeWidget,
sameLayout,
stackWidget,
} from "./widgetLayout";

const ids = (layout: { id: string }[]) => layout.map((slot) => slot.id);
Expand Down Expand Up @@ -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({
Expand Down
50 changes: 44 additions & 6 deletions apps/desktop/src/state/widgetLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WidgetId, string> = {
Expand Down Expand Up @@ -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 {
Expand All @@ -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)];
}

Expand All @@ -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(),
)
);
}

Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/src/state/widgets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,18 @@ 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 },
{ key: "codex", turns: 1, tokens: 2, part: 0.125 },
]);
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],
]);
});

Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/state/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {
Expand Down
21 changes: 20 additions & 1 deletion apps/desktop/src/ui/DashboardCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,14 +52,16 @@ export function Card({
}) {
const placement = useWidgetPlacement();
const editClass = useWidgetEditClass();
const stack = useWidgetStack();
return (
<section
aria-label={label}
data-widget={useWidgetId()}
style={{ height: useCardHeight(), ...placement }}
className={cx(
"rc-overview-card flex min-w-0 flex-col overflow-hidden rounded-xl bg-surface p-3 ring-inset",
"rc-overview-card relative flex min-w-0 flex-col overflow-hidden rounded-xl bg-surface p-3 ring-inset",
editClass ?? "ring-1 ring-border",
stack?.turned && "rc-stack-turn",
)}
>
<div className="rc-overview-body flex min-h-0 flex-1 flex-col gap-2">
Expand All @@ -71,6 +74,7 @@ export function Card({
</div>
{children}
</div>
<StackDots />
</section>
);
}
Expand Down Expand Up @@ -172,3 +176,18 @@ export function CardRow({
export function CardList({ children }: { children: ReactNode }) {
return <div className="-mt-1 flex min-h-0 flex-1 flex-col">{children}</div>;
}

/** 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 (
<Tooltip label={title}>
<span className="flex h-[18px] shrink-0 items-center gap-1.5 rounded-full bg-accent/14 px-2 font-medium text-caption text-accent tabular">
<span className="relative flex size-1.5">
<span className="absolute inset-0 rounded-full bg-accent opacity-60 motion-safe:animate-ping" />
<span className="relative size-1.5 rounded-full bg-accent" />
</span>
{count} live
</span>
</Tooltip>
);
}
15 changes: 12 additions & 3 deletions apps/desktop/src/ui/DashboardCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -256,16 +258,21 @@ function ShareRow({
part,
value,
shade,
mark,
}: {
name: string;
part: number;
value: string;
shade: string;
mark?: ReactNode;
}) {
return (
<div className="flex h-8 min-w-0 shrink-0 flex-col justify-center gap-1">
<div className="flex min-w-0 items-baseline justify-between gap-2 text-callout">
<span className="truncate text-fg">{name}</span>
<div className="flex min-w-0 items-center justify-between gap-2 text-callout">
<span className="flex min-w-0 items-center gap-1.5">
{mark}
<span className="truncate text-fg">{name}</span>
</span>
<span className="shrink-0 text-caption text-fg-muted tabular">{value}</span>
</div>
<div className="h-1.5 w-full overflow-hidden rounded-full bg-fill-subtle">
Expand Down Expand Up @@ -318,6 +325,7 @@ export function ModelsCard({ month }: { month?: UsageRow[] }) {
<div>
<ShareRow
name={share.key}
mark={<ModelIcon name={share.key} size={13} />}
part={share.part}
shade={shareShade(index)}
value={`${sharePercent(share.part)}${priced}`}
Expand Down Expand Up @@ -367,6 +375,7 @@ export function HarnessesCard({ month }: { month?: UsageRow[] }) {
{shares.slice(0, legend).map((share, index) => (
<li key={share.key} className="flex h-[18px] min-w-0 items-center gap-2 text-callout">
<span className="size-2 shrink-0 rounded-full" style={{ background: shareShade(index) }} />
<HarnessIcon id={share.key} name={names.get(share.key)} size={13} />
<span className="min-w-0 flex-1 truncate text-fg">{names.get(share.key) ?? share.key}</span>
<span className="shrink-0 text-caption text-fg-muted tabular">
{sharePercent(share.part)}
Expand Down
8 changes: 6 additions & 2 deletions apps/desktop/src/ui/DashboardWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
CardList,
CardRow,
LabelNote,
LivePill,
Nothing,
ROW_HEIGHT,
TWO_LINE_ROW_HEIGHT,
Expand Down Expand Up @@ -566,8 +567,11 @@ function RunningCard() {
label="Running now"
icon={Play}
aside={
more > 0 ? (
<LabelNote title={`${count(more, "more thread", "more threads")} running`}>+{more}</LabelNote>
threads.length > 0 ? (
<LivePill
count={threads.length}
title={more > 0 ? `${count(more, "more thread", "more threads")} running` : "Turns running now"}
/>
) : undefined
}
>
Expand Down
Loading
Loading