Skip to content

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

fix(onboarding): accept complete legacy free entitlement evidence (#5990)

Ezra Ellettee3adc22d1fbd
diff --git a/apps/screenpipe-app-tauri/lib/app-entitlement.test.ts b/apps/screenpipe-app-tauri/lib/app-entitlement.test.ts
index d01c45fbd..b0e2ba7c0 100644
--- a/apps/screenpipe-app-tauri/lib/app-entitlement.test.ts
+++ b/apps/screenpipe-app-tauri/lib/app-entitlement.test.ts
@@ -368,6 +368,51 @@ describe("app entitlement", () => {
expect(hasCloudEntitlement(normalized)).toBe(true);
});
+ it("normalizes an authenticated legacy cloud denial as verified free", () => {
+ const normalized = normalizeAppUser(
+ {
+ id: "user_legacy_free",
+ cloud_subscribed: false,
+ },
+ "token",
+ );
+
+ expect(getLocalPlanPolicy(normalized)).toBe("verified-free");
+ expect(isAuthenticatedFreeUser(normalized)).toBe(true);
+ expect(hasVerifiedPaidPlan(normalized)).toBe(false);
+ expect(hasAppEntitlement(normalized)).toBe(false);
+ });
+
+ it("keeps a partial newer entitlement unknown instead of synthesizing verified free", () => {
+ const normalized = normalizeAppUser(
+ {
+ id: "user_partial_entitlement",
+ cloud_subscribed: false,
+ entitlement: { plan: "none" },
+ },
+ "token",
+ );
+
+ expect(getLocalPlanPolicy(normalized)).toBe("unknown");
+ });
+
+ it("requires explicit feature evidence before accepting newer free evidence", () => {
+ const normalized = normalizeAppUser(
+ {
+ id: "user_incomplete_free",
+ cloud_subscribed: false,
+ entitlement: {
+ active: false,
+ plan: "none",
+ source: "none",
+ },
+ },
+ "token",
+ );
+
+ expect(getLocalPlanPolicy(normalized)).toBe("unknown");
+ });
+
// The server computes `subscription_plan` per request and may omit it while
// still returning a complete entitlement. Falling back to an invented label
// ("pro"/"standard") then contradicted the entitlement's own plan, and
@@ -576,12 +621,19 @@ describe("isAuthenticatedFreeUser", () => {
plan: "none",
source: "none",
checked_at: "2026-06-01T11:59:59.000Z",
+ features: { app: true },
},
}),
),
).toBe(true);
});
+ it("rejects a whitespace-only authentication token", () => {
+ expect(isAuthenticatedFreeUser(explicitFree({ token: " " }))).toBe(
+ false,
+ );
+ });
+
it("fails safe on missing or conflicting plan fields", () => {
const missing = explicitFree({ subscription_plan: null });
expect(isAuthenticatedFreeUser(missing)).toBe(false);
diff --git a/apps/screenpipe-app-tauri/lib/app-entitlement.ts b/apps/screenpipe-app-tauri/lib/app-entitlement.ts
index 88d9749d7..4b993fd9f 100644
--- a/apps/screenpipe-app-tauri/lib/app-entitlement.ts
+++ b/apps/screenpipe-app-tauri/lib/app-entitlement.ts
@@ -196,7 +196,7 @@ function isEntitlementFresh(entitlement: AppEntitlement | null) {
*/
function hasVerifiedFreePlan(user: AppUser | null | undefined): boolean {
const stableAccountId = getStableAccountId(user);
- if (!user || !stableAccountId || user.cloud_subscribed === true) return false;
+ if (!user || !stableAccountId || user.cloud_subscribed !== false) return false;
const entitlement = asEntitlement(user.entitlement);
// Once verified, free limits persist offline; merely waiting 72 hours must
@@ -221,10 +221,10 @@ function hasVerifiedFreePlan(user: AppUser | null | undefined): boolean {
? entitlement.source.trim().toLowerCase()
: null;
if (
- source === "manual" ||
- source === "enterprise" ||
- source === "lifetime" ||
- source === "dev" ||
+ source !== "none" ||
+ typeof entitlement?.active !== "boolean" ||
+ typeof entitlement.features?.app !== "boolean" ||
+ entitlement.features.cloud === true ||
hasFutureGrace(entitlement)
) {
return false;
@@ -253,7 +253,11 @@ export function hasFreePlanPolicy(user: AppUser | null | undefined): boolean {
export function isAuthenticatedFreeUser(
user: AppUser | null | undefined,
): boolean {
- return Boolean(user?.token) && hasFreePlanPolicy(user);
+ return (
+ typeof user?.token === "string" &&
+ user.token.trim().length > 0 &&
+ hasFreePlanPolicy(user)
+ );
}
function hasVerifiedPaidPlanAt(
@@ -558,9 +562,16 @@ export function normalizeAppUser(rawUser: any, token: string): AppUser {
: rawEntitlement
? rawEntitlement.features?.app === true
: cloudSubscribed;
+ const legacyVerifiedFree =
+ rawUser?.cloud_subscribed === false &&
+ rawUser?.app_entitled === undefined &&
+ rawUser?.subscription_plan === undefined &&
+ rawUser?.entitlement === undefined;
// Explicit server denial is stronger than a stale users.plan label left by a
// canceled or refunded account.
- const explicitlyFree = rawUser?.app_entitled === false && !cloudSubscribed;
+ const explicitlyFree =
+ legacyVerifiedFree ||
+ (rawUser?.app_entitled === false && !cloudSubscribed);
// The server computes `subscription_plan` per request and can omit it while
// still returning a full entitlement. The cloud_subscribed/app_entitled
// fallbacks below invent a *label* ("pro"/"standard"), and the entitlement is