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

Add cloud AI connections automatically without a CLI (#7301)

Louis Beaumontf4b724f3fda1
diff --git a/.github/pr-assets/cloud-ai-connect/README.md b/.github/pr-assets/cloud-ai-connect/README.md
new file mode 100644
index 000000000..310752374
--- /dev/null
+++ b/.github/pr-assets/cloud-ai-connect/README.md
@@ -0,0 +1,44 @@
+# Cloud AI connection screenshots
+
+24 screenshots of real production React components in an isolated browser preview with synthetic account/device data. These are component previews, not authenticated live sessions or native Tauri screenshots.
+
+Placement: Settings → Account, replacing Data Sync.
+
+Baseline recreated from `f1bcd5bbbb9d838e471cb73e3ec0e88316ef89e7` before editing. Website baseline uses the original DataSyncSetting with a synthetic Clerk user. Desktop baseline uses the exact Data Sync card from AccountSection with fixture inputs. Product CSS and fonts are loaded in both versions.
+
+Desktop viewport: 1000 × 900. Compact/mobile: 390 × 844. America/Los_Angeles. Reduced motion enabled. Before/after use the same viewport and theme. No real account was connected, synced, or deleted.
+
+The card reports saved sync state, not live transfer progress or verified client authentication. There is intentionally no simulated “Connected” screenshot. Codex uses the copyable add/login command; Claude uses a copyable URL and its connector settings. Real-client OAuth remains a release verification step.
+
+- [desktop-after-off](desktop-after-off.png)
+- [desktop-before-off](desktop-before-off.png)
+- [desktop-before-on](desktop-before-on.png)
+- [desktop-claude-copied](desktop-claude-copied.png)
+- [desktop-claude-setup](desktop-claude-setup.png)
+- [desktop-codex-copied](desktop-codex-copied.png)
+- [desktop-codex-setup](desktop-codex-setup.png)
+- [desktop-compact-before](desktop-compact-before.png)
+- [desktop-compact-claude](desktop-compact-claude.png)
+- [desktop-compact-consent](desktop-compact-consent.png)
+- [desktop-compact](desktop-compact.png)
+- [desktop-consent](desktop-consent.png)
+- [desktop-dark-setup](desktop-dark-setup.png)
+- [desktop-dark](desktop-dark.png)
+- [desktop-devices-error](desktop-devices-error.png)
+- [desktop-devices-loading](desktop-devices-loading.png)
+- [desktop-error](desktop-error.png)
+- [desktop-keyboard-focus](desktop-keyboard-focus.png)
+- [desktop-manage](desktop-manage.png)
+- [desktop-open-error](desktop-open-error.png)
+- [desktop-save-error](desktop-save-error.png)
+- [desktop-saving](desktop-saving.png)
+- [desktop-sync-on](desktop-sync-on.png)
+- [desktop-waiting-for-upload](desktop-waiting-for-upload.png)
+
+## Updated setup flow, September 25
+
+Recaptured after automatic desktop config setup and chat-message fallbacks. 28 images. Native writes and client authentication are fixture outcomes in these component screenshots; no live customer settings were changed. Native filesystem and OAuth end-to-end verification remain pending.
+
+- `components/cloud-ai-connection-card.tsx` SHA256 `1260d1c2260eff809e610c4405bc09428d4a57a852f7e5a34140a3c47bfbd03b`
+
+- `components/cloud-ai-client-setup.tsx` SHA256 `4f4ec8de4c79d755a2fb8a32a04980828c47a16a3e174143a6a873668dd9a913`
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-after-off.png b/.github/pr-assets/cloud-ai-connect/desktop-after-off.png
new file mode 100644
index 000000000..e3bcb0347
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-after-off.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-before-off.png b/.github/pr-assets/cloud-ai-connect/desktop-before-off.png
new file mode 100644
index 000000000..42ee6716e
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-before-off.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-before-on.png b/.github/pr-assets/cloud-ai-connect/desktop-before-on.png
new file mode 100644
index 000000000..6e48eff6f
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-before-on.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-claude-code-added.png b/.github/pr-assets/cloud-ai-connect/desktop-claude-code-added.png
new file mode 100644
index 000000000..440fd194f
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-claude-code-added.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-claude-copied.png b/.github/pr-assets/cloud-ai-connect/desktop-claude-copied.png
new file mode 100644
index 000000000..d2ae5a1bd
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-claude-copied.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-claude-setup.png b/.github/pr-assets/cloud-ai-connect/desktop-claude-setup.png
new file mode 100644
index 000000000..8c6e52dee
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-claude-setup.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-codex-copied.png b/.github/pr-assets/cloud-ai-connect/desktop-codex-copied.png
new file mode 100644
index 000000000..6d453011e
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-codex-copied.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-codex-setup.png b/.github/pr-assets/cloud-ai-connect/desktop-codex-setup.png
new file mode 100644
index 000000000..ea432ef3f
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-codex-setup.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-compact-before.png b/.github/pr-assets/cloud-ai-connect/desktop-compact-before.png
new file mode 100644
index 000000000..e524b067a
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-compact-before.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-compact-claude.png b/.github/pr-assets/cloud-ai-connect/desktop-compact-claude.png
new file mode 100644
index 000000000..6ad17b669
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-compact-claude.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-compact-consent.png b/.github/pr-assets/cloud-ai-connect/desktop-compact-consent.png
new file mode 100644
index 000000000..e854d6c1c
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-compact-consent.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-compact.png b/.github/pr-assets/cloud-ai-connect/desktop-compact.png
new file mode 100644
index 000000000..87000ce64
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-compact.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-config-error.png b/.github/pr-assets/cloud-ai-connect/desktop-config-error.png
new file mode 100644
index 000000000..c88a78840
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-config-error.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-configuring.png b/.github/pr-assets/cloud-ai-connect/desktop-configuring.png
new file mode 100644
index 000000000..0e6dfef08
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-configuring.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-consent.png b/.github/pr-assets/cloud-ai-connect/desktop-consent.png
new file mode 100644
index 000000000..0df254774
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-consent.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-dark-setup.png b/.github/pr-assets/cloud-ai-connect/desktop-dark-setup.png
new file mode 100644
index 000000000..df381d3b1
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-dark-setup.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-dark.png b/.github/pr-assets/cloud-ai-connect/desktop-dark.png
new file mode 100644
index 000000000..5b33ae958
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-dark.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-devices-error.png b/.github/pr-assets/cloud-ai-connect/desktop-devices-error.png
new file mode 100644
index 000000000..829c0eee4
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-devices-error.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-devices-loading.png b/.github/pr-assets/cloud-ai-connect/desktop-devices-loading.png
new file mode 100644
index 000000000..ed6058a4f
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-devices-loading.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-error.png b/.github/pr-assets/cloud-ai-connect/desktop-error.png
new file mode 100644
index 000000000..188dceacf
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-error.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-keyboard-focus.png b/.github/pr-assets/cloud-ai-connect/desktop-keyboard-focus.png
new file mode 100644
index 000000000..7aba815e2
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-keyboard-focus.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-manage.png b/.github/pr-assets/cloud-ai-connect/desktop-manage.png
new file mode 100644
index 000000000..6f00bd0d4
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-manage.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-missing.png b/.github/pr-assets/cloud-ai-connect/desktop-missing.png
new file mode 100644
index 000000000..45ca0fb22
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-missing.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-open-error.png b/.github/pr-assets/cloud-ai-connect/desktop-open-error.png
new file mode 100644
index 000000000..bc0826d76
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-open-error.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-save-error.png b/.github/pr-assets/cloud-ai-connect/desktop-save-error.png
new file mode 100644
index 000000000..bf21299d8
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-save-error.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-saving.png b/.github/pr-assets/cloud-ai-connect/desktop-saving.png
new file mode 100644
index 000000000..84ed2e879
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-saving.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-sync-on.png b/.github/pr-assets/cloud-ai-connect/desktop-sync-on.png
new file mode 100644
index 000000000..62f9e1349
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-sync-on.png differ
diff --git a/.github/pr-assets/cloud-ai-connect/desktop-waiting-for-upload.png b/.github/pr-assets/cloud-ai-connect/desktop-waiting-for-upload.png
new file mode 100644
index 000000000..eb6a8fab2
Binary files /dev/null and b/.github/pr-assets/cloud-ai-connect/desktop-waiting-for-upload.png differ
diff --git a/apps/screenpipe-app-tauri/bun.lock b/apps/screenpipe-app-tauri/bun.lock
index 16cdb6a16..408fe4b43 100644
--- a/apps/screenpipe-app-tauri/bun.lock
+++ b/apps/screenpipe-app-tauri/bun.lock
@@ -73,6 +73,7 @@
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"remark-parse": "^11.0.0",
+ "smol-toml": "1.8.0",
"tailwind-merge": "^2.6.1",
"tailwindcss-animate": "^1.0.7",
"tauri-plugin-sentry-api": "^0.5.0",
diff --git a/apps/screenpipe-app-tauri/components/cloud-ai-client-setup.tsx b/apps/screenpipe-app-tauri/components/cloud-ai-client-setup.tsx
new file mode 100644
index 000000000..1db05f24f
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/cloud-ai-client-setup.tsx
@@ -0,0 +1,214 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+"use client";
+
+import { screenpipeWebUrl, PROD_WEB_BASE } from "@/lib/web-url";
+import { Button } from "@/components/ui/button";
+
+export type CloudClient = "codex" | "claude-code";
+export const CLOUD_MCP_URL = screenpipeWebUrl("/api/user/data-sync/mcp", PROD_WEB_BASE);
+export const CLAUDE_CONNECTORS_URL = "https://claude.ai/customize/connectors";
+export const CODEX_CLOUD_SETUP = `codex mcp add screenpipe-cloud --url ${CLOUD_MCP_URL} && codex mcp login screenpipe-cloud --scopes data-sync:read`;
+export const CODEX_SETUP_PROMPT = `Connect my local Codex app to Screenpipe Cloud at ${CLOUD_MCP_URL} using a separate MCP server named screenpipe-cloud. Preserve my existing servers and settings. Check for an existing connection first. If the Codex CLI is available, add the HTTP server and start OAuth login with the data-sync:read scope. If no CLI is installed, safely add [mcp_servers.screenpipe-cloud] with url = "${CLOUD_MCP_URL}" to my active Codex config (respect CODEX_HOME; otherwise ~/.codex/config.toml). Do not overwrite a conflicting entry or install software. Ask me to authenticate in Settings > MCP servers and reload if required. Never ask me to paste tokens into chat. Verify by listing my synced devices before saying it is connected. If you cannot access my local config, tell me to add this URL in my app's MCP settings.`;
+export const CLAUDE_CODE_SETUP_PROMPT = `Connect Claude Code to Screenpipe Cloud at ${CLOUD_MCP_URL} with a user-scoped HTTP MCP server named screenpipe-cloud. Preserve existing connections and check whether it is already configured. If needed, run: claude mcp add --transport http --scope user screenpipe-cloud ${CLOUD_MCP_URL}. Ask me to open /mcp and authenticate. Do not install software or ask for tokens in chat. Verify by listing my synced devices before saying it is connected. If this is ordinary Claude chat rather than Claude Code, direct me to ${CLAUDE_CONNECTORS_URL} to add this URL and connect instead.`;
+
+type Props = {
+ client: "Codex" | "Claude";
+ native: boolean;
+ configuring: CloudClient | null;
+ configured: Partial<Record<CloudClient, boolean>>;
+ copied: string | null;
+ onConfigure: (client: CloudClient) => void;
+ onCopy: (text: string, kind: string) => void;
+ onOpenClaude: () => void;
+};
+
+export function CloudAiClientSetup({
+ client,
+ native,
+ configuring,
+ configured,
+ copied,
+ onConfigure,
+ onCopy,
+ onOpenClaude,
+}: Props) {
+ const target = client === "Codex" ? "codex" : "claude-code";
+ const prompt =
+ client === "Codex" ? CODEX_SETUP_PROMPT : CLAUDE_CODE_SETUP_PROMPT;
+ const promptControl = (
+ <div className="space-y-3">
+ <p className="text-sm text-muted-foreground">
+ Paste this into a local {client === "Codex" ? "Codex" : "Claude Code"}{" "}
+ chat. Your AI can handle setup, then ask you to sign in.
+ </p>
+ <Button
+ type="button"
+ className="w-full"
+ onClick={() => onCopy(prompt, "setup-message")}
+ >
+ {copied === "setup-message"
+ ? "Setup message copied"
+ : "Copy setup message"}
+ </Button>
+ {copied === "setup-message" && (
+ <p role="status" className="text-sm">
+ Now paste into {client === "Codex" ? "Codex" : "Claude Code"} and
+ send.
+ </p>
+ )}
+ <details className="text-xs text-muted-foreground">
+ <summary className="cursor-pointer">View setup message</summary>
+ <textarea
+ aria-label={`${client} setup message`}
+ readOnly
+ value={prompt}
+ rows={7}
+ className="mt-2 w-full rounded-md border bg-muted p-3 text-xs"
+ onFocus={(event) => event.target.select()}
+ />
+ </details>
+ </div>
+ );
+ const nativeControl = (
+ <div className="space-y-3">
+ {configured[target] ? (
+ <div role="status" className="space-y-2">
+ <p className="text-sm font-medium">
+ Added to {client === "Codex" ? "Codex" : "Claude Code"}
+ </p>
+ <p className="text-sm text-muted-foreground">
+ {client === "Codex"
+ ? "In Codex, open Settings → MCP servers, reload if needed, and authenticate screenpipe-cloud."
+ : "In Claude Code, open /mcp and authenticate screenpipe-cloud. Restart the session if it is not listed."}
+ </p>
+ </div>
+ ) : (
+ <>
+ <p className="text-sm text-muted-foreground">
+ {client === "Codex"
+ ? "Screenpipe adds the connection for you. No terminal or separate CLI install."
+ : "Screenpipe adds the connection to Claude Code on this computer."}
+ </p>
+ <Button
+ type="button"
+ className="w-full"
+ disabled={!!configuring}
+ onClick={() => onConfigure(target)}
+ >
+ {configuring === target
+ ? "Adding connection…"
+ : `Add to ${client === "Codex" ? "Codex" : "Claude Code"}`}
+ </Button>
+ </>
+ )}
+ <details className="text-sm">
+ <summary className="cursor-pointer">
+ Set up through chat instead
+ </summary>
+ <div className="pt-3">{promptControl}</div>
+ </details>
+ </div>
+ );
+ if (client === "Codex")
+ return (
+ <div className="space-y-4">
+ {native ? nativeControl : promptControl}
+ <details className="text-sm">
+ <summary className="cursor-pointer">Other ways to connect</summary>
+ <div className="space-y-3 pt-3">
+ <p className="text-sm text-muted-foreground">
+ No CLI? In the Codex app, open Settings → MCP servers → Add
+ server. Choose Streamable HTTP, name it screenpipe-cloud, paste
+ this URL, and authenticate.
+ </p>
+ <input
+ aria-label="Cloud MCP URL"
+ readOnly
+ value={CLOUD_MCP_URL}
+ className="w-full rounded-md border bg-muted p-3 font-mono text-xs"
+ onFocus={(event) => event.target.select()}
+ />
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onCopy(CLOUD_MCP_URL, "url")}
+ >
+ {copied === "url" ? "URL copied" : "Copy connection URL"}
+ </Button>
+ <p className="text-xs text-muted-foreground">
+ Already use the CLI?
+ </p>
+ <textarea
+ aria-label="Codex setup command"
+ readOnly
+ rows={4}
+ value={CODEX_CLOUD_SETUP}
+ className="w-full resize-none rounded-md border bg-muted p-3 font-mono text-xs"
+ onFocus={(event) => event.target.select()}
+ />
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onCopy(CODEX_CLOUD_SETUP, "setup")}
+ >
+ {copied === "setup"
+ ? "Setup command copied"
+ : "Copy setup command"}
+ </Button>
+ </div>
+ </details>
+ </div>
+ );
+ return (
+ <div className="space-y-4">
+ <p className="text-sm text-muted-foreground">
+ Add a custom connector in Claude, paste the URL, then connect your
+ Screenpipe account. Works with Claude web and desktop.
+ </p>
+ <Button type="button" className="w-full" onClick={onOpenClaude}>
+ {copied === "claude-url"
+ ? "URL copied · Open Claude again"
+ : "Copy URL and open Claude"}
+ </Button>
+ <p className="text-xs text-muted-foreground">
+ A chat message cannot add a connector to your Claude account. On a team
+ account, an owner may need to add it first.
+ </p>
+ <details className="text-sm">
+ <summary className="cursor-pointer">Connection URL and help</summary>
+ <div className="space-y-3 pt-3">
+ <input
+ aria-label="Cloud MCP URL"
+ readOnly
+ value={CLOUD_MCP_URL}
+ className="w-full rounded-md border bg-muted p-3 font-mono text-xs"
+ onFocus={(event) => event.target.select()}
+ />
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onCopy(CLOUD_MCP_URL, "url")}
+ >
+ {copied === "url" ? "URL copied" : "Copy connection URL"}
+ </Button>
+ <a
+ href={CLAUDE_CONNECTORS_URL}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="block text-xs underline"
+ >
+ Open Claude connectors
+ </a>
+ </div>
+ </details>
+ <details className="text-sm">
+ <summary className="cursor-pointer">Using Claude Code?</summary>
+ <div className="pt-3">{native ? nativeControl : promptControl}</div>
+ </details>
+ </div>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.test.tsx b/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.test.tsx
new file mode 100644
index 000000000..b35a3d64d
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.test.tsx
@@ -0,0 +1,212 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+import React, { useState } from "react";
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+import {
+ CloudAiConnectionCard,
+ CLOUD_MCP_URL,
+ CODEX_SETUP_PROMPT,
+} from "./cloud-ai-connection-card";
+
+afterEach(cleanup);
+
+describe("cloud AI setup", () => {
+ it("requires explicit upload consent and keeps a rejected save retryable", async () => {
+ const enable = vi
+ .fn()
+ .mockResolvedValueOnce(false)
+ .mockResolvedValueOnce(true);
+ function Harness() {
+ const [enabled, setEnabled] = useState(false);
+ return (
+ <CloudAiConnectionCard
+ enabled={enabled}
+ onEnable={async () => {
+ const ok = await enable();
+ if (ok) setEnabled(true);
+ return ok;
+ }}
+ />
+ );
+ }
+ render(<Harness />);
+ fireEvent.click(screen.getByRole("button", { name: "Connect Codex" }));
+ expect(enable).not.toHaveBeenCalled();
+ expect(screen.queryByLabelText("Codex setup command")).toBeNull();
+ fireEvent.click(
+ screen.getByRole("button", { name: "Enable cloud sync and continue" }),
+ );
+ expect(await screen.findByRole("alert")).toHaveTextContent(
+ "could not be enabled",
+ );
+ expect(screen.queryByLabelText("Codex setup command")).toBeNull();
+ fireEvent.click(
+ screen.getByRole("button", { name: "Enable cloud sync and continue" }),
+ );
+ fireEvent.click(await screen.findByText("View setup message"));
+ expect(screen.getByLabelText("Codex setup message")).toHaveValue(
+ CODEX_SETUP_PROMPT,
+ );
+ expect(enable).toHaveBeenCalledTimes(2);
+ expect(screen.queryByText("Connected", { exact: true })).toBeNull();
+ });
+
+ it("blocks repeat enables while the save is pending", async () => {
+ let finish!: (ok: boolean) => void;
+ const enable = vi.fn(
+ () =>
+ new Promise<boolean>((resolve) => {
+ finish = resolve;
+ }),
+ );
+ render(<CloudAiConnectionCard enabled={false} onEnable={enable} />);
+ fireEvent.click(screen.getByRole("button", { name: "Connect Claude" }));
+ fireEvent.click(
+ screen.getByRole("button", { name: "Enable cloud sync and continue" }),
+ );
+ expect(
+ screen.getByRole("button", { name: "Enabling cloud sync…" }),
+ ).toBeDisabled();
+ fireEvent.click(
+ screen.getByRole("button", { name: "Enabling cloud sync…" }),
+ );
+ expect(enable).toHaveBeenCalledTimes(1);
+ finish(false);
+ await screen.findByRole("alert");
+ });
+
+ it("keeps the URL selectable after clipboard failure and retries copying", async () => {
+ const copy = vi
+ .fn()
+ .mockRejectedValueOnce(new Error("permission denied"))
+ .mockResolvedValue(undefined);
+ Object.defineProperty(navigator, "clipboard", {
+ configurable: true,
+ value: { writeText: copy },
+ });
+ render(<CloudAiConnectionCard enabled onEnable={vi.fn()} />);
+ fireEvent.click(screen.getByRole("button", { name: "Connect Claude" }));
+ fireEvent.click(screen.getByText("Connection URL and help"));
+ fireEvent.click(
+ screen.getByRole("button", { name: "Copy connection URL" }),
+ );
+ expect(await screen.findByRole("alert")).toHaveTextContent(
+ "copy it manually",
+ );
+ expect(screen.getByLabelText("Cloud MCP URL")).toHaveValue(CLOUD_MCP_URL);
+ fireEvent.click(
+ screen.getByRole("button", { name: "Copy connection URL" }),
+ );
+ await screen.findByRole("button", { name: "URL copied" });
+ expect(screen.queryByRole("alert")).toBeNull();
+ expect(copy).toHaveBeenLastCalledWith(CLOUD_MCP_URL);
+ });
+
+ it("reports native browser-open failure without reporting a connected client", async () => {
+ const open = vi.fn().mockRejectedValue(new Error("blocked"));
+ render(
+ <CloudAiConnectionCard
+ enabled
+ onEnable={vi.fn()}
+ onOpenExternal={open}
+ />,
+ );
+ fireEvent.click(screen.getByRole("button", { name: "Connect Claude" }));
+ fireEvent.click(
+ screen.getByRole("button", { name: "Copy URL and open Claude" }),
+ );
+ expect(await screen.findByRole("alert")).toHaveTextContent(
+ "Could not open Claude",
+ );
+ expect(open).toHaveBeenCalledWith("https://claude.ai/customize/connectors");
+ expect(screen.queryByText("Connected", { exact: true })).toBeNull();
+ });
+
+ it("returns keyboard focus to the selected client after setup closes", async () => {
+ render(<CloudAiConnectionCard enabled onEnable={vi.fn()} />);
+ const trigger = screen.getByRole("button", { name: "Connect Codex" });
+ fireEvent.click(trigger);
+ fireEvent.keyDown(screen.getByRole("dialog"), {
+ key: "Escape",
+ code: "Escape",
+ });
+ await waitFor(() => expect(trigger).toHaveFocus());
+ });
+ it("configures Codex on the Connect click, without a CLI, and reports added rather than authenticated", async () => {
+ const configure = vi.fn().mockResolvedValue(undefined);
+ render(
+ <CloudAiConnectionCard
+ enabled
+ onEnable={vi.fn()}
+ onConfigureClient={configure}
+ />,
+ );
+ expect(configure).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole("button", { name: "Connect Codex" }));
+ await screen.findByText("Added to Codex");
+ expect(configure).toHaveBeenCalledTimes(1);
+ expect(configure).toHaveBeenCalledWith("codex");
+ expect(screen.queryByText("Connected", { exact: true })).toBeNull();
+ });
+
+ it("does not configure before consent, and makes missing-app setup retryable", async () => {
+ const configure = vi
+ .fn()
+ .mockRejectedValueOnce(new Error("Open Codex once, then retry."))
+ .mockResolvedValue(undefined);
+ function Harness() {
+ const [enabled, setEnabled] = useState(false);
+ return (
+ <CloudAiConnectionCard
+ enabled={enabled}
+ onEnable={async () => {
+ setEnabled(true);
+ return true;
+ }}
+ onConfigureClient={configure}
+ />
+ );
+ }
+ render(<Harness />);
+ fireEvent.click(screen.getByRole("button", { name: "Connect Codex" }));
+ expect(configure).not.toHaveBeenCalled();
+ fireEvent.click(
+ screen.getByRole("button", { name: "Enable cloud sync and continue" }),
+ );
+ expect(await screen.findByRole("alert")).toHaveTextContent(
+ "Open Codex once",
+ );
+ fireEvent.click(screen.getByText("Set up through chat instead"));
+ expect(
+ screen.getByRole("button", { name: "Copy setup message" }),
+ ).toBeVisible();
+ fireEvent.click(screen.getByRole("button", { name: "Add to Codex" }));
+ await screen.findByText("Added to Codex");
+ expect(configure).toHaveBeenCalledTimes(2);
+ });
+
+ it("keeps Claude account setup separate from an explicit Claude Code install", async () => {
+ const configure = vi.fn().mockResolvedValue(undefined);
+ render(
+ <CloudAiConnectionCard
+ enabled
+ onEnable={vi.fn()}
+ onConfigureClient={configure}
+ />,
+ );
+ fireEvent.click(screen.getByRole("button", { name: "Connect Claude" }));
+ expect(configure).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByText("Using Claude Code?"));
+ fireEvent.click(screen.getByRole("button", { name: "Add to Claude Code" }));
+ await screen.findByText("Added to Claude Code");
+ expect(configure).toHaveBeenCalledTimes(1);
+ expect(configure).toHaveBeenCalledWith("claude-code");
+ });
+});
diff --git a/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.tsx b/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.tsx
new file mode 100644
index 000000000..0815f4575
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/cloud-ai-connection-card.tsx
@@ -0,0 +1,331 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+"use client";
+
+import { useState, useRef, type ReactNode } from "react";
+import { ArrowUpRight, Loader2 } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+
+import {
+ CloudAiClientSetup,
+ CLOUD_MCP_URL,
+ CLAUDE_CONNECTORS_URL,
+ type CloudClient,
+} from "./cloud-ai-client-setup";
+export {
+ CLOUD_MCP_URL,
+ CODEX_CLOUD_SETUP,
+ CODEX_SETUP_PROMPT,
+} from "./cloud-ai-client-setup";
+export const CLOUD_EXAMPLE =
+ "Use Screenpipe to find the decisions and next steps from my meetings today.";
+
+type Props = {
+ enabled: boolean;
+ loading?: boolean;
+ busy?: boolean;
+ error?: string | null;
+ onEnable: () => Promise<boolean>;
+ onRetry?: () => void;
+ onOpenExternal?: (url: string) => Promise<void>;
+ onConfigureClient?: (client: CloudClient) => Promise<void>;
+ device?: boolean;
+ children?: ReactNode;
+};
+
+/** Cloud consent and client handoff are separate; neither proves client authentication. */
+export function CloudAiConnectionCard({
+ enabled,
+ loading,
+ busy,
+ error,
+ onEnable,
+ onRetry,
+ onOpenExternal,
+ device,
+ onConfigureClient,
+ children,
+}: Props) {
+ const triggerRef = useRef<HTMLButtonElement | null>(null);
+ const [client, setClient] = useState<"Codex" | "Claude" | null>(null);
+ const [enabling, setEnabling] = useState(false);
+ const [copied, setCopied] = useState<string | null>(null);
+ const [actionError, setActionError] = useState<string | null>(null);
+ const [configuring, setConfiguring] = useState<CloudClient | null>(null);
+ const [configured, setConfigured] = useState<
+ Partial<Record<CloudClient, boolean>>
+ >({});
+ const configLock = useRef(false);
+ const pending = busy || enabling || !!configuring;
+
+ async function configure(target: CloudClient) {
+ if (!onConfigureClient || configLock.current) return;
+ configLock.current = true;
+ setConfiguring(target);
+ setActionError(null);
+ try {
+ await onConfigureClient(target);
+ setConfigured((previous) => ({ ...previous, [target]: true }));
+ } catch (error) {
+ setActionError(
+ error instanceof Error
+ ? error.message
+ : "Could not add the connection. Retry or use the setup message.",
+ );
+ } finally {
+ configLock.current = false;
+ setConfiguring(null);
+ }
+ }
+
+ function openClaude() {
+ setActionError(null);
+ // Open synchronously from the click so browser popup blockers do not treat
+ // the clipboard await as a lost user gesture. No account state is inferred.
+ const opened = onOpenExternal
+ ? onOpenExternal(CLAUDE_CONNECTORS_URL)
+ : Promise.resolve(
+ window.open(CLAUDE_CONNECTORS_URL, "_blank", "noopener,noreferrer"),
+ );
+ void opened.catch(() =>
+ setActionError(
+ "Could not open Claude. Use the link under Connection URL and help.",
+ ),
+ );
+ void copy(CLOUD_MCP_URL, "claude-url");
+ }
+
+ async function copy(value: string, kind: string) {
+ setActionError(null);
+ setCopied(null);
+ try {
+ await navigator.clipboard.writeText(value);
+ setCopied(kind);
+ } catch {
+ setActionError(
+ "Could not copy. Expand the setup message or connection URL below and copy it manually.",
+ );
+ }
+ }
+
+ async function enable() {
+ if (pending) return;
+ setEnabling(true);
+ setActionError(null);
+ try {
+ if (!(await onEnable()))
+ setActionError("Cloud sync could not be enabled. Try again.");
+ else if (client === "Codex" && onConfigureClient)
+ await configure("codex");
+ } catch {
+ setActionError("Cloud sync could not be enabled. Try again.");
+ } finally {
+ setEnabling(false);
+ }
+ }
+
+ function selectClient(next: "Codex" | "Claude") {
+ setClient(next);
+ setCopied(null);
+ setActionError(null);
+ if (next === "Codex" && enabled && onConfigureClient)
+ void configure("codex");
+ }
+
+ return (
+ <section
+ className="space-y-5 rounded-lg border bg-card p-5 text-card-foreground"
+ aria-label="AI connections"
+ data-testid="cloud-ai-connections"
+ >
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <p className="text-sm font-medium">AI connections</p>
+ <p
+ className="flex items-center gap-2 text-xs text-muted-foreground"
+ role="status"
+ >
+ {loading || pending ? (
+ <Loader2 className="h-3.5 w-3.5 animate-spin motion-reduce:animate-none" />
+ ) : (
+ <span
+ className={`h-1.5 w-1.5 rounded-full ${enabled ? "bg-foreground" : "bg-muted-foreground"}`}
+ />
+ )}
+ {loading
+ ? "Checking cloud sync…"
+ : pending
+ ? configuring
+ ? "Adding connection…"
+ : "Saving…"
+ : error
+ ? "Sync needs attention"
+ : enabled
+ ? "Cloud sync on"
+ : "Cloud sync off"}
+ </p>
+ </div>
+ <div className="space-y-2">
+ <h2 className="text-xl font-semibold tracking-tight">
+ Give your AI context from your day
+ </h2>
+ <p className="max-w-xl text-sm text-muted-foreground">
+ Let Codex and Claude find what you saw, recall meeting decisions, and
+ pick up where you left off.
+ </p>
+ </div>
+ <div className="flex flex-wrap gap-2">
+ <Button
+ type="button"
+ onClick={(event) => {
+ triggerRef.current = event.currentTarget;
+ selectClient("Codex");
+ }}
+ disabled={loading || pending || !!error}
+ >
+ Connect Codex <ArrowUpRight className="ml-2 h-4 w-4" />
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={(event) => {
+ triggerRef.current = event.currentTarget;
+ selectClient("Claude");
+ }}
+ disabled={loading || pending || !!error}
+ >
+ Connect Claude <ArrowUpRight className="ml-2 h-4 w-4" />
+ </Button>
+ </div>
+ <p className="border-l-2 border-border pl-3 text-sm text-muted-foreground">
+ Try asking:{" "}
+ <span className="text-foreground">
+ “What did we decide in today’s meetings?”
+ </span>
+ </p>
+ <p className="text-xs text-muted-foreground">
+ Cloud sync uploads your Screenpipe history. Connected AI clients get
+ read-only access. You control syncing.
+ </p>
+ {error && (
+ <div role="alert" className="space-y-2 text-sm text-destructive">
+ <p>{error}</p>
+ {onRetry && (
+ <Button type="button" variant="outline" size="sm" onClick={onRetry}>
+ Try again
+ </Button>
+ )}
+ </div>
+ )}
+ {children && (
+ <details className="border-t pt-3">
+ <summary className="cursor-pointer text-sm font-medium focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-4">
+ Manage synced data
+ </summary>
+ <div className="space-y-4 pt-4">{children}</div>
+ </details>
+ )}
+
+ <Dialog
+ open={!!client}
+ onOpenChange={(open) => {
+ if (!open && !pending) {
+ setClient(null);
+ setActionError(null);
+ }
+ }}
+ >
+ <DialogContent
+ onCloseAutoFocus={(event) => {
+ event.preventDefault();
+ triggerRef.current?.focus();
+ }}
+ className="max-h-[90vh] overflow-y-auto outline-none sm:max-w-lg"
+ >
+ <DialogHeader className="pr-6 text-left">
+ <DialogTitle>
+ {enabled
+ ? `Connect ${client}`
+ : `Enable cloud sync for ${client}?`}
+ </DialogTitle>
+ <DialogDescription>
+ {enabled
+ ? "Finish setup in your AI app, then try your first question."
+ : device
+ ? "Upload this device’s Screenpipe history so your AI can search it. You can turn syncing off here anytime."
+ : "Allow your Screenpipe devices to upload history so your AI can search it. Each device also needs syncing enabled in the desktop app."}
+ </DialogDescription>
+ </DialogHeader>
+ {!enabled ? (
+ <div className="space-y-4">
+ <p className="text-sm text-muted-foreground">
+ Only this account’s synced history is available. Your AI cannot
+ change or delete it.
+ </p>
+ <Button
+ type="button"
+ className="w-full"
+ onClick={() => void enable()}
+ disabled={pending}
+ >
+ {pending && (
+ <Loader2 className="mr-2 h-4 w-4 animate-spin motion-reduce:animate-none" />
+ )}
+ {pending
+ ? "Enabling cloud sync…"
+ : "Enable cloud sync and continue"}
+ </Button>
+ </div>
+ ) : (
+ <div className="space-y-5">
+ <CloudAiClientSetup
+ client={client ?? "Codex"}
+ native={!!onConfigureClient}
+ configuring={configuring}
+ configured={configured}
+ copied={copied}
+ onConfigure={(target) => void configure(target)}
+ onCopy={(value, kind) => void copy(value, kind)}
+ onOpenClaude={openClaude}
+ />
+ <div className="space-y-2 border-t pt-4">
+ <p className="text-sm font-medium">Then try it in {client}</p>
+ <p className="text-sm text-muted-foreground">{CLOUD_EXAMPLE}</p>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => void copy(CLOUD_EXAMPLE, "prompt")}
+ >
+ {copied === "prompt"
+ ? "Question copied"
+ : "Copy first question"}
+ </Button>
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Setup is complete when your AI can list your synced devices.
+ Opening setup does not confirm a connection.
+ </p>
+ </div>
+ )}
+ {actionError && (
+ <p role="alert" className="text-sm text-destructive">
+ {actionError}
+ </p>
+ )}
+ {copied && (
+ <span role="status" className="sr-only">
+ {copied === "prompt" ? "Question copied" : "Setup copied"}
+ </span>
+ )}
+ </DialogContent>
+ </Dialog>
+ </section>
+ );
+}
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.tsx
new file mode 100644
index 000000000..f342ed1ba
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/settings/account-data-sync-card.tsx
@@ -0,0 +1,136 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+"use client";
+
+import { screenpipeWebUrl, PROD_WEB_BASE } from "@/lib/web-url";
+import { useState } from "react";
+import { CloudAiConnectionCard } from "@/components/cloud-ai-connection-card";
+import { Switch } from "@/components/ui/switch";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { Button } from "@/components/ui/button";
+
+type Props = {
+ enabled: boolean;
+ saving: boolean;
+ error: string | null;
+ onRetry: () => void;
+ onEnabledChange: (enabled: boolean) => Promise<boolean>;
+ deviceName: string;
+ onDeviceNameChange: (name: string) => void;
+ devices: { device_id: string; device_name: string; last_synced_at: string }[];
+ devicesLoading: boolean;
+ devicesError: boolean;
+ onRetryDevices: () => void;
+ locale: string;
+ onOpenExternal: (url: string) => Promise<void>;
+ onConfigureClient: (client: "codex" | "claude-code") => Promise<void>;
+};
+
+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="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.
+ </p>
+ </div>
+ <Switch
+ id="data-sync-toggle"
+ aria-label="Sync this device"
+ checked={props.enabled}
+ disabled={props.saving}
+ onCheckedChange={(value) => void props.onEnabledChange(value)}
+ />
+ </div>
+ {props.enabled && (
+ <div className="space-y-3 border-t pt-4">
+ <Label htmlFor="data-sync-device-name">Device name</Label>
+ <Input
+ id="data-sync-device-name"
+ maxLength={96}
+ value={props.deviceName}
+ onChange={(event) => props.onDeviceNameChange(event.target.value)}
+ />
+ <p className="text-xs text-muted-foreground">
+ Ask your AI about this device by name.
+ </p>
+ <div className="space-y-2">
+ <p className="text-sm font-medium">Synced devices</p>
+ {props.devicesLoading ? (
+ <p role="status" className="text-xs text-muted-foreground">
+ Checking synced devices…
+ </p>
+ ) : props.devicesError ? (
+ <div role="alert" className="space-y-2">
+ <p className="text-xs text-destructive">
+ Could not load synced devices.
+ </p>
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={props.onRetryDevices}
+ >
+ Retry devices
+ </Button>
+ </div>
+ ) : props.devices.length === 0 ? (
+ <p className="text-xs text-muted-foreground">
+ Waiting for the first upload. Keep Screenpipe running.
+ </p>
+ ) : (
+ props.devices.map((device) => (
+ <div
+ key={device.device_id}
+ className="flex flex-wrap justify-between gap-x-3 gap-y-1 text-xs"
+ >
+ <span className="break-words font-medium">
+ {device.device_name}
+ </span>
+ <span className="text-muted-foreground">
+ Last upload{" "}
+ {new Date(device.last_synced_at).toLocaleString(
+ props.locale,
+ )}
+ </span>
+ </div>
+ ))
+ )}
+ </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>
+ {openError && (
+ <p role="alert" className="text-xs text-destructive">
+ Could not open account settings. Open screenpipe.com/account in your
+ browser.
+ </p>
+ )}
+ </CloudAiConnectionCard>
+ </div>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/settings/account-section.tsx b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
index a8688c927..50c3b15d7 100644
--- a/apps/screenpipe-app-tauri/components/settings/account-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/account-section.tsx
@@ -13,13 +13,14 @@ 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("Data Sync", {}), keywords: ["allow data sync", "cloud", "account"] },
+ { label: msg("AI connections", {}), keywords: ["data sync", "allow data sync", "cloud", "account", "codex", "claude"] },
{ 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"] },
{ label: msg("Connection sync across devices", {}), keywords: ["connection sync", "sync", "slack", "notion"] },
{ label: msg("Restart remote sync", {}), keywords: ["reset sync", "older key", "new device", "decryption"] },
];
+import { AccountDataSyncCard } from "./account-data-sync-card";
import { Button } from "@/components/ui/button";
import { useSettings } from "@/lib/hooks/use-settings";
import {
@@ -150,6 +151,10 @@ export function AccountSection() {
const [showSyncKeyRecovery, setShowSyncKeyRecovery] = useState(false);
const [checkoutBusy, setCheckoutBusy] = useState(false);
const [dataSyncSaving, setDataSyncSaving] = useState(false);
+ const [dataSyncError, setDataSyncError] = useState<string | null>(null);
+ const [devicesLoading, setDevicesLoading] = useState(false);
+ const [devicesError, setDevicesError] = useState(false);
+ const [devicesRevision, setDevicesRevision] = useState(0);
const [syncedDevices, setSyncedDevices] = useState<SyncedDevice[]>([]);
const [upgradeSource, setUpgradeSource] = useState("app-account-section");
const upgradeCardRef = useRef<HTMLDivElement>(null);
@@ -171,7 +176,9 @@ export function AccountSection() {
!hasExpiringProfilePlan;
const setDataSyncEnabled = async (checked: boolean) => {
+ if (dataSyncSaving) return false;
setDataSyncSaving(true);
+ setDataSyncError(null);
try {
const token = await commands.getCloudToken();
if (!token) throw new Error("sign in again to change data sync");
@@ -230,12 +237,15 @@ export function AccountSection() {
dataSyncAccountId: checked ? accountId! : "",
...(checked ? { dataSyncEnabledAt: new Date().toISOString() } : {}),
});
+ return true;
} catch (error) {
+ setDataSyncError("Could not update syncing on this device. Try again.");
toast({
title: ui("Data sync was not changed"),
description: error instanceof Error ? error.message : String(error),
variant: "destructive",
});
+ return false;
} finally {
setDataSyncSaving(false);
}
@@ -270,22 +280,25 @@ export function AccountSection() {
}
let cancelled = false;
- void commands.getCloudToken().then(async (token) => {
- if (!token) return;
+ setDevicesLoading(true);
+ setDevicesError(false);
+ void (async () => {
+ const token = await commands.getCloudToken();
+ if (!token) throw new Error("not signed in");
const response = await tauriFetchWithDeadline(`${DATA_SYNC_URL}/devices`, {
headers: { Authorization: `Bearer ${token}` },
- }).catch(() => null);
- if (!response?.ok || cancelled) return;
- const body = await response.json().catch(() => null);
- if (!cancelled && Array.isArray(body?.devices)) {
- setSyncedDevices(body.devices);
- }
+ });
+ if (!response.ok) throw new Error("devices unavailable");
+ const body = await response.json();
+ if (!Array.isArray(body?.devices)) throw new Error("devices unavailable");
+ if (!cancelled) setSyncedDevices(body.devices);
+ })().catch(() => {
+ if (!cancelled) setDevicesError(true);
+ }).finally(() => {
+ if (!cancelled) setDevicesLoading(false);
});
-
- return () => {
- cancelled = true;
- };
- }, [settings.dataSyncEnabled]);
+ return () => { cancelled = true; };
+ }, [settings.dataSyncEnabled, devicesRevision]);
/** Capacity levels change an existing subscription, so they are proration on
* the web billing page rather than a new in-app checkout. */
const openCapacityBilling = async (
@@ -1092,66 +1105,25 @@ export function AccountSection() {
)}
{canUseDataSync(appUser) && (
- <Card className="p-4" data-testid="account-data-sync-setting">
- <div className="space-y-4">
- <div className="flex items-center justify-between gap-6">
- <div>
- <p className="text-sm font-medium">Data Sync</p>
- <p className="text-xs text-muted-foreground">
- Sync screenpipe data from this device to your account
- </p>
- </div>
- <Switch
- id="data-sync-toggle"
- aria-label={ui("Data Sync")}
- checked={settings.dataSyncEnabled ?? false}
- disabled={dataSyncSaving}
- onCheckedChange={(checked) => void setDataSyncEnabled(checked)}
- />
- </div>
-
- {settings.dataSyncEnabled && (
- <div className="space-y-2 border-t border-border/50 pt-4">
- <Label htmlFor="data-sync-device-name">Device name</Label>
- <Input
- id="data-sync-device-name"
- aria-label={ui("Device name")}
- maxLength={96}
- value={settings.dataSyncDeviceName ?? ""}
- onChange={(event) =>
- void updateSettings({
- dataSyncDeviceName: event.currentTarget.value,
- })
- }
- />
- <p className="text-xs text-muted-foreground">
- Synced data will be grouped under this name
- </p>
- <p className="text-xs text-muted-foreground">
- Ask Screenpipe: “What was I doing on {settings.dataSyncDeviceName || ui("this device")} this morning?”
- </p>
- <div className="space-y-1 pt-2">
- <p className="text-xs font-medium">Synced devices</p>
- {syncedDevices.length === 0 ? (
- <p className="text-xs text-muted-foreground">
- This device will appear after its first upload
- </p>
- ) : (
- syncedDevices.map((device) => (
- <p
- className="text-xs text-muted-foreground"
- key={device.device_id}
- >
- {device.device_name} · last synced{" "}
- {new Date(device.last_synced_at).toLocaleString(uiLocale)}
- </p>
- ))
- )}
- </div>
- </div>
- )}
- </div>
- </Card>
+ <AccountDataSyncCard
+ enabled={settings.dataSyncEnabled ?? false}
+ saving={dataSyncSaving}
+ error={dataSyncError}
+ onRetry={() => setDataSyncError(null)}
+ onEnabledChange={setDataSyncEnabled}
+ deviceName={settings.dataSyncDeviceName ?? ""}
+ onDeviceNameChange={(name) => void updateSettings({ dataSyncDeviceName: name })}
+ devices={syncedDevices}
+ devicesLoading={devicesLoading}
+ devicesError={devicesError}
+ onRetryDevices={() => setDevicesRevision((value) => value + 1)}
+ locale={uiLocale}
+ onOpenExternal={openExternalUrl}
+ onConfigureClient={async (client) => {
+ const { installCloudMcp } = await import("@/lib/ai-tools-mcp");
+ await installCloudMcp(client);
+ }}
+ />
)}
</div>
);
diff --git a/apps/screenpipe-app-tauri/lib/__tests__/ai-tools-mcp.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/ai-tools-mcp.test.ts
index 42f51054d..7a1d53cd7 100644
--- a/apps/screenpipe-app-tauri/lib/__tests__/ai-tools-mcp.test.ts
+++ b/apps/screenpipe-app-tauri/lib/__tests__/ai-tools-mcp.test.ts
@@ -23,6 +23,7 @@ const skillsMock = vi.hoisted(() => ({
}));
const tauriMock = vi.hoisted(() => ({
+ getEnv: vi.fn(async () => ""),
resolveAiToolConfigPath: vi.fn<[string], Promise<
{ status: "ok"; data: string } | { status: "error"; error: string }
>>(),
@@ -81,6 +82,7 @@ vi.mock("@tauri-apps/plugin-fs", () => ({
vi.mock("@/lib/utils/tauri", () => ({
commands: {
+ getEnv: tauriMock.getEnv,
resolveAiToolConfigPath: tauriMock.resolveAiToolConfigPath,
getLocalApiConfig: vi.fn(async () => ({ key: "sp-test", port: 3030, auth_enabled: true })),
bunCheck: vi.fn(async () => ({
@@ -106,6 +108,7 @@ import {
isVscodeMcpInstalled,
isToolConfigHealthy,
installCodexMcp,
+ installCloudMcp,
uninstallCodexMcp,
installCursorMcp,
uninstallCursorMcp,
@@ -138,6 +141,7 @@ const tmpsOf = (path: string) =>
beforeEach(() => {
pathMock.home = "/Users/test";
+ tauriMock.getEnv.mockReset().mockResolvedValue("");
tauriMock.resolveAiToolConfigPath.mockReset();
tauriMock.resolveAiToolConfigPath.mockImplementation(async (path) => ({ status: "ok", data: path }));
fsMock.files.clear();
@@ -556,3 +560,81 @@ describe("VS Code MCP", () => {
expect(JSON.parse(fsMock.files.get(path)!).servers).toEqual({ other: {} });
});
});
+
+
+describe("explicit cloud MCP setup without a CLI", () => {
+ const path = "/Users/test/.codex/config.toml";
+ const url = "https://screenpipe.com/api/user/data-sync/mcp";
+ it("preserves existing Codex text and local servers, backs up, and is idempotent", async () => {
+ fsMock.files.set("/Users/test/.codex", "");
+ const original =
+ '# personal settings\nmodel = "my-model"\n[mcp_servers.screenpipe]\ncommand = "local-server"\n';
+ fsMock.files.set(path, original);
+ await installCloudMcp("codex");
+ expect(fsMock.files.get(path)).toContain(original);
+ expect(fsMock.files.get(path)).toContain(
+ `[mcp_servers.screenpipe-cloud]\nurl = "${url}"`,
+ );
+ expect(backupsOf(path)).toHaveLength(1);
+ expect(fsMock.files.get(backupsOf(path)[0])).toBe(original);
+ const installed = fsMock.files.get(path);
+ await installCloudMcp("codex");
+ expect(fsMock.files.get(path)).toBe(installed);
+ expect(tmpsOf(path)).toHaveLength(0);
+ });
+ it.each([
+ "broken = [",
+ '[mcp_servers.screenpipe-cloud]\nurl = "https://other.test/mcp"',
+ '[mcp_servers.screenpipe-cloud]\nurl = "' + url + '"\nenabled = false',
+ 'mcp_servers = { local = { command = "keep" } }',
+ ])(
+ "refuses invalid, conflicting, disabled, or incompatible configs untouched: %s",
+ async (original) => {
+ fsMock.files.set("/Users/test/.codex", "");
+ fsMock.files.set(path, original);
+ await expect(installCloudMcp("codex")).rejects.toThrow("was not changed");
+ expect(fsMock.files.get(path)).toBe(original);
+ expect(backupsOf(path)).toHaveLength(0);
+ },
+ );
+ it("does not create an AI installation when no app config exists", async () => {
+ await expect(installCloudMcp("codex")).rejects.toThrow("Open Codex once");
+ await expect(installCloudMcp("claude-code")).rejects.toThrow(
+ "Open Claude Code once",
+ );
+ expect(fsMock.files.size).toBe(0);
+ });
+ it("preserves Claude Code user settings and local MCP entry", async () => {
+ fsMock.files.set(
+ CLAUDE_CODE,
+ JSON.stringify({
+ theme: "dark",
+ mcpServers: { screenpipe: { command: "local" } },
+ }),
+ );
+ await installCloudMcp("claude-code");
+ expect(JSON.parse(fsMock.files.get(CLAUDE_CODE)!)).toEqual({
+ theme: "dark",
+ mcpServers: {
+ screenpipe: { command: "local" },
+ "screenpipe-cloud": { type: "http", url },
+ },
+ });
+ const installed = fsMock.files.get(CLAUDE_CODE);
+ await installCloudMcp("claude-code");
+ expect(fsMock.files.get(CLAUDE_CODE)).toBe(installed);
+ });
+ it("preserves an unreadable config instead of replacing it", async () => {
+ fsMock.files.set("/Users/test/.codex", "");
+ fsMock.unreadable.add(path);
+ await expect(installCloudMcp("codex")).rejects.toThrow("could not read");
+ expect(fsMock.files.has(path)).toBe(false);
+ });
+ it("does not edit a default profile when the app uses a custom config home", async () => {
+ tauriMock.getEnv.mockResolvedValue("/custom/profile");
+ await expect(installCloudMcp("codex")).rejects.toThrow(
+ "custom config location",
+ );
+ expect(fsMock.files.size).toBe(0);
+ });
+});
diff --git a/apps/screenpipe-app-tauri/lib/ai-tools-mcp.ts b/apps/screenpipe-app-tauri/lib/ai-tools-mcp.ts
index a28f00890..2c452e73d 100644
--- a/apps/screenpipe-app-tauri/lib/ai-tools-mcp.ts
+++ b/apps/screenpipe-app-tauri/lib/ai-tools-mcp.ts
@@ -6,6 +6,7 @@
// launch reconciliation in crates/screenpipe-engine/src/cli/agent.rs; this
// module remains the explicit connect/remove surface in Settings.
+import { screenpipeWebUrl, PROD_WEB_BASE } from "@/lib/web-url";
import { homeDir, configDir, join, dirname } from "@tauri-apps/api/path";
import {
readTextFile,
@@ -32,6 +33,7 @@ import {
import { isGrokBotDetected, grokBotConnection } from "@/lib/grokbot-connection";
import { parse, modify, applyEdits, type ParseError } from "jsonc-parser";
+import { parse as parseToml } from "smol-toml";
type McpCommand = { command: string; args: string[]; env?: Record<string, string> };
@@ -260,7 +262,7 @@ async function writeConfigAtomic(configPath: string, text: string): Promise<void
await mkdir(dir, { recursive: true });
}
const tmpPath = `${configPath}.${Date.now()}.${Math.random().toString(36).slice(2, 10)}.tmp`;
- await writeFile(tmpPath, new TextEncoder().encode(text));
+ await writeFile(tmpPath, new TextEncoder().encode(text), { mode: 0o600 });
try {
await rename(tmpPath, configPath);
} catch (e) {
@@ -394,6 +396,111 @@ export async function installCodexMcp(): Promise<McpCommand> {
return config;
}
+/** Explicit cloud setup never needs a CLI and never replaces a local server. */
+export async function installCloudMcp(
+ target: "codex" | "claude-code",
+): Promise<void> {
+ const home = await homeDir();
+ const customHome = await commands.getEnv(
+ target === "codex" ? "CODEX_HOME" : "CLAUDE_CONFIG_DIR",
+ );
+ // A custom profile may be outside the app's filesystem scope. Let the
+ // user's own agent configure it rather than silently editing a default profile.
+ if (customHome)
+ throw new Error(
+ "Your AI uses a custom config location. Use the setup message in its chat instead.",
+ );
+ const detected =
+ target === "codex"
+ ? await exists(await join(home, ".codex"))
+ : await exists(await getClaudeCodeConfigPath());
+ if (!detected) {
+ throw new Error(
+ `Open ${target === "codex" ? "Codex" : "Claude Code"} once, then retry. You can also paste the setup message into its chat.`,
+ );
+ }
+ const configPath = await resolveConfigPath(
+ target === "codex"
+ ? await getCodexConfigPath()
+ : await getClaudeCodeConfigPath(),
+ );
+ const original = await readConfigText(configPath);
+ const existing = original ?? "";
+ const url = screenpipeWebUrl("/api/user/data-sync/mcp", PROD_WEB_BASE);
+ let next: string;
+ try {
+ if (target === "codex") {
+ const config = parseToml(existing);
+ const servers = config.mcp_servers as Record<string, unknown> | undefined;
+ const current = servers?.["screenpipe-cloud"] as
+ | Record<string, unknown>
+ | undefined;
+ if (current) {
+ if (
+ current.url === url &&
+ current.enabled !== false &&
+ !current.command &&
+ !current.bearer_token_env_var &&
+ !current.http_headers &&
+ !current.env_http_headers
+ )
+ return;
+ throw new Error(
+ "An existing screenpipe-cloud entry needs review in Codex settings.",
+ );
+ }
+ next = `${existing}${existing.endsWith("\n") || !existing ? "" : "\n"}\n[mcp_servers.screenpipe-cloud]\nurl = "${url}"\nenabled = true\n`;
+ // Refuse unsupported inline/dotted layouts rather than damage a valid config.
+ parseToml(next);
+ } else {
+ const config = JSON.parse(existing || "{}");
+ if (!config || typeof config !== "object" || Array.isArray(config))
+ throw new Error("Invalid Claude Code config.");
+ const servers = config.mcpServers;
+ if (
+ servers !== undefined &&
+ (!servers || typeof servers !== "object" || Array.isArray(servers))
+ )
+ throw new Error("Invalid MCP config.");
+ const current = servers?.["screenpipe-cloud"];
+ if (current) {
+ if (
+ current.url === url &&
+ current.type === "http" &&
+ !current.headers &&
+ !current.command
+ )
+ return;
+ throw new Error(
+ "An existing screenpipe-cloud entry needs review in Claude Code.",
+ );
+ }
+ next = applyEdits(
+ existing || "{}",
+ modify(
+ existing || "{}",
+ ["mcpServers", "screenpipe-cloud"],
+ { type: "http", url },
+ { formattingOptions: { insertSpaces: true, tabSize: 2 } },
+ ),
+ );
+ }
+ } catch (error) {
+ throw new Error(
+ `Could not add the connection. Your config was not changed. ${error instanceof Error ? error.message : "Check the config in your AI app."}`,
+ );
+ }
+ await backupConfigIfExists(configPath);
+ if ((await readConfigText(configPath)) !== original) {
+ throw new Error(
+ "Your AI config changed during setup. Retry to use the latest version.",
+ );
+ }
+ await writeConfigAtomic(configPath, next);
+ if ((await readTextFile(configPath)) !== next)
+ throw new Error("Could not verify the saved connection. Retry setup.");
+}
+
export async function uninstallClaudeMcp(): Promise<void> {
const configPath = await getClaudeConfigPath();
if (!configPath) return;
diff --git a/apps/screenpipe-app-tauri/package.json b/apps/screenpipe-app-tauri/package.json
index 744f26b83..341321bf0 100644
--- a/apps/screenpipe-app-tauri/package.json
+++ b/apps/screenpipe-app-tauri/package.json
@@ -86,6 +86,7 @@
"build:production": "bun scripts/build-production.ts"
},
"dependencies": {
+ "smol-toml": "1.8.0",
"@dnd-kit/core": "^6.3.1",
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",