[Feat] Let deployment admins turn Voice off when the key comes from the environment - #2722
Merged
Merged
Conversation
…he environment An R_VOICE_OPENAI_API_KEY environment variable (an operator's or a fleet-wide key) previously forced Voice on: the key resolver returned it before checking the deployment's enablement, and the Settings card hid every control. The environment key now decides which account pays for Voice while the deployment's admins decide whether it is on. The resolver and the connection-status query honor the existing per-deployment enablement for the environment key too, the enable mutation accepts Voice without a stored connection when the environment provides the key and keeps a stored key when disabling, and the card offers Enable/Disable Voice instead of naming the environment variable.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the Voice key comes from
R_VOICE_OPENAI_API_KEY(a self-hosted operator's key, or the fleet-wide key Cloud now installs on managed deployments), Voice was forced on: the key resolver returned the environment key before consulting the deployment's enablement, and the Settings card hid every control behind a "configured by the environment variable" line. A deployment admin had no way to turn it off.This separates the two concerns. The environment key decides which OpenAI account pays for Voice; the deployment's admins decide whether Voice is on, using the same per-deployment enablement every other integration has.
Changes
lib/server/voice.ts:resolveVoiceOpenAiKeyhonors the deployment's Voice enablement for the environment key too. The enablement is read on every call (one indexed read) so a toggle applies immediately; only the environment key value itself stays cached.trpc/commands/mcp-connections:getVoiceConnectionCommandreportsenabledso the card can offer the switch (no enablement row means on).setDeploymentMcpEnabledCommandaccepts enabling Voice without a stored connection when the environment provides the key, and does not delete a stored key when disabling in that case, so the deployment falls back to its own key if the environment key is ever removed.Tests
enabled: false, and the connection query reportsenabled: false.pnpm lint:fastand webtsc --noEmitpass.