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(chat): make quota upgrade CTA phosphor primary (#6172)
Ezra Ellette1b4357cd825e
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.test.tsxindex 019d31e97..87021fbdc 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.test.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.test.tsx@@ -58,6 +58,17 @@ vi.mock("@/lib/upgrade-flow", () => ({openBusinessUpgradeSurface: mocks.openBusinessUpgradeSurface,}));+function expectPhosphorPrimary(button: HTMLElement) {+ expect(button).toHaveClass(+ "border-[#4A6B00]",+ "bg-[#C7FF3E]",+ "text-black",+ "hover:border-black",+ "hover:bg-black",+ "hover:text-[#C7FF3E]",+ );+}+describe("UpgradeQuotaBanner", () => {beforeEach(() => {mocks.usageState = {@@ -106,7 +117,9 @@ describe("UpgradeQuotaBanner", () => {mocks.gateState = true;render(<UpgradeQuotaBanner />);- fireEvent.click(screen.getByRole("button", { name: "View Business" }));+ const upgrade = screen.getByRole("button", { name: "View Business" });+ expectPhosphorPrimary(upgrade);+ fireEvent.click(upgrade);await waitFor(() =>expect(mocks.openBusinessUpgradeSurface).toHaveBeenCalledWith("ai-quota-banner",@@ -302,9 +315,11 @@ describe("UpgradeQuotaBanner", () => {expect(mocks.seenEligibility).toBe(true);expect(screen.getByTestId("hosted-ai-allowance-banner")).toBeTruthy();- fireEvent.click(- screen.getByRole("button", { name: `Upgrade to ${planLabel}` }),- );+ const polledUpgrade = screen.getByRole("button", {+ name: `Upgrade to ${planLabel}`,+ });+ expectPhosphorPrimary(polledUpgrade);+ fireEvent.click(polledUpgrade);await waitFor(() =>expect(mocks.openExternalUrl).toHaveBeenCalledWith(upgradeUrl),);@@ -319,9 +334,11 @@ describe("UpgradeQuotaBanner", () => {};render(<UpgradeQuotaBanner />);- fireEvent.click(- screen.getByRole("button", { name: `Upgrade to ${planLabel}` }),- );+ const immediateUpgrade = screen.getByRole("button", {+ name: `Upgrade to ${planLabel}`,+ });+ expectPhosphorPrimary(immediateUpgrade);+ fireEvent.click(immediateUpgrade);await waitFor(() =>expect(mocks.openExternalUrl).toHaveBeenCalledWith(upgradeUrl),);diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.tsxindex 8ef72f475..49cb67194 100644--- a/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.tsx+++ b/apps/screenpipe-app-tauri/components/chat/standalone/upgrade-quota-banner.tsx@@ -190,8 +190,8 @@ export function UpgradeQuotaBanner() {<Buttontype="button"size="sm"- variant="outline"- className="h-7 text-[12px]"+ variant="default"+ className="h-7 border-[#4A6B00] bg-[#C7FF3E] text-[12px] text-black hover:border-black hover:bg-black hover:text-[#C7FF3E]"onClick={onUpgrade}disabled={busy}>diff --git a/apps/screenpipe-app-tauri/e2e/COVERAGE.md b/apps/screenpipe-app-tauri/e2e/COVERAGE.mdindex db793d767..fda85adbe 100644--- a/apps/screenpipe-app-tauri/e2e/COVERAGE.md+++ b/apps/screenpipe-app-tauri/e2e/COVERAGE.md@@ -119,7 +119,7 @@ pass/fail/skip counts.| chat-automation-card-duplicate.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat, chat-sidebar-dedupe | medium | partial | real-user-flow | 1 | Home automation card clicks must create exactly one persisted conversation per card, guarding the #4719 duplicate-row path. || chat-composer-isolation.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat, chat-drafts | medium | partial | mixed | 1 | Composer draft isolation across conversations. || chat-connections-context-duplicate.spec.ts | windows, macos | chat-ai | chat, chat-sidebar-dedupe | medium | partial | synthetic | 1 | QUARANTINED (#4689): connections-context wrapper stripping regression. The synthetic background-router event path never persists deterministically on Linux/macOS CI; re-enable once it drives a deterministic persisted session. |-| chat-cost-limit-upgrade.spec.ts | macos | chat-ai, real-ui-e2e, tauri-command | chat | high | strong | real-user-flow | 1 | A local provider returns the gateway's structured daily-limit rejection for a Business account; the request crosses the real Pi and foreground-event path, then the UI shows usage-limit copy and a targeted Business Max billing action. |+| chat-cost-limit-upgrade.spec.ts | macos | chat-ai, real-ui-e2e, tauri-command | chat | high | strong | real-user-flow | 1 | A local provider returns the gateway's structured daily-limit rejection across the four self-serve upgrade targets; each request crosses the real Pi and foreground-event path, then the UI asserts the phosphor primary CTA, captures a screenshot, and opens the exact billing URL. || chat-cross-window-transcript-sync.spec.ts | windows, macos, linux | chat-ai, window-lifecycle, real-ui-e2e | chat, chat-streaming, window-lifecycle | high | strong | mixed | 1 | Both Home and standalone Chat show persistent pending feedback, then hydrate a completed disk transcript and clear stop state from the real cross-window save event without calling a provider. || chat-empty-space.spec.ts | windows, macos, linux | chat-ai, real-ui-e2e | chat | medium | strong | real-user-flow | 1 | A real Tauri chat session keeps a short answer at the top of the message rail without exposing a false new-content state. || chat-hosted-retry-feedback.spec.ts | macos | chat-ai, real-ui-e2e, tauri-command | chat, chat-streaming | high | strong | real-user-flow | 1 | A local provider returns priced_request_in_flight twice; Pi retries while the UI remains active, a real composer follow-up enters the Rust queue, and both turns recover without the misleading mid-response error. |diff --git a/apps/screenpipe-app-tauri/e2e/coverage-map.json b/apps/screenpipe-app-tauri/e2e/coverage-map.jsonindex 481b458d1..519586280 100644--- a/apps/screenpipe-app-tauri/e2e/coverage-map.json+++ b/apps/screenpipe-app-tauri/e2e/coverage-map.json@@ -1059,7 +1059,7 @@"criticality": "high","confidence": "strong","ux": "real-user-flow",- "notes": "A local provider returns the gateway's structured daily-limit rejection for a Business account; the request crosses the real Pi and foreground-event path, then the UI shows usage-limit copy and a targeted Business Max billing action."+ "notes": "A local provider returns the gateway's structured daily-limit rejection across the four self-serve upgrade targets; each request crosses the real Pi and foreground-event path, then the UI asserts the phosphor primary CTA, captures a screenshot, and opens the exact billing URL."},{"spec": "chat-local-ai-gateway.spec.ts",diff --git a/apps/screenpipe-app-tauri/e2e/specs/chat-cost-limit-upgrade.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/chat-cost-limit-upgrade.spec.tsindex 0eb6d7fcf..be3de04b6 100644--- a/apps/screenpipe-app-tauri/e2e/specs/chat-cost-limit-upgrade.spec.ts+++ b/apps/screenpipe-app-tauri/e2e/specs/chat-cost-limit-upgrade.spec.ts@@ -5,12 +5,11 @@/*** Real-app regression for the hosted-AI usage-limit recovery path.*- * A local OpenAI-compatible provider returns the exact structured 429 contract- * used by the gateway for a Business account. The request travels through Pi and the real- * foreground event bus, proving desktop renders a concise failure message and- * an inline recovery banner that opens the server-reviewed Business Max billing URL- * without waiting for `remaining` to hit zero or for the proactive PostHog- * upsell gate.+ * A local OpenAI-compatible provider returns the exact structured 429 contracts+ * used by the gateway across the self-serve plan ladder. Each request travels+ * through Pi and the real foreground event bus, proving desktop renders a+ * concise failure message and a phosphor primary recovery action without+ * waiting for `remaining` to hit zero or for the proactive PostHog upsell gate.*/import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";@@ -25,6 +24,38 @@ const CHATS_DIR = join(E2E_DATA_DIR, "chats");const CHAT_FILE = join(CHATS_DIR, `${CHAT_ID}.json`);const PROMPT = "E2E trigger structured hosted AI usage rejection";const piConversation = new PiConversationHarness(CHAT_ID);+const UPGRADE_CASES = [+ {+ currentPlan: "free",+ requiredPlan: "basic",+ planLabel: "Basic",+ upgradeUrl: "https://screenpi.pe/account/billing",+ screenshot: "chat-cost-limit-basic-upgrade",+ },+ {+ currentPlan: "basic",+ requiredPlan: "business",+ planLabel: "Business",+ upgradeUrl: "https://screenpi.pe/account/billing",+ screenshot: "chat-cost-limit-business-upgrade",+ },+ {+ currentPlan: "business",+ requiredPlan: "business_max",+ planLabel: "Business Max",+ upgradeUrl:+ "https://screenpipe.com/account/billing?target_plan=pro_max&interval=month",+ screenshot: "chat-cost-limit-business-max-upgrade",+ },+ {+ currentPlan: "business_max",+ requiredPlan: "business_ultra",+ planLabel: "Business Ultra",+ upgradeUrl:+ "https://screenpipe.com/account/billing?target_plan=pro_ultra&interval=month",+ screenshot: "chat-cost-limit-business-ultra-upgrade",+ },+] as const;function writeActiveConversation(): number {const now = Date.now();@@ -123,8 +154,8 @@ async function submitComposer(text: string): Promise<void> {});}-describe("Hosted AI usage-limit Business Max recovery", function () {- this.timeout(120_000);+describe("Hosted AI usage-limit upgrade recovery", function () {+ this.timeout(t(240_000));before(async function () {if (process.platform !== "darwin") this.skip();@@ -157,54 +188,7 @@ describe("Hosted AI usage-limit Business Max recovery", function () {rmSync(CHAT_FILE, { force: true });});- it("shows the server-backed Business Max action while query allowance can remain positive", async () => {- piConversation.setGatewayErrorResponse({- error: JSON.stringify({- error: "daily_limit_exceeded",- message:- "You've used your daily AI allowance. Background scheduled tasks share this allowance.",- resets_at: "2026-08-02T00:00:00.000Z",- plan: "business",- required_plan: "business_max",- upgrade_url:- "https://screenpipe.com/account/billing?target_plan=pro_max&interval=month",- can_buy_credits: false,- byok_supported: true,- }),- });-- await submitComposer(PROMPT);-- const assistant = await $('[data-testid="chat-message-assistant"]');- await browser.waitUntil(- async () => (await assistant.getText()).includes("recovery option below"),- {- timeout: t(30_000),- interval: 100,- timeoutMsg: "structured usage-limit recovery copy did not render",- },- );- expect(await assistant.getText()).toContain("plan's usage limit");- expect(await assistant.getText()).not.toContain("Background scheduled tasks");-- const banner = await $('[data-testid="cost-limit-upgrade-banner"]');- await banner.waitForDisplayed({ timeout: t(10_000) });- expect(await banner.getText()).toContain("AI usage limit reached");- expect(await banner.getText()).toContain("Resets");-- // The recovery action lives inline on the banner — no blocking dialog.- const modal = await $('[data-testid="ai-usage-limit-modal"]');- expect(await modal.isExisting()).toBe(false);- const upgrade = await banner.$("button=Upgrade to Business Max");- await upgrade.waitForDisplayed({- timeout: t(10_000),- });-- const screenshot = await saveScreenshot(- "chat-cost-limit-business-max-upgrade",- );- expect(existsSync(screenshot)).toBe(true);-+ it("shows a phosphor primary action for every server-backed upgrade plan", async () => {await browser.execute(() => {const target = window as Window & {__SCREENPIPE_E2E_OPEN_URLS?: string[];@@ -213,23 +197,88 @@ describe("Hosted AI usage-limit Business Max recovery", function () {target.__SCREENPIPE_E2E_OPEN_URLS = [];target.__SCREENPIPE_E2E_INTERCEPT_OPEN_URLS = true;});- await upgrade.click();- await browser.waitUntil(- async () => {- const urls = await browser.execute(- () =>- (window as Window & { __SCREENPIPE_E2E_OPEN_URLS?: string[] })- .__SCREENPIPE_E2E_OPEN_URLS ?? [],- );- return urls.includes(- "https://screenpipe.com/account/billing?target_plan=pro_max&interval=month",++ for (const [index, upgradeCase] of UPGRADE_CASES.entries()) {+ piConversation.setGatewayErrorResponse({+ error: JSON.stringify({+ error: "daily_limit_exceeded",+ message:+ "You've used your daily AI allowance. Background scheduled tasks share this allowance.",+ resets_at: "2026-08-02T00:00:00.000Z",+ plan: upgradeCase.currentPlan,+ required_plan: upgradeCase.requiredPlan,+ upgrade_url: upgradeCase.upgradeUrl,+ can_buy_credits: false,+ byok_supported: true,+ }),+ });++ await submitComposer(`${PROMPT}: ${upgradeCase.currentPlan}`);+ await piConversation.waitForRequestCount(+ index + 1,+ `${upgradeCase.currentPlan} usage-limit request`,+ );++ const banner = await $('[data-testid="cost-limit-upgrade-banner"]');+ await banner.waitForDisplayed({ timeout: t(10_000) });+ expect(await banner.getText()).toContain("AI usage limit reached");+ expect(await banner.getText()).toContain("Resets");++ // The recovery action lives inline on the banner — no blocking dialog.+ const modal = await $('[data-testid="ai-usage-limit-modal"]');+ expect(await modal.isExisting()).toBe(false);+ const ctaLabel = `Upgrade to ${upgradeCase.planLabel}`;+ const upgrade = await banner.$(`button=${ctaLabel}`);+ await upgrade.waitForDisplayed({ timeout: t(30_000) });++ const style = await browser.execute((label: string) => {+ const button = Array.from(document.querySelectorAll("button")).find(+ (candidate) => candidate.textContent?.trim() === label,);- },- {- timeout: t(10_000),- interval: 100,- timeoutMsg: "Usage-limit upgrade did not open the billing URL",- },- );+ if (!button) return null;+ const computed = getComputedStyle(button);+ return {+ backgroundColor: computed.backgroundColor,+ borderColor: computed.borderTopColor,+ color: computed.color,+ };+ }, ctaLabel);+ expect(style).toEqual({+ backgroundColor: "rgb(199, 255, 62)",+ borderColor: "rgb(74, 107, 0)",+ color: "rgb(0, 0, 0)",+ });++ const screenshot = await saveScreenshot(upgradeCase.screenshot);+ expect(existsSync(screenshot)).toBe(true);++ await browser.execute(() => {+ const target = window as Window & {+ __SCREENPIPE_E2E_OPEN_URLS?: string[];+ };+ target.__SCREENPIPE_E2E_OPEN_URLS = [];+ });+ await upgrade.click();+ await browser.waitUntil(+ async () => {+ const urls = await browser.execute(+ () =>+ (window as Window & { __SCREENPIPE_E2E_OPEN_URLS?: string[] })+ .__SCREENPIPE_E2E_OPEN_URLS ?? [],+ );+ return urls.includes(upgradeCase.upgradeUrl);+ },+ {+ timeout: t(10_000),+ interval: 100,+ timeoutMsg: `${ctaLabel} did not open its billing URL`,+ },+ );+ }++ const assistant = await $('[data-testid="chat-message-assistant"]');+ expect(await assistant.getText()).toContain("recovery option below");+ expect(await assistant.getText()).toContain("plan's usage limit");+ expect(await assistant.getText()).not.toContain("Background scheduled tasks");});});