Skip to content

feat(desktop): Darkbloom macOS desktop app (Electron) backed by the Swift CLI - #1518

Merged
Gajesh2007 merged 169 commits into
masterfrom
feat/desktop-app-on-master
Oct 23, 2026
Merged

Gajesh2007 merged 169 commits into
masterfrom
feat/desktop-app-on-master

Conversation

@jonathan308

@jonathan308 jonathan308 commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

The Darkbloom macOS desktop app: an Electron frontend (desktop-app/) that drives the existing Swift darkbloom CLI through a new authenticated loopback control API (darkbloom desktop serve|ensure|login|logout, run as the io.darkbloom.desktop-api user LaunchAgent). Swift stays the source of truth for provider lifecycle, models, Autopilot, cooling, account sign-in and coordinator requests; the renderer only sends validated actions. See docs/developer/desktop-app.md and docs/reference/desktop-control.md.

This is one squashable PR against master. It supersedes #1318 and #1354 (left open for reference; close them once this lands).

The review Storybook (Before/After stories for every fix, flows, and the app shell) is in draft #1578, stacked on this PR. It isn't part of the app and doesn't need to merge with it.

What's included

How it was reconciled with master

master only squash-merges, so origin/master was merged into the desktop branch (one merge commit, ae8251457) instead of rebasing ~160 commits, plus two follow-up commits.

  • coordinator/ — taken from master (deleted). All desktop-side coordinator changes are dropped: the platform owns them now and already implements the desktop account session, desktop_account device-code purpose and earnings reads in darkbloom-platform#23. The Swift client only calls routes that exist there (/v1/me/providers, /v1/me/summary, /v1/provider/account-earnings, /v1/device/*, public stats/leaderboard/releases).
  • console-ui/ — identical to master. The /link desktop purpose is fix(console): send the device authorization purpose from /link (desktop sign-in) #1493 and is not duplicated here.
  • Coordinator docs master deleted (docs/reference/api-contracts.md, docs/architecture/{billing,storage}.md, docs/consumer/{billing,models}.md) stay deleted; desktop docs now link the pinned platform contracts instead, and the stale "compatibility routes" claim is corrected.
  • provider-swift/.../Auth/DeviceAuth.swift — kept the desktop DeviceLoginClient (purpose, allowLegacyAccountFlow, automaticallyOpenBrowser) and ported master's issuer recording into it: provider-scope logins now save AuthTokenStore.save(token, coordinatorURL:) from the final token-response URL, as master's performDeviceCodeLogin does. Desktop account logins still never touch provider credentials.
  • Follow-up a62731a05 — master's dev-build identity (provider: dev builds are darkbloom-dev with their own paths, port, label and keychain items #1485) separates dev/staging install paths, labels and ports, so the desktop API's state directory, installed-runtime path and LaunchAgent label now come from BuildEnvironment. Production values are unchanged.
  • Follow-up 942af952e: two desktop frontend tests that had been failing only on the Linux frontend runner since the stacked audit branches are fixed. previewRuntime now expects error on every platform, matching 7202cde, and backendInstall teardown no longer races the reconnect's real I/O against the fake clock.
  • CHANGELOG.md — master's file unchanged. The desktop branch's ~45 ## Unreleased — desktop … sections are now six changelog.d fragments: desktop-app, desktop-control-api, desktop-hardware-load, desktop-signed-preview, desktop-onboarding, desktop-ui-fixes.
  • Other docs (docs/README.md, design/README.md, developer/{build,test}.md, provider/cli-reference.md, reference/{README,configuration}.md) — master's restructured text with the desktop sections added back.

CI / Makefile

  • .github/workflows/ci.yml: master's version plus one provider-lane step, Test desktop control API with isolated local state (python3 scripts/test-desktop-api.py provider-swift/.build/debug/darkbloom, 3 min), placed after master's provider test watchdog and diagnostics upload. scripts/test-provider-ci-workflow.py asserts it.
  • scripts/ci-component-paths.py: scripts/test-desktop-api.py routes to the provider lane (with a test).
  • .github/workflows/desktop.yml (new): frontend lint/test/build on desktop-app changes, plus an unsigned review package on manual dispatch.
  • Makefile: desktop-install, desktop-build, desktop-test, desktop-package, desktop-api-test.

Validation (local, macOS 27, Apple silicon)

