Skip to content

Add bb cloud voice transcription - #4569

Merged
SawyerHood merged 3 commits into
mainfrom
bb/enable-bb-cloud-ai-for-inference-thr_tdbycrkh9q
Sep 30, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
bb/enable-bb-cloud-ai-for-inference-thr_tdbycrkh9q

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

bb cloud (the bb-ai plugin, #4254) only served thread titles and commit messages. Voice input had no hosted option, so a bb without a Codex login had no microphone. The plan left voice as phase 2 (plans/bb-account-and-hosted-generation.md, Part 8). The bb side already had everything voice needs: the plugin SDK's transcribe hook, the Voice input row in Settings → AI services, the server's transcribe route, bb voice transcribe, and the mic's readiness check. The missing pieces were a hosted endpoint and bb-ai implementing transcribe.

What changed

  • bb-ai-gateway (apps/ai-gateway): new POST /api/ai/v1/transcribe.
    • Takes {audio, format, hint} with base64 audio, capped at 10 MB, and forwards it to OpenRouter's POST /api/v1/audio/transcriptions with provider: {zdr: true, data_collection: "deny"}.
    • Metering is shared with /complete through one handleMetered path: the same auth, rate limit, daily budget and request log. Transcription reserves 2¢ per call and settles to the reported cost.
    • AI_TRANSCRIBE_MODELS (new, required var, set in wrangler.jsonc for production and staging) lists the models in order. OpenRouter's transcription endpoint has no models fallback, so the gateway moves to the next model when one answers with an HTTP error, all within an 8 s deadline. It never retries after a timeout.
    • The vocabulary hint goes to provider.options.groq.prompt, the only hint option OpenRouter documents.
    • Default models: microsoft/mai-transcribe-2, then openai/whisper-large-v3-turbo. Both have ZDR endpoints.
  • bb-account: bb-account.v1.fetch accepts request bodies up to 16 MB instead of 1 MB, since base64 recordings didn't fit. Responses stay capped at 1 MB.
  • bb-ai: registers transcribe.
    • It sends the recording through bb-account.v1.fetch with a 10 s timeout.
    • It maps the MIME type or file extension to an OpenRouter format, so Chrome's audio/webm;codecs=opus becomes webm and Safari's audio/mp4 becomes m4a.
    • It refuses recordings over 10 MB or in unknown formats without contacting getbb.app.
    • The opt-in, sign-in and used-up-budget checks are shared with complete.
    • bb cloud now appears for Voice input, and Automatic tries Codex, then bb cloud.
  • Copy and docs: bb ai help, the plugin README, overview and skill, docs/configuration.md, and the verify-bb feature map now cover voice input and say recordings are never stored. (Merged with Enable bb cloud AI by default and remove its settings page #4522, which made bb cloud on by default and removed its settings page and disclosure, and docs: remove stale feature plans and redundant reports #4525, which deleted the plan doc. The model comparison that was going into the plan is below.)

Model choice (OpenRouter transcription models with ZDR endpoints, 2026-09-29): microsoft/mai-transcribe-2 (Azure, about $0.0017/min at a launch price that ends 2026-12-31, #1 on FLEURS and #2 on Artificial Analysis's word-error-rate board), openai/whisper-large-v3-turbo (Groq/DeepInfra, $0.0002–0.0007/min, takes a vocabulary prompt on Groq), and Voxtral Mini Transcribe, Deepgram Nova-3 and AssemblyAI Universal-3.5 Pro. openai/gpt-transcribe, google/gemini-3.5-transcribe and x-ai/grok-stt-1.0 have no ZDR endpoint.

  • Stale docs from Enable bb cloud AI by default and remove its settings page #4522: the bb-cloud-ai skill, plugin overview, README, docs/configuration.md and the verify-bb feature map still described the removed opt-in and settings page. They now say bb cloud is on by default once you sign in, bb ai off turns it off, and disabling the plugin also stops it. The skill also covers voice input: accepted formats, the 10 MB limit, the 10 s timeout, and bb voice transcribe.

No server, daemon or SDK changes. No HOST_DAEMON_PROTOCOL_VERSION bump.

Known issue, not addressed here: through OpenRouter, MAI-Transcribe 2 answers 400 for WebM and MP4 audio but accepts the same speech as Ogg or MP3. Chrome and Safari recordings therefore get transcribed by Whisper after one refused MAI call. The follow-up is either to put Whisper first in AI_TRANSCRIBE_MODELS (config only) or to convert recordings to Ogg before upload.

How you verified

  • pnpm exec turbo run typecheck test lint --filter=@bb/ai-gateway --filter=bb-plugin-bb-ai --filter=bb-plugin-bb-account: pass (gateway 32 tests, bb-ai 28, bb-account 59).
  • New gateway tests cover:
    • the exact OpenRouter request, including ZDR and the Groq hint, and the metering and request log, which never contains audio or text;
    • falling back on an HTTP error but not on a timeout;
    • charging nothing when every model refuses;
    • input validation (base64, the 10 MB cap, format, hint size);
    • the 2¢ reserve, so a nearly spent budget still allows a title but not a recording;
    • 401 without a credential;
    • a Miniflare test that sends a 4 MB body through the real Workers runtime and D1.
  • New bb-ai tests cover the fetch payload and timeout, refusals that send nothing (off, too large, unknown format), budget exhaustion from a transcription answer, and MIME/extension mapping.
  • Local end to end against real OpenRouter (pnpm cloud:dev with a key, plus pnpm dev signed in to a local account, bb ai on, and bb settings ai-services set voice bb):
    • bb voice transcribe on WebM, MP3 and M4A clips returned correct transcripts in 1.0–1.6 s. The gateway log showed MAI answering MP3 and Whisper answering WebM and M4A.
    • bb ai usage counted the requests.
  • After merging main: typecheck, test and lint pass again (bb-ai 24 tests, gateway 32, bb-account 59).
    • Recording with the mic in the app worked.

Rollout

Deploy the gateway (Deploy AI Gateway) before releasing bb-ai. A released bb-ai against an old gateway would show the mic and fail every recording with a 404.

AGENT GENERATED

🤖 Generated with Claude Code

The bb-ai-gateway gains POST /api/ai/v1/transcribe, which forwards base64
audio to OpenRouter's transcription endpoint with zero data retention,
tries AI_TRANSCRIBE_MODELS in order, and meters against the same daily
budget with a 2 cent reserve. bb-ai registers transcribe, so bb cloud
joins the Voice input picker and Automatic after Codex. bb-account's
fetch accepts request bodies up to 16 MB so recordings fit.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T16:43:59.738201Z b8b9a0b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b8b9a0b4e4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +306 to +307
TRANSCRIBE_TIMEOUT_MS,
signal,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate cancellation through the hosted transcription request

When voice transcription is cancelled or reaches the server's 10-second timeout after accountFetch has started, this signal only aborts bb-ai's local plugin-RPC fetch. The bb-account RPC handler receives no abort signal, and authenticatedFetch uses an independent timeout, so the recording can continue uploading to getbb.app and be transcribed, billed, and logged after bb has told the user it was cancelled or timed out. Cancellation needs to propagate through bb-account and the gateway's upstream fetch, not just this RPC call.

Useful? React with 👍 / 👎.

SawyerHood and others added 2 commits September 30, 2026 09:46
…-for-inference-thr_tdbycrkh9q

# Conflicts:
#	plans/bb-account-and-hosted-generation.md
#	plugins/bb-ai/app.test.tsx
#	plugins/bb-ai/app.tsx
#	plugins/bb-ai/src/disclosure.ts
#	plugins/bb-ai/src/server.test.ts
#	plugins/bb-ai/src/server.ts
The bb-cloud-ai skill, plugin overview, README, configuration guide, and
verify-bb feature map still described the removed opt-in settings page.
They now describe bb cloud as on by default with `bb ai off` to opt out,
and cover voice input formats, limits, and model fallback.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@SawyerHood
SawyerHood merged commit 6a75b2d into main Sep 30, 2026
20 checks passed
@SawyerHood
SawyerHood deleted the bb/enable-bb-cloud-ai-for-inference-thr_tdbycrkh9q branch September 30, 2026 17:16
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