Skip to content
Open
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
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

## Unreleased — macOS desktop app

- Use one bottom operation notification across Home, My Macs and its tabs, Leaderboard, Updates and onboarding. Dismiss success after ten seconds without restarting on navigation or state refresh, retain failures until Close, and route immediate action errors through the same popup. Preserve cancellation and expandable diagnostics; keep sign-in in its dedicated dialog.

- Show the signed-in email and status in the sidebar account control. Reuse the existing account-earnings response for verified identity, retain it across desktop restarts, truncate long addresses visually with their full value accessible, and clear it on sign-out. Add an optional owner email to the coordinator response; older coordinators keep the generic Account label.

- Replace backend event text with current desktop readiness and a loaded-model count; respect coordinator verification and offline status. Use product labels for operations, Mac/model activity, fan policy, model memory preferences, cached-data notices and connection/version descriptions. Keep diagnostic failure details accessible.
- Replace the sidebar machine-name card with a bottom-left account control. Sign in opens a connection-code modal with Copy code, Open sign-in, Cancel and retry; use a short instruction and a prominent Continue in browser button, then show waiting status after that click. Reopen pending approval across pages without duplicate requests, confirm completion in the dialog, and preserve automatic browser opening for CLI login.
- Replace Home's chip live-status label with a Cooling shortcut: blue while automatic provider cooling is enabled, and increasingly red above 60°C when disabled. Read the helper's enabled state independently of its current SMC mode; unavailable observations stay neutral.
- Fix desktop sign-in with existing coordinators by accepting their standard browser device-code grant into a separate dashboard credential. Prefer scoped account sessions when acknowledged, validate token scope, and preserve provider linkage and serving credentials.
- Show the top three Models rows by default, with a full-width expansion bar for the remaining models. Preserve ranking and reset the compact view when searching or changing filters.
- Fix Browse models crashing on unmeasured memory estimates from the native catalog. Treat null estimates as unknown and preserve the download-size fallback for pin capacity.
- Make Models Autopilot-first for new installations: open Your models by default, separate Browse models, recommend the top three compatible models by seven-day network inference earnings, and let users edit the downloads before starting. Keep personal earnings separate from network rankings. Add directly clickable Keep in memory and Download & keep in memory controls, observed residency, download progress and bounded pin capacity. Collapse descriptions and phase explanations.
- Connect desktop Autopilot enrollment, pinning, pause/resume, disabling and inventory refresh to the existing Swift CLI. Complete selected downloads before one enrollment, preserve startup/endpoint choices during noninteractive refresh, and reject removal of resident or advertised models. Add settled model payout aggregates to existing public stats; unavailable rankings remain unavailable.
- Keep Electron on the same `darkbloom` CLI backend. Swift owns coordinator requests, shared resource caches, browser account sign-in and sign-out, and catalog refresh independent of local snapshots. Add a separate read-only dashboard session with bounded expiry; provider credentials and serving stay independent. Reuse existing account/fleet and ledger APIs, including full 7/30-day aggregates through the existing earnings route. Refresh visible pages from the native clock, and use streamed operation progress with a polling fallback.

- Reorganize the Home chip panel into a larger diagram and a hardware/memory sidebar, with prominent GPU/CPU measurements and individually labeled model footprints. Move live status to the header and stack sections at narrow widths. Retry only the specific transient fan-ownership firmware restore failure through the verified signed CLI; preserve permanent hardware errors and distinguish canceled authorization.

- Populate this Mac’s Stats and Activity from verified existing settlement records, including exact input/output tokens, session earnings and model totals. Hide unavailable Home activity readouts; retain a seven-day earnings axis with explicit gaps for missing history. Use the verified signed installed runtime for fan status and cooling authorization, reflect its active policy, and restrict controls to the supported 60–90% range.

- Populate desktop account earnings, daily charts and model rankings by aggregating the existing account-earnings response when desktop-specific analytics are unavailable. Preserve authoritative lifetime totals, deduplicate settlements, separate base rewards, and label truncated history as recent rather than a complete week or month.

