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.

Remove the "Link to a port" control from the Space page (#5856)

ddupont6ce373db3637
diff --git a/apps/cua-spaces-web/src/bridge/__tests__/links.test.tsx b/apps/cua-spaces-web/src/bridge/__tests__/links.test.tsx
index 62980eeb2d..d70c9bb360 100644
--- a/apps/cua-spaces-web/src/bridge/__tests__/links.test.tsx
+++ b/apps/cua-spaces-web/src/bridge/__tests__/links.test.tsx
@@ -10,7 +10,6 @@ import { NOT_ON_RELAY } from "../adapters/demo/links";
import { createWebkitAdapter } from "../adapters/webkit";
import { BridgeProvider, UnsupportedOperationError, linkEnds, needsRelaySetup, type DataAdapter } from "..";
import type { HostWindow } from "../detect";
-import { SpacePortLink } from "@/components/links/copy-link";
import { SharedLinks } from "@/components/links/shared-links";
import { noCore } from "./testCore";
@@ -58,30 +57,7 @@ describe("links.*", () => {
});
});
-describe("Copy link", () => {
- it("copies the link of a Space port and says so", async () => {
- const writeText = vi.fn(async () => {});
- Object.defineProperty(navigator, "clipboard", { value: { writeText }, configurable: true });
- inApp(createDemoAdapter({ latencyMs: 0 }), <SpacePortLink spaceId="dev" />);
- const button = await screen.findByRole("button", { name: "Copy link" });
- expect((button as HTMLButtonElement).disabled).toBe(true);
- fireEvent.change(screen.getByLabelText("Port"), { target: { value: "3000" } });
- fireEvent.click(button);
- await screen.findByRole("button", { name: "Link copied" });
- expect(writeText).toHaveBeenCalledWith(expect.stringMatching(/^https:\/\/s.*\.m\.relay\.example\/$/));
- });
-
- it("a machine that is not on the relay gets the fix", async () => {
- const demo = createDemoAdapter({ latencyMs: 0 });
- demo.state.links.notOnRelay = true;
- inApp(demo, <SpacePortLink spaceId="dev" />);
- fireEvent.change(await screen.findByLabelText("Port"), { target: { value: "3000" } });
- fireEvent.click(screen.getByRole("button", { name: "Copy link" }));
- await waitFor(() => expect(document.querySelector("[data-link-error]")?.textContent).toContain("not on your cua.ai relay"));
- expect(document.querySelector("[data-link-error]")?.textContent).not.toContain("unsupported:");
- expect(document.querySelector("[data-link-setup]")?.textContent).toBe("Set up this machine first");
- });
-
+describe("Links without host support", () => {
it("shows nothing where the host has no links", async () => {
const demo = createDemoAdapter({ latencyMs: 0 });
const adapter: DataAdapter = { ...demo, call: (op, args) => (String(op).startsWith("links.") ? Promise.reject(new UnsupportedOperationError("tauri", op)) : demo.call(op, args)) };
diff --git a/apps/cua-spaces-web/src/components/links/copy-link.tsx b/apps/cua-spaces-web/src/components/links/copy-link.tsx
deleted file mode 100644
index 15b21d6504..0000000000
--- a/apps/cua-spaces-web/src/components/links/copy-link.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-// SPDX-License-Identifier: FSL-1.1-MIT
-// Copyright (c) 2026 Cua AI, Inc.
-
-import { Link } from "@tanstack/react-router";
-import { useState } from "react";
-
-import { needsRelaySetup, useLinks } from "@/bridge";
-import { SettingsGroup } from "@/components/settings-group";
-import { Button } from "@/components/ui/button";
-
-type Status = { kind: "idle" } | { kind: "busy" } | { kind: "copied" } | { kind: "error"; message: string };
-
-/** The host's words without the error class (`unsupported: ...`). */
-function plain(message: string): string {
- return message.replace(/^(unsupported|invalid argument|not found|internal): /i, "");
-}
-
-/** The failure line: the host's words, and the fix when the machine is not on the relay. */
-export function LinkError({ message }: { message: string }) {
- const setup = needsRelaySetup(message);
- return (
- <p data-link-error="" className="px-4 pb-3 text-[13px] text-destructive">
- {setup ? "This machine is not on your cua.ai relay yet, so a link would only open here." : plain(message)}
- {setup ? (
- <>
- {" "}
- <Link to="/machines" className="underline" data-link-setup="">
- Set up this machine first
- </Link>
- </>
- ) : null}
- </p>
- );
-}
-
-/**
- * "Copy link" for a port in a Space: shares `space:<space>:<port>` (private:
- * your signed-in devices) and puts the link on the clipboard. Nothing shows
- * where the host has no links.
- */
-export function SpacePortLink({ spaceId, title = "Link to a port" }: { spaceId: string; title?: string }) {
- const { unsupported, createLink } = useLinks({ load: false });
- const [port, setPort] = useState("");
- const [status, setStatus] = useState<Status>({ kind: "idle" });
- if (unsupported) return null;
- const n = Number(port);
- const valid = Number.isInteger(n) && n > 0 && n < 65536;
-
- const copy = async () => {
- setStatus({ kind: "busy" });
- try {
- const link = await createLink({ target: `space:${spaceId}:${n}` });
- await navigator.clipboard.writeText(link.url);
- setStatus({ kind: "copied" });
- } catch (e) {
- setStatus({ kind: "error", message: e instanceof Error ? e.message : String(e) });
- }
- };
-
- return (
- <SettingsGroup title={title}>
- <form
- className="flex min-h-12 items-center justify-between gap-6 px-4 py-2.5"
- onSubmit={(e) => {
- e.preventDefault();
- if (valid) void copy();
- }}
- >
- <label htmlFor="link-port" className="text-[13px]">
- Port
- </label>
- <div className="flex items-center gap-2">
- <input
- id="link-port"
- inputMode="numeric"
- placeholder="3000"
- value={port}
- onChange={(e) => {
- setPort(e.target.value.replace(/\D/g, "").slice(0, 5));
- setStatus({ kind: "idle" });
- }}
- className="h-8 w-20 rounded-lg border bg-background px-2 text-right text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/60"
- />
- <Button type="submit" variant="outline" disabled={!valid || status.kind === "busy"} data-copy-link="">
- {status.kind === "copied" ? "Link copied" : "Copy link"}
- </Button>
- </div>
- </form>
- {status.kind === "error" ? <LinkError message={status.message} /> : null}
- </SettingsGroup>
- );
-}
diff --git a/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx b/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
index 11cf60c643..9f94000979 100644
--- a/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
+++ b/apps/cua-spaces-web/src/routes/spaces/$spaceId.tsx
@@ -15,7 +15,6 @@ import { FactList } from "@/components/space-detail/facts";
import { SpaceResourcesPanel } from "@/components/resources/space-resources-panel";
import { StreamSection } from "@/components/space-detail/stream-section";
import { StreamSurface } from "@/components/space-detail/stream-surface";
-import { SpacePortLink } from "@/components/links/copy-link";
import { StateLabel } from "@/components/state-dot";
import { ConfirmDialog } from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
@@ -323,11 +322,6 @@ function SpaceDetailPage() {
{volumeUnavailableNote(volumeError)}
</p>
) : null}
- {!space.id.startsWith("pending:") && !detail.desktopNote ? (
- <div className="mt-7">
- <SpacePortLink spaceId={space.id} />
- </div>
- ) : null}
{showTeleport ? (
<div className="mt-7">
<DropWell