Skip to content

Commit 64baae8

Browse files
authored
🤖 refactor: rename coupon code to voucher for mux-gateway (#814)
Renames all 'coupon code' references to 'voucher' for mux-gateway provider. _Generated with `mux`_
1 parent da9acc6 commit 64baae8

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

src/browser/components/Settings/sections/ProvidersSection.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@ function getProviderFields(provider: ProviderName): FieldConfig[] {
4545
];
4646
}
4747

48-
// Mux Gateway only needs couponCode
48+
// Mux Gateway only needs voucher
4949
if (provider === "mux-gateway") {
50-
return [
51-
{ key: "couponCode", label: "Coupon Code", placeholder: "Enter coupon code", type: "secret" },
52-
];
50+
return [{ key: "voucher", label: "Voucher", placeholder: "Enter voucher", type: "secret" }];
5351
}
5452

5553
// Default for most providers
@@ -152,9 +150,9 @@ export function ProvidersSection() {
152150
);
153151
}
154152

155-
// For Mux Gateway, check couponCodeSet
153+
// For Mux Gateway, check voucherSet
156154
if (provider === "mux-gateway") {
157-
return providerConfig.couponCodeSet ?? false;
155+
return providerConfig.voucherSet ?? false;
158156
}
159157

160158
// For other providers, check apiKeySet
@@ -172,8 +170,8 @@ export function ProvidersSection() {
172170
if (fieldConfig.type === "secret") {
173171
// For apiKey, we have apiKeySet from the sanitized config
174172
if (field === "apiKey") return config[provider]?.apiKeySet ?? false;
175-
// For couponCode (mux-gateway), check couponCodeSet
176-
if (field === "couponCode") return config[provider]?.couponCodeSet ?? false;
173+
// For voucher (mux-gateway), check voucherSet
174+
if (field === "voucher") return config[provider]?.voucherSet ?? false;
177175
// For other secrets, check if the field exists in the raw config
178176
// Since we don't expose secret values, we assume they're not set if undefined
179177
const providerConfig = config[provider] as Record<string, unknown> | undefined;

src/browser/components/Settings/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ProviderConfigDisplay {
1717
accessKeyIdSet?: boolean;
1818
secretAccessKeySet?: boolean;
1919
// Mux Gateway-specific fields
20-
couponCodeSet?: boolean;
20+
voucherSet?: boolean;
2121
// Allow additional fields for extensibility
2222
[key: string]: unknown;
2323
}

src/node/services/aiService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -742,9 +742,9 @@ export class AIService extends EventEmitter {
742742

743743
// Handle Mux Gateway provider
744744
if (providerName === "mux-gateway") {
745-
// Mux Gateway uses couponCode as the API key
746-
const couponCode = providerConfig.couponCode;
747-
if (typeof couponCode !== "string" || !couponCode) {
745+
// Mux Gateway uses voucher as the API key (fallback to legacy couponCode)
746+
const voucher = providerConfig.voucher ?? providerConfig.couponCode;
747+
if (typeof voucher !== "string" || !voucher) {
748748
return Err({
749749
type: "api_key_not_found",
750750
provider: providerName,
@@ -764,7 +764,7 @@ export class AIService extends EventEmitter {
764764
const gatewayBaseURL =
765765
providerConfig.baseURL ?? "https://gateway.mux.coder.com/api/v1/ai-gateway/v1/ai";
766766
const gateway = createGateway({
767-
apiKey: couponCode,
767+
apiKey: voucher,
768768
baseURL: gatewayBaseURL,
769769
fetch: fetchWithCacheControl,
770770
});

src/node/services/ipcMain.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,13 +1536,13 @@ export class IpcMain {
15361536
// Load current providers config or create empty
15371537
const providersConfig = this.config.loadProvidersConfig() ?? {};
15381538

1539-
// Track if this is first time setting couponCode for mux-gateway
1540-
const isFirstMuxGatewayCoupon =
1539+
// Track if this is first time setting voucher for mux-gateway
1540+
const isFirstMuxGatewayVoucher =
15411541
provider === "mux-gateway" &&
15421542
keyPath.length === 1 &&
1543-
keyPath[0] === "couponCode" &&
1543+
keyPath[0] === "voucher" &&
15441544
value !== "" &&
1545-
!providersConfig[provider]?.couponCode;
1545+
!providersConfig[provider]?.voucher;
15461546

15471547
// Ensure provider exists
15481548
if (!providersConfig[provider]) {
@@ -1570,7 +1570,7 @@ export class IpcMain {
15701570
}
15711571

15721572
// Add default models when setting up mux-gateway for the first time
1573-
if (isFirstMuxGatewayCoupon) {
1573+
if (isFirstMuxGatewayVoucher) {
15741574
const providerConfig = providersConfig[provider] as Record<string, unknown>;
15751575
if (!providerConfig.models || (providerConfig.models as string[]).length === 0) {
15761576
providerConfig.models = [
@@ -1652,9 +1652,9 @@ export class IpcMain {
16521652
providerData.secretAccessKeySet = !!providerConfig.secretAccessKey;
16531653
}
16541654

1655-
// Mux Gateway-specific fields
1655+
// Mux Gateway-specific fields (fallback to legacy couponCode)
16561656
if (provider === "mux-gateway") {
1657-
providerData.couponCodeSet = !!providerConfig.couponCode;
1657+
providerData.voucherSet = !!(providerConfig.voucher ?? providerConfig.couponCode);
16581658
}
16591659

16601660
sanitized[provider] = providerData;

0 commit comments

Comments
 (0)