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: 2 additions & 2 deletions changelog.d/app-on-a-paired-mac.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### The app on a paired Mac offers Start serving, and its lines say what happened

- On a Mac in a two-Mac pair, the app's Autopilot was a dead end. Onboarding's **Start serving with Autopilot** first downloaded a model, then showed three lines meant for the command line, and **Retry** showed them again. Autopilot chooses the models of one Mac, so on a paired Mac it is now refused before anything downloads, in words the app shows: "This Mac serves in a pair; Autopilot isn't available for pairs yet. Use Start serving." The Autopilot page's model refresh is refused the same way.
- The app now offers **Start serving** on a paired Mac, which starts the pair. Its onboarding says "This Mac serves in a pair. Start serving starts the pair with <model>.", and it starts the pair without naming a model or a local API of its own. When the pair has no model yet, it says so in one line: "No model was chosen for the pair yet: run `darkbloom start` in a terminal to choose one." The Mac tells the app it is in a pair, so even an app from before this offers the plain start there.
- On a Mac in a two-Mac pair, the app's Autopilot was a dead end. Onboarding's **Start serving with Autopilot** first downloaded a model, then showed three lines meant for the command line, and **Retry** showed them again. Autopilot chooses the models of one Mac, so on a paired Mac it is now refused before anything downloads, in words the app shows: the pair's state and what works there, for example "This Mac is in a pair, which is stopped; Autopilot isn't available for pairs yet. Use Start serving." The Autopilot page's model refresh is refused the same way.
- The app now offers **Start serving** on a paired Mac, which starts the pair. Its onboarding says the pair's state and what Start serving does there, for example "This Mac is in a pair, which is stopped. Start serving starts it with <model>." ("This Mac serves in a pair …" only while it serves), and it starts the pair without naming a model or a local API of its own. When the pair has no model yet, the page offers no Start serving: it says to choose one with “darkbloom cluster” in Terminal on the Mac that leads the pair. The Mac tells the app it is in a pair, so even an app from before this offers the plain start there.
- After the app's Start on a paired Mac, its last lines say what happened. When the app named another model, the pair "serves" its own model, or "was asked to start" with it and "isn't serving" when it doesn't serve yet. Before, it said "serves in a pair: started the pair" in both cases, and also for a pair that was already running. When the app asked for a local API that the pair doesn't give this Mac, it now says "No local API was added on this Mac", with where to change how the pair serves.
- When the app's runtime refuses an action, the app's notice now shows only the refusal's own words, without "Error invoking remote method …" in front of them.
- When a pair's other Mac isn't answering and this Mac's part was given up after 15 minutes, a start's `Next:` line and `cluster status --json`'s `next` now also name `darkbloom start --solo` to serve this Mac alone.
8 changes: 8 additions & 0 deletions changelog.d/pair-words-and-pause.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### A paired start says what it does, Apple's check reads as progress, and both Macs show the pause

- A script's `darkbloom start` on a pair that already serves now says `…: the pair already serves.`, shows the result block and exits 0, without asking either Mac to start again. Before, it said "starting the pair".
- `darkbloom start` in a terminal no longer says "starting the pair" before a screen where nothing starts until you choose. On the leading Mac of a stopped pair it says "Press Enter to start it with Qwen 3.8 27B (last used), or choose another model." (or "Choose its model to start it."), and otherwise "opening the pair's screen".
- During a normal pair start, each Mac's new part waits about a minute for Apple's check (App Attest). Status and a script's start now say `… is not serving yet: checking both Macs with Apple.`, read as loading. Before, every healthy start said "This Mac isn't verified by Apple yet; … Don't restart either Mac until then." for both Macs. That warning now comes only once a Mac's part has run 2 minutes without the check, or its key-generation safeguard holds it back.
- While a pair that serves Both, me first is paused for you, `darkbloom status` and `darkbloom cluster status` on the Mac that follows now say so under the pair's line too, with how long and when it comes back. Before, that Mac said only "✓ Serving … through Darkbloom". The leading Mac's status carries the pause, which the other Mac already asks for, so nothing new crosses the cable.
- A pair with no model yet: a script's `darkbloom start`, and the app, now say to choose one with `darkbloom cluster` in a terminal on the Mac that leads the pair, which has the model list: ``No model was chosen for the pair yet: choose one with `darkbloom cluster` in a terminal on this Mac.`` Before, they said to run `darkbloom start` in a terminal, which on the Mac that follows opens a screen that can't choose one.
- Pause times are said from now: "paused for 10 minutes", "back in about 2 minutes if you stay idle". Before, they were clock times in the Mac's own time zone, which no line named, such as "since 21:41" read over SSH at 05:41 UTC. This applies to one Mac's `Serving:` line and to the pair's `Pair:` line.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ function machineLine({ machine, eligibility }: Snapshot) {
}

