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
Make data sync directly accessible in account settings
Ezra Ellette0d6370fa6ee0
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/account-section.subscription-gate.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/account-section.subscription-gate.test.tsxindex ee6d47481..01a7b6de5 100644--- a/apps/screenpipe-app-tauri/components/settings/__tests__/account-section.subscription-gate.test.tsx+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/account-section.subscription-gate.test.tsx@@ -28,13 +28,15 @@ import {} from "@testing-library/react";const mocks = vi.hoisted(() => ({- state: { user: null as any },+ state: { user: null as any, dataSyncEnabled: false },managed: false,managedAuthenticated: true,updateSettings: vi.fn().mockResolvedValue(undefined),loadUser: vi.fn().mockResolvedValue(undefined),openLoginWindow: vi.fn().mockResolvedValue(undefined),piUpdateConfig: vi.fn().mockResolvedValue(undefined),+ getCloudToken: vi.fn().mockResolvedValue("test-cloud-token"),+ dataSyncFetch: vi.fn(),capture: vi.fn(),openUrl: vi.fn().mockResolvedValue(undefined),eventHandlers: new Map<string, (event: any) => unknown>(),@@ -54,6 +56,9 @@ vi.mock("@/lib/hooks/use-settings", () => ({pipeSyncEnabled: false,memoriesSyncEnabled: false,connectionSyncEnabled: false,+ deviceId: "test-device-id",+ dataSyncEnabled: mocks.state.dataSyncEnabled,+ dataSyncDeviceName: "Work laptop",},updateSettings: mocks.updateSettings,loadUser: mocks.loadUser,@@ -76,11 +81,15 @@ vi.mock("@/lib/utils/tauri", () => ({commands: {openLoginWindow: mocks.openLoginWindow,piUpdateConfig: mocks.piUpdateConfig,+ getCloudToken: mocks.getCloudToken,},}));vi.mock("@/components/ui/use-toast", () => ({ toast: vi.fn() }));vi.mock("@/lib/api", () => ({ localFetch: vi.fn() }));+vi.mock("@/lib/http/tauri-fetch", () => ({+ tauriFetchWithDeadline: mocks.dataSyncFetch,+}));vi.mock("posthog-js", () => ({ default: { capture: mocks.capture } }));// Tauri plugins the effect wires up on mount — keep them inert.@@ -138,6 +147,8 @@ describe("AccountSection subscription/login gating", () => {vi.unstubAllEnvs();mocks.eventHandlers.clear();mocks.state.user = null;+ mocks.state.dataSyncEnabled = false;+ mocks.dataSyncFetch.mockReset();mocks.managed = false;mocks.managedAuthenticated = true;});@@ -450,6 +461,7 @@ describe("AccountSection subscription/login gating", () => {expect(loginStatus()).toContain("logged in as [email protected]");expect(screen.queryByTestId(ACTIVE_CARD)).not.toBeInTheDocument();+ expect(screen.queryByTestId("account-data-sync-setting")).not.toBeInTheDocument();// Branch-3 named-plan badge still renders for the paying Basic user.expect(screen.getByText("Active")).toBeInTheDocument();expect(screen.getByTestId("account-plan-standard")).toHaveAttribute(@@ -549,5 +561,116 @@ describe("AccountSection subscription/login gating", () => {expect(loginStatus()).toContain("not logged in");expect(screen.queryByTestId(ACTIVE_CARD)).not.toBeInTheDocument();expect(screen.getByText(/sign in to screenpipe/i)).toBeInTheDocument();+ expect(screen.queryByTestId("account-data-sync-setting")).not.toBeInTheDocument();+ });++ function signInForDataSync() {+ mocks.state.user = {+ id: "u1",+ token: "tok",+ cloud_subscribed: true,+ subscription_plan: "pro",+ app_entitled: true,+ entitlement: {+ active: true,+ plan: "pro",+ source: "subscription",+ checked_at: new Date().toISOString(),+ },+ };+ }++ it("enables account consent and this device from the visible switch before saving locally", async () => {+ signInForDataSync();+ let finishDevice!: (response: Response) => void;+ mocks.dataSyncFetch+ .mockResolvedValueOnce(new Response("{}"))+ .mockImplementationOnce(() => new Promise<Response>((resolve) => {+ finishDevice = resolve;+ }));+ render(<AccountSection />);+ const sync = screen.getByRole("switch", { name: "Sync this device" });+ expect(sync).toBeVisible();+ expect(sync.closest("details")).toBeNull();+ expect(mocks.dataSyncFetch).not.toHaveBeenCalled();+ fireEvent.click(sync);++ await waitFor(() => expect(mocks.dataSyncFetch).toHaveBeenCalledTimes(2));+ expect(mocks.dataSyncFetch).toHaveBeenNthCalledWith(1,+ expect.stringMatching(/\/api\/user\/data-sync$/),+ expect.objectContaining({+ method: "PATCH",+ headers: expect.objectContaining({ Authorization: "Bearer test-cloud-token" }),+ body: JSON.stringify({ allow_data_sync: true }),+ }),+ );+ expect(mocks.dataSyncFetch).toHaveBeenNthCalledWith(2,+ expect.stringMatching(/\/api\/user\/data-sync\/ingest$/),+ expect.objectContaining({+ method: "PATCH",+ headers: expect.objectContaining({+ "X-Screenpipe-Device-Id": "test-device-id",+ "X-Screenpipe-Device-Label": "Work laptop",+ }),+ body: JSON.stringify({ enabled: true }),+ }),+ );+ expect(mocks.updateSettings).not.toHaveBeenCalled();+ expect(sync).toBeDisabled();+ fireEvent.click(sync);+ expect(mocks.dataSyncFetch).toHaveBeenCalledTimes(2);++ await act(async () => finishDevice(new Response("{}")));+ expect(mocks.updateSettings).toHaveBeenCalledWith({+ dataSyncEnabled: true,+ dataSyncDeviceName: "Work laptop",+ dataSyncAccountId: "u1",+ dataSyncEnabledAt: expect.any(String),+ });+ expect(mocks.openUrl).not.toHaveBeenCalled();+ });++ it.each(["account", "device"])("keeps sync off after a %s save failure and retries in the app", async (stage) => {+ signInForDataSync();+ if (stage === "device") mocks.dataSyncFetch.mockResolvedValueOnce(new Response("{}"));+ mocks.dataSyncFetch.mockResolvedValueOnce(new Response(+ JSON.stringify({ error: "sync service unavailable" }), { status: 503 },+ ));+ render(<AccountSection />);+ fireEvent.click(screen.getByRole("switch", { name: "Sync this device" }));+ expect(await screen.findByRole("alert")).toHaveTextContent("Could not update syncing on this device");+ expect(screen.getByRole("switch", { name: "Sync this device" })).toHaveAttribute("aria-checked", "false");+ expect(mocks.updateSettings).not.toHaveBeenCalled();+ expect(mocks.dataSyncFetch).toHaveBeenCalledTimes(stage === "account" ? 1 : 2);++ mocks.dataSyncFetch.mockImplementation(async () => new Response("{}"));+ fireEvent.click(screen.getByRole("button", { name: "Try again", exact: true }));+ await waitFor(() => expect(mocks.updateSettings).toHaveBeenCalledWith(+ expect.objectContaining({ dataSyncEnabled: true }),+ ));+ expect(screen.queryByRole("alert")).not.toBeInTheDocument();+ });++ it("disables only this device and leaves deletion on the website", async () => {+ signInForDataSync();+ mocks.state.dataSyncEnabled = true;+ mocks.dataSyncFetch.mockImplementation(async () => new Response(JSON.stringify({ devices: [] })));+ render(<AccountSection />);+ await screen.findByText("Waiting for the first upload. Keep Screenpipe running.");+ mocks.dataSyncFetch.mockClear();+ fireEvent.click(screen.getByRole("switch", { name: "Sync this device" }));+ await waitFor(() => expect(mocks.updateSettings).toHaveBeenCalledWith({+ dataSyncEnabled: false,+ dataSyncDeviceName: "Work laptop",+ dataSyncAccountId: "",+ }));+ expect(mocks.dataSyncFetch).toHaveBeenCalledTimes(1);+ expect(mocks.dataSyncFetch).toHaveBeenCalledWith(+ expect.stringMatching(/\/api\/user\/data-sync\/ingest$/),+ expect.objectContaining({ method: "PATCH", body: JSON.stringify({ enabled: false }) }),+ );+ fireEvent.click(screen.getByRole("button", { name: "Manage or delete cloud data on website" }));+ await waitFor(() => expect(mocks.openUrl).toHaveBeenCalledWith("https://screenpipe.com/account"));+ expect(mocks.dataSyncFetch).toHaveBeenCalledTimes(1);});});diff --git a/apps/screenpipe-app-tauri/components/settings/account-data-sync-card.tsx b/apps/screenpipe-app-tauri/components/settings/account-data-sync-card.tsxindex f342ed1ba..0cfbe9cce 100644--- a/apps/screenpipe-app-tauri/components/settings/account-data-sync-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/account-data-sync-card.tsx@@ -4,6 +4,7 @@import { screenpipeWebUrl, PROD_WEB_BASE } from "@/lib/web-url";import { useState } from "react";+import { ExternalLink, Loader2 } from "lucide-react";import { CloudAiConnectionCard } from "@/components/cloud-ai-connection-card";import { Switch } from "@/components/ui/switch";import { Input } from "@/components/ui/input";@@ -30,32 +31,65 @@ type Props = {export function AccountDataSyncCard(props: Props) {const [openError, setOpenError] = useState(false);return (- <div data-testid="account-data-sync-setting">- <CloudAiConnectionCard- enabled={props.enabled}- busy={props.saving}- error={props.error}- onEnable={() => props.onEnabledChange(true)}- onRetry={props.onRetry}- onOpenExternal={props.onOpenExternal}- onConfigureClient={props.onConfigureClient}- device+ <div className="space-y-4" data-testid="account-data-sync-setting">+ <section+ className="space-y-4 rounded-lg border bg-card p-5 text-card-foreground"+ aria-labelledby="data-sync-heading"><div className="flex items-center justify-between gap-4">- <div>- <p className="text-sm font-medium">Sync this device</p>- <p className="text-xs text-muted-foreground">- Upload this device’s history to your Screenpipe account.+ <h2 id="data-sync-heading" className="text-sm font-medium">+ Data sync+ </h2>+ <p+ role="status"+ className="flex items-center gap-2 text-xs text-muted-foreground"+ >+ {props.saving && (+ <Loader2 className="h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />+ )}+ {props.saving+ ? "Saving…"+ : props.enabled+ ? "On for this device"+ : "Off for this device"}+ </p>+ </div>+ <div className="flex items-center justify-between gap-4">+ <div className="space-y-1">+ <Label htmlFor="data-sync-toggle">Sync this device</Label>+ <p id="data-sync-description" className="text-xs text-muted-foreground">+ Upload this device’s history to your Screenpipe account to search+ it across devices and connected AI apps.</p></div><Switchid="data-sync-toggle"aria-label="Sync this device"+ aria-describedby="data-sync-description data-sync-setup"checked={props.enabled}disabled={props.saving}onCheckedChange={(value) => void props.onEnabledChange(value)}/></div>+ <p id="data-sync-setup" className="text-xs text-muted-foreground">+ Turning this on enables sync for your account and this device. No+ website setup needed. Turn it on in the app on each device you want to+ sync.+ </p>+ {props.error && (+ <div role="alert" className="space-y-2 text-sm text-destructive">+ <p>{props.error}</p>+ <Button+ type="button"+ variant="outline"+ size="sm"+ disabled={props.saving}+ onClick={props.onRetry}+ >+ Try again+ </Button>+ </div>+ )}{props.enabled && (<div className="space-y-3 border-t pt-4"><Label htmlFor="data-sync-device-name">Device name</Label>@@ -112,25 +146,40 @@ export function AccountDataSyncCard(props: Props) {</div></div>)}- <Button- variant="link"- className="h-auto p-0 text-xs"- onClick={() =>- void props- .onOpenExternal(screenpipeWebUrl("/account", PROD_WEB_BASE))- .then(() => setOpenError(false))- .catch(() => setOpenError(true))- }- >- Manage account cloud data- </Button>+ <div className="space-y-2 border-t pt-3">+ <p className="text-xs text-muted-foreground">+ Turning sync off stops new uploads from this device. Data already+ synced stays in your account until you delete it.+ </p>+ <Button+ variant="link"+ className="h-auto whitespace-normal p-0 text-left text-xs"+ onClick={() =>+ void props+ .onOpenExternal(screenpipeWebUrl("/account", PROD_WEB_BASE))+ .then(() => setOpenError(false))+ .catch(() => setOpenError(true))+ }+ >+ Manage or delete cloud data on website+ <ExternalLink className="ml-1.5 h-3 w-3 shrink-0" />+ </Button>+ </div>{openError && (<p role="alert" className="text-xs text-destructive">Could not open account settings. Open screenpipe.com/account in yourbrowser.</p>)}- </CloudAiConnectionCard>+ </section>+ <CloudAiConnectionCard+ enabled={props.enabled}+ busy={props.saving}+ onEnable={() => props.onEnabledChange(true)}+ onOpenExternal={props.onOpenExternal}+ onConfigureClient={props.onConfigureClient}+ device+ /></div>);}diff --git a/apps/screenpipe-app-tauri/components/settings/account-section.tsx b/apps/screenpipe-app-tauri/components/settings/account-section.tsxindex 50c3b15d7..d0acb58d2 100644--- a/apps/screenpipe-app-tauri/components/settings/account-section.tsx+++ b/apps/screenpipe-app-tauri/components/settings/account-section.tsx@@ -13,7 +13,8 @@ export const searchIndex: SettingsField[] = [{ label: msg("Sign in to Screenpipe", {}), keywords: ["login", "log in", "sign in"] },{ label: msg("Logout", {}), keywords: ["signout", "sign out", "log out"] },{ label: msg("Screenpipe Business", {}), keywords: ["subscription", "billing", "plan", "pro", "business", "max", "ultra", "upgrade", "manage"] },- { label: msg("AI connections", {}), keywords: ["data sync", "allow data sync", "cloud", "account", "codex", "claude"] },+ { label: msg("Data sync", {}), keywords: ["allow data sync", "sync this device", "cloud", "account", "upload"] },+ { label: msg("AI connections", {}), keywords: ["codex", "claude", "connect"] },{ label: msg("Device name", {}), keywords: ["data sync", "hostname", "computer"] },{ label: msg("Sync scheduled tasks across devices", {}), keywords: ["scheduled sync", "pipe sync", "sync"] },{ label: msg("Memories sync across devices", {}), keywords: ["memories sync", "sync", "facts"] },@@ -1109,7 +1110,7 @@ export function AccountSection() {enabled={settings.dataSyncEnabled ?? false}saving={dataSyncSaving}error={dataSyncError}- onRetry={() => setDataSyncError(null)}+ onRetry={() => void setDataSyncEnabled(!settings.dataSyncEnabled)}onEnabledChange={setDataSyncEnabled}deviceName={settings.dataSyncDeviceName ?? ""}onDeviceNameChange={(name) => void updateSettings({ dataSyncDeviceName: name })}