Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

spaces desktop: record agents_page_open, teleport_app_picker, share_open and volume_open_finder (CUA-1914) (#5549)

Francesco Bonacci62ba67b2c552
diff --git a/apps/cua-spaces-desktop/src/bridge/volume.ts b/apps/cua-spaces-desktop/src/bridge/volume.ts
index 40958933b1..1d2a581bd0 100644
--- a/apps/cua-spaces-desktop/src/bridge/volume.ts
+++ b/apps/cua-spaces-desktop/src/bridge/volume.ts
@@ -80,6 +80,12 @@ export function volumeMethods(ctx: BridgeContext): Handlers {
const full = homePath(ctx, string(args, "path"));
if (!system) throw Failure.unsupported("Showing files is not available in this build");
system.reveal(full);
+ // The `volume_open_finder` usage event the SwiftUI and Tauri apps record; this host recorded none.
+ try {
+ ctx.model.recordFeature("volume_open_finder");
+ } catch {
+ // Telemetry never fails a reveal.
+ }
return null;
},
};
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/feature-recorded.test.tsx b/apps/cua-spaces-web/src/bridge/__tests__/feature-recorded.test.tsx
new file mode 100644
index 0000000000..32c97af839
--- /dev/null
+++ b/apps/cua-spaces-web/src/bridge/__tests__/feature-recorded.test.tsx
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: FSL-1.1-MIT
+// Copyright (c) 2026 Cua AI, Inc.
+
+import { renderHook, waitFor } from "@testing-library/react";
+import type { ReactNode } from "react";
+import { describe, expect, it, vi } from "vitest";
+import { BridgeContext, type BridgeContextValue } from "../BridgeProvider";
+import { useFeatureRecorded } from "../hooks";
+
+function wrapper(track: (batch: unknown[]) => void) {
+ const store = { telemetry: { track } };
+ const value = { mode: "electron", core: {}, adapter: null, store, ready: Promise.resolve(store) } as unknown as BridgeContextValue;
+ return ({ children }: { children?: ReactNode }) => <BridgeContext.Provider value={value}>{children}</BridgeContext.Provider>;
+}
+
+describe("useFeatureRecorded", () => {
+ it("records the feature once when it opens, not while `when` is false", async () => {
+ const track = vi.fn();
+ const { rerender } = renderHook(({ when }) => useFeatureRecorded("agents_page_open", when), {
+ wrapper: wrapper(track),
+ initialProps: { when: false },
+ });
+ await Promise.resolve();
+ expect(track).not.toHaveBeenCalled();
+ rerender({ when: true });
+ await waitFor(() => expect(track).toHaveBeenCalledTimes(1));
+ expect(track).toHaveBeenCalledWith([{ type: "feature", feature: "agents_page_open" }]);
+ rerender({ when: true });
+ expect(track).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/apps/cua-spaces-web/src/bridge/hooks.ts b/apps/cua-spaces-web/src/bridge/hooks.ts
index cf85e02c05..0ad51a05e2 100644
--- a/apps/cua-spaces-web/src/bridge/hooks.ts
+++ b/apps/cua-spaces-web/src/bridge/hooks.ts
@@ -81,6 +81,21 @@ function useAction(): <R>(f: (s: BridgeStore) => Promise<R> | R) => Promise<R> {
return (f) => ready.then(f);
}
+/**
+ * Records a Spaces app feature (a fixed name such as `agents_page_open`) once
+ * each time `when` turns true, as the SwiftUI and Tauri apps do when the page
+ * or sheet opens. The host and the machine's telemetry switch decide whether
+ * anything is sent.
+ */
+export function useFeatureRecorded(feature: string, when = true): void {
+ // Not an error without a provider: a screen drawn on its own records nothing.
+ const ready = useContext(BridgeContext)?.ready;
+ useEffect(() => {
+ if (!when || !ready) return;
+ void ready.then((s) => s.telemetry.track([{ type: "feature", feature }]));
+ }, [ready, feature, when]);
+}
+
/** The host, the app core and the raw adapter. */
export function useBridge(): { mode: BridgeMode; core: CoreClient; data: DataAdapter | null } {
const { mode, core, adapter } = useBridgeContext();
diff --git a/apps/cua-spaces-web/src/bridge/index.ts b/apps/cua-spaces-web/src/bridge/index.ts
index 7f2370331e..7259afbfea 100644
--- a/apps/cua-spaces-web/src/bridge/index.ts
+++ b/apps/cua-spaces-web/src/bridge/index.ts
@@ -12,6 +12,7 @@ export {
useAgentTimeline,
useAgents,
useBridge,
+ useFeatureRecorded,
useKeyvault,
useMachines,
useOnboarding,
diff --git a/apps/cua-spaces-web/src/components/share-sheet.tsx b/apps/cua-spaces-web/src/components/share-sheet.tsx
index 6bbfdb83a5..c0ca3f67b8 100644
--- a/apps/cua-spaces-web/src/components/share-sheet.tsx
+++ b/apps/cua-spaces-web/src/components/share-sheet.tsx
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: FSL-1.1-MIT
// Copyright (c) 2026 Cua AI, Inc.
-import { teamName, useShareSheet, useTeamChoices } from "@/bridge";
+import { teamName, useFeatureRecorded, useShareSheet, useTeamChoices } from "@/bridge";
import { Button } from "@/components/ui/button";
import { Dialog, DialogPopup, DialogTitle } from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
@@ -19,6 +19,7 @@ import { cn } from "@/lib/utils";
*/
export default function ShareSheet() {
const { session, sharing } = useShareSheet();
+ useFeatureRecorded("share_open", Boolean(session));
const choices = useTeamChoices(Boolean(session?.input.signedIn && session.input.shareable));
if (!session || !sharing) return null;
const v = session.view;
diff --git a/apps/cua-spaces-web/src/components/teleport/teleport-dialog.tsx b/apps/cua-spaces-web/src/components/teleport/teleport-dialog.tsx
index b3b8679514..360db0c5f3 100644
--- a/apps/cua-spaces-web/src/components/teleport/teleport-dialog.tsx
+++ b/apps/cua-spaces-web/src/components/teleport/teleport-dialog.tsx
@@ -6,7 +6,7 @@ import { RadioGroup } from "@base-ui/react/radio-group";
import { LoaderCircleIcon, SearchIcon } from "lucide-react";
import type { ReactNode } from "react";
-import { useTeleport, type PickerState, type TeleportMove, type TeleportSession, type TeleportStore } from "@/bridge";
+import { useFeatureRecorded, useTeleport, type PickerState, type TeleportMove, type TeleportSession, type TeleportStore } from "@/bridge";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Dialog, DialogPopup, DialogTitle } from "@/components/ui/dialog";
@@ -32,6 +32,7 @@ export const MOVE_LABEL: Record<TeleportMove, string> = {
*/
export default function TeleportDialog() {
const { session, images, teleport } = useTeleport();
+ useFeatureRecorded("teleport_app_picker", Boolean(session));
if (!session || !teleport) return null;
return (
<Dialog open onOpenChange={(open) => !open && teleport.close()}>
diff --git a/apps/cua-spaces-web/src/routes/agents/index.tsx b/apps/cua-spaces-web/src/routes/agents/index.tsx
index 19a018badf..a81d146125 100644
--- a/apps/cua-spaces-web/src/routes/agents/index.tsx
+++ b/apps/cua-spaces-web/src/routes/agents/index.tsx
@@ -10,6 +10,7 @@ import {
useAgentDetail,
useAgents,
useAgentTimeline,
+ useFeatureRecorded,
useSession,
type AgentRunSummary,
type AgentsData,
@@ -70,6 +71,7 @@ function AgentsPage() {
const search = Route.useSearch();
const navigate = useNavigate({ from: "/agents/" });
const { data, isLoading, error } = useAgents();
+ useFeatureRecorded("agents_page_open");
const [connectOpen, setConnectOpen] = useState(false);
const selected = resolveSelection(data, search);
const select = (next: AgentsSelection) => void navigate({ search: next, replace: true });