function startingLine(snapshot: Snapshot, method: StartMethod, pinned: string[]) {
if (snapshot.pair) return `Starts the pair with ${pairModel(snapshot.pair)}, on both Macs.`;
if (snapshot.pair)
return snapshot.pair.state === 'serving'
? `Keeps the pair serving ${pairModel(snapshot.pair)}, on both Macs.`
: `Starts the pair with ${pairModel(snapshot.pair)}, on both Macs.`;
const ids = startModels(snapshot, method, pinned);
const chosen = snapshot.models.filter((model) => ids.includes(model.id));
if (!chosen.length) return 'Choose a model in Advanced to start.';
Expand Down
13 changes: 8 additions & 5 deletions desktop-app/src/renderer/components/onboarding/StartServing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { ServingSummary } from './ServingSummary';
import { pinnedMemory, startingModel } from '../../models/selection';
import {
methodFor,
pairModel,
pairBlocked,
pairLead,
pairStartable,
startAction,
startModels,
usablePins,
Expand All @@ -33,10 +35,11 @@ const copy: Record<StartMethod, { lead: string; start: string; empty: string }>
};

// A paired Mac starts its pair (`startAction`), never Autopilot, which serves one Mac: the plain
// start's page, with the pair's words.
// start's page, with the pair's words, and why there is no Start where the pair needs Terminal.
const pairCopy = (pair: NonNullable<Snapshot['pair']>) => ({
...copy.manual,
lead: `This Mac serves in a pair. Start serving starts the pair with ${pairModel(pair)}.`,
lead: pairLead(pair),
empty: pairBlocked(pair),
});

function accountLine(snapshot: Snapshot) {
Expand Down Expand Up @@ -75,7 +78,7 @@ export function StartServing({
const recommended =
method === 'autopilot' && !pins.length ? recommendedModels(snapshot.models, network) : [];
const showRecommendations = recommended.length > 0;
const empty = !pair && !startModels(snapshot, method, pinned).length;
const empty = pair ? !pairStartable(pair) : !startModels(snapshot, method, pinned).length;
const tooLarge = pinnedMemory(snapshot, pins).exceeds;
const running = snapshot.operations.find((operation) => operation.state === 'running');
// Serving needs a linked account: an unlinked Mac goes back to link it first.
Expand All @@ -86,7 +89,7 @@ export function StartServing({
{!showRecommendations && (
<>
<p>{text.lead}</p>
<ServingSummary snapshot={snapshot} method={method} pinned={pins} />
{!(pair && empty) && <ServingSummary snapshot={snapshot} method={method} pinned={pins} />}
</>
)}
{serving.rejected && method === 'manual' && (
Expand Down
46 changes: 45 additions & 1 deletion desktop-app/src/renderer/components/onboarding/startPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,52 @@ export function startModels(snapshot: Snapshot, method: StartMethod, pinned: str
return model ? [model.id] : [];
}

type Pair = NonNullable<Snapshot['pair']>;

// How onboarding names the pair's model: its name, or "its model" before the pair has one.
export const pairModel = (pair: NonNullable<Snapshot['pair']>) => pair.model ?? 'its model';
export const pairModel = (pair: Pair) => pair.model ?? 'its model';

// Whether Start serving can start the pair. A pair with no model yet, or whose pairing record can't
// be read, needs Terminal first, so the page offers no Start there and says why: the runtime
// refused that Start (#1905's review).
export const pairStartable = (pair: Pair) => pair.model !== null && pair.state !== 'unreadable';

// Why the page offers no Start serving on this pair (`pairStartable`), under the button.
export const pairBlocked = (pair: Pair) =>
pair.state === 'unreadable'
? 'Check the pairing in Terminal first.'
: 'Choose the pair’s model in Terminal first.';

// Where the pair's model is chosen: on the Mac that leads it.
const leadingMac = (pair: Pair) =>
pair.leads === true
? 'on this Mac'
: pair.leads === false
? 'on the other Mac, which leads the pair'
: 'on the leading Mac';

// The pair as it is, from the runtime's own view, then what Start serving does there: "serves" only
// when the runtime says it serves (#1905's review). An older runtime says no state: its words are
// true in every state.
export function pairLead(pair: Pair): string {
if (pair.state === 'unreadable')
return 'This Mac’s pairing record couldn’t be read, so it may be in a pair. Run “darkbloom cluster” in Terminal on this Mac to check it.';
if (pair.model === null)
return `This Mac is in a pair that has no model yet. Choose one with “darkbloom cluster” in Terminal ${leadingMac(pair)}, then come back to Start serving.`;
const model = pair.model;
switch (pair.state) {
case 'serving':
return `This Mac serves in a pair with ${model}. Start serving keeps it serving.`;
case 'started':
return `This Mac is in a pair, started with ${model}. Start serving makes sure it serves.`;
case 'not_running':
return `This Mac is in a pair that isn’t running here. Start serving starts it with ${model}.`;
case 'stopped':
return `This Mac is in a pair, which is stopped. Start serving starts it with ${model}.`;
default:
return `This Mac is in a pair. Start serving starts the pair with ${model}.`;
}
}

// On a paired Mac a start starts the pair, never this Mac alone, and the pair serves its own model
// and its own local API, so the action names neither.
Expand Down
13 changes: 9 additions & 4 deletions desktop-app/src/shared/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ export interface Snapshot {
account_revision?: string;
resource_revision?: string;
capabilities?: string[];
// The two-Mac pair this Mac is in, with its model (the name, else the ID; null until the pair
// has one). Null when this Mac isn't paired; absent from older runtimes. Start serving starts
// the pair.
pair?: { model: string | null } | null;
// The two-Mac pair this Mac is in: its model (the name, else the ID; null until the pair has
// one), its state from this Mac's own view, and whether this Mac leads it, so chooses its model
// (null when not known). Null when this Mac isn't paired; absent from older runtimes, and
// `state` and `leads` from runtimes before they were reported. Start serving starts the pair.
pair?: {
model: string | null;
state?: 'serving' | 'started' | 'not_running' | 'stopped' | 'unreadable';
leads?: boolean | null;
} | null;
account?: {
signed_in: boolean;
email?: string | null;
Expand Down
2 changes: 1 addition & 1 deletion desktop-app/tests/actionRefusal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ afterEach(() => {
// with no model yet. The real `useBackend` and failure toast show only the action's own words.
it('shows a refused action’s own words in the failure toast, without Electron’s prefix', async () => {
const words =
'No model was chosen for the pair yet: run `darkbloom start` in a terminal to choose one.';
'No model was chosen for the pair yet: choose one with `darkbloom cluster` in a terminal on this Mac.';
const refusal = new Error(`Error invoking remote method 'backend:act': Error: ${words}`);
(window as any).darkbloom = {
status: async () => ({ state: 'ready' }),
Expand Down
42 changes: 41 additions & 1 deletion desktop-app/tests/onboarding.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ it('starts without overriding an automatic-update opt-out', async () => {
it('offers Start serving for the pair on a paired Mac, never Autopilot', async () => {
const { done } = toStartPage(pairedMac());
expect(
screen.getByText('This Mac serves in a pair. Start serving starts the pair with Qwen 3.8 27B.'),
screen.getByText(
'This Mac is in a pair, which is stopped. Start serving starts it with Qwen 3.8 27B.',
),
).toBeVisible();
expect(screen.getByText('Starts the pair with Qwen 3.8 27B, on both Macs.')).toBeVisible();
expect(screen.getByText('The pair keeps its model loaded until you change it.')).toBeVisible();
Expand All @@ -272,3 +274,41 @@ it('offers Start serving for the pair on a paired Mac, never Autopilot', async (
expect(api.act).not.toHaveBeenCalled();
await waitFor(() => expect(done).toHaveBeenCalled());
});

// The pair as it is: a pair that serves is kept serving, and the page says so (#1905's review).
it('says a serving pair serves, and that Start serving keeps it', () => {
toStartPage(pairedMac({ state: 'serving' }));
expect(
screen.getByText(
'This Mac serves in a pair with Qwen 3.8 27B. Start serving keeps it serving.',
),
).toBeVisible();
expect(screen.getByText('Keeps the pair serving Qwen 3.8 27B, on both Macs.')).toBeVisible();
expect(screen.getByRole('button', { name: /^Start serving/ })).toBeEnabled();
});

// A pair with no model yet, or a pairing record that can't be read: Start serving would be refused,
// so the page says what works first, in Terminal, and offers no Start (#1905's review).
it('offers no Start serving where the pair needs Terminal first, and says why', () => {
const noModel = toStartPage(pairedMac({ model: null, leads: false }));
expect(
screen.getByText(
'This Mac is in a pair that has no model yet. Choose one with “darkbloom cluster” in Terminal on the other Mac, which leads the pair, then come back to Start serving.',
),
).toBeVisible();
expect(screen.getByRole('button', { name: /^Start serving/ })).toBeDisabled();
expect(screen.getByText('Choose the pair’s model in Terminal first.')).toBeVisible();
expect(screen.queryByRole('region', { name: 'What happens next' })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: /^Start serving/ }));
expect(backend.act).not.toHaveBeenCalled();
expect(noModel.done).not.toHaveBeenCalled();
cleanup();
toStartPage(pairedMac({ model: null, state: 'unreadable', leads: null }));
expect(
screen.getByText(
'This Mac’s pairing record couldn’t be read, so it may be in a pair. Run “darkbloom cluster” in Terminal on this Mac to check it.',
),
).toBeVisible();
expect(screen.getByRole('button', { name: /^Start serving/ })).toBeDisabled();
expect(screen.getByText('Check the pairing in Terminal first.')).toBeVisible();
});
9 changes: 5 additions & 4 deletions desktop-app/tests/onboardingFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ export function snapshot(overrides: Partial<Snapshot> = {}): Snapshot {
};
}

// A Mac in a two-Mac pair, as the runtime reports it: it names the pair and its model, and offers
// no Autopilot, which serves one Mac.
export const pairedMac = () =>
// A Mac in a two-Mac pair, as the runtime reports it: it names the pair, its model, its state from
// this Mac's own view and whether this Mac leads it, and offers no Autopilot, which serves one Mac.
// Here the leading Mac of a stopped pair, unless `pair` says otherwise.
export const pairedMac = (pair: Partial<NonNullable<Snapshot['pair']>> = {}) =>
snapshot({
capabilities: ['account-signin', 'account-signout', 'request-history'],
pair: { model: 'Qwen 3.8 27B' },
pair: { model: 'Qwen 3.8 27B', state: 'stopped', leads: true, ...pair },
});

// As the runtime reports it: the only catalog model does not fit, so it is not eligible.
Expand Down
51 changes: 50 additions & 1 deletion desktop-app/tests/onboardingStartPlan.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { describe, expect, it } from 'vitest';
import { methodFor, pairModel, startAction } from '../src/renderer/components/onboarding/startPlan';
import {
methodFor,
pairLead,
pairModel,
pairStartable,
startAction,
} from '../src/renderer/components/onboarding/startPlan';
import { pinnedMemory, startingModel } from '../src/renderer/models/selection';
import { models, pairedMac, snapshot } from './onboardingFixtures';

Expand Down Expand Up @@ -124,4 +130,47 @@ describe('a paired Mac', () => {
expect(pairModel({ model: 'Qwen 3.8 27B' })).toBe('Qwen 3.8 27B');
expect(pairModel({ model: null })).toBe('its model');
});

// #1905's review: the page said “This Mac serves in a pair” whatever the pair's state.
it('says the pair as it is, and what Start serving does there', () => {
const pair = pairedMac().pair!;
expect(pairLead({ ...pair, state: 'serving' })).toBe(
'This Mac serves in a pair with Qwen 3.8 27B. Start serving keeps it serving.',
);
expect(pairLead({ ...pair, state: 'started', leads: false })).toBe(
'This Mac is in a pair, started with Qwen 3.8 27B. Start serving makes sure it serves.',
);
expect(pairLead({ ...pair, state: 'not_running' })).toBe(
'This Mac is in a pair that isn’t running here. Start serving starts it with Qwen 3.8 27B.',
);
expect(pairLead(pair)).toBe(
'This Mac is in a pair, which is stopped. Start serving starts it with Qwen 3.8 27B.',
);
// A runtime from before the state was reported: words that are true in every state.
expect(pairLead({ model: 'Qwen 3.8 27B' })).toBe(
'This Mac is in a pair. Start serving starts the pair with Qwen 3.8 27B.',
);
});

// #1905's review: a pair with no model yet was offered Start serving, which the runtime then
// refused. Its model is chosen in Terminal, on the Mac that leads the pair.
it('says what works first where Start serving can’t start the pair', () => {
const pair = pairedMac().pair!;
expect(pairLead({ ...pair, model: null })).toBe(
'This Mac is in a pair that has no model yet. Choose one with “darkbloom cluster” in Terminal on this Mac, then come back to Start serving.',
);
expect(pairLead({ ...pair, model: null, leads: false })).toBe(
'This Mac is in a pair that has no model yet. Choose one with “darkbloom cluster” in Terminal on the other Mac, which leads the pair, then come back to Start serving.',
);
expect(pairLead({ model: null })).toBe(
'This Mac is in a pair that has no model yet. Choose one with “darkbloom cluster” in Terminal on the leading Mac, then come back to Start serving.',
);
expect(pairLead({ model: null, state: 'unreadable', leads: null })).toBe(
'This Mac’s pairing record couldn’t be read, so it may be in a pair. Run “darkbloom cluster” in Terminal on this Mac to check it.',
);
expect(pairStartable(pair)).toBe(true);
expect(pairStartable({ model: 'Qwen 3.8 27B' })).toBe(true);
expect(pairStartable({ ...pair, model: null })).toBe(false);
expect(pairStartable({ model: null, state: 'unreadable', leads: null })).toBe(false);
});
});
Loading
Loading