Command Result
cd desktop-app && node scripts/assets.mjs && npx vitest run --maxWorkers=4 99 files / 662 tests passed
npx tsc --noEmit / npx prettier --check src scripts tests *.ts *.json clean / clean
swift build --product darkbloom; full swift build OK; OK (incremental)
swift test --filter Desktop 79 tests / 17 suites passed (one cold-start flake in DesktopWorkerTests.aTimedOutProbeIsReaped… on the first run; passed on 5 reruns)
swift test --filter "DeviceCodeLogin|DeviceAuth|Logout|AuthTokenStore" 18 + 7 tests passed
python3 scripts/test-desktop-api.py provider-swift/.build/debug/darkbloom passed
python3 scripts/test-provider-ci-workflow.py, scripts/test-ci-component-paths.py, scripts/test-provider-identity.py OK
python3 scripts/changelog.py check 24 valid fragments
make docs-check / make docs-impact-check BASE=origin/master 189 files OK / coverage OK
git diff origin/master...HEAD -- coordinator console-ui CHANGELOG.md empty; no conflict markers

Known limitations

🤖 Generated with Claude Code

Gajesh2007 and others added 30 commits October 1, 2026 20:53
…ount

GET /v1/provider/desktop was registered without request bookkeeping or a
rate limit, and its 20 s cache key included the client-controlled
X-Darkbloom-Device-Identity header, so a token holder could bypass the
cache and force a full registry walk plus per-machine earnings queries on
every request.

- Authenticate through requireDesktopProviderToken: active, account-linked
  provider tokens only, checked on every request before the cache, with
  outcome-stage and auth stamping.
- Apply the per-account limiter via rateLimitDesktop (429 + Retry-After).
- Cache one typed projection per account and compute is_this_mac per
  request on a copy; the SE key stays unexported and out of the JSON.
- Document the route, auth label and limiter in api-contracts.md.
- Start hidden at login on macOS: login-item args are Windows-only in
  Electron 44, so honor app.getLoginItemSettings().wasOpenedAtLogin as
  well as --hidden.
- Stop consuming provider releases as GUI updates. The build config moves
  to electron-builder.ts and emits a generic feed only when
  DARKBLOOM_DESKTOP_UPDATE_URL is set (publish: null otherwise, so no
  GitHub feed is inferred). At runtime the updater is used only when the
  embedded app-update.yml declares a generic https feed; otherwise the
  Updates screen reports an explicit "unconfigured" state.
- Rebuild the tray menu only when its visible model changes; Start reads
  the latest snapshot at click time.
- Fetch cooling status only while the Cooling screen is shown.
- Verify the installed runtime's signature before repair runs its update,
  drop the unused CI=1 installer env, and allow 90 s for desktop ensure.
- Trigger the Desktop App workflow on scripts/install.sh changes.
- Split main/index.ts into focused modules (security, protocol, window,
  ipc, tray, updates, login launch, lifecycle); renderer trust checks live
  in electron-free security.ts with unit tests.
- desktop ensure now goes through ProviderCore launchctl wrappers and a
  pure decision function (DesktopService.nextStep): install when not
  loaded, bootout/rewrite/bootstrap when the plist differs, kickstart when
  the API is unresponsive or reports another version. At most one restart
  per run, never during a running operation (the API owns its children's
  output pipes), and an HTTP error with an unchanged plist fails fast.
  The plist adds ExitTimeOut and an absolute --config path.
- The API records its executable stamp at startup and exits when the
  binary is replaced and no operation is running, so launchd relaunches
  the new build after terminal, self-update or repair updates.
- stop --uninstall also boots out and deletes io.darkbloom.desktop-api.
- Pass --config to restart and desktop stop-local/restart-local (switch,
  stop and logout do not accept it); every generated argv is parsed in
  tests.
- Map HTTP errors: validation 400 verbatim, malformed bodies 400, unknown
  resource 404, oversized body 413, stream limit 429, coordinator 502 and
  internal 500 with fixed text.
- Share one cooling status read with a 10 s cache, cleared when a cooling
  change finishes.
- Document ensure/restart semantics, uninstall and status codes; update
  the desktop changelog entry.
Buttons, links, cards, chips, rows and form controls now respond to the
pointer in both themes, using a shared --hover-duration:

- Buttons tint and brighten their border; primary gains a soft glow,
  quiet brightens its text, danger deepens. Disabled controls no longer
  tint or press.
- Text links and setting-link cards nudge their arrow; filter chips,
  serving-mode cards, onboarding choices, schedule days, table rows, the
  profile button and the appearance menu tint or brighten.
