Skip to content

feat(speech): set the OpenAI dictation key on a headless host - #31230

Merged
nwparker merged 2 commits into
mainfrom
nwparker/headless-openai-speech-key
Oct 20, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/headless-openai-speech-key

Conversation

@nwparker

@nwparker nwparker commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​190 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​190

ELI5

Cloud voice dictation, which uses OpenAI's models, needs an OpenAI key saved on the machine that does the transcribing. Until now the only way to save one was desktop Settings, so a headless server had no way to use cloud dictation at all. This PR adds a small command that saves the key on the server:

printf %s "$OPENAI_API_KEY" | orca speech openai-key set

What Changed

Before: on a headless orca serve host, or a managed SSH or WSL server, there was no way to save an OpenAI key there. A key saved through the desktop can't be read by the headless server, so cloud dictation stayed unavailable.

After: orca speech openai-key status | set | clear manages the key on whichever host the CLI targets: the local one, or a paired remote one with --host. Once the key is saved, the cloud models show as ready on the phone.

How it works:

  • Three new runtime methods.
    • speech.openAiKey.status (workspace permission) reports {configured, protection}.
    • speech.openAiKey.set and speech.openAiKey.clear (settings-write permission) save and remove the key through the existing openai-api-key-store.
    • That store is the same file, and the same host secret sealing, that desktop Settings uses, so this adds no new storage.
  • Phones can't call them. The methods aren't in the mobile allow-list, because phones shouldn't set host secrets.
  • The CLI reads the key from stdin only, so it never appears in shell history or a process list.
    • It refuses an interactive terminal, and refuses empty or over-long input.
    • It never prints the key, only whether one is saved and whether it's encrypted.
  • Mixed versions: against an older server that lacks these methods, the CLI says "Update Orca on the server" instead of method_not_found.

Why

The key belongs on the host that transcribes. On a headless host, the RPC is the only way in. This reuses the existing key store, which keeps one storage format and one sealing path, and the desktop path is unchanged.

Alternatives I rejected:

  • An environment variable. It would bypass the secret sealing and leak into child processes.
  • A field on settings.update. A secret doesn't belong in a general settings write that echoes settings back.
  • A field on speech.dictation.setup. An older host would silently drop it, and the client would believe the key was saved.

Linked Issue

Refs #31174. Follow-up to #31217, reported by @delorean2020.

Visual Proof

N/A. This is a CLI and RPC addition; the command output is plain text, for example "OpenAI key saved on this host."

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

Tests:

  • src/cli/handlers/speech.test.ts:
    • reads and trims the key from a pipe
    • refuses a terminal, empty input and oversized input
    • maps an older server's method_not_found to the update message
  • src/main/runtime/runtime-mobile-speech-openai-key.test.ts: save, status and clear go through the key store, and the parameter schema trims input and rejects an empty key.
  • The CLI registries, the generated RPC parameter catalog and the full static job pass locally.

Not verified live: the packaged orcad build fails its own smoke step on this machine right now (the bundled file watcher times out under load; this has nothing to do with this change), so I didn't run the command against a live server.

Review

  • Codex (gpt-6.1-sol, high), round 1: no findings. Round 2: see the follow-up comment.
  • Independent Opus review: nothing blocking. I adopted:
    • the clear update message on older servers
    • one shared maximum key length for the CLI and the server
    • a PowerShell example

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH and remote: the key lands on the host that runs dictation. The speech command family was already marked as host-owned.
  • Windows: trim() drops \r\n and a byte-order mark, so a key piped from PowerShell or cmd works.
  • Security: the key is never logged or echoed, and a validation error doesn't include the input.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…peech openai-key)

Cloud dictation needs an OpenAI key on the host that transcribes, and
desktop Settings was the only way to save one. A headless orca serve or
managed server had none. speech.openAiKey.{status,set,clear} save it
through the host's existing key store and secret sealing; the CLI reads
the key from stdin so it never lands in shell history.
…ethods; one key length cap; PowerShell example (Opus review)
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 17 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1553a39b-5d23-4d9a-9580-3013b013b8fd
📥 Commits

Reviewing files that changed from the base of the PR and between 3be5039 and 786114b.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 12
  • src/cli/args.ts
  • src/cli/handler-group-manifest.ts
  • src/cli/handlers/speech.test.ts
  • src/cli/handlers/speech.ts
  • src/cli/specs/index.ts
  • src/cli/specs/speech.ts
  • src/main/runtime/rpc/methods/speech.ts
  • src/main/runtime/runtime-mobile-speech-catalog.ts
  • src/main/runtime/runtime-mobile-speech-openai-key.test.ts
  • src/main/runtime/runtime-service-command-surface.ts
  • src/main/startup/cli-command-names.ts
  • src/shared/rpc-contract/speech-params.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit d563f8e into main Oct 20, 2026
41 checks passed
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