- Replace the desktop preview's step diagram with a continuous particle scene: incoming requests gather around orbiting model cores, then spread into token trails. Preserve pause, reduced-motion, inactive-provider, and off-screen behavior; keep illustrative motion separate from native activity.

- Replace Analysis with Stats and add a visual-first traffic preview with animated request stages, model traffic shares, an inspectable traffic curve, and milestones. Keep illustrative metrics confined to development preview; live mode uses existing native observations until richer APIs are added.
Expand All @@ -17,7 +37,7 @@

- Give This Mac's Overview a health bar (readiness with next steps, memory, and a fan that turns with reported RPM), per-Mac earnings and an hourly tokens-shared chart. Add a Stats Activity table of served-request metadata, show Tokens served as stacked input, cached input and output bars, make the view-only Mac page a compact read-only summary, and fit Cooling on one screen. Values the runtime does not report yet show as unavailable.

- Make Models Autopilot-first: downloading builds the pool, pinning keeps a model loaded, and runtimes with Autopilot off or unsupported keep manual selection. Replace the idle-memory select with a Keep models loaded switch and a custom duration, remove the Preload models option without changing its native value, and fix the switch geometry.
- Make Models Autopilot-first: downloading builds the pool, pinning protects a model from unloading during active Autopilot control, and runtimes with Autopilot explicitly off or unsupported keep manual selection. Replace the idle-memory select with a Keep models loaded switch and a custom duration, remove the Preload models option without changing its native value, and fix the switch geometry.

- Open onboarding with a paced eligibility scan that advances eligible Macs and explains why others can't serve yet, with an email waitlist. Merge model choice into one Start serving with Autopilot step with Advanced pinning, and fall back to manual selection on runtimes without Autopilot.

