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
fix(policy): Restore share-link copying and close enforcement gaps
Chadpiha082b73fe8c65
diff --git a/package-lock.json b/package-lock.jsonindex 23157c1fe..3da9a7e26 100644--- a/package-lock.json+++ b/package-lock.json@@ -87,6 +87,7 @@"eslint": "^10.7.0","eslint-plugin-react-hooks": "^7.1.1","eslint-plugin-react-refresh": "^0.5.2",+ "espree": "^11.2.0","globals": "17.5.0","postcss": "^8.5.10","prettier": "^3.8.3",diff --git a/package.json b/package.jsonindex 84b2a32a4..abafee884 100644--- a/package.json+++ b/package.json@@ -108,6 +108,7 @@"eslint": "^10.7.0","eslint-plugin-react-hooks": "^7.1.1","eslint-plugin-react-refresh": "^0.5.2",+ "espree": "^11.2.0","globals": "17.5.0","postcss": "^8.5.10","prettier": "^3.8.3",diff --git a/src/components/TranscriptionModelPicker.tsx b/src/components/TranscriptionModelPicker.tsxindex 35b89c84b..9d1f7641d 100644--- a/src/components/TranscriptionModelPicker.tsx+++ b/src/components/TranscriptionModelPicker.tsx@@ -398,19 +398,16 @@ export default function TranscriptionModelPicker({(providerId: string) => isProviderAllowedByPolicy(policyState, "transcription", providerId),[policyState]);+ const availableCloudProviders = useMemo(+ () => (streamingOnly ? getStreamingTranscriptionProviders() : getTranscriptionProviders()),+ [streamingOnly]+ );const cloudProviders = useMemo(- () =>- (streamingOnly ? getStreamingTranscriptionProviders() : getTranscriptionProviders()).filter(- (p) => providerAllowed(p.id)- ),- [streamingOnly, providerAllowed]+ () => availableCloudProviders.filter((p) => providerAllowed(p.id)),+ [availableCloudProviders, providerAllowed]);const cloudProviderTabs = useMemo(() => {- const availableIds = new Set(- (streamingOnly ? getStreamingTranscriptionProviders() : getTranscriptionProviders()).map(- (p) => p.id- )- );+ const availableIds = new Set(availableCloudProviders.map((p) => p.id));availableIds.add("custom");return CLOUD_PROVIDER_TABS.filter((p) => availableIds.has(p.id)).map((provider) => {const named =@@ -421,7 +418,7 @@ export default function TranscriptionModelPicker({? named: { ...named, disabled: true, disabledLabel: t("common.managedByOrg") };});- }, [streamingOnly, providerAllowed, t]);+ }, [availableCloudProviders, providerAllowed, t]);useEffect(() => {selectedLocalModelRef.current = selectedLocalModel;@@ -482,7 +479,10 @@ export default function TranscriptionModelPicker({}, []);const ensureValidCloudSelection = useCallback(() => {- const knownProviderUrls = cloudProviders.map((provider) => provider.baseUrl);+ // Every provider's URL counts as known, including policy-blocked ones:+ // otherwise a blocked provider's stored URL reads as a custom endpoint and+ // reconciliation would keep pointing "custom" at what policy just denied.+ const knownProviderUrls = availableCloudProviders.map((provider) => provider.baseUrl);const hasCustomUrl = Boolean(cloudTranscriptionBaseUrl &&cloudTranscriptionBaseUrl.trim() !== "" &&@@ -500,6 +500,7 @@ export default function TranscriptionModelPicker({if (selection.provider !== selectedCloudProvider) onCloudProviderSelect(selection.provider);if (selection.model !== selectedCloudModel) onCloudModelSelect(selection.model);}, [+ availableCloudProviders,cloudProviders,cloudTranscriptionBaseUrl,selectedCloudProvider,diff --git a/src/helpers/workspacePolicyManager.js b/src/helpers/workspacePolicyManager.jsindex 0df6dc93d..67574aed8 100644--- a/src/helpers/workspacePolicyManager.js+++ b/src/helpers/workspacePolicyManager.js@@ -164,17 +164,17 @@ function createWorkspacePolicyManager({const wasRequired = requiresManagedPolicy(identity);managedPolicyRequired.add(key);- if (cached && !wasRequired) {+ if (!wasRequired) {try {+ // A first-ever unresolvable verdict has nothing cached to mark, so seed+ // an unmanaged entry; without it a restart fails open on 404/501.writeWorkspacePolicyCache(cachePath, cacheIdentity(identity), {- ...cached,+ ...(cached ?? { managed: false, policy: null, policyUpdatedAt: null }),requiresManagedPolicy: true,});} catch (error) {logger?.error?.("Policy fail-closed marker write failed", error);}- }- if (!wasRequired) {broadcast?.(errorSnapshot(identity, "POLICY_UNRESOLVABLE", message));}}diff --git a/src/stores/policyRules.ts b/src/stores/policyRules.tsindex dbdb7be9b..6a53e69fb 100644--- a/src/stores/policyRules.ts+++ b/src/stores/policyRules.ts@@ -225,7 +225,9 @@ export function isShareActionAllowed(return true;}if (action === "copy-link" || action === "rotate-link") {- return currentVisibility === "link" && isShareVisibilityAllowed(state, "link");+ // A domain or invited share has a link too, scoped by that visibility, so+ // the current visibility governs rather than open link sharing.+ return currentVisibility !== "private" && isShareVisibilityAllowed(state, currentVisibility);}if (action === "create-link") return isShareVisibilityAllowed(state, "link");if (action === "set-domain") return isShareVisibilityAllowed(state, "domain");diff --git a/src/stores/policyStore.ts b/src/stores/policyStore.tsindex b765d0ab1..0bc1a3010 100644--- a/src/stores/policyStore.ts+++ b/src/stores/policyStore.ts@@ -53,7 +53,7 @@ interface PolicyIpcSnapshot {function readAppVersion(): Promise<string | null> {if (!appVersionPromise) {- appVersionPromise =+ const pending: Promise<string | null> =window.electronAPI.getAppVersion?.().then((result) => result?.version ?? null)@@ -61,6 +61,12 @@ function readAppVersion(): Promise<string | null> {logger.error("Failed to read app version for workspace policy:", error);return null;}) ?? Promise.resolve(null);+ // An unknown version denies every managed action while hiding the update+ // banner that explains it, so never cache a failed read for the session.+ appVersionPromise = pending.then((version) => {+ if (!version) appVersionPromise = null;+ return version;+ });}return appVersionPromise;}diff --git a/test/helpers/policyAppVersionRetry.test.js b/test/helpers/policyAppVersionRetry.test.jsnew file mode 100644index 000000000..82301ddde--- /dev/null+++ b/test/helpers/policyAppVersionRetry.test.js@@ -0,0 +1,65 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");++const managedPolicy = {+ version: 1,+ transcription: { allowedModes: ["openwhispr", "local"], allowedByokProviders: ["openai"] },+ llm: {+ allowedModes: ["openwhispr"],+ allowedByokProviders: [],+ allowedEnterpriseProviders: [],+ },+ features: { agentEnabled: true, webSearchEnabled: true },+ sharing: { externalLinkSharing: "allowed" },+ dataRetention: {+ audioRetentionMaxDays: null,+ localHistoryMode: "user_choice",+ cloudBackupAllowed: true,+ },+ minAppVersion: "1.0.0",+};++test("a failed app-version read is retried instead of denying the session", async (t) => {+ let versionRequestCount = 0;+ installBrowserGlobals(t, {+ window: {+ electronAPI: {+ getAppVersion: async () => {+ versionRequestCount += 1;+ if (versionRequestCount === 1) throw new Error("IPC unavailable");+ return { version: "1.8.1" };+ },+ getWorkspacePolicy: async () => ({+ success: true,+ status: "network",+ revision: 1,+ accountId: "account-a",+ authGeneration: 1,+ managed: true,+ policy: managedPolicy,+ policyUpdatedAt: "2026-01-01T00:00:00.000Z",+ endpointSupported: true,+ }),+ onWorkspacePolicyChanged() {},+ },+ },+ });++ const vite = await createRendererServer(t, {+ cachePrefix: "openwhispr-policy-app-version-test-",+ mockModules: { "/utils/logger": "export default { error() {} };" },+ });++ const { usePolicyStore } = await vite.ssrLoadModule("/stores/policyStore.ts");+ const { isPolicyActionAllowed } = await vite.ssrLoadModule("/stores/policyRules.ts");++ await usePolicyStore.getState().fetchPolicy("account-a", 1);+ assert.equal(usePolicyStore.getState().appVersion, null);+ assert.equal(isPolicyActionAllowed(usePolicyStore.getState()), false);++ await usePolicyStore.getState().fetchPolicy("account-a", 1);+ assert.equal(versionRequestCount, 2);+ assert.equal(usePolicyStore.getState().appVersion, "1.8.1");+ assert.equal(isPolicyActionAllowed(usePolicyStore.getState()), true);+});diff --git a/test/helpers/policyRules.test.js b/test/helpers/policyRules.test.jsindex 0b4020597..c2b940a85 100644--- a/test/helpers/policyRules.test.js+++ b/test/helpers/policyRules.test.js@@ -187,6 +187,25 @@ test("domain-only sharing permits only private recovery and domain visibility",assert.equal(isShareActionAllowed(snapshot, "copy-link", "link"), false);assert.equal(isShareActionAllowed(snapshot, "rotate-link", "link"), false);assert.equal(isShareActionAllowed(snapshot, "invite", "private"), false);+ // A domain share's link stays copyable — it is scoped to the allowed domain.+ assert.equal(isShareActionAllowed(snapshot, "copy-link", "domain"), true);+ assert.equal(isShareActionAllowed(snapshot, "rotate-link", "domain"), true);+ assert.equal(isShareActionAllowed(snapshot, "copy-link", "invited"), false);+});++test("copying an existing share link follows its own visibility", async () => {+ const { isShareActionAllowed } = await load();+ const unmanaged = { status: "unmanaged", policy: null, appVersion: "1.8.1" };+ const allowed = { status: "managed", policy, appVersion: "1.8.1" };++ for (const snapshot of [unmanaged, allowed]) {+ for (const visibility of ["link", "domain", "invited"]) {+ assert.equal(isShareActionAllowed(snapshot, "copy-link", visibility), true);+ assert.equal(isShareActionAllowed(snapshot, "rotate-link", visibility), true);+ }+ // Nothing to copy before a link exists; the dialog asks for create-link.+ assert.equal(isShareActionAllowed(snapshot, "copy-link", "private"), false);+ }});test("sharing recovery remains available when exposure-increasing actions are blocked", async () => {diff --git a/test/helpers/workspacePolicyManager.test.js b/test/helpers/workspacePolicyManager.test.jsindex d0c97b07d..7f33b66ab 100644--- a/test/helpers/workspacePolicyManager.test.js+++ b/test/helpers/workspacePolicyManager.test.js@@ -597,6 +597,36 @@ test("a managed cache remains fail-closed during an unresolvable refresh", asyncassert.deepEqual(fallback.policy, managed.policy);});+test("a first-ever unresolvable verdict still fails closed after restart", async (t) => {+ const context = setup(async () =>+ response(503, {+ error: "Organization policy could not be resolved.",+ code: "POLICY_UNRESOLVABLE",+ })+ );+ t.after(context.cleanup);+ const request = { accountId: "account-a", expectedAuthGeneration: 1 };++ const unresolvable = await context.manager.getPolicy(request);+ assert.equal(unresolvable.success, false);+ assert.equal(unresolvable.code, "POLICY_UNRESOLVABLE");++ // Nothing was ever cached for this identity, so the marker is the only thing+ // on disk standing between a restart and a fail-open on an unsupported route.+ const restarted = createWorkspacePolicyManager({+ cachePath: context.cachePath,+ getApiUrl: () => "https://api.openwhispr.test",+ getAppVersion: () => "1.8.1",+ proxyFetch: async () => response(404, { error: "Not found" }),+ tokenStore: { getState: () => ({ ...context.tokenState }) },+ logger: { error() {}, warn() {} },+ });+ const afterRestart = await restarted.getPolicy(request);++ assert.equal(afterRestart.success, false);+ assert.equal(afterRestart.code, "POLICY_UNRESOLVABLE");+});+test("a managed-unresolvable signal survives throttling, other windows, and restart", async (t) => {let currentTime = 0;let requestCount = 0;