- Selects and text inputs strengthen their border. Rows wrapping native
  checkboxes, switches and sliders brighten the control and description,
  and show a not-allowed cursor when the control is disabled.
- Notice and dialog close icons get a halo without shifting layout.
- Selected and active items keep their look under the pointer.
The final onboarding step no longer requires ticking "I agree to the
Terms of Service" before Start is enabled. A note under the start action
reads "By turning on, you agree to our Terms of Service", linking to the
terms page.
Add the DarkbloomHardwareLoad library and expose it on the loopback desktop
control API so the desktop chip view shows real machine load instead of a
simulation.

- GET /control/v1/hardware returns chip topology (CPU tiers and clusters from
  hw.perflevelN and the device tree, GPU core groups, ANE presence, memory)
  plus the latest whole-machine sample; /hardware/events streams one sample
  per SSE frame at 1 Hz and shares the eight-stream limit.
- Public counters: per-CPU busy fraction, GPU utilization and the provider's
  share of GPU time, ANE activity, memory use and pressure, thermal state.
  IOReport (bound at runtime) adds GPU/ANE power, GPU frequency and DRAM/ANE
  bandwidth estimates, each tagged measured/estimated/pending/unavailable.
- Sampling is demand-driven (only while a stream is open or for 10 s after),
  costs about 3 ms of CPU per sample, needs no root or helper, and never
  leaves the machine: nothing is logged, heartbeated or sent to the
  coordinator. Unknown values are null, never zero.
- darkbloom doctor --hardware prints the same document for diagnosis.
- Documented in the desktop-control reference and CLI reference, with route
  and sampler tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
…scan and live hardware

Redesign the desktop app around the Mac itself and wire it to real load.

- Home: an animated chip anatomy (blueprint by default, optional photoreal)
  laid out from the real topology (CPU tiers and clusters, GPU core groups,
  Neural Engine, unified memory). It is driven by the new hardware stream via
  a main-process SSE watcher and IPC subscription that stops when no view
  listens, with reduced-motion support. Fleet summary, earnings and network
  milestone cards sit beside it.
- Models: autopilot-first page (on, shadow, off, unsupported) with a manual
  pool, model facts and a preview fixture.
- Onboarding: a hardware eligibility scan, waitlist, account linking, serving
  summary and advanced options, split into focused components.
- Machines, stats, cooling, updates, settings and leaderboard reworked into
  feature modules (request activity, token bars, request curve, performance,
  release timeline, network map geography).
- Shared formatters (count, timeOfDay, clockTime, bigint compact), one SSE
  frame parser for state and hardware streams, and one preview topology
  (64 GB M4 Max) as the source of truth for all preview fixtures.
- Dead modules removed (System, Contribution, ActivityChart, the old Models,
  FleetOverview and MachineOverview); dark-mode and warning tokens unified.
- README gains a "Run it locally" guide for the preview, the Electron window
  and attaching to an isolated real runtime.
- 51 test files / 366 tests, including a real-HTTP watch() test and a
  fixture-agreement test for the hardware load document.

Co-authored-by: Cursor <cursoragent@cursor.com>
- docs/developer/desktop-app.md: module map for the chip home, models
  autopilot, onboarding scan, hardware watcher (hardware.ts, sse.ts) and
  preview fixtures, including the shared preview topology and the preview
  query parameters; freshness stamp refreshed.
- CHANGELOG.md: the desktop Unreleased section is updated in place for the
  chip anatomy home, live hardware load, autopilot-first models and the
  onboarding scan.

Co-authored-by: Cursor <cursoragent@cursor.com>
…t backend

Simplify Home and live chip activity, preserve exact session usage, rank models by earnings, improve Mac Stats and cooling recovery, and reuse existing coordinator APIs through scoped native caches and read-only dashboard sessions. Include native, UI, API and store regression tests and canonical documentation.
…count-polish

Make desktop Models Autopilot-first; polish sign-in, cooling and notifications
The document is the desktop window's scroll container, and route or Mac
changes never reset it. Following View earnings or Explore Stats from
lower on Home, switching Macs, or changing My Macs tabs kept the previous
scroll offset and hid the new page's header and tabs.

Reset the document scroll position in a layout effect whenever the route
or selected Mac changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The native desktop API reports this session's local request history
with completed_at only (DesktopRequestHistory.swift). recordedTraffic
bucketed by settled_at ?? started_at, so every local record produced a
NaN bucket and an empty series. Because history existed, Performance did
not fall back to observed samples and hid the traffic chart entirely on
a serving Mac.

