Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat(policy): Enforce every org policy field
Chadpiha96290dae0b50
diff --git a/src/components/AgentOverlay.tsx b/src/components/AgentOverlay.tsxindex 8c24a0660..7eb3ee47c 100644--- a/src/components/AgentOverlay.tsx+++ b/src/components/AgentOverlay.tsx@@ -5,6 +5,7 @@ import { AgentTitleBar } from "./agent/AgentTitleBar";import { AgentChat } from "./agent/AgentChat";import { AgentInput } from "./agent/AgentInput";import AudioManager from "../helpers/audioManager";+import { usePolicyStore, isAgentAllowed } from "../stores/policyStore";import { useChatPersistence } from "./chat/useChatPersistence";import { useChatStreaming } from "./chat/useChatStreaming";import { useChatMessageSender } from "./chat/useChatMessageSender";@@ -193,6 +194,22 @@ export default function AgentOverlay() {window.electronAPI?.hideAgentOverlay?.();}, []);+ // The overlay is its own BrowserWindow, so this renderer has to fetch the+ // policy itself — the control panel's fetch lives in a different context.+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const agentAllowed = isAgentAllowed({ managed: policyManaged, policy: policyDoc });++ useEffect(() => {+ void usePolicyStore.getState().fetchPolicy();+ }, []);++ useEffect(() => {+ if (!agentAllowed) window.electronAPI?.hideAgentOverlay?.();+ }, [agentAllowed]);++ if (!agentAllowed) return null;+return (<div className="agent-overlay-window w-screen h-screen bg-transparent relative"><divdiff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 8ccebf9f6..8af14bd9c 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -32,6 +32,8 @@ import {clearTranscriptions as clearStore,} from "../stores/transcriptionStore";import { useSettingsStore } from "../stores/settingsStore";+import { usePolicyStore, isAgentAllowed } from "../stores/policyStore";+import { compareAppVersions } from "../utils/version";import {useIsMeetingMode,useIsNarrowWindow,@@ -173,9 +175,25 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProisInstalling,downloadUpdate,installUpdate,+ getAppVersion,error: updateError,} = useUpdater();+ const policyMinAppVersion = usePolicyStore((s) =>+ s.managed ? (s.policy?.minAppVersion ?? null) : null+ );+ const agentAllowedByPolicy = usePolicyStore((s) =>+ isAgentAllowed({ managed: s.managed, policy: s.policy })+ );+ const [appVersion, setAppVersion] = useState<string | null>(null);+ useEffect(() => {+ if (!policyMinAppVersion) return;+ void getAppVersion().then((version: string | null) => setAppVersion(version));+ }, [policyMinAppVersion, getAppVersion]);+ const updateRequiredByOrg = Boolean(+ policyMinAppVersion && appVersion && compareAppVersions(appVersion, policyMinAppVersion) < 0+ );+const {confirmDialog,alertDialog,@@ -1011,6 +1029,27 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro)}</div><div className="flex-1 overflow-y-auto pt-1">+ {updateRequiredByOrg && (+ <div className="max-w-3xl mx-auto w-full mb-3">+ <div className="rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/50 p-3">+ <div className="flex items-start gap-3">+ <div className="shrink-0 w-8 h-8 rounded-md bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center">+ <AlertTriangle size={16} className="text-amber-600 dark:text-amber-400" />+ </div>+ <div className="flex-1 min-w-0">+ <p className="text-xs font-medium text-amber-900 dark:text-amber-200 mb-0.5">+ {t("controlPanel.updateRequiredByOrg.title")}+ </p>+ <p className="text-xs text-amber-700 dark:text-amber-300/80">+ {t("controlPanel.updateRequiredByOrg.description", {+ version: policyMinAppVersion,+ })}+ </p>+ </div>+ </div>+ </div>+ </div>+ )}{usage?.isPastDue && activeView === "home" && (<div className="max-w-3xl mx-auto w-full mb-3"><div className="rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/50 p-3">@@ -1111,7 +1150,7 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro}}/>)}- {activeView === "chat" && (+ {activeView === "chat" && agentAllowedByPolicy && (<Suspense fallback={null}><ChatView /></Suspense>diff --git a/src/components/ControlPanelSidebar.tsx b/src/components/ControlPanelSidebar.tsxindex 1d48ff35e..cbe6cf18e 100644--- a/src/components/ControlPanelSidebar.tsx+++ b/src/components/ControlPanelSidebar.tsx@@ -19,6 +19,7 @@ import { cn } from "./lib/utils";import SupportDropdown from "./ui/SupportDropdown";import { getCachedPlatform } from "../utils/platform";import type { UpsellDecision } from "../lib/upsell";+import { usePolicyStore, isAgentAllowed } from "../stores/policyStore";const platform = getCachedPlatform();@@ -73,13 +74,17 @@ export default function ControlPanelSidebar({const showLimitBanner = upsell === "show" && Boolean(isSignedIn) && Boolean(isOverLimit);const showUpgradeBanner = upsell === "show" && !showLimitBanner && !upgradeDismissed;+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const agentAllowed = isAgentAllowed({ managed: policyManaged, policy: policyDoc });+const navItems: {id: ControlPanelView;label: string;icon: React.ComponentType<{ size?: number; className?: string }>;}[] = [{ id: "home", label: t("sidebar.home"), icon: Home },- { id: "chat", label: t("sidebar.chat"), icon: MessageSquare },+ ...(agentAllowed ? [{ id: "chat" as const, label: t("sidebar.chat"), icon: MessageSquare }] : []),{ id: "personal-notes", label: t("sidebar.notes"), icon: NotebookPen },{ id: "upload", label: t("sidebar.upload"), icon: Upload },{ id: "dictionary", label: t("sidebar.dictionary"), icon: BookOpen },diff --git a/src/components/EnterpriseSection.tsx b/src/components/EnterpriseSection.tsxindex d23b5b02f..ec29fdc52 100644--- a/src/components/EnterpriseSection.tsx+++ b/src/components/EnterpriseSection.tsx@@ -1,8 +1,10 @@+import { useTranslation } from "react-i18next";import { ProviderTabs } from "./ui/ProviderTabs";import EnterpriseProviderConfig from "./EnterpriseProviderConfig";import { REASONING_PROVIDERS } from "../models/ModelRegistry";import { useSettingsStore } from "../stores/settingsStore";import { adjustBedrockModelForRegion } from "../utils/bedrockRegions";+import { usePolicyStore, isEnterpriseProviderAllowed } from "../stores/policyStore";const ENTERPRISE_PROVIDER_TABS = [{ id: "bedrock", name: "AWS Bedrock" },@@ -23,14 +25,26 @@ export default function EnterpriseSection({setReasoningModel,setLocalReasoningProvider,}: EnterpriseSectionProps) {+ const { t } = useTranslation();const azureDeploymentName = useSettingsStore((s) => s.azureDeploymentName);const bedrockRegion = useSettingsStore((s) => s.bedrockRegion);+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const providerAllowed = (providerId: string) =>+ isEnterpriseProviderAllowed({ managed: policyManaged, policy: policyDoc }, providerId);++ const providerTabs = ENTERPRISE_PROVIDER_TABS.map((tab) =>+ providerAllowed(tab.id)+ ? tab+ : { ...tab, disabled: true, disabledLabel: t("common.managedByOrg") }+ );const selectedEnterprise = ENTERPRISE_PROVIDER_TABS.some((p) => p.id === currentProvider)? currentProvider: "";const handleEnterpriseSelect = (providerId: string) => {if (selectedEnterprise === providerId) return;+ if (!providerAllowed(providerId)) return;setLocalReasoningProvider(providerId);const providerData = REASONING_PROVIDERS[providerId];@@ -49,7 +63,7 @@ export default function EnterpriseSection({return (<div className="space-y-2"><ProviderTabs- providers={ENTERPRISE_PROVIDER_TABS}+ providers={providerTabs}selectedId={selectedEnterprise}onSelect={handleEnterpriseSelect}colorScheme="purple"diff --git a/src/components/ReasoningModelSelector.tsx b/src/components/ReasoningModelSelector.tsxindex f374d5e42..e09ccef56 100644--- a/src/components/ReasoningModelSelector.tsx+++ b/src/components/ReasoningModelSelector.tsx@@ -24,6 +24,7 @@ import { getRemoteProviderIcon } from "../utils/providerIcons";import { GetApiKeyLink } from "./ui/GetApiKeyLink";import { getCachedPlatform } from "../utils/platform";import { useSettingsStore } from "../stores/settingsStore";+import { usePolicyStore, isProviderAllowed } from "../stores/policyStore";type CloudModelOption = {value: string;@@ -348,10 +349,17 @@ export default function ReasoningModelSelector({loading: tinfoilModelsLoading,error: tinfoilModelsError,} = useTinfoilModels(selectedCloudProvider === "tinfoil");+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const providerAllowed = useCallback(+ (providerId: string) =>+ isProviderAllowed({ managed: policyManaged, policy: policyDoc }, "llm", providerId),+ [policyManaged, policyDoc]+ );const effectiveMode = mode || selectedMode;- const cloudProviders = CLOUD_PROVIDER_IDS.map((id) => ({+ const cloudProviders = CLOUD_PROVIDER_IDS.filter(providerAllowed).map((id) => ({id,name:id === "custom"@@ -467,8 +475,15 @@ export default function ReasoningModelSelector({if (newMode === "cloud") {window.electronAPI?.llamaServerStop?.();- setLocalReasoningProvider(selectedCloudProvider);- selectDefaultModelForProvider(selectedCloudProvider);+ // The remembered cloud provider may have become policy-disallowed while+ // the user was in local mode — fall back to the first allowed one.+ const nextProvider = providerAllowed(selectedCloudProvider)+ ? selectedCloudProvider+ : cloudProviders[0]?.id;+ if (!nextProvider) return;+ if (nextProvider !== selectedCloudProvider) setSelectedCloudProvider(nextProvider);+ setLocalReasoningProvider(nextProvider);+ selectDefaultModelForProvider(nextProvider);} else {setLocalReasoningProvider(selectedLocalProvider);const downloaded = await loadDownloadedModels();@@ -486,6 +501,7 @@ export default function ReasoningModelSelector({};const handleCloudProviderChange = (provider: string) => {+ if (!providerAllowed(provider)) return;setSelectedCloudProvider(provider);setLocalReasoningProvider(provider);selectDefaultModelForProvider(provider);diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex 5fdeb2fb6..b6e211446 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -108,7 +108,14 @@ import { syncService } from "../services/SyncService.js";import { formatBytes } from "../utils/formatBytes";import { clearMissingLocalModelSelections, useSettingsStore } from "../stores/settingsStore";import { useWorkspaceStore } from "../stores/workspaceStore";-import { usePolicyStore, enforceModeOptions, isModeAllowed } from "../stores/policyStore";+import {+ usePolicyStore,+ enforceModeOptions,+ isModeAllowed,+ lockedLocalHistoryValue,+ isCloudBackupAllowed,+ maxAudioRetentionDays,+} from "../stores/policyStore";import { canManageSystemAudioInApp } from "../utils/systemAudioAccess";import WorkspaceSection from "./settings/WorkspaceSection";import WorkspaceBillingOverview from "./settings/WorkspaceBillingOverview";@@ -864,6 +871,13 @@ export default function SettingsPage({const translationKey = useSettingsStore((s) => s.translationKey);const setTranslationKey = useSettingsStore((s) => s.setTranslationKey);+ const settingsPolicyManaged = usePolicyStore((s) => s.managed);+ const settingsPolicyDoc = usePolicyStore((s) => s.policy);+ const settingsPolicyState = { managed: settingsPolicyManaged, policy: settingsPolicyDoc };+ const historyLockedByPolicy = lockedLocalHistoryValue(settingsPolicyState) !== null;+ const cloudBackupPolicyAllowed = isCloudBackupAllowed(settingsPolicyState);+ const audioRetentionCap = maxAudioRetentionDays(settingsPolicyState);+const { t, i18n } = useTranslation();const { toast } = useToast();@@ -3514,10 +3528,15 @@ EOF`,<SettingsPanelRow><SettingsRowlabel={t("settingsPage.privacy.cloudBackup")}- description={t("settingsPage.privacy.cloudBackupDescription")}+ description={+ cloudBackupPolicyAllowed+ ? t("settingsPage.privacy.cloudBackupDescription")+ : t("common.managedByOrg")+ }><Togglechecked={cloudBackupEnabled}+ disabled={!cloudBackupPolicyAllowed}onChange={(v) => {setCloudBackupEnabled(v);if (v) {@@ -3616,12 +3635,20 @@ EOF`,><selectvalue={audioRetentionDays}- onChange={(e) => setAudioRetentionDays(parseInt(e.target.value, 10))}+ onChange={(e) => {+ const days = parseInt(e.target.value, 10);+ if (audioRetentionCap !== null && days > audioRetentionCap) return;+ setAudioRetentionDays(days);+ }}className={RETENTION_SELECT_CLASS}><option value={0}>{t("settingsPage.privacy.audioRetentionDisabled")}</option>{RETENTION_DAY_OPTIONS.map((days) => (- <option key={days} value={days}>+ <option+ key={days}+ value={days}+ disabled={audioRetentionCap !== null && days > audioRetentionCap}+ >{t("settingsPage.privacy.retentionDays", { count: days })}</option>))}@@ -3660,9 +3687,17 @@ EOF`,<SettingsPanelRow><SettingsRowlabel={t("settingsPage.privacy.dataRetention")}- description={t("settingsPage.privacy.dataRetentionDescription")}+ description={+ historyLockedByPolicy+ ? t("common.managedByOrg")+ : t("settingsPage.privacy.dataRetentionDescription")+ }>- <Toggle checked={dataRetentionEnabled} onChange={setDataRetentionEnabled} />+ <Toggle+ checked={dataRetentionEnabled}+ disabled={historyLockedByPolicy}+ onChange={setDataRetentionEnabled}+ /></SettingsRow></SettingsPanelRow><SettingsPanelRow>diff --git a/src/components/TranscriptionModelPicker.tsx b/src/components/TranscriptionModelPicker.tsxindex e57c6f2db..dbde45583 100644--- a/src/components/TranscriptionModelPicker.tsx+++ b/src/components/TranscriptionModelPicker.tsx@@ -25,6 +25,7 @@ import {type ModelPickerStyles,} from "../utils/modelPickerStyles";import { useSettingsStore } from "../stores/settingsStore";+import { usePolicyStore, isProviderAllowed } from "../stores/policyStore";import { getRemoteProviderIcon } from "../utils/providerIcons";import { createExternalLinkHandler } from "../utils/externalLinks";import { API_ENDPOINTS, normalizeBaseUrl } from "../config/constants";@@ -393,16 +394,27 @@ export default function TranscriptionModelPicker({const { confirmDialog, showConfirmDialog, hideConfirmDialog } = useDialogs();const colorScheme: ColorScheme = variant === "settings" ? "purple" : "blue";const styles = useMemo(() => MODEL_PICKER_COLORS[colorScheme], [colorScheme]);+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const providerAllowed = useCallback(+ (providerId: string) =>+ isProviderAllowed({ managed: policyManaged, policy: policyDoc }, "transcription", providerId),+ [policyManaged, policyDoc]+ );const cloudProviders = useMemo(- () => (streamingOnly ? getStreamingTranscriptionProviders() : getTranscriptionProviders()),- [streamingOnly]+ () =>+ (streamingOnly ? getStreamingTranscriptionProviders() : getTranscriptionProviders()).filter(+ (p) => providerAllowed(p.id)+ ),+ [streamingOnly, providerAllowed]);const cloudProviderTabs = useMemo(() => {- const visibleIds = new Set([...cloudProviders.map((p) => p.id), "custom"]);+ const visibleIds = new Set(cloudProviders.map((p) => p.id));+ if (providerAllowed("custom")) visibleIds.add("custom");return CLOUD_PROVIDER_TABS.filter((p) => visibleIds.has(p.id)).map((provider) =>provider.id === "custom" ? { ...provider, name: t("transcription.customProvider") } : provider);- }, [cloudProviders, t]);+ }, [cloudProviders, providerAllowed, t]);useEffect(() => {selectedLocalModelRef.current = selectedLocalModel;@@ -473,7 +485,7 @@ export default function TranscriptionModelPicker({cloudTranscriptionBaseUrl !== API_ENDPOINTS.TRANSCRIPTION_BASE &&!knownProviderUrls.includes(cloudTranscriptionBaseUrl);- if (hasCustomUrl) {+ if (hasCustomUrl && providerAllowed("custom")) {onCloudProviderSelect("custom");} else {const firstProvider = cloudProviders[0];@@ -497,6 +509,7 @@ export default function TranscriptionModelPicker({selectedCloudModel,onCloudProviderSelect,onCloudModelSelect,+ providerAllowed,]);useEffect(() => {@@ -633,6 +646,7 @@ export default function TranscriptionModelPicker({const handleCloudProviderChange = useCallback((providerId: string) => {+ if (!providerAllowed(providerId)) return;onCloudProviderSelect(providerId);const provider = cloudProviders.find((p) => p.id === providerId);@@ -648,7 +662,7 @@ export default function TranscriptionModelPicker({}}},- [cloudProviders, onCloudProviderSelect, onCloudModelSelect, setCloudTranscriptionBaseUrl]+ [cloudProviders, onCloudProviderSelect, onCloudModelSelect, setCloudTranscriptionBaseUrl, providerAllowed]);const handleLocalProviderChange = useCallback(diff --git a/src/components/chat/useChatStreaming.ts b/src/components/chat/useChatStreaming.tsindex 896e8b029..a6405354c 100644--- a/src/components/chat/useChatStreaming.ts+++ b/src/components/chat/useChatStreaming.ts@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";import ReasoningService, { type AgentStreamChunk } from "../../services/ReasoningService";import { isEnterpriseProvider } from "../../models/ModelRegistry";import { getSettings } from "../../stores/settingsStore";+import { usePolicyStore, isWebSearchAllowed } from "../../stores/policyStore";import { getAgentSystemPrompt } from "../../config/prompts";import { createToolRegistry } from "../../services/tools";import type { ToolRegistry } from "../../services/tools/ToolRegistry";@@ -131,7 +132,8 @@ export function useChatStreaming({let registry: ToolRegistry | null = null;if (supportsTools) {const scopeKey = scope ? `${scope.spaceId}:${scope.folderId ?? ""}` : "";- const cacheKey = `${settings.isSignedIn}-${settings.gcalConnected}-${settings.cloudBackupEnabled}-${scopeKey}`;+ const webSearchEnabled = isWebSearchAllowed(usePolicyStore.getState());+ const cacheKey = `${settings.isSignedIn}-${settings.gcalConnected}-${settings.cloudBackupEnabled}-${scopeKey}-${webSearchEnabled}`;if (toolRegistryRef.current?.key === cacheKey) {registry = toolRegistryRef.current.registry;} else {@@ -140,6 +142,7 @@ export function useChatStreaming({gcalConnected: settings.gcalConnected,cloudBackupEnabled: settings.cloudBackupEnabled,searchScope: scope,+ webSearchEnabled,});toolRegistryRef.current = { key: cacheKey, registry };}diff --git a/src/components/notes/ShareNoteDialog.tsx b/src/components/notes/ShareNoteDialog.tsxindex 493ea33d0..a63cf35ee 100644--- a/src/components/notes/ShareNoteDialog.tsx+++ b/src/components/notes/ShareNoteDialog.tsx@@ -30,6 +30,7 @@ import {} from "../../stores/noteStore";import { useToast } from "../ui/useToast";import MemberAvatar from "../MemberAvatar";+import { usePolicyStore, isShareVisibilityAllowed } from "../../stores/policyStore";import { emailDomain, isPersonalEmailDomain } from "../../utils/personalEmailDomains";import { EMAIL_REGEX } from "../../utils/validation";import type {@@ -90,8 +91,18 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteDlocalIsSharedRef.current = Boolean(note.is_shared);}, [note.is_shared]);+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const visibilityAllowed = useCallback(+ (visibility: ShareVisibility) =>+ isShareVisibilityAllowed({ managed: policyManaged, policy: policyDoc }, visibility),+ [policyManaged, policyDoc]+ );+const ownerDomain = useMemo(() => emailDomain(ownerEmail), [ownerEmail]);- const showDomainOption = Boolean(ownerDomain && !isPersonalEmailDomain(ownerDomain));+ const showDomainOption = Boolean(+ ownerDomain && !isPersonalEmailDomain(ownerDomain) && visibilityAllowed("domain")+ );const share = cached?.share ?? null;const access = cached?.access;@@ -230,6 +241,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteDconst applyVisibility = useCallback(async (next: ShareVisibility): Promise<ShareMutationResponse | null> => {if (!cloudId || !canManageSharing) return null;+ if (!visibilityAllowed(next)) return null;const previous = getShareCacheEntry(cloudId);if (!previous || previous.share.visibility === next) return null;setSavingVisibility(true);@@ -297,7 +309,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteDsetSavingVisibility(false);}},- [cloudId, canManageSharing, ownerDomain, note.id, t, toast]+ [cloudId, canManageSharing, ownerDomain, note.id, t, toast, visibilityAllowed]);const copyLink = useCallback(@@ -838,6 +850,7 @@ export default function ShareNoteDialog({ open, onOpenChange, note }: ShareNoteDvalue={share?.visibility ?? "private"}ownerDomain={ownerDomain}showDomainOption={showDomainOption}+ showLinkOption={visibilityAllowed("link")}disabled={loading || !share || !canManageSharing || savingVisibility || linkBusy}onChange={(v) => void applyVisibility(v)}/>diff --git a/src/components/notes/ShareVisibilityMenu.tsx b/src/components/notes/ShareVisibilityMenu.tsxindex 1bd8df349..71b3a440a 100644--- a/src/components/notes/ShareVisibilityMenu.tsx+++ b/src/components/notes/ShareVisibilityMenu.tsx@@ -14,6 +14,7 @@ interface ShareVisibilityMenuProps {value: ShareVisibility;ownerDomain: string;showDomainOption: boolean;+ showLinkOption?: boolean;disabled?: boolean;onChange: (visibility: ShareVisibility) => void;}@@ -22,6 +23,7 @@ export default function ShareVisibilityMenu({value,ownerDomain,showDomainOption,+ showLinkOption = true,disabled,onChange,}: ShareVisibilityMenuProps) {@@ -63,12 +65,14 @@ export default function ShareVisibilityMenu({active={value === "invited"}onSelect={() => onChange("invited")}/>- <VisibilityItem- icon={<Globe size={13} className="text-foreground/50" />}- label={t("noteEditor.share.dialog.visibility.link")}- active={value === "link"}- onSelect={() => onChange("link")}- />+ {showLinkOption && (+ <VisibilityItem+ icon={<Globe size={13} className="text-foreground/50" />}+ label={t("noteEditor.share.dialog.visibility.link")}+ active={value === "link"}+ onSelect={() => onChange("link")}+ />+ )}{showDomainOption && (<VisibilityItemicon={<Building2 size={13} className="text-foreground/50" />}diff --git a/src/components/settings/DictationAgentSettings.tsx b/src/components/settings/DictationAgentSettings.tsxindex ad7e019d2..6765afcfc 100644--- a/src/components/settings/DictationAgentSettings.tsx+++ b/src/components/settings/DictationAgentSettings.tsx@@ -1,6 +1,7 @@import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";import { useSettingsStore } from "../../stores/settingsStore";+import { usePolicyStore, isAgentAllowed } from "../../stores/policyStore";import { useAgentName } from "../../utils/agentName";import { useDialogs } from "../../hooks/useDialogs";import { Toggle } from "../ui/toggle";@@ -14,6 +15,9 @@ export default function DictationAgentSettings() {const { t } = useTranslation();const useDictationAgent = useSettingsStore((s) => s.useDictationAgent);const setUseDictationAgent = useSettingsStore((s) => s.setUseDictationAgent);+ const policyManaged = usePolicyStore((s) => s.managed);+ const policyDoc = usePolicyStore((s) => s.policy);+ const agentAllowed = isAgentAllowed({ managed: policyManaged, policy: policyDoc });const { agentName, setAgentName } = useAgentName();const [agentNameInput, setAgentNameInput] = useState(agentName);@@ -111,9 +115,17 @@ export default function DictationAgentSettings() {<SettingsPanelRow><SettingsRowlabel={t("dictationAgent.enabled")}- description={t("dictationAgent.enabledDescription", { agentName })}+ description={+ agentAllowed+ ? t("dictationAgent.enabledDescription", { agentName })+ : t("common.managedByOrg")+ }>- <Toggle checked={useDictationAgent} onChange={setUseDictationAgent} />+ <Toggle+ checked={useDictationAgent}+ onChange={setUseDictationAgent}+ disabled={!agentAllowed}+ /></SettingsRow></SettingsPanelRow></SettingsPanel>diff --git a/src/helpers/policyValidation.js b/src/helpers/policyValidation.jsindex 6b9d8dafd..856d65a00 100644--- a/src/helpers/policyValidation.js+++ b/src/helpers/policyValidation.js@@ -1,8 +1,11 @@// Structural validation for the org policy delivered by /api/workspace-policy.-// The renderer dereferences policy.<scope>.allowedModes etc. unchecked, and-// treats a null policy as "allow everything" — so a managed response must-// carry a structurally valid policy or the whole response is malformed.+// The renderer dereferences policy.<scope>.allowedModes, policy.features.*,+// policy.sharing.*, and policy.dataRetention.* unchecked, and treats a null+// policy as "allow everything" — so a managed response must carry a+// structurally valid policy or the whole response is malformed.const POLICY_SCOPES = ["transcription", "llm"];+const SHARING_MODES = ["allowed", "domain_only", "disabled"];+const LOCAL_HISTORY_MODES = ["user_choice", "always_on", "always_off"];function isValidPolicyShape(policy) {return (@@ -13,7 +16,15 @@ function isValidPolicyShape(policy) {Array.isArray(policy[scope]?.allowedModes) &&Array.isArray(policy[scope]?.allowedByokProviders)) &&- Array.isArray(policy.llm?.allowedEnterpriseProviders)+ Array.isArray(policy.llm?.allowedEnterpriseProviders) &&+ typeof policy.features?.agentEnabled === "boolean" &&+ typeof policy.features?.webSearchEnabled === "boolean" &&+ SHARING_MODES.includes(policy.sharing?.externalLinkSharing) &&+ LOCAL_HISTORY_MODES.includes(policy.dataRetention?.localHistoryMode) &&+ typeof policy.dataRetention?.cloudBackupAllowed === "boolean" &&+ (policy.dataRetention?.audioRetentionMaxDays === null ||+ typeof policy.dataRetention?.audioRetentionMaxDays === "number") &&+ (policy.minAppVersion === null || typeof policy.minAppVersion === "string"));}diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex b1ae8dbcc..0d200c2be 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Update erforderlich",+ "description": "Ihre Organisation erfordert OpenWhispr {{version}} oder neuer. Bitte aktualisieren Sie die App."+ },"update": {"readyTitle": "Update bereit zur Installation","readyDescription": "Klicken Sie auf 'Update installieren', um mit der neuesten Version neu zu starten.",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 505776338..aabc731c7 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Update required",+ "description": "Your organization requires OpenWhispr {{version}} or newer. Please update the app."+ },"update": {"readyTitle": "Update ready to install","readyDescription": "Click 'Install Update' to restart with the latest version.",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 1345f0fc8..bca62e9ed 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Actualización obligatoria",+ "description": "Tu organización requiere OpenWhispr {{version}} o una versión más reciente. Actualiza la aplicación."+ },"update": {"readyTitle": "Actualización lista para instalar","readyDescription": "Haz clic en 'Instalar actualización' para reiniciar con la última versión.",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex 34749b0b0..de01738c7 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Mise à jour requise",+ "description": "Votre organisation exige OpenWhispr {{version}} ou une version plus récente. Veuillez mettre à jour l'application."+ },"update": {"readyTitle": "Mise à jour prête à installer","readyDescription": "Cliquez sur « Installer la mise à jour » pour redémarrer avec la dernière version.",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex ef8c48593..10eab2b84 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Aggiornamento richiesto",+ "description": "La tua organizzazione richiede OpenWhispr {{version}} o versioni successive. Aggiorna l'app."+ },"update": {"readyTitle": "Aggiornamento pronto da installare","readyDescription": "Fai clic su 'Installa aggiornamento' per riavviare con l'ultima versione.",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 14ac94d7b..c6005e1fd 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "アップデートが必要です",+ "description": "組織では OpenWhispr {{version}} 以降が必要です。アプリを更新してください。"+ },"update": {"readyTitle": "アップデートの準備完了","readyDescription": "「アップデートをインストール」をクリックして最新バージョンで再起動します。",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex a1ec27002..83f4453a5 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -303,6 +303,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Atualização obrigatória",+ "description": "Sua organização exige o OpenWhispr {{version}} ou mais recente. Atualize o aplicativo."+ },"update": {"readyTitle": "Atualização pronta para instalar","readyDescription": "Clique em 'Instalar atualização' para reiniciar com a versão mais recente.",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex 809da6ed8..9296b24b7 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "Требуется обновление",+ "description": "Ваша организация требует OpenWhispr {{version}} или новее. Пожалуйста, обновите приложение."+ },"update": {"readyTitle": "Обновление готово к установке","readyDescription": "Нажмите «Установить обновление», чтобы перезапустить приложение с новой версией.",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 81e1f0294..faf403b29 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "需要更新",+ "description": "您的组织要求使用 OpenWhispr {{version}} 或更高版本。请更新应用。"+ },"update": {"readyTitle": "更新已准备就绪","readyDescription": "点击“安装更新”以重启并安装最新版本。",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex af9368e37..339d7117e 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -324,6 +324,10 @@}},"controlPanel": {+ "updateRequiredByOrg": {+ "title": "需要更新",+ "description": "您的組織要求使用 OpenWhispr {{version}} 或更新版本。請更新應用程式。"+ },"update": {"readyTitle": "更新已準備就緒","readyDescription": "點擊「安裝更新」以重新啟動並套用最新版本。",diff --git a/src/services/tools/index.ts b/src/services/tools/index.tsindex 611af8585..9d8e30f2d 100644--- a/src/services/tools/index.ts+++ b/src/services/tools/index.ts@@ -18,6 +18,7 @@ interface ToolRegistrySettings {cloudBackupEnabled: boolean;/** Pins search_notes to a container (overview chat); the LLM cannot widen it. */searchScope?: ContainerScope;+ webSearchEnabled: boolean;}export function createToolRegistry(settings: ToolRegistrySettings): ToolRegistry {@@ -31,7 +32,7 @@ export function createToolRegistry(settings: ToolRegistrySettings): ToolRegistryregistry.register(listFoldersTool);registry.register(clipboardTool);- if (settings.isSignedIn) {+ if (settings.isSignedIn && settings.webSearchEnabled) {registry.register(webSearchTool);}diff --git a/src/stores/policyStore.ts b/src/stores/policyStore.tsindex df4a7243c..861ef03fe 100644--- a/src/stores/policyStore.ts+++ b/src/stores/policyStore.ts@@ -6,8 +6,14 @@ import {setResolvedLLMConfig,} from "./settingsStore";import { INFERENCE_SCOPES, type InferenceScope } from "../config/inferenceScopes";-import { isProviderValidForMode } from "../models/ModelRegistry";-import type { InferenceMode } from "../types/electron";+import {+ isProviderValidForMode,+ getTranscriptionProviders,+ modelRegistry,+ REASONING_PROVIDERS,+ ENTERPRISE_PROVIDERS,+} from "../models/ModelRegistry";+import type { InferenceMode, ShareVisibility } from "../types/electron";import type { OrgPolicy, PolicyScope } from "../types/policy";interface PolicyState {@@ -63,6 +69,74 @@ export function isModeAllowed(return state.policy[scope].allowedModes.includes(mode);}+/** Whether a BYOK provider id is allowed for a scope. Unmanaged users allow everything. */+export function isProviderAllowed(+ state: Pick<PolicyState, "managed" | "policy">,+ scope: PolicyScope,+ providerId: string+): boolean {+ if (!state.managed || !state.policy) return true;+ return state.policy[scope].allowedByokProviders.includes(providerId);+}++/** Whether an enterprise-cloud provider id is allowed. Unmanaged users allow everything. */+export function isEnterpriseProviderAllowed(+ state: Pick<PolicyState, "managed" | "policy">,+ providerId: string+): boolean {+ if (!state.managed || !state.policy) return true;+ return state.policy.llm.allowedEnterpriseProviders.includes(providerId);+}++/** Whether the AI agent (dictation, voice, and chat) is allowed. */+export function isAgentAllowed(state: Pick<PolicyState, "managed" | "policy">): boolean {+ if (!state.managed || !state.policy) return true;+ return state.policy.features.agentEnabled;+}++/** Whether the agent's web_search tool is allowed. */+export function isWebSearchAllowed(state: Pick<PolicyState, "managed" | "policy">): boolean {+ if (!state.managed || !state.policy) return true;+ return state.policy.features.webSearchEnabled;+}++/** Whether a note share visibility is allowed under the org's external-sharing mode. */+export function isShareVisibilityAllowed(+ state: Pick<PolicyState, "managed" | "policy">,+ visibility: ShareVisibility+): boolean {+ if (!state.managed || !state.policy) return true;+ const mode = state.policy.sharing.externalLinkSharing;+ if (mode === "allowed") return true;+ if (mode === "domain_only") return visibility !== "link";+ return visibility !== "link" && visibility !== "domain";+}++/** The org-forced local history value, or null when the user may choose. */+export function lockedLocalHistoryValue(+ state: Pick<PolicyState, "managed" | "policy">+): boolean | null {+ if (!state.managed || !state.policy) return null;+ const mode = state.policy.dataRetention.localHistoryMode;+ if (mode === "always_on") return true;+ if (mode === "always_off") return false;+ return null;+}++/** Whether cloud backup/sync is allowed. */+export function isCloudBackupAllowed(state: Pick<PolicyState, "managed" | "policy">): boolean {+ if (!state.managed || !state.policy) return true;+ return state.policy.dataRetention.cloudBackupAllowed;+}++/** The org cap on audio retention days, or null when uncapped. */+export function maxAudioRetentionDays(+ state: Pick<PolicyState, "managed" | "policy">+): number | null {+ if (!state.managed || !state.policy) return null;+ return state.policy.dataRetention.audioRetentionMaxDays;+}+/** Mark policy-disallowed mode options disabled with a "managed" badge. */export function enforceModeOptions<T extends { id: InferenceMode; disabled?: boolean; badge?: string },@@ -80,11 +154,17 @@ export function enforceModeOptions<);}-// Force any already-selected mode the policy disallows onto the first allowed-// mode, mirroring what the settings UI does on a manual switch. Without this,-// stored settings would keep using a mode the org has blocked and the policy+// Force any already-selected setting the policy disallows onto an allowed+// value, mirroring what the settings UI does on a manual change. Without this,+// stored settings would keep using values the org has blocked and the policy// would only gate future UI clicks.function reconcileSettingsWithPolicy(policy: OrgPolicy): void {+ reconcileModes(policy);+ reconcileProviders(policy);+ reconcileFeaturesAndRetention(policy);+}++function reconcileModes(policy: OrgPolicy): void {const settings = useSettingsStore.getState();if (!policy.transcription.allowedModes.includes(settings.transcriptionMode)) {@@ -120,3 +200,72 @@ function reconcileSettingsWithPolicy(policy: OrgPolicy): void {window.electronAPI?.llamaServerStop?.();}}++// Providers are only reconciled for the mode that actually uses them; stale+// values behind an inactive mode are filtered by the pickers when re-entered.+function reconcileProviders(policy: OrgPolicy): void {+ const settings = useSettingsStore.getState();++ const transcriptionAllowed = policy.transcription.allowedByokProviders;+ if (!transcriptionAllowed.includes(settings.cloudTranscriptionProvider)) {+ const next = getTranscriptionProviders().find((p) => transcriptionAllowed.includes(p.id));+ if (next) {+ settings.setCloudTranscriptionProvider(next.id);+ settings.setCloudTranscriptionModel(next.models[0]?.id ?? "");+ }+ }++ for (const scope of Object.keys(INFERENCE_SCOPES) as InferenceScope[]) {+ const config = selectResolvedLLMConfig(useSettingsStore.getState(), scope);+ if (!config.provider) continue;++ if (config.mode === "providers" && !policy.llm.allowedByokProviders.includes(config.provider)) {+ const next = modelRegistry+ .getCloudProviders()+ .find((p) => policy.llm.allowedByokProviders.includes(p.id));+ setResolvedLLMConfig(scope, {+ provider: next?.id ?? "",+ model: next ? (REASONING_PROVIDERS[next.id]?.models[0]?.value ?? "") : "",+ });+ }++ if (+ config.mode === "enterprise" &&+ !policy.llm.allowedEnterpriseProviders.includes(config.provider)+ ) {+ const next = ENTERPRISE_PROVIDERS.find((id) =>+ policy.llm.allowedEnterpriseProviders.includes(id)+ );+ setResolvedLLMConfig(scope, {+ provider: next ?? "",+ model: next ? (REASONING_PROVIDERS[next]?.models[0]?.value ?? "") : "",+ });+ }+ }+}++function reconcileFeaturesAndRetention(policy: OrgPolicy): void {+ const settings = useSettingsStore.getState();++ if (!policy.features.agentEnabled && settings.useDictationAgent) {+ settings.setUseDictationAgent(false);+ }++ const historyMode = policy.dataRetention.localHistoryMode;+ if (historyMode === "always_on" && !settings.dataRetentionEnabled) {+ settings.setDataRetentionEnabled(true);+ } else if (historyMode === "always_off" && settings.dataRetentionEnabled) {+ settings.setDataRetentionEnabled(false);+ }++ if (!policy.dataRetention.cloudBackupAllowed && settings.cloudBackupEnabled) {+ settings.setCloudBackupEnabled(false);+ }++ const maxDays = policy.dataRetention.audioRetentionMaxDays;+ // audioRetentionDays === 0 means audio is not kept at all, which is always+ // within any cap — only clamp values above the cap.+ if (maxDays !== null && settings.audioRetentionDays > maxDays) {+ settings.setAudioRetentionDays(maxDays);+ }+}diff --git a/src/utils/version.ts b/src/utils/version.tsnew file mode 100644index 000000000..283e29716--- /dev/null+++ b/src/utils/version.ts@@ -0,0 +1,20 @@+/**+ * Compare two dotted numeric versions (e.g. "1.8.0" vs "1.10.2").+ * Prerelease/build suffixes are ignored ("1.8.0-beta" compares as "1.8.0").+ * Returns negative when a < b, positive when a > b, 0 when equal.+ */+export function compareAppVersions(a: string, b: string): number {+ const parse = (version: string): number[] =>+ version+ .trim()+ .split(".")+ .map((segment) => parseInt(segment, 10) || 0);+ const left = parse(a);+ const right = parse(b);+ const length = Math.max(left.length, right.length);+ for (let i = 0; i < length; i += 1) {+ const diff = (left[i] ?? 0) - (right[i] ?? 0);+ if (diff !== 0) return diff;+ }+ return 0;+}diff --git a/test/helpers/policyValidation.test.js b/test/helpers/policyValidation.test.jsindex 99c87e22e..acf8d49c6 100644--- a/test/helpers/policyValidation.test.js+++ b/test/helpers/policyValidation.test.js@@ -66,3 +66,58 @@ test("rejects non-array allowlists the renderer dereferences", () => {assert.equal(isValidPolicyShape(policy), false, `${scope}.${field} missing`);}});++test("rejects missing or mistyped feature flags", () => {+ for (const field of ["agentEnabled", "webSearchEnabled"]) {+ const policy = validPolicy();+ policy.features[field] = "true";+ assert.equal(isValidPolicyShape(policy), false, `features.${field} as string`);+ delete policy.features[field];+ assert.equal(isValidPolicyShape(policy), false, `features.${field} missing`);+ }+ const policy = validPolicy();+ delete policy.features;+ assert.equal(isValidPolicyShape(policy), false, "features missing");+});++test("rejects unknown sharing and local-history modes", () => {+ const badSharing = validPolicy();+ badSharing.sharing.externalLinkSharing = "everyone";+ assert.equal(isValidPolicyShape(badSharing), false);++ const noSharing = validPolicy();+ delete noSharing.sharing;+ assert.equal(isValidPolicyShape(noSharing), false);++ const badHistory = validPolicy();+ badHistory.dataRetention.localHistoryMode = "sometimes";+ assert.equal(isValidPolicyShape(badHistory), false);+});++test("rejects mistyped retention fields", () => {+ const badBackup = validPolicy();+ badBackup.dataRetention.cloudBackupAllowed = "no";+ assert.equal(isValidPolicyShape(badBackup), false);++ const badDays = validPolicy();+ badDays.dataRetention.audioRetentionMaxDays = "30";+ assert.equal(isValidPolicyShape(badDays), false);++ const cappedDays = validPolicy();+ cappedDays.dataRetention.audioRetentionMaxDays = 30;+ assert.equal(isValidPolicyShape(cappedDays), true);+});++test("accepts null or string minAppVersion, rejects other types", () => {+ const versioned = validPolicy();+ versioned.minAppVersion = "1.8.0";+ assert.equal(isValidPolicyShape(versioned), true);++ const badVersion = validPolicy();+ badVersion.minAppVersion = 1.8;+ assert.equal(isValidPolicyShape(badVersion), false);++ const noVersion = validPolicy();+ delete noVersion.minAppVersion;+ assert.equal(isValidPolicyShape(noVersion), false);+});