YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: steer enterprise users to enterprise app
Louis Beaumontec859296b3be
diff --git a/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx b/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsxindex 7d24282e0..2202850a9 100644--- a/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx+++ b/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx@@ -16,6 +16,8 @@ const mocks = vi.hoisted(() => ({openLoginWindow: vi.fn().mockResolvedValue(undefined),setCloudToken: vi.fn().mockResolvedValue(undefined),getCloudToken: vi.fn().mockResolvedValue(null),+ platform: vi.fn(() => "windows"),+ arch: vi.fn(() => "x86_64"),loadUser: vi.fn().mockResolvedValue(undefined),updateSettings: vi.fn().mockResolvedValue(undefined),state: { isSettingsLoaded: true, user: null as any },@@ -57,6 +59,10 @@ vi.mock("@/lib/hooks/use-enterprise-policy", () => ({vi.mock("posthog-js", () => ({ default: { capture: mocks.capture } }));vi.mock("@tauri-apps/plugin-shell", () => ({ open: mocks.open }));+vi.mock("@tauri-apps/plugin-os", () => ({+ platform: mocks.platform,+ arch: mocks.arch,+}));// The resume effect only restarts the engine from the primary window, which it// detects via getCurrentWindow().label. Stand in as the primary "main" window so@@ -418,6 +424,66 @@ describe("AppEntitlementGate", () => {}});+ it("routes enterprise accounts away from the consumer app", async () => {+ mocks.state.user = baseUser({+ app_entitled: true,+ cloud_subscribed: true,+ subscription_plan: "pro",+ enterprise_account: {+ org_name: "Bungalow",+ role: "member",+ requires_enterprise_app: true,+ },+ entitlement: {+ active: true,+ plan: "pro",+ source: "enterprise",+ checked_at: minsAgo(1),+ features: { app: true, cloud: true },+ },+ });++ render(<AppEntitlementGate>{protectedApp}</AppEntitlementGate>);++ expect(screen.getByText(/enterprise app required/i)).toBeInTheDocument();+ expect(screen.getByText(/belongs to Bungalow/i)).toBeInTheDocument();+ expect(screen.queryByTestId("protected-app")).not.toBeInTheDocument();++ fireEvent.click(screen.getByRole("button", { name: /download enterprise app/i }));++ const downloadUrl = String(mocks.open.mock.calls.at(-1)?.[0] ?? "");+ expect(downloadUrl).toContain("/api/download");+ expect(downloadUrl).toContain("token=verified");+ expect(downloadUrl).toContain("channel=enterprise");+ expect(downloadUrl).toContain("platform=windows");+ });++ it("does not show the consumer-app warning inside the enterprise build", () => {+ mocks.enterprise.isEnterprise = true;+ mocks.state.user = baseUser({+ app_entitled: true,+ cloud_subscribed: true,+ subscription_plan: "pro",+ enterprise_account: {+ org_name: "Bungalow",+ role: "member",+ requires_enterprise_app: true,+ },+ entitlement: {+ active: true,+ plan: "pro",+ source: "enterprise",+ checked_at: minsAgo(1),+ features: { app: true, cloud: true },+ },+ });++ render(<AppEntitlementGate>{protectedApp}</AppEntitlementGate>);++ expect(screen.queryByText(/enterprise app required/i)).not.toBeInTheDocument();+ expect(screen.getByTestId("protected-app")).toBeInTheDocument();+ });+it("resumes recording when access transitions to entitled", async () => {mocks.state.user = baseUser(); // unentitled firstconst { rerender } = render(diff --git a/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx b/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsxindex b5073bd17..a8f89ba5f 100644--- a/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx+++ b/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx@@ -5,12 +5,16 @@"use client";import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";-import { CreditCard, LogIn, RefreshCw } from "lucide-react";+import { Building2, CreditCard, Download, LogIn, RefreshCw } from "lucide-react";import posthog from "posthog-js";import { open as openUrl } from "@tauri-apps/plugin-shell";+import { arch as getOsArch, platform as getOsPlatform } from "@tauri-apps/plugin-os";import { Button } from "@/components/ui/button";import {AppUser,+ ENTERPRISE_BUILDS_URL,+ ENTERPRISE_DOWNLOAD_URL,+ getEnterpriseAccount,hasAppEntitlement,hasPersistedEntitlementEvidence,isDevBillingBypassEnabled,@@ -46,6 +50,29 @@ function isPrimaryWindow(): boolean {}}+function getDownloadPlatform(): string | null {+ try {+ const os = getOsPlatform();+ if (os === "windows") return getOsArch() === "aarch64" ? "windows-arm" : "windows";+ if (os === "macos") return getOsArch() === "aarch64" ? "macos-arm" : "macos-intel";+ if (os === "linux") return "linux";+ } catch {}+ return null;+}++function getEnterpriseDownloadUrl() {+ try {+ const url = new URL(ENTERPRISE_DOWNLOAD_URL);+ url.searchParams.set("token", "verified");+ url.searchParams.set("channel", "enterprise");+ const platform = getDownloadPlatform();+ if (platform) url.searchParams.set("platform", platform);+ return url.toString();+ } catch {+ return ENTERPRISE_BUILDS_URL;+ }+}+function EntitlementShell({title,description,@@ -94,6 +121,7 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })const devBypass = isDevBillingBypassEnabled();const isEntitled = hasAppEntitlement(user);const needsRefresh = needsAppEntitlementRefresh(user);+ const enterpriseAccount = getEnterpriseAccount(user);// loadUser is re-created on every render (it is NOT memoized), so the// background re-verify poll below can't depend on its identity without@@ -134,10 +162,19 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })!needsLicenseKey &&!isSectionHidden("account");const shouldGateForEnterpriseLogin = enterpriseRequiresLogin && !user?.token;+ const shouldGateForEnterpriseApp =+ !devBypass &&+ !isEnterprise &&+ Boolean(user?.token) &&+ enterpriseAccount?.requires_enterprise_app === true;const shouldGateForEntitlement =!devBypass && !isEntitled && !failOpenForTransientAccessLoss;- const shouldGate = shouldGateForEnterpriseLogin || shouldGateForEntitlement;+ const shouldGate =+ shouldGateForEnterpriseApp ||+ shouldGateForEnterpriseLogin ||+ shouldGateForEntitlement;const email = user?.email || "this account";+ const enterpriseOrgName = enterpriseAccount?.org_name || "your workspace";const planLabel = useMemo(() => normalizePlanLabel(user?.subscription_plan),[user?.subscription_plan],@@ -247,6 +284,14 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })commands.openLoginWindow();}, [updateSettings]);+ const downloadEnterpriseApp = useCallback(() => {+ const url = getEnterpriseDownloadUrl();+ posthog.capture("app_entitlement_enterprise_download_clicked", {+ org_name: enterpriseAccount?.org_name ?? null,+ });+ openUrl(url).catch(() => window.open(url, "_blank"));+ }, [enterpriseAccount?.org_name]);+// Dev/preview only: deep links do not reach the `bun tauri dev` binary on// macOS, so paste the login token (or the whole screenpipe://...api_key=...// URL the browser tried to open) here to sign in without the OAuth callback.@@ -416,6 +461,34 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })return <>{children}</>;}+ if (shouldGateForEnterpriseApp) {+ return (+ <EntitlementShell+ title="enterprise app required"+ description={`${email} belongs to ${enterpriseOrgName}. download the screenpipe enterprise app so this device follows workspace policy and uploads to your org storage.`}+ >+ <div className="flex flex-col gap-3">+ <Button onClick={downloadEnterpriseApp} className="w-full gap-2">+ <Download className="h-4 w-4" />+ download enterprise app+ </Button>+ <Button+ onClick={() => openUrl(ENTERPRISE_BUILDS_URL).catch(() => window.open(ENTERPRISE_BUILDS_URL, "_blank"))}+ variant="outline"+ className="w-full gap-2"+ >+ <Building2 className="h-4 w-4" />+ open enterprise builds+ </Button>+ <Button onClick={useDifferentAccount} variant="ghost" className="w-full">+ use different account+ </Button>+ </div>+ {devLoginBlock}+ </EntitlementShell>+ );+ }+if (shouldGateForEnterpriseLogin) {return (<EntitlementShelldiff --git a/apps/screenpipe-app-tauri/lib/app-entitlement.ts b/apps/screenpipe-app-tauri/lib/app-entitlement.tsindex c76eba733..3dff2ea30 100644--- a/apps/screenpipe-app-tauri/lib/app-entitlement.ts+++ b/apps/screenpipe-app-tauri/lib/app-entitlement.ts@@ -45,15 +45,24 @@ export type AppEntitlement = {features?: AppEntitlementFeatures | null;};+export type AppEnterpriseAccount = {+ org_name?: string | null;+ role?: string | null;+ requires_enterprise_app?: boolean | null;+};+export type AppUser = User & {app_entitled?: boolean | null;subscription_plan?: string | null;entitlement?: AppEntitlement | JsonValue | null;+ enterprise_account?: AppEnterpriseAccount | JsonValue | null;};export const APP_ENTITLEMENT_MAX_STALE_MS = 72 * 60 * 60 * 1000;export const APP_ENTITLEMENT_CLOCK_SKEW_MS = 5 * 60 * 1000;export const PRICING_URL = screenpipeWebUrl("/onboarding", "https://screenpipe.com");+export const ENTERPRISE_BUILDS_URL = screenpipeWebUrl("/enterprise?tab=builds", "https://screenpipe.com");+export const ENTERPRISE_DOWNLOAD_URL = screenpipeWebUrl("/api/download", "https://screenpipe.com");// localStorage key an e2e spec can set to force the gate ON even in a bypassed// build. It can only ever make the gate stricter (never bypass), so it is safe@@ -104,6 +113,16 @@ function asEntitlement(entitlement: AppUser["entitlement"] | undefined): AppEntireturn entitlement as AppEntitlement;}+export function getEnterpriseAccount(+ user: AppUser | null | undefined,+): AppEnterpriseAccount | null {+ const account = user?.enterprise_account;+ if (!account || typeof account !== "object" || Array.isArray(account)) {+ return null;+ }+ return account as AppEnterpriseAccount;+}+function parseEntitlementTime(value: string | null | undefined) {if (!value) return null;const time = Date.parse(value);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rsindex 4d31dc8ca..7aca22a7f 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs@@ -374,8 +374,8 @@ fn emit_meeting_note_route_with_retries(app: &tauri::AppHandle, deeplink_url: &s#[cfg(all(test, target_os = "macos"))]mod tests {use super::{- fallback_local_api_config, notification_copy_value, notification_source_url,- parse_meeting_deeplink,+ fallback_local_api_config, is_login_callback_scheme, notification_copy_value,+ notification_source_url, parse_meeting_deeplink,};use serde_json::json;@@ -404,6 +404,11 @@ mod tests {assert_eq!(parse_meeting_deeplink("screenpipe://settings"), None);}+ #[test]+ fn login_callback_accepts_website_fallback_scheme() {+ assert!(is_login_callback_scheme("screenpipe"));+ }+#[test]fn notification_copy_action_uses_value_field() {let action = json!({@@ -1782,28 +1787,16 @@ pub fn deep_link_scheme() -> &'static str {}}+fn is_login_callback_scheme(scheme: &str) -> bool {+ scheme == deep_link_scheme() || scheme == "screenpipe"+}+/// Open the screenpipe.com login page.-/// Windows: system browser + registered deep-link scheme handles the redirect./// macOS: ASWebAuthenticationSession (system-managed sheet, forwards callback).-/// Linux: in-app WebView that intercepts the screenpipe:// redirect.+/// Windows/Linux: in-app WebView that intercepts the screenpipe:// redirect.#[tauri::command]#[specta::specta]pub async fn open_login_window(app_handle: tauri::AppHandle) -> Result<(), String> {- // Windows: open in system browser — deep link is registered via- // tauri_plugin_deep_link::register_all() so the screenpipe:// redirect works- #[cfg(target_os = "windows")]- {- use tauri_plugin_opener::OpenerExt;- app_handle- .opener()- .open_url(- format!("{}?return_scheme={}", LOGIN_URL, deep_link_scheme()),- None::<&str>,- )- .map_err(|e| e.to_string())?;- return Ok(());- }-#[cfg(target_os = "macos")]{// ASWebAuthenticationSession intercepts the redirect itself (no OS@@ -1833,7 +1826,7 @@ pub async fn open_login_window(app_handle: tauri::AppHandle) -> Result<(), Strinreturn Ok(());}- #[cfg(target_os = "linux")]+ #[cfg(not(target_os = "macos"))]{use tauri::{WebviewUrl, WebviewWindowBuilder};@@ -1859,7 +1852,7 @@ pub async fn open_login_window(app_handle: tauri::AppHandle) -> Result<(), Strin.focused(true);builder = builder.on_navigation(move |url| {- if url.scheme() == deep_link_scheme() {+ if is_login_callback_scheme(url.scheme()) {info!("login window intercepted deep link callback");let _ = app_for_nav.emit("deep-link-received", url.to_string());if let Some(w) = app_for_nav.get_webview_window("login-browser") {@@ -1918,7 +1911,7 @@ pub async fn open_google_calendar_auth_window(}builder = builder.on_navigation(move |url| {- if url.scheme() == deep_link_scheme() {+ if is_login_callback_scheme(url.scheme()) {info!("google calendar auth window intercepted deep link: {}", url);let _ = app_for_nav.emit("deep-link-received", url.to_string());if let Some(w) = app_for_nav.get_webview_window("google-calendar-auth") {