Bucket with the shared requestTime helper (settled, completed, started)
and label local history as completed rather than settled requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tory

The native release-history resource is synthesized from the latest
release and carries no minimum_provider_version until the coordinator's
desktop release feed is deployed (DesktopResources.swift).
parseReleaseHistory rejected any history without that floor, so Updates
always showed history and support policy as unavailable with the real API.
Accept a missing or null floor as unknown while still rejecting malformed
values; the contract already marks it optional.

This Mac's Overview readiness compares the runtime with the latest
release and floor, but the machines route only requested cloud data. A
runtime below the floor therefore read "a compatible update isn't
available yet" with no Update now action unless Updates had been visited
earlier. Request release and release-history on that route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The desktop frontend job runs npm test on Ubuntu, where /usr/bin/codesign
does not exist. Backend.connect() then fails verification with ENOENT
and reports the runtime as missing, so the assertion that the unsigned
preview backend yields state 'error' failed on every CI run after the
preview packaging commit.

Assert the platform's outcome while keeping the security assertions on
every platform: the unsigned binary is never executed (no
connection.json) and installing over the bundled API is still rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
App rendered first-run Onboarding whenever no snapshot had arrived yet,
even when onboarding was already complete. Every cold launch therefore
flashed Welcome ("Put this Mac to work." / Start) for as long as the
runtime took to answer (up to the 90-second ensure or 30-second preview
startup bounds), and stayed there when the runtime was unreachable, so
returning users had to press Start to reach Install/Repair.

Render a Startup view for returning users: the onboarding brand shell
with the connection status, or RuntimeSetup when the runtime is missing,
incompatible or failing. First-run onboarding is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preview spawns `darkbloom desktop serve`, which holds an exclusive
flock on service.lock and does not exit when its parent dies. After a
GUI crash or force quit, every relaunch spawned an API that exited with
"Desktop API is already running"; start() only accepts a discovery
record with the new child's pid, so ensure() failed every time, watch()
retried every five seconds, and Repair could not help.

Electron's single-instance lock means no other preview app owns the
preview directory, so an API still recorded there was left by an earlier
app process. Before spawning, stop the recorded pid only while ps shows
it is exactly this bundled binary running `desktop serve`, guarding
against pid reuse.

The child's stdio was ignored, so the API's own stderr (lock, discovery
and runtime-resolution failures) was lost and the user only saw a
generic message. Keep a bounded stderr tail, include its last line in a
PreviewStartError, and surface that in the backend status the runtime
setup screen already displays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Onboarding derives eligibility because the runtime sends no report.
DesktopSnapshot.swift fills memory_gb only for downloaded models
(local?.estimatedMemoryGb), so on a fresh install no model reported a
memory need, the memory check stayed unevaluated, and every Mac,
including a 128 GB M4 Max, got "We couldn't confirm everything".

Use memory_gb || size_gb as a model's need, matching the runtime's own
fit check (modelFitsBudget uses the catalog size for models not yet
downloaded). Models the runtime accepts set the bar. When it accepts
none, memory fails only if every reported model needs more than the
Mac's total memory; otherwise the result stays unknown rather than
reimplementing the runtime's load allowance.

Make the 8 GB fixture match what the runtime reports (the model that
does not fit is not eligible), and model the preview's unknown scenario
as a runtime that has not loaded the catalog yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backend.connect() stored the discovered connection before checking the
initial snapshot's protocol. When the check failed it set an error
status but kept the connection, so watch() opened /events about 250 ms
later, reported the runtime as ready, and forwarded every streamed
snapshot without any protocol check.

Clear the connection whenever connect() fails, and validate every
snapshot, initial or streamed, with one compatibility check. A stream
that changes protocol now drops the connection and reconnects through
the checked path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uality

