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
chore: cleanup comments
Chadpiha35f64a46a5c0
diff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex 9df42cef7..8ccebf9f6 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -313,7 +313,6 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelPro}, [toast, t]);useEffect(() => {- // isPastDue is only ever true on a successful usage response.if (!usage?.isPastDue) return;if (sessionStorage.getItem("pastDueNotified")) return;sessionStorage.setItem("pastDueNotified", "true");diff --git a/src/components/ControlPanelSidebar.tsx b/src/components/ControlPanelSidebar.tsxindex 389181feb..1d48ff35e 100644--- a/src/components/ControlPanelSidebar.tsx+++ b/src/components/ControlPanelSidebar.tsx@@ -70,8 +70,6 @@ export default function ControlPanelSidebar({() => localStorage.getItem("upgradeProDismissed") === "true");- // "unknown" renders neither banner: an unloaded or failed usage response is- // not evidence the account is free.const showLimitBanner = upsell === "show" && Boolean(isSignedIn) && Boolean(isOverLimit);const showUpgradeBanner = upsell === "show" && !showLimitBanner && !upgradeDismissed;diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 500bcd682..a328ed081 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -7450,9 +7450,8 @@ class IPCHandlers {const authHeader = await getAuthHeader(event);if (!Object.keys(authHeader).length) throw new Error("Not authenticated");- // Entitlement must never be served from Chromium's HTTP cache: the- // desktop authenticates with a bearer token, so a cached response can- // outlive both the account that produced it and a mid-flight upgrade.+ // Never serve entitlement from Chromium's HTTP cache: a cached+ // response can outlive the account that produced it.const response = await proxyFetch(`${apiUrl}/api/usage`, {headers: authHeader,cache: "no-store",@@ -7468,8 +7467,6 @@ class IPCHandlers {const errorData = await response.json().catch(() => ({}));const message = errorData.error || `API error: ${response.status}`;debugLogger.error(`Cloud usage fetch error: ${message}`);- // The refusal code drives the renderer's retry policy — a coded- // refusal must not be retried as if it were a transport blip.return { success: false, error: message, code: errorData.code };}@@ -7508,8 +7505,6 @@ class IPCHandlers {const errorData = await response.json().catch(() => ({}));const message = errorData.error || `API error: ${response.status}`;debugLogger.error(`${errorPrefix}: ${message}`);- // The refusal code lets the renderer branch on why — a non-owner of a- // past-due workspace needs different copy from a generic failure.return { success: false, error: message, code: errorData.code };}diff --git a/src/hooks/useBillingPortal.ts b/src/hooks/useBillingPortal.tsindex d989f3a21..26b56ed78 100644--- a/src/hooks/useBillingPortal.ts+++ b/src/hooks/useBillingPortal.ts@@ -10,9 +10,6 @@ interface UseBillingPortalReturn {}/**- * Opens Stripe's portal and reports a refusal with the copy that fits its code.- * Every entry point shares this so the same failure never reads two ways.- ** Takes the caller's usage object rather than calling `useUsage` itself: the* in-flight guard behind `openBillingPortal` is per-instance, so a second* instance would let a checkout and a portal open at the same time.@@ -26,8 +23,6 @@ export function useBillingPortal(usage: UseUsageResult | null): UseBillingPortalif (!usage) return;setIsOpening(true);try {- // A rejection (rather than a coded refusal) has no self-serve copy; it- // falls through to the generic toast instead of escaping the click handler.const result: { success: boolean; code?: string } = await usage.openBillingPortal().catch(() => ({ success: false }));diff --git a/src/hooks/useNotesOnboarding.ts b/src/hooks/useNotesOnboarding.tsindex a08e6da80..cc1b56fef 100644--- a/src/hooks/useNotesOnboarding.ts+++ b/src/hooks/useNotesOnboarding.ts@@ -12,7 +12,6 @@ interface UseNotesOnboardingReturn {export function useNotesOnboarding(): UseNotesOnboardingReturn {const usage = useUsage();- // Unknown entitlement is treated as loading, never as free.const isProUser = usage?.hasPaidAccess === true;const isProLoading = usage !== null && usage.status !== "success";const useCleanupModel = useSettingsStore((s) => s.useCleanupModel);diff --git a/src/hooks/useUsage.ts b/src/hooks/useUsage.tsindex 1b22902ee..13475d83b 100644--- a/src/hooks/useUsage.ts+++ b/src/hooks/useUsage.ts@@ -25,9 +25,8 @@ export interface UseUsageResult {hasPaidAccess: boolean | null;/*** `hasPaidAccess` with the unknown case resolved in the account's favour, for- * gates where wrongly locking out a payer costs more than briefly over-granting- * (the server stays authoritative). Signed out the hook is `null`, so a- * `?? false` at the call site keeps that a known "not entitled".+ * gates where locking out a payer costs more than briefly over-granting+ * (the server stays authoritative).*/hasPaidAccessOptimistic: boolean;plan: string;@@ -45,12 +44,7 @@ export interface UseUsageResult {isOverLimit: boolean;isApproachingLimit: boolean;resetAt: string | null;- /**- * Any Stripe action — checkout, switch-plan or portal — is in flight. They- * share one in-flight guard, so this is what sibling buttons disable on.- * `useBillingPortal`'s `isOpening` narrows it to the portal, for the buttons- * whose own label changes while it opens.- */+ /** Any Stripe action — checkout, switch-plan or portal — is in flight; they share one guard. */checkoutLoading: boolean;openCheckout: (opts?: {plan?: "monthly" | "annual";diff --git a/src/lib/billingPortalError.ts b/src/lib/billingPortalError.tsindex 1e45bf738..67e43e998 100644--- a/src/lib/billingPortalError.ts+++ b/src/lib/billingPortalError.ts@@ -1,5 +1,3 @@-// A non-owner of a workspace-billed subscription has no self-serve recovery,-// so the generic "couldn't open billing" copy is a dead end for them.export function billingPortalErrorCopy(code?: string): {titleKey: string;descriptionKey: string;diff --git a/src/lib/upsell.ts b/src/lib/upsell.tsindex cedd84885..7545eb9f4 100644--- a/src/lib/upsell.ts+++ b/src/lib/upsell.ts@@ -3,16 +3,11 @@ export type UpsellDecision = "show" | "hide" | "unknown";export interface UpsellInput {authLoaded: boolean;isSignedIn: boolean;- /** `null` while the entitlement is unresolved — see `useUsage`. */+ /** `null` while the entitlement is unresolved. */hasPaidAccess: boolean | null;isPastDue: boolean;}-/**- * Three-way so an unknown entitlement is never rendered as free. Signed-out- * users still get the CTA — there is no usage response to confirm, and the- * upsell is the point of the screen for them.- */export function decideUpsell({authLoaded,isSignedIn,@@ -20,6 +15,7 @@ export function decideUpsell({isPastDue,}: UpsellInput): UpsellDecision {if (!authLoaded) return "unknown";+ // Signed out there is no usage response to await; the upsell is the point.if (!isSignedIn) return "show";if (hasPaidAccess === null) return "unknown";// Past due already has its own banner, toast and recovery button.diff --git a/src/lib/usageStore.ts b/src/lib/usageStore.tsindex e0ed2590c..6c1d9ac42 100644--- a/src/lib/usageStore.ts+++ b/src/lib/usageStore.ts@@ -1,10 +1,6 @@import { CACHE_CONFIG } from "../config/constants.ts";import { clearIsSubscribed, writeIsSubscribed } from "./subscriptionFlag.ts";-// One account-scoped entitlement result shared by every consumer, so two-// screens can never disagree about the same account. Unknown is a real state:-// nothing here manufactures a free plan out of missing data.-const USAGE_ACCOUNT_KEY = "openwhispr:usageAccountId";const USAGE_CACHE_TTL = CACHE_CONFIG.API_KEY_TTL;const RETRY_DELAYS_MS = [2000, 4000, 8000];@@ -59,8 +55,6 @@ export type UsageState =const IDLE_SIGNED_OUT: UsageState = { status: "idle", accountId: null };let state: UsageState = IDLE_SIGNED_OUT;-// Bumped on every account change; a response whose generation is stale is-// dropped, so user A's in-flight request cannot land on user B's session.let generation = 0;let lastFetchAt = 0;let inFlight: Promise<void> | null = null;@@ -104,8 +98,8 @@ export function normalizeUsage(response: UsageResponse): UsageData {return {wordsUsed: response.wordsUsed ?? 0,wordsRemaining: response.wordsRemaining ?? 0,- // Not the free-tier allowance: a missing limit is an unknown one, and every- // meter is guarded on `limit > 0` so it stays hidden rather than wrong.+ // Not the free-tier allowance: a missing limit is unknown, and meters+ // guard on `limit > 0` so they stay hidden rather than wrong.limit: response.limit ?? 0,plan,subscriptionStatus,@@ -130,11 +124,6 @@ export function isPastDueUsage(data: UsageData): boolean {return PAID_PLANS.has(data.plan) && data.subscriptionStatus === "past_due";}-/**- * Point the store at the authenticated account. Any previous account's data,- * in-flight request, retry timer and persisted subscription flag are dropped- * atomically, so user B never inherits user A's entitlement.- */export function setUsageAccount(accountId: string | null): void {if (state.accountId === accountId) return;@@ -145,11 +134,9 @@ export function setUsageAccount(accountId: string | null): void {lastFetchAt = 0;retryAttempt = 0;- // The flag survives only for the account that produced it: a relaunch of the- // same account keeps it, so offline sessions still sync before the first- // successful usage fetch. Sign-out, a different account, or a build that- // never recorded an owner all invalidate it — an unattributable `true` would- // hand user B user A's entitlement.+ // The persisted flag survives only for the account that produced it: a+ // same-account relaunch keeps it for offline use; anything unattributable+ // would hand user B user A's entitlement.const store = storage();const previousAccountId = store?.getItem(USAGE_ACCOUNT_KEY) ?? null;if (accountId === null || previousAccountId !== accountId) clearIsSubscribed();@@ -206,19 +193,13 @@ function startLoad(accountId: string, fetcher: UsageFetcher): Promise<void> {return run;}-/**- * Fetch usage for the active account. Concurrent callers share one request, and- * a successful result is reused for the cache TTL — mounting another consumer- * costs nothing. Errors are never TTL-cached.- */export function loadUsage(fetcher: UsageFetcher, opts: { force?: boolean } = {}): Promise<void> {const { accountId } = state;if (!accountId) return Promise.resolve();if (inFlight) {if (!opts.force) return inFlight;- // A forced caller knows something the in-flight request predates — words- // just spent, a plan just switched — so its answer is already stale.- // Every such caller coalesces into one follow-up rather than stampeding.+ // The in-flight answer predates whatever forced the refetch; coalesce all+ // forced callers into one follow-up rather than stampeding.const forceGeneration = generation;queuedForce ??= inFlight.then(() => {// Clear before the check and a stale chain would wipe the follow-up the@@ -235,16 +216,12 @@ export function loadUsage(fetcher: UsageFetcher, opts: { force?: boolean } = {})return startLoad(accountId, fetcher);}-/** Manual retry: clears the backoff budget so the user gets an immediate attempt. */export function retryUsage(fetcher: UsageFetcher): Promise<void> {retryAttempt = 0;return loadUsage(fetcher, { force: true });}-/**- * Post-checkout poll that outlives webhook lag. Guarded so mounting N consumers- * still runs one poll.- */+/** Post-checkout poll that outlives Stripe webhook lag. */export async function watchForUpgrade(fetcher: UsageFetcher): Promise<void> {if (upgradeWatchActive) return;upgradeWatchActive = true;