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(app): keep recording during build detection
Louis Beaumontd9548d37e837
diff --git a/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx b/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsxindex fd69dd017..8e0605219 100644--- a/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx+++ b/apps/screenpipe-app-tauri/components/app-entitlement-gate.test.tsx@@ -24,6 +24,7 @@ const mocks = vi.hoisted(() => ({state: { isSettingsLoaded: true, user: null as any },enterprise: {isEnterprise: false,+ isEnterpriseBuildResolved: true,authenticationState: "authenticated",authenticationError: null as string | null,isEnterpriseAuthenticated: true,@@ -55,7 +56,7 @@ vi.mock("@/lib/utils/tauri", () => ({vi.mock("@/lib/hooks/use-enterprise-policy", () => ({useEnterprisePolicy: () => ({isEnterprise: mocks.enterprise.isEnterprise,- isEnterpriseBuildResolved: true,+ isEnterpriseBuildResolved: mocks.enterprise.isEnterpriseBuildResolved,authenticationState: mocks.enterprise.authenticationState,authenticationError: mocks.enterprise.authenticationError,isEnterpriseAuthenticated: mocks.enterprise.isEnterpriseAuthenticated,@@ -110,6 +111,7 @@ describe("AppEntitlementGate", () => {mocks.state = { isSettingsLoaded: true, user: null };mocks.enterprise = {isEnterprise: false,+ isEnterpriseBuildResolved: true,authenticationState: "authenticated",authenticationError: null,isEnterpriseAuthenticated: true,@@ -126,6 +128,7 @@ describe("AppEntitlementGate", () => {window.history.replaceState({}, "", "/onboarding");mocks.enterprise = {isEnterprise: true,+ isEnterpriseBuildResolved: true,authenticationState: "choice",authenticationError: null,isEnterpriseAuthenticated: false,@@ -137,6 +140,16 @@ describe("AppEntitlementGate", () => {expect(screen.queryByText(/enterprise access/i)).not.toBeInTheDocument();});+ it("does not stop recording while build detection is unresolved", async () => {+ mocks.enterprise.isEnterpriseBuildResolved = false;++ render(<AppEntitlementGate>{protectedApp}</AppEntitlementGate>);++ expect(screen.getByText(/checking access/i)).toBeInTheDocument();+ await new Promise((resolve) => setTimeout(resolve, 0));+ expect(mocks.stopScreenpipe).not.toHaveBeenCalled();+ });+it("asks a signed-out user to sign in and never reveals the app", () => {mocks.state.user = null;render(<AppEntitlementGate>{protectedApp}</AppEntitlementGate>);@@ -151,6 +164,7 @@ describe("AppEntitlementGate", () => {it("offers account and enterprise-key routes in the fallback gate", () => {mocks.enterprise = {isEnterprise: true,+ isEnterpriseBuildResolved: true,authenticationState: "choice",authenticationError: null,isEnterpriseAuthenticated: false,@@ -172,6 +186,7 @@ describe("AppEntitlementGate", () => {vi.stubEnv("TAURI_ENV_DEBUG", "true");mocks.enterprise = {isEnterprise: true,+ isEnterpriseBuildResolved: true,authenticationState: "account",authenticationError: null,isEnterpriseAuthenticated: false,@@ -192,6 +207,7 @@ describe("AppEntitlementGate", () => {vi.stubEnv("TAURI_ENV_DEBUG", "true");mocks.enterprise = {isEnterprise: true,+ isEnterpriseBuildResolved: true,authenticationState: "authenticated",authenticationError: null,isEnterpriseAuthenticated: true,@@ -469,6 +485,7 @@ describe("AppEntitlementGate", () => {try {mocks.enterprise = {isEnterprise: true,+ isEnterpriseBuildResolved: true,authenticationState: "account",authenticationError: null,isEnterpriseAuthenticated: false,diff --git a/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx b/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsxindex cea974376..54491ed5e 100644--- a/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx+++ b/apps/screenpipe-app-tauri/components/app-entitlement-gate.tsx@@ -274,7 +274,12 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })}, [devBypass, failOpenForTransientAccessLoss, tokenPending, loadUser]);useEffect(() => {- if (!isSettingsLoaded || !shouldGate) {+ // Build detection is asynchronous in newly-created webviews. `shouldGate`+ // deliberately stays true while it is unresolved so we render the neutral+ // "checking access" shell, but that transient state must never stop the+ // recorder. Otherwise opening the overlay can tear down the local API just+ // before the consumer/enterprise result arrives.+ if (!isSettingsLoaded || !isEnterpriseBuildResolved || !shouldGate) {stoppedForGateRef.current = false;return;}@@ -283,7 +288,7 @@ export function AppEntitlementGate({ children }: { children: React.ReactNode })commands.stopScreenpipe().catch((err) => {console.warn("failed to stop screenpipe after entitlement gate:", err);});- }, [isSettingsLoaded, shouldGate]);+ }, [isSettingsLoaded, isEnterpriseBuildResolved, shouldGate]);const openPricing = useCallback(() => {posthog.capture("app_entitlement_choose_plan_clicked", {