RequestTable recomputed `timing` and `settled` for every row and shadowed
the table-level values; drop the per-row copies. Remove unused test
imports (waitFor, act, models, fireEvent). No behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Storybook is a review tool, not part of the app: nothing ships it and
no check runs it, and its frozen Before snapshot duplicates the old
renderer. It now lives on tools/desktop-storybook (its own draft PR), so
this PR carries only the app and its fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Oct 23, 2026
Restores desktop-app/storybook (and the Review Storybook docs section),
moved out of #1518 so the app PR carries only the app. Before/After
stories for each desktop audit fix (#1452-#1508), flow walkthroughs, the
app shell with its sidebar at every page, and the install flow. After is
the live desktop-app source; Before is a frozen snapshot of bfa75a2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gajesh2007
Gajesh2007 merged commit 09692e5 into master Oct 23, 2026
34 of 36 checks passed
@Gajesh2007
Gajesh2007 deleted the feat/desktop-app-on-master branch October 23, 2026 19:53
jonathan308 added a commit that referenced this pull request Oct 23, 2026
The desktop app (#1518) merged to master after this preparation was rendered, so its six changelog fragments were still pending. Render them verbatim into the v0.10.1 entry and remove them: the desktop control API and hardware report ship in the provider CLI. Note in the rollout notes and the runbook that the provider release does not build, sign or publish the Electron desktop app, whose public distribution still needs a signed, notarized build and an update feed.
Gajesh2007 pushed a commit that referenced this pull request Oct 23, 2026
* chore(release): prepare provider 0.10.1

Set ProviderCore.version to 0.10.1 and render the v0.10.1 changelog
entry from the 13 fragments added since v0.10.0: the GLM-5.3-Flash and
Nemotron 3.5 Super OpenRouter readiness work (#1561, #1560) and the
many-file download progress display (#1558), plus already-merged
installer, sign-in and release-note fixes (#1505, #1493, #1482). Order
the entries by theme behind an upgrade and rollout section. Logprobs are
deferred, so the native-engine entry keeps the typed refusal and calls
the GLM logprob code disabled groundwork. Drop the forced-tool-choice
refusal that the GLM JSON and forced-choice entry supersedes, and
clarify the GLM startup savings and the wired-limit notice.

Mark v0.10.0 as published on 2026-10-23. Record in the provider release
runbook that darkbloom-platform#411 must be deployed before tagging,
that no catalog row gains the logprobs capability for 0.10.1, and that
#1561 re-pins mlx-swift-lm to the #340 squash commit before it merges.
No tag, registration, upload or deployment is performed.

* chore(release): render the desktop app entries into provider 0.10.1

The desktop app (#1518) merged to master after this preparation was rendered, so its six changelog fragments were still pending. Render them verbatim into the v0.10.1 entry and remove them: the desktop control API and hardware report ship in the provider CLI. Note in the rollout notes and the runbook that the provider release does not build, sign or publish the Electron desktop app, whose public distribution still needs a signed, notarized build and an update feed.

* chore(release): render the Autopilot entry into provider 0.10.1

Autopilot placements, downloads and busy reasons (#1565) merged to master after the desktop update. Render its fragment into the v0.10.1 entry and remove it, correcting "startup is not slower": with consent, start first fetches the catalog, waiting up to 10 s. Add rollout notes: changes apply only to Macs with saved consent; the wider selected_models also counts toward reward qualification, approval counts and operation victims on the current coordinator; one reconnect after start; holds, adopted routing and downloads need darkbloom-platform#439.

---------

Co-authored-by: Jonathan Spangler <5055076+jonathan308@users.noreply.github.com>
jonathan308 added a commit that referenced this pull request Nov 1, 2026
#1518 merged to master as squash 09692e5, so this branch's only own change is
the commit that adds desktop-app/storybook and the Review Storybook section of
docs/developer/desktop-app.md. Every other path takes master's content, which
includes the 16 conflicted files; those conflicts came from #1518's history and
the squash. The section sits where this branch put it, in master's version of
the page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 8, 2026
Adds desktop-app/storybook (Before/After stories for the desktop audit
fixes, onboarding/status/model-loading/Autopilot flows, the app shell and
the install flow) and the Review Storybook section of
docs/developer/desktop-app.md.

Rebased onto dev as one commit: the branch's earlier history carried the
original #1518 app commits, which landed in master as a squash, so the
storybook's own tree change is re-applied here instead of replaying them.

This branch was successfully deployed

5 active deployments
Preview – d-inference-console-ui-dev — feaac32f Deployed Oct 23, 2026 by vercel[bot]
Preview – eigen-homepages-darkbloom — feaac32f Deployed Oct 23, 2026 by vercel[bot]
Preview – d-inference-landing — feaac32f Deployed Oct 23, 2026 by vercel[bot]
Preview – d-inference — feaac32f Deployed Oct 23, 2026 by vercel[bot]
Preview – darkbloom-status — feaac32f Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants