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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased — desktop singular counts

- Use singular nouns for counts of one: “1 Mac” on Home, “Show 1 more model” on Models, “1 download” in model recommendations, the Stats chart and token-bar descriptions, and “1 request processing” in live activity.

## Unreleased — desktop hardware load

- Serve real whole-machine load to the desktop app over the authenticated loopback control API: per-core CPU load with the chip's tier and cluster layout (including M5 Super cores), GPU utilization and memory, ANE activity, memory use and pressure, thermal state, and Darkbloom's share of GPU time. Sampling runs in the desktop API process only while the app is looking, without root, and never reaches heartbeats, logs or the coordinator.
Expand Down
4 changes: 2 additions & 2 deletions desktop-app/src/renderer/features/home/FleetMacs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { machineStatus } from '../../presentation/status';
import { useState } from 'react';
import { Search } from 'lucide-react';
import type { Machine } from '../../../shared/contracts';
import { money } from '../../format';
import { money, plural } from '../../format';
import { Empty, Status } from '../../components/UI';
import { MachineIcon } from '../machines/MachineIcon';
import { isOnline, memoryLabel } from '../machines/fleet';
Expand Down Expand Up @@ -30,7 +30,7 @@ export function FleetMacs({
<section aria-label="Your Macs">
<div className={styles.listHeading}>
<h3>Your Macs</h3>
<span>{machines.length} Macs</span>
<span>{plural(machines.length, 'Mac')}</span>
</div>
<div className={styles.filters}>
<label className="search">
Expand Down
2 changes: 1 addition & 1 deletion desktop-app/src/renderer/features/insights/LiveModels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function LiveModels({ state }: { state: Snapshot }) {
<div className={styles.liveSummary}>
<strong>{stale ? '—' : running}</strong>
<span>
requests processing
{!stale && running === 1 ? 'request' : 'requests'} processing
<br />
<span className="muted">Live activity</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useId, useState, type ReactNode } from 'react';
import { ChevronDown } from 'lucide-react';
import styles from './expandableModels.module.css';
import { plural } from '../../format';

export function ExpandableModelList<T>({
items,
Expand All @@ -24,7 +25,7 @@ export function ExpandableModelList<T>({
aria-controls={listId}
onClick={() => setExpanded(!expanded)}
>
{expanded ? 'Show fewer models' : `Show ${extra} more models`}
{expanded ? 'Show fewer models' : `Show ${plural(extra, 'more model', 'more models')}`}
<ChevronDown size={16} />
</button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Check, Download, Sparkles } from 'lucide-react';
import type { NativeModel, Snapshot } from '../../../shared/contracts';
import { Button } from '../../components/UI';
import { gigabytes } from '../../models/facts';
import { money } from '../../format';
import { money, plural } from '../../format';
import type { AutopilotAction } from '../../../shared/autopilot';
import { recommendedStart } from './recommendations';
import type { ModelActions } from './useModelActions';
Expand Down Expand Up @@ -111,7 +111,7 @@ export function RecommendedModels({
{setup && (
<footer>
{missing.length
? `${missing.length} downloads · ${gigabytes(missing.reduce((total, model) => total + model.size_gb, 0))} total`
? `${plural(missing.length, 'download')} · ${gigabytes(missing.reduce((total, model) => total + model.size_gb, 0))} total`
: 'No downloads needed'}
</footer>
)}
Expand Down
4 changes: 2 additions & 2 deletions desktop-app/src/renderer/features/stats/RequestCurve.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useId, useState } from 'react';
import { compact, timeOfDay } from '../../format';
import { compact, plural, timeOfDay } from '../../format';
import { curve, type TrafficPoint } from './data';
import styles from './stats.module.css';

Expand Down Expand Up @@ -62,7 +62,7 @@ export function RequestCurve({ points }: { points: TrafficPoint[] }) {
{points.map((p, i) => (
<button
key={p.at}
aria-label={`${timeOfDay(p.at)}: ${compact(p.requests)} requests`}
aria-label={`${timeOfDay(p.at)}: ${plural(p.requests, 'request', 'requests', compact)}`}
onFocus={() => setSelected(i)}
onMouseEnter={() => setSelected(i)}
onClick={() => setSelected(i)}
Expand Down
4 changes: 2 additions & 2 deletions desktop-app/src/renderer/features/stats/tokenSeries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { count } from '../../format';
import { count, plural } from '../../format';
import type { TrafficPoint } from './data';

export const MAX_TOKEN_BARS = 48;
Expand Down Expand Up @@ -52,6 +52,6 @@ export function describeTokenBar(bar: TokenBar) {
`Input ${amount(bar.input)}`,
`Cached input ${amount(bar.cached)}`,
`Output ${amount(bar.output)}`,
`Total ${count(bar.total)} tokens`,
`Total ${plural(bar.total, 'token')}`,
].join(' · ');
}
8 changes: 8 additions & 0 deletions desktop-app/src/renderer/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ export function gb(n?: number) {
}

export const shortModelName = (id: string) => id.split('/').pop() || id;

/** “1 Mac”, “2 Macs”: a formatted count and the noun that agrees with it. */
export const plural = (
value: number,
one: string,
many = `${one}s`,
format: (value: number) => string = count,
) => `${format(value)} ${value === 1 ? one : many}`;
63 changes: 63 additions & 0 deletions desktop-app/tests/pluralization.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// @vitest-environment jsdom
import { afterEach, expect, it } from 'vitest';
import { cleanup, render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/vitest';
import { compact, plural } from '../src/renderer/format';
import { FleetMacs } from '../src/renderer/features/home/FleetMacs';
import { LiveModels } from '../src/renderer/features/insights/LiveModels';
import { ExpandableModelList } from '../src/renderer/features/models/ExpandableModelList';
import { describeTokenBar, tokenBars } from '../src/renderer/features/stats/tokenSeries';
import type { Machine, Snapshot } from '../src/shared/contracts';

afterEach(cleanup);

it('agrees nouns with their counts', () => {
expect(plural(1, 'Mac')).toBe('1 Mac');
expect(plural(2, 'Mac')).toBe('2 Macs');
expect(plural(0, 'download')).toBe('0 downloads');
expect(plural(1200, 'request', 'requests', compact)).toBe('1.2K requests');
expect(plural(12_345, 'token')).toBe('12,345 tokens');
});

it('says “1 Mac” for a single Mac', () => {
const mac = {
id: 'this-mac',
name: 'MacBook Pro',
chip: 'Apple M4 Max',
memory_gb: 64,
status: 'running',
models: [],
} as unknown as Machine;
render(<FleetMacs machines={[mac]} localID="this-mac" onOpen={() => {}} />);
expect(screen.getByText('1 Mac')).toBeVisible();
expect(screen.queryByText('1 Macs')).not.toBeInTheDocument();
});

it('offers “Show 1 more model” when one model is hidden', () => {
render(
<ExpandableModelList items={[1, 2, 3, 4]}>{(n) => <p key={n}>{n}</p>}</ExpandableModelList>,
);
expect(screen.getByRole('button', { name: 'Show 1 more model' })).toBeVisible();
});

it('describes a single-token bar in the singular', () => {
const [bar] = tokenBars([{ at: 0, requests: 1, tokens: 1, input: 0, cached: 0 }]);
expect(describeTokenBar(bar)).toContain('Total 1 token');
expect(describeTokenBar(bar)).not.toContain('1 tokens');
});

it('says “1 request processing” for a single live request', () => {
const now = Date.now() / 1000;
const state = {
state: 'running',
observed_at: now,
models: [],
activity: {
sampled_at: now,
models: [{ model: 'test', state: 'running', running: 1, waiting: 0 }],
},
} as unknown as Snapshot;
const { container } = render(<LiveModels state={state} />);
expect(container).toHaveTextContent('1request processing');
expect(container).not.toHaveTextContent('requests processing');
});
Loading