Expand Down
12 changes: 10 additions & 2 deletions console-ui/__tests__/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("BillingPage", () => {
describe("LinkPage", () => {
it("renders without crashing and shows heading", async () => {
const LinkPage = (await import("@/app/link/page")).default;
render(<LinkPage />);
render(await LinkPage({ searchParams: Promise.resolve({}) }));

expect(screen.getByText("Link Your Device")).toBeInTheDocument();
expect(
Expand All @@ -206,7 +206,7 @@ describe("LinkPage", () => {

it("shows the device code input form when authenticated", async () => {
const LinkPage = (await import("@/app/link/page")).default;
render(<LinkPage />);
render(await LinkPage({ searchParams: Promise.resolve({}) }));

// The DeviceLinkForm renders code input when authenticated
expect(
Expand All @@ -215,6 +215,14 @@ describe("LinkPage", () => {
expect(screen.getByPlaceholderText("XXXX-XXXX")).toBeInTheDocument();
expect(screen.getByText("Link Device")).toBeInTheDocument();
});
it("labels desktop authorization separately from provider linking", async () => {
const LinkPage = (await import("@/app/link/page")).default;
render(await LinkPage({ searchParams: Promise.resolve({ purpose: "desktop_account" }) }));
expect(screen.getByText("Sign in to Darkbloom Desktop")).toBeInTheDocument();
expect(screen.getByRole("button", { name: "Authorize Desktop" })).toBeInTheDocument();
expect(screen.queryByText("Link Device")).not.toBeInTheDocument();
});

});

// =========================================================================
Expand Down
23 changes: 11 additions & 12 deletions console-ui/src/app/link/DeviceLinkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { trackEvent } from "@/lib/google-analytics";

type LinkStatus = "idle" | "submitting" | "success" | "error";

export function DeviceLinkForm() {
export function DeviceLinkForm({ account = false }: { account?: boolean }) {
const { ready, authenticated, login, getAccessToken, user } = useAuthContext();
const [code, setCode] = useState("");
const [status, setStatus] = useState<LinkStatus>("idle");
Expand Down Expand Up @@ -41,7 +41,7 @@ export function DeviceLinkForm() {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
body: JSON.stringify({ user_code: code.trim().toUpperCase() }),
body: JSON.stringify({ user_code: code.trim().toUpperCase(), purpose: account ? "desktop_account" : "provider" }),
});

const data = await res.json();
Expand Down Expand Up @@ -71,7 +71,7 @@ export function DeviceLinkForm() {
setStatus("error");
}
},
[code, getAccessToken]
[code, getAccessToken, account]
);

// Format input as XXXX-XXXX
Expand Down Expand Up @@ -112,13 +112,12 @@ export function DeviceLinkForm() {
</svg>
</div>
<h2 className="text-2xl font-semibold text-ink mb-2">
Device Linked!
{account ? "Signed In!" : "Device Linked!"}
</h2>
<p className="text-text-secondary">
Your provider is now connected to your account. Earnings will be
credited automatically.
{account ? "Return to the desktop app to view your account." : "Your provider is now connected to your account. Earnings will be credited automatically."}
</p>
<p className="text-text-tertiary text-sm mt-4">Return to your terminal to finish starting the provider.</p>
{!account && <p className="text-text-tertiary text-sm mt-4">Return to your terminal to finish starting the provider.</p>}
<a href="/providers" className="mt-6 inline-flex min-h-11 items-center rounded-lg bg-accent-brand px-5 text-sm font-medium text-white dark:text-bg-primary">Open your provider workspace</a>
</div>
);
Expand All @@ -129,7 +128,7 @@ export function DeviceLinkForm() {
return (
<div className="bg-bg-white rounded-2xl border border-border-dim shadow-md p-8 text-center">
<p className="text-text-secondary mb-6">
Sign in to your Darkbloom account to link your device.
{account ? "Sign in to view your Macs and earnings." : "Sign in to your Darkbloom account to link your device."}
</p>
<button
onClick={() => {
Expand Down Expand Up @@ -163,7 +162,7 @@ export function DeviceLinkForm() {
htmlFor="device-code"
className="block text-sm font-semibold text-ink mb-2"
>
Enter the code shown in your terminal
{account ? "Enter the code shown in the desktop app" : "Enter the code shown in your terminal"}
</label>
<input
id="device-code"
Expand Down Expand Up @@ -194,17 +193,17 @@ export function DeviceLinkForm() {
hover:opacity-90
transition-all disabled:opacity-40 disabled:cursor-not-allowed"
>
{status === "submitting" ? "Linking..." : "Link Device"}
{status === "submitting" ? "Authorizing..." : account ? "Authorize Desktop" : "Link Device"}
</button>
</form>

<div className="mt-6 text-xs text-text-tertiary text-center">
{!account && <div className="mt-6 text-xs text-text-tertiary text-center">
Run{" "}
<code className="bg-bg-tertiary px-1.5 py-0.5 rounded font-mono text-coral border border-border-dim">
darkbloom login
</code>{" "}
on your Mac to get a code.
</div>
</div>}
</div>
);
}
12 changes: 5 additions & 7 deletions console-ui/src/app/link/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"use client";

import { DeviceLinkForm } from "./DeviceLinkForm";

export default function LinkPage() {
export default async function LinkPage({ searchParams }: { searchParams: Promise<{ purpose?: string }> }) {
const account = (await searchParams).purpose === "desktop_account";
return (
<div className="min-h-screen bg-bg-primary flex items-center justify-center p-4">
<div className="w-full max-w-md">
Expand All @@ -19,14 +18,13 @@ export default function LinkPage() {

<div className="text-center mb-8">
<h1 className="text-3xl font-semibold text-ink">
Link Your Device
{account ? "Sign in to Darkbloom Desktop" : "Link Your Device"}
</h1>
<p className="text-text-secondary mt-2">
Connect your Mac to your Darkbloom account to receive
earnings for providing compute.
{account ? "View your Macs and earnings." : "Connect your Mac to your Darkbloom account to receive earnings for providing compute."}
</p>
</div>
<DeviceLinkForm />
<DeviceLinkForm account={account} />
</div>
</div>
);
Expand Down
47 changes: 47 additions & 0 deletions coordinator/api/account_identity_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package api

import (
"encoding/json"
"net/http/httptest"
"strings"
"testing"
"time"

"github.com/eigeninference/d-inference/coordinator/store"
)

func TestAccountEarningsEmailBelongsToAuthenticatedOwner(t *testing.T) {
for _, prefix := range []string{"eigeninference-pt-", desktopAccountTokenPrefix} {
t.Run(prefix, func(t *testing.T) {
srv, st := deviceTestServer()
for i, owner := range []string{"alice", "bob"} {
if err := st.CreateUser(&store.User{AccountID: owner, PrivyUserID: "did:privy:" + owner, Email: owner + "@example.com"}); err != nil {
t.Fatal(err)
}
token := prefix + strings.Repeat(string(rune('a'+i)), 64)
if err := st.CreateProviderToken(&store.ProviderToken{TokenHash: sha256Hash(token), AccountID: owner, Active: true, Label: desktopAccountCodePrefix + "TEST", CreatedAt: time.Now()}); err != nil {
t.Fatal(err)
}
// Query parameters must never select another person's identity, including cached reads.
for range 2 {
req := httptest.NewRequest("GET", "/v1/provider/account-earnings?account_id=someone-else", nil)
req.Header.Set("Authorization", "Bearer "+token)
w := httptest.NewRecorder()
srv.Handler().ServeHTTP(w, req)
var body struct {
Email string `json:"email"`
AccountID string `json:"account_id"`
}
if err := json.Unmarshal(w.Body.Bytes(), &body); err != nil || w.Code != 200 || body.Email != owner+"@example.com" || body.AccountID != owner {
t.Fatalf("incorrect identity: status=%d body=%s", w.Code, w.Body)
}
}
}
w := httptest.NewRecorder()
srv.Handler().ServeHTTP(w, httptest.NewRequest("GET", "/v1/provider/account-earnings", nil))
if w.Code != 401 || strings.Contains(w.Body.String(), "@example.com") {
t.Fatal("unauthenticated email disclosure")
}
})
}
}
12 changes: 10 additions & 2 deletions coordinator/api/billing_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ func (s *Server) handleModelCatalog(w http.ResponseWriter, r *http.Request) {
// for the authenticated provider account.
// Cached for 20s per account — dashboard polls this frequently.
func (s *Server) handleAccountEarnings(w http.ResponseWriter, r *http.Request) {
if r.URL.Query().Get("window") != "" {
s.handleDesktopInsights(w, r)
return
}
accountID := s.resolveAccountID(r)

limit := 50
Expand Down Expand Up @@ -610,7 +614,7 @@ func (s *Server) handleAccountEarnings(w http.ResponseWriter, r *http.Request) {

availableBalance, withdrawableBalance := s.store.GetBalanceWithWithdrawable(accountID)

body, err := json.Marshal(map[string]any{
response := map[string]any{
"account_id": accountID,
"earnings": earnings,
"total_micro_usd": summary.TotalMicroUSD,
Expand All @@ -622,7 +626,11 @@ func (s *Server) handleAccountEarnings(w http.ResponseWriter, r *http.Request) {
"available_balance_usd": fmt.Sprintf("%.6f", float64(availableBalance)/1_000_000),
"withdrawable_balance_micro_usd": withdrawableBalance,
"withdrawable_balance_usd": fmt.Sprintf("%.6f", float64(withdrawableBalance)/1_000_000),
})
}
if user := auth.UserFromContext(r.Context()); user != nil && user.AccountID == accountID && user.Email != "" {
response["email"] = user.Email
}
body, err := json.Marshal(response)
if err != nil {
writeJSON(w, http.StatusInternalServerError, errorResponse("internal_error", "failed to marshal earnings"))
return
Expand Down
Loading