Skip to content

feat(desktop): cloud-mode option in onboarding wizard#375

Draft
yagudaev wants to merge 1 commit into
mainfrom
michael/nan-660-desktop-cloud-mode
Draft

feat(desktop): cloud-mode option in onboarding wizard#375
yagudaev wants to merge 1 commit into
mainfrom
michael/nan-660-desktop-cloud-mode

Conversation

@yagudaev

@yagudaev yagudaev commented May 1, 2026

Copy link
Copy Markdown
Owner

Why

NAN-660 PR #3 of 4. Adds the user-facing path to the broker: the wizard now offers VoiceClaw Cloud as a first-class option above BYO-key.

What's in this PR

cloud-broker moduledesktop/src/main/cloud-broker.ts

  • Thin client over /api/auth/me and /api/gemini/session-token
  • Reads device token from encrypted SQLite devices row (set in PR Add displayText function call for write-only display during voice (NAN-534) #1's auth flow)
  • Caches the broker-issued ephemeral token in memory; refreshes at 80% of newSessionExpireTime
  • Coalesces concurrent fetches (one cache miss → one upstream call)
  • 15 vitest cases: happy / not-signed-in / 401 / 429 with Retry-After / cache reuse / forceRefresh / call coalescing / fetchMe

IPC + preload

  • New handlers: cloud:getStatus, cloud:fetchMe, cloud:fetchSessionToken
  • Renderer-side cloudApi wrapper in onboarding-api.ts

Wizard StepProvider

  • New access-mode picker at the top of step 4: VoiceClaw Cloud vs Bring-Your-Own
  • Cloud branch auto-verifies on select: hits /api/auth/me, surfaces tier + minutes-remaining-today
  • Three failure shapes covered: not signed in (sends user back to step 2), broker error (with retry), or 401 (treated as not signed in)
  • BYO branch unchanged from main
  • Onboarding payload records accessMode + cloudVerified for downstream steps

Out of scope

  • Relay-server consumption of ephemeral tokens (PR Fix microphone: remove expo-audio audio session conflict #3.5). The token is fetched and cached, but the relay-server still uses GEMINI_API_KEY from env. Wiring relay to ask cloud-broker for a fresh token at session start is its own diff — it touches relay's lifecycle and queue management.
  • Dashboard "minutes remaining" widget. Will land alongside PR Fix microphone: remove expo-audio audio session conflict #3.5 when there's a real session-time-used signal.
  • Settings page to switch modes post-wizard. Today, switching modes requires re-running the wizard. Settings UI is a follow-up.

Coordination

Depends on:

Test plan

  • 15 new cloud-broker vitest cases passing
  • Existing 119 desktop tests still passing (134 total)
  • Typecheck clean
  • Local dev with VOICECLAW_AUTH_BASE_URL=http://localhost:3000 against a running voiceclaw-cloud — pick cloud mode, see the verified panel
  • Live dev against cloud.getvoiceclaw.com after deploys land
  • Sign out → re-enter wizard → cloud panel renders "sign in first" branch

🤖 Generated with Claude Code

Adds the "VoiceClaw Cloud" radio at the top of the provider step.
Picking it skips the BYO key flow entirely — the wizard verifies the
user against cloud.getvoiceclaw.com and surfaces today's free-tier
allowance instead of asking for a Gemini/OpenAI/Grok key.

cloud-broker module
- src/main/cloud-broker.ts: thin client over /api/auth/me and
  /api/gemini/session-token. Reads the device token from the encrypted
  sqlite devices row, caches the broker token in-memory, refreshes at
  80% of newSessionExpireTime, coalesces concurrent fetches so one
  cache miss doesn't cause N upstream calls.
- 15 vitest cases covering happy / not-signed-in / 401 / 429+retry /
  cache reuse / forceRefresh / call coalescing / fetchMe.

IPC + preload
- cloud:getStatus, cloud:fetchMe, cloud:fetchSessionToken
- Renderer-side wrappers in onboarding-api.ts as cloudApi.

Wizard
- StepProvider grows an "access mode" picker (Cloud vs Bring-Your-Own).
- Cloud mode auto-verifies on selection: hits /api/auth/me, surfaces
  tier + minutes-remaining-today, or shows a "go sign in first" panel
  when there's no device token, or an error+retry when the broker is
  unreachable.
- Continue is gated on cloudVerified=true (cloud) or
  providerKeyValidated=true (byo-key). Payload now records accessMode
  + cloudVerified for downstream steps.

Out of scope (PR #3.5)
- Wiring relay-server to consume ephemeral tokens from cloud-broker
  at session start instead of GEMINI_API_KEY. The minted token is
  fetched and cached here; it's not yet handed to relay-server. That
  plumbing change touches the relay's lifecycle and warrants its own
  reviewable PR.

Depends on PR #1.5 (URL flip to cloud.getvoiceclaw.com) being live
before this lands, otherwise cloud:getStatus reaches the wrong host.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented May 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
voiceclaw Ready Ready Preview, Comment May 1, 2026 8:24am

Request Review

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.

1 participant