Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

chore(enterprise): PR review cleanups

Gabriel Stein795e7c1fb9e0
diff --git a/src/components/EnterpriseProviderConfig.tsx b/src/components/EnterpriseProviderConfig.tsx
index af3d7d872..2b3024bd5 100644
--- a/src/components/EnterpriseProviderConfig.tsx
+++ b/src/components/EnterpriseProviderConfig.tsx
@@ -6,61 +6,71 @@ import ModelCardList from "./ui/ModelCardList";
import CustomModelInput from "./ui/CustomModelInput";
import TestConnectionButton from "./TestConnectionButton";
import { REASONING_PROVIDERS } from "../models/ModelRegistry";
-import { modelRegistry } from "../models/ModelRegistry";
+import { useSettingsStore } from "../stores/settingsStore";
import { getProviderIcon, isMonochromeProvider } from "../utils/providerIcons";
interface EnterpriseProviderConfigProps {
provider: "bedrock" | "azure" | "vertex";
reasoningModel: string;
setReasoningModel: (model: string) => void;
- // Bedrock
- bedrockAuthMode: string;
- setBedrockAuthMode: (v: string) => void;
- bedrockRegion: string;
- setBedrockRegion: (v: string) => void;
- bedrockProfile: string;
- setBedrockProfile: (v: string) => void;
- bedrockAccessKeyId: string;
- setBedrockAccessKeyId: (v: string) => void;
- bedrockSecretAccessKey: string;
- setBedrockSecretAccessKey: (v: string) => void;
- bedrockSessionToken: string;
- setBedrockSessionToken: (v: string) => void;
- // Azure
- azureEndpoint: string;
- setAzureEndpoint: (v: string) => void;
- azureApiKey: string;
- setAzureApiKey: (v: string) => void;
- azureDeploymentName: string;
- setAzureDeploymentName: (v: string) => void;
- azureApiVersion: string;
- setAzureApiVersion: (v: string) => void;
- // Vertex
- vertexAuthMode: string;
- setVertexAuthMode: (v: string) => void;
- vertexProject: string;
- setVertexProject: (v: string) => void;
- vertexLocation: string;
- setVertexLocation: (v: string) => void;
- vertexApiKey: string;
- setVertexApiKey: (v: string) => void;
}
const BEDROCK_REGIONS = [
"us-east-1",
+ "us-east-2",
+ "us-west-1",
"us-west-2",
- "eu-west-1",
+ "ca-central-1",
"eu-central-1",
- "ap-northeast-1",
+ "eu-west-1",
+ "eu-west-2",
+ "eu-west-3",
+ "eu-north-1",
+ "eu-south-1",
+ "ap-south-1",
"ap-southeast-1",
+ "ap-southeast-2",
+ "ap-southeast-3",
+ "ap-northeast-1",
+ "ap-northeast-2",
+ "ap-northeast-3",
+ "sa-east-1",
+ "me-central-1",
+ "af-south-1",
];
const VERTEX_LOCATIONS = [
"us-central1",
+ "us-east1",
"us-east4",
+ "us-east5",
+ "us-west1",
+ "us-west4",
+ "us-south1",
+ "northamerica-northeast1",
+ "northamerica-northeast2",
+ "southamerica-east1",
+ "europe-west1",
+ "europe-west2",
+ "europe-west3",
"europe-west4",
+ "europe-west6",
+ "europe-west8",
+ "europe-west9",
+ "europe-north1",
+ "europe-central2",
+ "europe-southwest1",
+ "asia-east1",
+ "asia-east2",
"asia-northeast1",
+ "asia-northeast2",
+ "asia-northeast3",
+ "asia-south1",
"asia-southeast1",
+ "asia-southeast2",
+ "australia-southeast1",
+ "australia-southeast2",
+ "me-west1",
];
function AuthModeToggle({
@@ -100,14 +110,13 @@ function FieldHint({ children }: { children: React.ReactNode }) {
return <p className="text-xs text-muted-foreground/70">{children}</p>;
}
-function BedrockConfig(props: EnterpriseProviderConfigProps) {
+function useSuggestedModels(provider: "bedrock" | "vertex") {
const { t } = useTranslation();
-
- const suggestedModels = useMemo(() => {
- const providerData = REASONING_PROVIDERS.bedrock;
+ return useMemo(() => {
+ const providerData = REASONING_PROVIDERS[provider];
if (!providerData?.models?.length) return [];
- const iconUrl = getProviderIcon("bedrock");
- const invertInDark = isMonochromeProvider("bedrock");
+ const iconUrl = getProviderIcon(provider);
+ const invertInDark = isMonochromeProvider(provider);
return providerData.models.map((m) => ({
...m,
description: m.descriptionKey
@@ -116,15 +125,21 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
icon: iconUrl,
invertInDark,
}));
- }, [t]);
+ }, [t, provider]);
+}
+
+function BedrockConfig({ reasoningModel, setReasoningModel }: EnterpriseProviderConfigProps) {
+ const { t } = useTranslation();
+ const store = useSettingsStore();
+ const suggestedModels = useSuggestedModels("bedrock");
const getTestConfig = () => ({
- bedrockRegion: props.bedrockRegion,
- bedrockProfile: props.bedrockAuthMode === "sso" ? props.bedrockProfile : "",
- bedrockAccessKeyId: props.bedrockAuthMode === "keys" ? props.bedrockAccessKeyId : "",
- bedrockSecretAccessKey: props.bedrockAuthMode === "keys" ? props.bedrockSecretAccessKey : "",
- bedrockSessionToken: props.bedrockAuthMode === "keys" ? props.bedrockSessionToken : "",
- model: props.reasoningModel,
+ bedrockRegion: store.bedrockRegion,
+ bedrockProfile: store.bedrockAuthMode === "sso" ? store.bedrockProfile : "",
+ bedrockAccessKeyId: store.bedrockAuthMode === "keys" ? store.bedrockAccessKeyId : "",
+ bedrockSecretAccessKey: store.bedrockAuthMode === "keys" ? store.bedrockSecretAccessKey : "",
+ bedrockSessionToken: store.bedrockAuthMode === "keys" ? store.bedrockSessionToken : "",
+ model: reasoningModel,
});
return (
@@ -144,20 +159,20 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
label: t("reasoning.enterprise.accessKeys", { defaultValue: "Access Keys" }),
},
]}
- value={props.bedrockAuthMode}
- onChange={props.setBedrockAuthMode}
+ value={store.bedrockAuthMode}
+ onChange={store.setBedrockAuthMode}
/>
</div>
- {props.bedrockAuthMode === "sso" ? (
+ {store.bedrockAuthMode === "sso" ? (
<div className="space-y-2">
<div className="space-y-1.5">
<FieldLabel>
{t("reasoning.enterprise.profile", { defaultValue: "Profile Name" })}
</FieldLabel>
<Input
- value={props.bedrockProfile}
- onChange={(e) => props.setBedrockProfile(e.target.value)}
+ value={store.bedrockProfile}
+ onChange={(e) => store.setBedrockProfile(e.target.value)}
placeholder="default"
className="text-sm"
/>
@@ -176,8 +191,8 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.accessKeyId", { defaultValue: "Access Key ID" })}
</FieldLabel>
<ApiKeyInput
- apiKey={props.bedrockAccessKeyId}
- setApiKey={props.setBedrockAccessKeyId}
+ apiKey={store.bedrockAccessKeyId}
+ setApiKey={store.setBedrockAccessKeyId}
label=""
placeholder="AKIA..."
/>
@@ -187,8 +202,8 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.secretAccessKey", { defaultValue: "Secret Access Key" })}
</FieldLabel>
<ApiKeyInput
- apiKey={props.bedrockSecretAccessKey}
- setApiKey={props.setBedrockSecretAccessKey}
+ apiKey={store.bedrockSecretAccessKey}
+ setApiKey={store.setBedrockSecretAccessKey}
label=""
/>
</div>
@@ -199,8 +214,8 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
})}
</FieldLabel>
<Input
- value={props.bedrockSessionToken}
- onChange={(e) => props.setBedrockSessionToken(e.target.value)}
+ value={store.bedrockSessionToken}
+ onChange={(e) => store.setBedrockSessionToken(e.target.value)}
placeholder=""
className="text-sm"
/>
@@ -211,8 +226,8 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
<div className="space-y-1.5">
<FieldLabel>{t("reasoning.enterprise.region", { defaultValue: "Region" })}</FieldLabel>
<select
- value={props.bedrockRegion}
- onChange={(e) => props.setBedrockRegion(e.target.value)}
+ value={store.bedrockRegion}
+ onChange={(e) => store.setBedrockRegion(e.target.value)}
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm"
>
{BEDROCK_REGIONS.map((r) => (
@@ -230,28 +245,29 @@ function BedrockConfig(props: EnterpriseProviderConfigProps) {
</FieldLabel>
<ModelCardList
models={suggestedModels}
- selectedModel={props.reasoningModel}
- onModelSelect={props.setReasoningModel}
+ selectedModel={reasoningModel}
+ onModelSelect={setReasoningModel}
colorScheme="purple"
/>
</div>
)}
- <CustomModelInput value={props.reasoningModel} onChange={props.setReasoningModel} />
+ <CustomModelInput value={reasoningModel} onChange={setReasoningModel} />
<TestConnectionButton provider="bedrock" getConfig={getTestConfig} />
</div>
);
}
-function AzureConfig(props: EnterpriseProviderConfigProps) {
+function AzureConfig({ reasoningModel, setReasoningModel }: EnterpriseProviderConfigProps) {
const { t } = useTranslation();
+ const store = useSettingsStore();
const getTestConfig = () => ({
- azureEndpoint: props.azureEndpoint,
- azureApiVersion: props.azureApiVersion,
- apiKey: props.azureApiKey,
- model: props.azureDeploymentName || props.reasoningModel,
+ azureEndpoint: store.azureEndpoint,
+ azureApiVersion: store.azureApiVersion,
+ apiKey: store.azureApiKey,
+ model: store.azureDeploymentName || reasoningModel,
});
return (
@@ -261,8 +277,8 @@ function AzureConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.endpoint", { defaultValue: "Endpoint URL" })}
</FieldLabel>
<Input
- value={props.azureEndpoint}
- onChange={(e) => props.setAzureEndpoint(e.target.value)}
+ value={store.azureEndpoint}
+ onChange={(e) => store.setAzureEndpoint(e.target.value)}
placeholder="https://yourresource.openai.azure.com"
className="text-sm"
/>
@@ -276,11 +292,7 @@ function AzureConfig(props: EnterpriseProviderConfigProps) {
<div className="space-y-1.5">
<FieldLabel>API Key</FieldLabel>
- <ApiKeyInput
- apiKey={props.azureApiKey}
- setApiKey={props.setAzureApiKey}
- label=""
- />
+ <ApiKeyInput apiKey={store.azureApiKey} setApiKey={store.setAzureApiKey} label="" />
</div>
<div className="space-y-1.5">
@@ -288,10 +300,10 @@ function AzureConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.deploymentName", { defaultValue: "Deployment Name" })}
</FieldLabel>
<Input
- value={props.azureDeploymentName}
+ value={store.azureDeploymentName}
onChange={(e) => {
- props.setAzureDeploymentName(e.target.value);
- props.setReasoningModel(e.target.value);
+ store.setAzureDeploymentName(e.target.value);
+ setReasoningModel(e.target.value);
}}
placeholder="gpt-4o-deployment"
className="text-sm font-mono"
@@ -308,8 +320,8 @@ function AzureConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.apiVersion", { defaultValue: "API Version" })}
</FieldLabel>
<Input
- value={props.azureApiVersion}
- onChange={(e) => props.setAzureApiVersion(e.target.value)}
+ value={store.azureApiVersion}
+ onChange={(e) => store.setAzureApiVersion(e.target.value)}
placeholder="2024-10-21"
className="text-sm font-mono"
/>
@@ -320,29 +332,16 @@ function AzureConfig(props: EnterpriseProviderConfigProps) {
);
}
-function VertexConfig(props: EnterpriseProviderConfigProps) {
+function VertexConfig({ reasoningModel, setReasoningModel }: EnterpriseProviderConfigProps) {
const { t } = useTranslation();
-
- const suggestedModels = useMemo(() => {
- const providerData = REASONING_PROVIDERS.vertex;
- if (!providerData?.models?.length) return [];
- const iconUrl = getProviderIcon("vertex");
- const invertInDark = isMonochromeProvider("vertex");
- return providerData.models.map((m) => ({
- ...m,
- description: m.descriptionKey
- ? t(m.descriptionKey, { defaultValue: m.description })
- : m.description,
- icon: iconUrl,
- invertInDark,
- }));
- }, [t]);
+ const store = useSettingsStore();
+ const suggestedModels = useSuggestedModels("vertex");
const getTestConfig = () => ({
- vertexProject: props.vertexProject,
- vertexLocation: props.vertexLocation,
- apiKey: props.vertexAuthMode === "apikey" ? props.vertexApiKey : "",
- model: props.reasoningModel,
+ vertexProject: store.vertexProject,
+ vertexLocation: store.vertexLocation,
+ apiKey: store.vertexAuthMode === "apikey" ? store.vertexApiKey : "",
+ model: reasoningModel,
});
return (
@@ -364,17 +363,17 @@ function VertexConfig(props: EnterpriseProviderConfigProps) {
label: t("reasoning.enterprise.apiKeyMode", { defaultValue: "API Key" }),
},
]}
- value={props.vertexAuthMode}
- onChange={props.setVertexAuthMode}
+ value={store.vertexAuthMode}
+ onChange={store.setVertexAuthMode}
/>
</div>
- {props.vertexAuthMode === "apikey" ? (
+ {store.vertexAuthMode === "apikey" ? (
<div className="space-y-1.5">
<FieldLabel>API Key</FieldLabel>
<ApiKeyInput
- apiKey={props.vertexApiKey}
- setApiKey={props.setVertexApiKey}
+ apiKey={store.vertexApiKey}
+ setApiKey={store.setVertexApiKey}
label=""
helpText={t("reasoning.enterprise.vertex.apikeyHelp", {
defaultValue: "Vertex AI Express Mode API key from Google AI Studio.",
@@ -395,20 +394,18 @@ function VertexConfig(props: EnterpriseProviderConfigProps) {
{t("reasoning.enterprise.projectId", { defaultValue: "Project ID" })}
</FieldLabel>
<Input
- value={props.vertexProject}
- onChange={(e) => props.setVertexProject(e.target.value)}
+ value={store.vertexProject}
+ onChange={(e) => store.setVertexProject(e.target.value)}
placeholder="my-gcp-project-123"
className="text-sm"
/>
</div>
<div className="space-y-1.5">
- <FieldLabel>
- {t("reasoning.enterprise.location", { defaultValue: "Location" })}
- </FieldLabel>
+ <FieldLabel>{t("reasoning.enterprise.location", { defaultValue: "Location" })}</FieldLabel>
<select
- value={props.vertexLocation}
- onChange={(e) => props.setVertexLocation(e.target.value)}
+ value={store.vertexLocation}
+ onChange={(e) => store.setVertexLocation(e.target.value)}
className="w-full rounded-md border border-input bg-background px-3 py-2 text-sm"
>
{VERTEX_LOCATIONS.map((loc) => (
@@ -426,14 +423,14 @@ function VertexConfig(props: EnterpriseProviderConfigProps) {
</FieldLabel>
<ModelCardList
models={suggestedModels}
- selectedModel={props.reasoningModel}
- onModelSelect={props.setReasoningModel}
+ selectedModel={reasoningModel}
+ onModelSelect={setReasoningModel}
colorScheme="purple"
/>
</div>
)}
- <CustomModelInput value={props.reasoningModel} onChange={props.setReasoningModel} />
+ <CustomModelInput value={reasoningModel} onChange={setReasoningModel} />
<TestConnectionButton provider="vertex" getConfig={getTestConfig} />
</div>
diff --git a/src/components/EnterpriseSection.tsx b/src/components/EnterpriseSection.tsx
index f72e10464..20bb4d7c7 100644
--- a/src/components/EnterpriseSection.tsx
+++ b/src/components/EnterpriseSection.tsx
@@ -24,10 +24,10 @@ export default function EnterpriseSection({
setReasoningModel,
setLocalReasoningProvider,
}: EnterpriseSectionProps) {
+ const azureDeploymentName = useSettingsStore((s) => s.azureDeploymentName);
const selectedEnterprise = ENTERPRISE_PROVIDER_TABS.some((p) => p.id === currentProvider)
? currentProvider
: "";
- const store = useSettingsStore();
const handleEnterpriseSelect = (providerId: string) => {
if (selectedEnterprise === providerId) return;
@@ -36,8 +36,8 @@ export default function EnterpriseSection({
const providerData = REASONING_PROVIDERS[providerId];
if (providerData?.models?.length) {
setReasoningModel(providerData.models[0].value);
- } else if (providerId === "azure" && store.azureDeploymentName) {
- setReasoningModel(store.azureDeploymentName);
+ } else if (providerId === "azure" && azureDeploymentName) {
+ setReasoningModel(azureDeploymentName);
}
};
@@ -57,34 +57,6 @@ export default function EnterpriseSection({
provider={selectedEnterprise as "bedrock" | "azure" | "vertex"}
reasoningModel={reasoningModel}
setReasoningModel={setReasoningModel}
- bedrockAuthMode={store.bedrockAuthMode}
- setBedrockAuthMode={store.setBedrockAuthMode}
- bedrockRegion={store.bedrockRegion}
- setBedrockRegion={store.setBedrockRegion}
- bedrockProfile={store.bedrockProfile}
- setBedrockProfile={store.setBedrockProfile}
- bedrockAccessKeyId={store.bedrockAccessKeyId}
- setBedrockAccessKeyId={store.setBedrockAccessKeyId}
- bedrockSecretAccessKey={store.bedrockSecretAccessKey}
- setBedrockSecretAccessKey={store.setBedrockSecretAccessKey}
- bedrockSessionToken={store.bedrockSessionToken}
- setBedrockSessionToken={store.setBedrockSessionToken}
- azureEndpoint={store.azureEndpoint}
- setAzureEndpoint={store.setAzureEndpoint}
- azureApiKey={store.azureApiKey}
- setAzureApiKey={store.setAzureApiKey}
- azureDeploymentName={store.azureDeploymentName}
- setAzureDeploymentName={store.setAzureDeploymentName}
- azureApiVersion={store.azureApiVersion}
- setAzureApiVersion={store.setAzureApiVersion}
- vertexAuthMode={store.vertexAuthMode}
- setVertexAuthMode={store.setVertexAuthMode}
- vertexProject={store.vertexProject}
- setVertexProject={store.setVertexProject}
- vertexLocation={store.vertexLocation}
- setVertexLocation={store.setVertexLocation}
- vertexApiKey={store.vertexApiKey}
- setVertexApiKey={store.setVertexApiKey}
/>
</div>
)}
diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsx
index 807405ba3..5c2783319 100644
--- a/src/components/ReasoningModelSelector.tsx
+++ b/src/components/ReasoningModelSelector.tsx
@@ -999,7 +999,6 @@ export default function ReasoningModelSelector({
<GpuStatusBadge />
</>
)}
-
</div>
);
}
diff --git a/src/components/TestConnectionButton.tsx b/src/components/TestConnectionButton.tsx
index 135544232..7f262ef5e 100644
--- a/src/components/TestConnectionButton.tsx
+++ b/src/components/TestConnectionButton.tsx
@@ -66,9 +66,7 @@ export default function TestConnectionButton({ provider, getConfig }: TestConnec
{status === "error" && errorInfo && (
<div className="rounded-md bg-destructive/10 border border-destructive/20 p-2.5 space-y-1.5">
<p className="text-xs text-destructive font-medium">{errorInfo.message}</p>
- {errorInfo.action && (
- <p className="text-xs text-muted-foreground">{errorInfo.action}</p>
- )}
+ {errorInfo.action && <p className="text-xs text-muted-foreground">{errorInfo.action}</p>}
{errorInfo.copyCommand && (
<div className="flex items-center gap-1.5">
<code className="text-xs bg-muted px-1.5 py-0.5 rounded flex-1 font-mono">
diff --git a/src/helpers/enterpriseProviderErrors.js b/src/helpers/enterpriseProviderErrors.js
index 797286e1c..f236f3221 100644
--- a/src/helpers/enterpriseProviderErrors.js
+++ b/src/helpers/enterpriseProviderErrors.js
@@ -139,9 +139,40 @@ function isEnterpriseProvider(value) {
return typeof value === "string" && ENTERPRISE_PROVIDERS.includes(value);
}
+const BLOCKED_HOSTS = new Set([
+ "localhost",
+ "169.254.169.254",
+ "metadata.google.internal",
+ "metadata",
+]);
+
+const BLOCKED_SUFFIXES = [".internal", ".localhost", ".local"];
+
+function isPrivateIPv4(hostname) {
+ const match = hostname.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
+ if (!match) return false;
+ const [, a, b] = match.map(Number);
+ return (
+ a === 0 ||
+ a === 10 ||
+ a === 127 ||
+ (a === 169 && b === 254) ||
+ (a === 172 && b >= 16 && b <= 31) ||
+ (a === 192 && b === 168)
+ );
+}
+
+function isPrivateIPv6(hostname) {
+ if (hostname === "::1") return true;
+ if (/^(fe80|fc[0-9a-f]{2}|fd[0-9a-f]{2}):/i.test(hostname)) return true;
+ const mapped = hostname.match(/^::ffff:(.+)$/i);
+ return mapped ? isPrivateIPv4(mapped[1]) : false;
+}
+
/**
* SSRF guard for enterprise HTTP endpoints (currently only Azure).
* Throws if the URL is non-HTTPS or resolves to a private/metadata host.
+ * Note: DNS rebinding is not mitigated — hostnames resolve per-request.
*/
function validateEnterpriseEndpoint(endpoint) {
if (!endpoint) return;
@@ -151,12 +182,10 @@ function validateEnterpriseEndpoint(endpoint) {
}
const hostname = url.hostname.toLowerCase();
if (
- hostname === "localhost" ||
- hostname === "169.254.169.254" ||
- hostname === "metadata.google.internal" ||
- hostname.startsWith("10.") ||
- hostname.startsWith("192.168.") ||
- hostname.startsWith("127.")
+ BLOCKED_HOSTS.has(hostname) ||
+ BLOCKED_SUFFIXES.some((suffix) => hostname.endsWith(suffix)) ||
+ isPrivateIPv4(hostname) ||
+ isPrivateIPv6(hostname)
) {
throw new Error("Private/metadata endpoints are not allowed.");
}
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 9bff0cedf..56cb16f8b 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -2446,7 +2446,7 @@ class IPCHandlers {
await generateText({
model,
prompt: "Say hello in one word.",
- maxTokens: 10,
+ maxOutputTokens: 10,
});
return { success: true };
@@ -2457,6 +2457,7 @@ class IPCHandlers {
error: mapped.message,
action: mapped.action,
copyCommand: mapped.copyCommand,
+ retryable: mapped.retryable,
};
}
});
@@ -2508,7 +2509,7 @@ class IPCHandlers {
} catch (err) {
debugLogger.error("Enterprise reasoning error:", err);
const mapped = mapEnterpriseError(provider, err, config || {});
- return { success: false, error: mapped.message };
+ return { success: false, error: mapped.message, retryable: mapped.retryable };
}
}
);
diff --git a/src/hooks/useReasoningRetry.ts b/src/hooks/useReasoningRetry.ts
deleted file mode 100644
index fc0a5a3ec..000000000
--- a/src/hooks/useReasoningRetry.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { useState, useCallback } from "react";
-
-interface ReasoningRetryPayload {
- text: string;
- model: string;
- agentName: string | null;
- config: Record<string, unknown>;
-}
-
-const STORAGE_KEY = "pendingReasoningInput";
-
-function readStoredPayload(): ReasoningRetryPayload | null {
- try {
- const stored = sessionStorage.getItem(STORAGE_KEY);
- return stored ? (JSON.parse(stored) as ReasoningRetryPayload) : null;
- } catch {
- return null;
- }
-}
-
-export function useReasoningRetry() {
- const [retryPayload, setRetryPayload] = useState<ReasoningRetryPayload | null>(() =>
- readStoredPayload()
- );
-
- const clearRetry = useCallback(() => {
- sessionStorage.removeItem(STORAGE_KEY);
- setRetryPayload(null);
- }, []);
-
- const refreshRetry = useCallback(() => {
- setRetryPayload(readStoredPayload());
- }, []);
-
- return {
- hasPendingRetry: retryPayload !== null,
- retryPayload,
- clearRetry,
- refreshRetry,
- };
-}
diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.json
index 9e889de48..109b2b64f 100644
--- a/src/locales/zh-CN/translation.json
+++ b/src/locales/zh-CN/translation.json
@@ -1052,12 +1052,7 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最受欢迎",
- "features": [
- "无限会议录制",
- "代理模式",
- "与您的数据对话",
- "优先支持"
- ],
+ "features": ["无限会议录制", "代理模式", "与您的数据对话", "优先支持"],
"cta": "开始使用",
"switchToAnnual": "切换为年付"
},
diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.json
index f3bd7b533..204bd2810 100644
--- a/src/locales/zh-TW/translation.json
+++ b/src/locales/zh-TW/translation.json
@@ -1052,12 +1052,7 @@
"annualEquivalent": "$16.67",
"includesPrefix": "所有 Pro 功能 +",
"badge": "最熱門",
- "features": [
- "無限會議錄製",
- "代理模式",
- "與您的資料對話",
- "優先支援"
- ],
+ "features": ["無限會議錄製", "代理模式", "與您的資料對話", "優先支援"],
"cta": "開始使用",
"switchToAnnual": "切換為年付"
},
diff --git a/src/models/ModelRegistry.ts b/src/models/ModelRegistry.ts
index f6c7042d6..858901e9c 100644
--- a/src/models/ModelRegistry.ts
+++ b/src/models/ModelRegistry.ts
@@ -213,16 +213,9 @@ export interface ReasoningProvider {
export type ReasoningProviders = Record<string, ReasoningProvider>;
export type EnterpriseProvider = "bedrock" | "azure" | "vertex";
-export const ENTERPRISE_PROVIDERS: readonly EnterpriseProvider[] = [
- "bedrock",
- "azure",
- "vertex",
-];
+export const ENTERPRISE_PROVIDERS: readonly EnterpriseProvider[] = ["bedrock", "azure", "vertex"];
export function isEnterpriseProvider(value: unknown): value is EnterpriseProvider {
- return (
- typeof value === "string" &&
- (ENTERPRISE_PROVIDERS as readonly string[]).includes(value)
- );
+ return typeof value === "string" && (ENTERPRISE_PROVIDERS as readonly string[]).includes(value);
}
function buildReasoningProviders(): ReasoningProviders {
@@ -287,8 +280,6 @@ export function getReasoningModelLabel(modelId: string): string {
return model?.fullLabel || modelId;
}
-const ENTERPRISE_PROVIDER_IDS = ["bedrock", "azure", "vertex"];
-
export function getModelProvider(modelId: string): string {
if (isCloudReasoningMode()) {
return "openwhispr";
@@ -300,8 +291,7 @@ export function getModelProvider(modelId: string): string {
return "custom";
}
- // Enterprise providers are authoritative — don't fall through to heuristic matching
- if (ENTERPRISE_PROVIDER_IDS.includes(storedProvider)) {
+ if (isEnterpriseProvider(storedProvider)) {
return storedProvider;
}
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index 97549f450..5e56d10a4 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -2,7 +2,7 @@ import {
getModelProvider,
getCloudModel,
getOpenAiApiConfig,
- ENTERPRISE_PROVIDERS,
+ isEnterpriseProvider,
type EnterpriseProvider,
} from "../models/ModelRegistry";
import { BaseReasoningService, ReasoningConfig } from "./BaseReasoningService";
@@ -492,15 +492,6 @@ class ReasoningService extends BaseReasoningService {
timestamp: new Date().toISOString(),
});
- // Persist input for retry on enterprise auth failures
- const isEnterprise = (ENTERPRISE_PROVIDERS as readonly string[]).includes(provider);
- if (isEnterprise && typeof sessionStorage !== "undefined") {
- sessionStorage.setItem(
- "pendingReasoningInput",
- JSON.stringify({ text, model: trimmedModel, agentName, config })
- );
- }
-
try {
let result: string;
const startTime = Date.now();
@@ -564,11 +555,6 @@ class ReasoningService extends BaseReasoningService {
resultPreview: result.substring(0, 100) + (result.length > 100 ? "..." : ""),
});
- // Clear persisted input on success
- if (isEnterprise && typeof sessionStorage !== "undefined") {
- sessionStorage.removeItem("pendingReasoningInput");
- }
-
return result;
} catch (error) {
logger.logReasoning("PROVIDER_ERROR", {
@@ -578,21 +564,6 @@ class ReasoningService extends BaseReasoningService {
stack: (error as Error).stack,
});
- // For enterprise providers, mark auth errors as retryable (input is preserved in sessionStorage)
- if (isEnterprise) {
- const msg = (error as Error).message || "";
- const isAuthError =
- msg.includes("ExpiredToken") ||
- msg.includes("UNAUTHENTICATED") ||
- msg.includes("Unauthorized") ||
- msg.includes("expired") ||
- msg.includes("Could not load the default credentials");
- if (isAuthError) {
- const enhanced = error as Error & { retryable?: boolean };
- enhanced.retryable = true;
- }
- }
-
throw error;
}
}
@@ -921,36 +892,27 @@ class ReasoningService extends BaseReasoningService {
const s = getSettings();
const apiKey =
- provider === "azure"
- ? s.azureApiKey
- : provider === "vertex"
- ? s.vertexApiKey
- : "";
+ provider === "azure" ? s.azureApiKey : provider === "vertex" ? s.vertexApiKey : "";
const { supportsTemperature } = getOpenAiApiConfig(model);
const startTime = Date.now();
- const result = await window.electronAPI.processEnterpriseReasoning(
- text,
- model,
- agentName,
- {
- ...config,
- systemPrompt,
- provider,
- apiKey,
- supportsTemperature,
- bedrockRegion: s.bedrockRegion,
- bedrockProfile: s.bedrockProfile,
- bedrockAccessKeyId: s.bedrockAccessKeyId,
- bedrockSecretAccessKey: s.bedrockSecretAccessKey,
- bedrockSessionToken: s.bedrockSessionToken,
- azureEndpoint: s.azureEndpoint,
- azureApiVersion: s.azureApiVersion,
- vertexProject: s.vertexProject,
- vertexLocation: s.vertexLocation,
- }
- );
+ const result = await window.electronAPI.processEnterpriseReasoning(text, model, agentName, {
+ ...config,
+ systemPrompt,
+ provider,
+ apiKey,
+ supportsTemperature,
+ bedrockRegion: s.bedrockRegion,
+ bedrockProfile: s.bedrockProfile,
+ bedrockAccessKeyId: s.bedrockAccessKeyId,
+ bedrockSecretAccessKey: s.bedrockSecretAccessKey,
+ bedrockSessionToken: s.bedrockSessionToken,
+ azureEndpoint: s.azureEndpoint,
+ azureApiVersion: s.azureApiVersion,
+ vertexProject: s.vertexProject,
+ vertexLocation: s.vertexLocation,
+ });
const processingTimeMs = Date.now() - startTime;
@@ -961,7 +923,11 @@ class ReasoningService extends BaseReasoningService {
processingTimeMs,
error: result.error,
});
- throw new Error(result.error || `${provider} reasoning failed`);
+ const enhanced = new Error(result.error || `${provider} reasoning failed`) as Error & {
+ retryable?: boolean;
+ };
+ enhanced.retryable = result.retryable ?? false;
+ throw enhanced;
}
logger.logReasoning("ENTERPRISE_SUCCESS", {
@@ -1561,6 +1527,13 @@ class ReasoningService extends BaseReasoningService {
config: ReasoningConfig & { systemPrompt: string },
tools?: Record<string, import("ai").Tool>
): AsyncGenerator<AgentStreamChunk, void, unknown> {
+ if (isEnterpriseProvider(provider)) {
+ throw new Error(
+ "Agent Mode is not yet supported with enterprise providers (Bedrock/Azure/Vertex). " +
+ "Switch to Cloud or Local for Agent Mode, or use this provider for text cleanup only."
+ );
+ }
+
const cloudProviders = ["openai", "groq", "gemini", "anthropic", "custom"];
const isLocalProvider = !cloudProviders.includes(provider);
@@ -1858,14 +1831,12 @@ class ReasoningService extends BaseReasoningService {
if (hasBedrockCreds) return true;
}
if (settings.reasoningProvider === "azure") {
- const hasAzureCreds =
- !!settings.azureApiKey?.trim() && !!settings.azureEndpoint?.trim();
+ const hasAzureCreds = !!settings.azureApiKey?.trim() && !!settings.azureEndpoint?.trim();
logger.logReasoning("API_KEY_CHECK", { azure: true, hasAzureCreds });
if (hasAzureCreds) return true;
}
if (settings.reasoningProvider === "vertex") {
- const hasVertexCreds =
- !!settings.vertexApiKey?.trim() || !!settings.vertexProject?.trim();
+ const hasVertexCreds = !!settings.vertexApiKey?.trim() || !!settings.vertexProject?.trim();
logger.logReasoning("API_KEY_CHECK", { vertex: true, hasVertexCreds });
if (hasVertexCreds) return true;
}
diff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.ts
index c6e391246..8f43c2eb2 100644
--- a/src/stores/settingsStore.ts
+++ b/src/stores/settingsStore.ts
@@ -328,7 +328,6 @@ function createBooleanSetter(key: string) {
};
}
-
let envPersistTimer: ReturnType<typeof setTimeout> | null = null;
function debouncedPersistToEnv() {
if (!isBrowser) return;
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 6db61f8e4..188ddbe4c 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -703,7 +703,7 @@ declare global {
modelId: string,
agentName: string | null,
config: any
- ) => Promise<{ success: boolean; text?: string; error?: string }>;
+ ) => Promise<{ success: boolean; text?: string; error?: string; retryable?: boolean }>;
// llama.cpp management
llamaCppCheck: () => Promise<{ isInstalled: boolean; version?: string }>;