Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(computers): connect a computer with just its address and a way in

rubenluetke10-beep7dbc40246f4b
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/computers/de.json b/jarvis/ui/web/frontend/src/i18n/locales/computers/de.json
index efa20b96e1..a3fefab0f5 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/computers/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/computers/de.json
@@ -281,6 +281,37 @@
"wz_next_agents_body": "Prüft tmux, git und die Coding-CLIs und installiert Fehlendes mit einem Klick.",
"wz_next_ide": "IDE-Sitzungen dort laufen lassen",
"wz_next_ide_body": "Wähle in der Agentic IDE beim Öffnen eines Workspaces „Läuft auf: {computer}“.",
- "wz_open": "{computer} öffnen"
+ "wz_open": "{computer} öffnen",
+ "cx_title": "Computer verbinden",
+ "cx_subtitle": "{name} braucht nur die Adresse des Servers und einen Weg hinein.",
+ "cx_address": "Server-Adresse",
+ "cx_address_hint": "Die IP aus deinem Anbieter-Panel, z. B. 203.0.113.10 – oder füge eine ganze „ssh root@…“-Zeile ein.",
+ "cx_login": "Anmeldung",
+ "cx_login_password": "Passwort",
+ "cx_login_key": "SSH-Schlüssel",
+ "cx_password": "Passwort",
+ "cx_password_hint": "Wird einmal benutzt: {name} hinterlegt seinen eigenen Schlüssel und vergisst das Passwort.",
+ "cx_private_key": "Privater Schlüssel",
+ "cx_private_key_hint": "Einfügen oder Datei wählen (z. B. id_ed25519). Er bleibt im Schlüsselbund deines Systems.",
+ "cx_key_file": "Datei wählen…",
+ "cx_passphrase": "Passwortsatz (falls der Schlüssel einen hat)",
+ "cx_key_too_big": "Diese Datei ist zu groß für einen SSH-Schlüssel.",
+ "cx_own_key_hint": "Öffentlicher Schlüssel von {name} – er muss schon in authorized_keys auf dem Server stehen",
+ "cx_key_already_there": "Der Schlüssel von {name} ist schon auf dem Server",
+ "cx_use_password": "Stattdessen mit Passwort oder Schlüssel anmelden",
+ "cx_more": "Weitere Optionen",
+ "cx_keep_password": "Weiter mit Passwort statt Schlüssel anmelden",
+ "cx_connect": "Verbinden",
+ "cx_accounts_title": "Oder ein Hosting-Konto verbinden",
+ "cx_accounts_body": "Sieh alle deine Server in einer Liste und wähle einen aus – ohne IP abzutippen.",
+ "cx_account_title": "Deine Server bei {provider}",
+ "cx_vm_link": "Stattdessen eine virtuelle Maschine auf diesem PC anlegen",
+ "cx_vm_title": "Virtuelle Maschine auf diesem PC",
+ "cx_fail_auth": "Der Server hat die Anmeldung abgelehnt. Prüfe Passwort, Schlüssel oder Login-Namen.",
+ "cx_fail_unreachable": "Der Server ist nicht erreichbar. Prüfe die Adresse und ob SSH (Port 22) offen ist.",
+ "cx_fail_timeout": "Der Server hat nicht rechtzeitig geantwortet. Prüfe Adresse und Firewall.",
+ "cx_fail_host_key_changed": "Die Identität des Servers hat sich seit der letzten Verbindung geändert.",
+ "cx_fail_protocol": "Die SSH-Verbindung ist fehlgeschlagen.",
+ "cx_fail_bad_key": "Das sieht nicht nach einem gültigen privaten Schlüssel aus, oder der Passwortsatz stimmt nicht."
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/computers/en.json b/jarvis/ui/web/frontend/src/i18n/locales/computers/en.json
index 6a09327b28..6a187e0f63 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/computers/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/computers/en.json
@@ -281,6 +281,37 @@
"wz_next_agents_body": "Checks tmux, git and the coding CLIs, and installs what is missing on one click.",
"wz_next_ide": "Run IDE sessions there",
"wz_next_ide_body": "In the Agentic IDE, choose “Runs on: {computer}” when you open a workspace.",
- "wz_open": "Open {computer}"
+ "wz_open": "Open {computer}",
+ "cx_title": "Connect a computer",
+ "cx_subtitle": "All {name} needs is the server's address and a way in.",
+ "cx_address": "Server address",
+ "cx_address_hint": "The IP your provider shows, e.g. 203.0.113.10 — or paste a whole \"ssh root@…\" line.",
+ "cx_login": "How to log in",
+ "cx_login_password": "Password",
+ "cx_login_key": "SSH key",
+ "cx_password": "Password",
+ "cx_password_hint": "Used once: {name} adds its own key and forgets the password.",
+ "cx_private_key": "Private key",
+ "cx_private_key_hint": "Paste it or pick the file (for example id_ed25519). It stays in your system's keychain.",
+ "cx_key_file": "Choose file…",
+ "cx_passphrase": "Passphrase (if the key has one)",
+ "cx_key_too_big": "That file is too large to be an SSH key.",
+ "cx_own_key_hint": "{name}'s public key — it must already be in the server's authorized_keys",
+ "cx_key_already_there": "{name}'s key is already on the server",
+ "cx_use_password": "Log in with a password or key instead",
+ "cx_more": "More options",
+ "cx_keep_password": "Keep using the password instead of a key",
+ "cx_connect": "Connect",
+ "cx_accounts_title": "Or connect a hosting account",
+ "cx_accounts_body": "See all your servers in one list and pick one — no IP to copy.",
+ "cx_account_title": "Your {provider} servers",
+ "cx_vm_link": "Create a virtual machine on this PC instead",
+ "cx_vm_title": "Virtual machine on this PC",
+ "cx_fail_auth": "The server refused the login. Check the password, the key or the login name.",
+ "cx_fail_unreachable": "The server could not be reached. Check the address and that SSH (port 22) is open.",
+ "cx_fail_timeout": "The server did not answer in time. Check the address and your firewall.",
+ "cx_fail_host_key_changed": "The server's identity changed since the last connection.",
+ "cx_fail_protocol": "The SSH connection failed.",
+ "cx_fail_bad_key": "This does not look like a valid private key, or the passphrase is wrong."
}
}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/computers/es.json b/jarvis/ui/web/frontend/src/i18n/locales/computers/es.json
index 46e83cb801..c4027390c9 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/computers/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/computers/es.json
@@ -281,6 +281,37 @@
"wz_next_agents_body": "Comprueba tmux, git y las CLI de código, e instala lo que falte con un clic.",
"wz_next_ide": "Ejecutar sesiones del IDE allí",
"wz_next_ide_body": "En el Agentic IDE, elige «Se ejecuta en: {computer}» al abrir un espacio de trabajo.",
- "wz_open": "Abrir {computer}"
+ "wz_open": "Abrir {computer}",
+ "cx_title": "Conectar un ordenador",
+ "cx_subtitle": "{name} solo necesita la dirección del servidor y una forma de entrar.",
+ "cx_address": "Dirección del servidor",
+ "cx_address_hint": "La IP que muestra tu proveedor, p. ej. 203.0.113.10, o pega una línea «ssh root@…» completa.",
+ "cx_login": "Inicio de sesión",
+ "cx_login_password": "Contraseña",
+ "cx_login_key": "Clave SSH",
+ "cx_password": "Contraseña",
+ "cx_password_hint": "Se usa una vez: {name} añade su propia clave y olvida la contraseña.",
+ "cx_private_key": "Clave privada",
+ "cx_private_key_hint": "Pégala o elige el archivo (por ejemplo id_ed25519). Se queda en el llavero de tu sistema.",
+ "cx_key_file": "Elegir archivo…",
+ "cx_passphrase": "Frase de contraseña (si la clave tiene una)",
+ "cx_key_too_big": "Ese archivo es demasiado grande para ser una clave SSH.",
+ "cx_own_key_hint": "Clave pública de {name}: ya debe estar en authorized_keys del servidor",
+ "cx_key_already_there": "La clave de {name} ya está en el servidor",
+ "cx_use_password": "Entrar con contraseña o clave",
+ "cx_more": "Más opciones",
+ "cx_keep_password": "Seguir entrando con contraseña en lugar de clave",
+ "cx_connect": "Conectar",
+ "cx_accounts_title": "O conecta una cuenta de hosting",
+ "cx_accounts_body": "Ve todos tus servidores en una lista y elige uno, sin copiar la IP.",
+ "cx_account_title": "Tus servidores en {provider}",
+ "cx_vm_link": "Crear una máquina virtual en este PC",
+ "cx_vm_title": "Máquina virtual en este PC",
+ "cx_fail_auth": "El servidor rechazó el acceso. Revisa la contraseña, la clave o el usuario.",
+ "cx_fail_unreachable": "No se pudo alcanzar el servidor. Revisa la dirección y que SSH (puerto 22) esté abierto.",
+ "cx_fail_timeout": "El servidor no respondió a tiempo. Revisa la dirección y el cortafuegos.",
+ "cx_fail_host_key_changed": "La identidad del servidor ha cambiado desde la última conexión.",
+ "cx_fail_protocol": "La conexión SSH falló.",
+ "cx_fail_bad_key": "No parece una clave privada válida, o la frase de contraseña es incorrecta."
}
}
diff --git a/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx b/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
index e8bb24ff18..7c5cba5f61 100644
--- a/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
@@ -1,7 +1,7 @@
/**
- * ComputersView: the empty page explains itself; the add-computer wizard goes
- * provider -> method -> test connection -> add; a failed test says how to fix
- * it; a machine opens on tabs and its console runs a command.
+ * ComputersView: the empty page explains itself; connecting needs only an
+ * address and a way in (tested before anything is saved); hosting accounts are
+ * an optional shortcut; a machine opens on tabs and its console runs a command.
*/
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
@@ -136,7 +136,7 @@ describe("ComputersView", () => {
expect(screen.getByTestId("computers-add-first")).toBeTruthy();
});
- it("adds a server: provider, method, test connection, add", async () => {
+ it("connects a server from just its address and password", async () => {
let rows: Computer[] = [];
const calls = installFetch({
"GET /api/computers": () => ({ computers: rows }),
@@ -158,59 +158,46 @@ describe("ComputersView", () => {
renderView();
fireEvent.click(await screen.findByTestId("computers-add-first"));
- fireEvent.click(await screen.findByTestId("wz-provider-ionos"));
- // IONOS has no API: the password path is recommended and pre-selected.
- expect(screen.queryByTestId("wz-method-api")).toBeNull();
- expect(screen.getByTestId("wz-method-password").getAttribute("aria-checked")).toBe("true");
- fireEvent.click(screen.getByTestId("wz-continue"));
+ const connect = await screen.findByTestId("cx-connect");
+ expect((connect as HTMLButtonElement).disabled).toBe(true);
+ // A whole "ssh user@host:port" line is understood.
+ fireEvent.change(screen.getByTestId("cx-address"), { target: { value: "ssh [email protected]:2222" } });
+ fireEvent.change(screen.getByTestId("cx-password"), { target: { value: "hunter2" } });
+ fireEvent.click(connect);
- fireEvent.change(await screen.findByTestId("wz-host"), { target: { value: "203.0.113.15" } });
- fireEvent.change(screen.getByTestId("wz-password"), { target: { value: "hunter2" } });
- expect((screen.getByTestId("wz-add") as HTMLButtonElement).disabled).toBe(true);
- fireEvent.click(screen.getByTestId("wz-test"));
- expect(await screen.findByTestId("wz-test-ok")).toBeTruthy();
- fireEvent.click(screen.getByTestId("wz-add"));
-
- expect(await screen.findByTestId("wz-done")).toBeTruthy();
+ expect(await screen.findByTestId("computer-detail")).toBeTruthy();
const post = calls.find((c) => c.method === "POST" && c.url === "/api/computers");
expect(post?.body).toMatchObject({
host: "203.0.113.15",
- username: "root",
+ port: 2222,
+ username: "admin",
auth: "password",
password: "hunter2",
- provider: "ionos",
});
- fireEvent.click(screen.getByTestId("wz-open"));
- expect(await screen.findByTestId("computer-detail")).toBeTruthy();
});
- it("recommends the API import where the provider plants keys", async () => {
+ it("offers hosting accounts as an optional shortcut", async () => {
installFetch({
"GET /api/computers": () => ({ computers: [] }),
"GET /api/computers/providers": () => ({ providers: PROVIDERS }),
+ "GET /api/computers/identity": () => IDENTITY,
});
renderView();
fireEvent.click(await screen.findByTestId("computers-add-first"));
- fireEvent.click(await screen.findByTestId("wz-provider-hostinger"));
-
- expect(screen.getByTestId("wz-method-api").getAttribute("aria-checked")).toBe("true");
- for (const method of ["password", "private_key", "jarvis_key"]) {
- expect(screen.getByTestId(`wz-method-${method}`)).toBeTruthy();
- }
- fireEvent.click(screen.getByTestId("wz-continue"));
+ fireEvent.click(await screen.findByTestId("cx-account-hostinger"));
expect(await screen.findByTestId("wz-token")).toBeTruthy();
});
- it("shows a fix-it sentence when the test fails", async () => {
- installFetch({
+ it("says how to fix a failed connection and saves nothing", async () => {
+ const calls = installFetch({
"GET /api/computers": () => ({ computers: [] }),
"GET /api/computers/providers": () => ({ providers: PROVIDERS }),
"GET /api/computers/identity": () => IDENTITY,
"POST /api/computers/test": () => ({
ok: false,
- kind: "bad_key",
- message: "The key could not be read.",
+ kind: "auth",
+ message: null,
host_fingerprint: null,
facts: null,
latency_ms: null,
@@ -219,16 +206,12 @@ describe("ComputersView", () => {
renderView();
fireEvent.click(await screen.findByTestId("computers-add-first"));
- fireEvent.click(await screen.findByTestId("wz-provider-raspberry_pi"));
- fireEvent.click(screen.getByTestId("wz-method-private_key"));
- fireEvent.click(screen.getByTestId("wz-continue"));
- fireEvent.change(await screen.findByTestId("wz-host"), { target: { value: "192.168.1.20" } });
- fireEvent.change(screen.getByTestId("wz-private-key"), { target: { value: "-----BEGIN KEY-----" } });
- fireEvent.click(screen.getByTestId("wz-test"));
+ fireEvent.change(await screen.findByTestId("cx-address"), { target: { value: "192.168.1.20" } });
+ fireEvent.change(screen.getByTestId("cx-password"), { target: { value: "wrong" } });
+ fireEvent.click(screen.getByTestId("cx-connect"));
- expect(await screen.findByTestId("wz-test-failed")).toBeTruthy();
- expect(screen.getByText(/Paste the private key/)).toBeTruthy();
- expect((screen.getByTestId("wz-add") as HTMLButtonElement).disabled).toBe(true);
+ expect(await screen.findByText(/refused the login/)).toBeTruthy();
+ expect(calls.some((c) => c.method === "POST" && c.url === "/api/computers")).toBe(false);
});
it("lists a machine, opens it and runs a console command", async () => {
diff --git a/jarvis/ui/web/frontend/src/views/ComputersView.tsx b/jarvis/ui/web/frontend/src/views/ComputersView.tsx
index db0eb50447..90fa6e2ee5 100644
--- a/jarvis/ui/web/frontend/src/views/ComputersView.tsx
+++ b/jarvis/ui/web/frontend/src/views/ComputersView.tsx
@@ -21,7 +21,7 @@ import { ComputerDetail, type DetailTab } from "@/views/computers/ComputerDetail
import { ComputerRow, ComputerTableHead } from "@/views/computers/ComputerRow";
import { KeepWorking } from "@/views/computers/KeepWorking";
import { CopyField, needsAttention } from "@/views/computers/parts";
-import { AddComputerWizard } from "@/views/computers/wizard/AddComputerWizard";
+import { ConnectDialog } from "@/views/computers/ConnectDialog";
/** Keyframes the provisioning bar uses; scoped by name, shipped with the view. */
const KEYFRAMES = `@keyframes computers-indeterminate {
@@ -188,7 +188,7 @@ export function ComputersView() {
</div>
</ScrollArea>
- {adding && <AddComputerWizard onClose={() => setAdding(false)} onOpen={openComputer} />}
+ {adding && <ConnectDialog onClose={() => setAdding(false)} onOpen={openComputer} />}
</div>
);
}
diff --git a/jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx b/jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx
new file mode 100644
index 0000000000..e043ce8fa3
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx
@@ -0,0 +1,385 @@
+/**
+ * "Connect a computer" — one screen, because SSH needs only two things: where
+ * the server is, and a way in (the password once, or an SSH key). Which
+ * company runs the server does not matter for that.
+ *
+ * Two optional doors sit below the form: connect a hosting account to pick
+ * from all its servers (no IP to copy), or create a virtual machine here.
+ *
+ * "Connect" tests first and saves only a connection that works, so a typo
+ * never leaves a broken entry behind. A password is used once to plant the
+ * assistant's own key and is then forgotten, unless "keep" is ticked.
+ */
+import { useEffect, useMemo, useRef, useState } from "react";
+import { ArrowLeft, ChevronDown, KeyRound, Loader2, Lock, MonitorSmartphone, Plug, X } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { ProviderLogo } from "@/components/providers/ProviderLogo";
+import { useIdentity, useProviderCatalog, useUpsertComputer } from "@/hooks/useComputers";
+import { useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+import { computersApi, type AddServerInput, type Computer, type ProviderInfo } from "@/lib/computersApi";
+import { CopyField, Field, inputClass } from "./parts";
+import { ApiImportStep } from "./wizard/ApiImportStep";
+import { LocalVmStep } from "./wizard/LocalVmStep";
+import { ErrorNote, errorText } from "./wizard/shared";
+
+type Screen = { kind: "form" } | { kind: "account"; provider: ProviderInfo } | { kind: "vm" };
+type Login = "password" | "private_key" | "key";
+
+/** "[email protected]:2222" → user, host, port (each optional in the input). */
+export function parseAddress(raw: string): { user: string | null; host: string; port: number | null } {
+ let rest = raw.trim().replace(/^ssh\s+/i, "");
+ let user: string | null = null;
+ const at = rest.lastIndexOf("@");
+ if (at > 0) {
+ user = rest.slice(0, at);
+ rest = rest.slice(at + 1);
+ }
+ let port: number | null = null;
+ const bracket = rest.match(/^\[(.+)\](?::(\d+))?$/);
+ if (bracket) {
+ rest = bracket[1];
+ port = bracket[2] ? Number(bracket[2]) : null;
+ } else if ((rest.match(/:/g) ?? []).length === 1) {
+ const [h, p] = rest.split(":");
+ if (/^\d+$/.test(p)) {
+ rest = h;
+ port = Number(p);
+ }
+ }
+ return { user, host: rest, port };
+}
+
+export function ConnectDialog({
+ onClose,
+ onOpen,
+}: {
+ onClose: () => void;
+ onOpen: (computer: Computer, tab: "overview" | "agents") => void;
+}) {
+ const t = useT();
+ const upsert = useUpsertComputer();
+ const catalog = useProviderCatalog();
+ const identity = useIdentity();
+ const [screen, setScreen] = useState<Screen>({ kind: "form" });
+ const [address, setAddress] = useState("");
+ const [login, setLogin] = useState<Login>("password");
+ const [password, setPassword] = useState("");
+ const [privateKey, setPrivateKey] = useState("");
+ const [passphrase, setPassphrase] = useState("");
+ const [more, setMore] = useState(false);
+ const [name, setName] = useState("");
+ const [username, setUsername] = useState("");
+ const [port, setPort] = useState("");
+ const [keepPassword, setKeepPassword] = useState(false);
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const fileInput = useRef<HTMLInputElement>(null);
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onClose();
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [onClose]);
+
+ const accounts = useMemo(() => (catalog.data ?? []).filter((p) => p.api), [catalog.data]);
+ const parsed = parseAddress(address);
+ const effectiveUser = username.trim() || parsed.user || "root";
+ const effectivePort = Number(port) || parsed.port || 22;
+ const ready =
+ parsed.host.length > 0 &&
+ (login === "key" || (login === "password" ? password.length > 0 : privateKey.trim().length > 0));
+
+ const finish = (computer: Computer) => {
+ upsert(computer);
+ onOpen(computer, "overview");
+ };
+
+ async function connect() {
+ if (!ready || busy) return;
+ setBusy(true);
+ setError(null);
+ const input: AddServerInput = {
+ name: name.trim() || parsed.host,
+ host: parsed.host,
+ port: effectivePort,
+ username: effectiveUser,
+ auth: login,
+ password: login === "password" ? password : undefined,
+ keep_password: login === "password" ? keepPassword : undefined,
+ private_key: login === "private_key" ? privateKey : undefined,
+ passphrase: login === "private_key" && passphrase ? passphrase : undefined,
+ provider: "generic",
+ };
+ try {
+ const test = await computersApi.test(input);
+ if (!test.ok) {
+ setError(test.message || t(`computers.cx_fail_${test.kind ?? "protocol"}`));
+ return;
+ }
+ finish(await computersApi.add(input));
+ } catch (e) {
+ setError(errorText(e));
+ } finally {
+ setBusy(false);
+ }
+ }
+
+ async function pickKeyFile(file: File | undefined) {
+ if (!file) return;
+ if (file.size > 64 * 1024) {
+ setError(t("computers.cx_key_too_big"));
+ return;
+ }
+ setPrivateKey(await file.text());
+ }
+
+ const loginTabs: { id: Login; label: string; icon: typeof Lock }[] = [
+ { id: "password", label: t("computers.cx_login_password"), icon: Lock },
+ { id: "private_key", label: t("computers.cx_login_key"), icon: KeyRound },
+ ];
+
+ return (
+ <div className="fixed inset-0 z-50 flex items-center justify-center bg-scrim/50 p-4 backdrop-blur-sm">
+ <div
+ role="dialog"
+ aria-modal="true"
+ aria-label={t("computers.cx_title")}
+ data-testid="computers-connect-dialog"
+ className="flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-xl border border-border bg-popover shadow-float"
+ >
+ <header className="flex items-start gap-3 border-b border-border px-6 py-5">
+ {screen.kind !== "form" && (
+ <button
+ type="button"
+ onClick={() => setScreen({ kind: "form" })}
+ aria-label={t("computers.back")}
+ className="mt-0.5 rounded-md p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
+ >
+ <ArrowLeft className="h-4 w-4" />
+ </button>
+ )}
+ <div className="min-w-0 flex-1">
+ <h2 className="text-lg font-semibold text-foreground-strong">
+ {screen.kind === "account"
+ ? t("computers.cx_account_title").replace("{provider}", screen.provider.name)
+ : screen.kind === "vm"
+ ? t("computers.cx_vm_title")
+ : t("computers.cx_title")}
+ </h2>
+ {screen.kind === "form" && (
+ <p className="mt-0.5 text-sm text-muted-foreground">{t("computers.cx_subtitle")}</p>
+ )}
+ </div>
+ <button
+ type="button"
+ onClick={onClose}
+ aria-label={t("computers.close")}
+ className="rounded-md p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
+ >
+ <X className="h-4 w-4" />
+ </button>
+ </header>
+
+ <div className="min-h-0 flex-1 overflow-y-auto px-6 py-5 scrollbar-jarvis">
+ {screen.kind === "account" && (
+ <ApiImportStep
+ provider={screen.provider}
+ onBack={() => setScreen({ kind: "form" })}
+ onAdded={finish}
+ onProviderChanged={() => void catalog.refetch()}
+ />
+ )}
+ {screen.kind === "vm" && <LocalVmStep onBack={() => setScreen({ kind: "form" })} onAdded={finish} />}
+
+ {screen.kind === "form" && (
+ <form
+ className="space-y-5"
+ onSubmit={(e) => {
+ e.preventDefault();
+ void connect();
+ }}
+ >
+ <Field label={t("computers.cx_address")} hint={t("computers.cx_address_hint")}>
+ <input
+ className={cn(inputClass, "h-10 font-mono")}
+ value={address}
+ onChange={(e) => setAddress(e.target.value)}
+ placeholder="[email protected]"
+ autoFocus
+ spellCheck={false}
+ autoComplete="off"
+ data-testid="cx-address"
+ />
+ </Field>
+
+ <div>
+ <div role="tablist" aria-label={t("computers.cx_login")} className="flex gap-1 rounded-lg bg-secondary p-1">
+ {loginTabs.map((tab) => {
+ const Icon = tab.icon;
+ const active = login === tab.id;
+ return (
+ <button
+ key={tab.id}
+ type="button"
+ role="tab"
+ aria-selected={active}
+ onClick={() => setLogin(tab.id)}
+ className={cn(
+ "flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md text-sm font-medium transition-colors",
+ active ? "bg-popover text-foreground-strong shadow-sm" : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ <Icon className="h-3.5 w-3.5" aria-hidden />
+ {tab.label}
+ </button>
+ );
+ })}
+ </div>
+
+ <div className="mt-4">
+ {login === "password" && (
+ <Field label={t("computers.cx_password")} hint={t("computers.cx_password_hint")}>
+ <input
+ type="password"
+ className={cn(inputClass, "h-10")}
+ value={password}
+ onChange={(e) => setPassword(e.target.value)}
+ autoComplete="new-password"
+ data-testid="cx-password"
+ />
+ </Field>
+ )}
+ {login === "private_key" && (
+ <div className="space-y-3">
+ <Field label={t("computers.cx_private_key")} hint={t("computers.cx_private_key_hint")}>
+ <textarea
+ className={cn(inputClass, "h-24 resize-none py-2 font-mono text-xs")}
+ value={privateKey}
+ onChange={(e) => setPrivateKey(e.target.value)}
+ placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
+ spellCheck={false}
+ data-testid="cx-private-key"
+ />
+ </Field>
+ <div className="flex items-center gap-3">
+ <Button type="button" variant="outline" size="sm" onClick={() => fileInput.current?.click()}>
+ {t("computers.cx_key_file")}
+ </Button>
+ <input
+ ref={fileInput}
+ type="file"
+ className="hidden"
+ onChange={(e) => void pickKeyFile(e.target.files?.[0])}
+ />
+ <input
+ type="password"
+ className={cn(inputClass, "h-8 flex-1 text-sm")}
+ value={passphrase}
+ onChange={(e) => setPassphrase(e.target.value)}
+ placeholder={t("computers.cx_passphrase")}
+ aria-label={t("computers.cx_passphrase")}
+ autoComplete="off"
+ />
+ </div>
+ </div>
+ )}
+ {login === "key" && identity.data && (
+ <CopyField
+ multiline
+ label={t("computers.cx_own_key_hint")}
+ value={identity.data.public_key}
+ copyLabel={t("computers.copy")}
+ copiedLabel={t("computers.copied")}
+ />
+ )}
+ <button
+ type="button"
+ onClick={() => setLogin(login === "key" ? "password" : "key")}
+ className="mt-2 text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
+ >
+ {login === "key" ? t("computers.cx_use_password") : t("computers.cx_key_already_there")}
+ </button>
+ </div>
+ </div>
+
+ <div>
+ <button
+ type="button"
+ onClick={() => setMore((v) => !v)}
+ aria-expanded={more}
+ className="flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground"
+ >
+ <ChevronDown className={cn("h-4 w-4 transition-transform", more && "rotate-180")} aria-hidden />
+ {t("computers.cx_more")}
+ </button>
+ {more && (
+ <div className="mt-3 grid gap-3 sm:grid-cols-[minmax(0,1fr)_110px_80px]">
+ <Field label={t("computers.field_name")}>
+ <input className={inputClass} value={name} onChange={(e) => setName(e.target.value)} placeholder={parsed.host || t("computers.field_name_placeholder")} />
+ </Field>
+ <Field label={t("computers.field_username")}>
+ <input className={cn(inputClass, "font-mono")} value={username} onChange={(e) => setUsername(e.target.value)} placeholder={parsed.user || "root"} spellCheck={false} />
+ </Field>
+ <Field label={t("computers.field_port")}>
+ <input className={cn(inputClass, "font-mono")} value={port} inputMode="numeric" onChange={(e) => setPort(e.target.value.replace(/[^0-9]/g, ""))} placeholder={String(parsed.port ?? 22)} />
+ </Field>
+ {login === "password" && (
+ <label className="col-span-full flex items-center gap-2 text-sm text-foreground-secondary">
+ <input type="checkbox" checked={keepPassword} onChange={(e) => setKeepPassword(e.target.checked)} className="h-4 w-4" />
+ {t("computers.cx_keep_password")}
+ </label>
+ )}
+ </div>
+ )}
+ </div>
+
+ <ErrorNote message={error} />
+
+ <Button type="submit" className="h-10 w-full" disabled={!ready || busy} data-testid="cx-connect">
+ {busy ? <Loader2 className="animate-spin" /> : <Plug />}
+ {busy ? t("computers.connecting") : t("computers.cx_connect")}
+ </Button>
+ </form>
+ )}
+ </div>
+
+ {screen.kind === "form" && (
+ <footer className="space-y-3 border-t border-border bg-secondary/30 px-6 py-4">
+ {accounts.length > 0 && (
+ <div>
+ <div className="text-sm font-medium text-foreground-secondary">{t("computers.cx_accounts_title")}</div>
+ <p className="text-xs text-muted-foreground">{t("computers.cx_accounts_body")}</p>
+ <div className="mt-2.5 flex flex-wrap gap-1.5">
+ {accounts.map((provider) => (
+ <button
+ key={provider.id}
+ type="button"
+ data-testid={`cx-account-${provider.id}`}
+ onClick={() => setScreen({ kind: "account", provider })}
+ className="inline-flex h-8 items-center gap-2 rounded-md border border-border bg-popover px-2.5 text-sm text-foreground transition-colors hover:border-border-strong"
+ >
+ <ProviderLogo providerId={provider.id} label={provider.name} size="sm" />
+ {provider.name}
+ {provider.api?.connected && <span className="h-1.5 w-1.5 rounded-full bg-success" aria-hidden />}
+ </button>
+ ))}
+ </div>
+ </div>
+ )}
+ <button
+ type="button"
+ onClick={() => setScreen({ kind: "vm" })}
+ className="inline-flex items-center gap-1.5 text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
+ >
+ <MonitorSmartphone className="h-3.5 w-3.5" aria-hidden />
+ {t("computers.cx_vm_link")}
+ </button>
+ </footer>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/views/computers/wizard/AddComputerWizard.tsx b/jarvis/ui/web/frontend/src/views/computers/wizard/AddComputerWizard.tsx
deleted file mode 100644
index ccc378f38c..0000000000
--- a/jarvis/ui/web/frontend/src/views/computers/wizard/AddComputerWizard.tsx
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * "Add a computer" — a four-step wizard with a visible step indicator:
- *
- * 1 Where the provider gallery (or a VM on this computer)
- * 2 How the connection methods that work for that provider
- * 3 Details address + credential + a real connection test
- * (or: API token → the account's server list)
- * 4 Done what to do with the new computer next
- *
- * Every step has exactly one primary action. Back never loses what was typed
- * in an earlier step; closing the dialog does.
- */
-import { useEffect, useState } from "react";
-import { useQueryClient } from "@tanstack/react-query";
-import { Check, X } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { ProviderLogo } from "@/components/providers/ProviderLogo";
-import { useProviderCatalog, useUpsertComputer } from "@/hooks/useComputers";
-import { useT } from "@/i18n";
-import { cn } from "@/lib/utils";
-import type { Computer } from "@/lib/computersApi";
-import { ApiImportStep } from "./ApiImportStep";
-import { DetailsStep } from "./DetailsStep";
-import { DoneStep } from "./DoneStep";
-import { LocalVmStep } from "./LocalVmStep";
-import { MethodStep, recommendedMethod } from "./MethodStep";
-import { ProviderStep } from "./ProviderStep";
-import { ErrorNote, errorText, type Method, type Pick } from "./shared";
-import { StepActions } from "./StepActions";
-
-type Step = 0 | 1 | 2 | 3;
-
-export function AddComputerWizard({
- onClose,
- onOpen,
-}: {
- onClose: () => void;
- /** Close the wizard and show the new computer, on this tab. */
- onOpen: (computer: Computer, tab: "overview" | "agents") => void;
-}) {
- const t = useT();
- const qc = useQueryClient();
- const upsert = useUpsertComputer();
- const catalog = useProviderCatalog();
- const [step, setStep] = useState<Step>(0);
- const [pick, setPick] = useState<Pick | null>(null);
- const [method, setMethod] = useState<Method>("password");
- const [added, setAdded] = useState<Computer | null>(null);
-
- useEffect(() => {
- const onKey = (e: KeyboardEvent) => {
- if (e.key === "Escape") onClose();
- };
- window.addEventListener("keydown", onKey);
- return () => window.removeEventListener("keydown", onKey);
- }, [onClose]);
-
- const choose = (next: Pick) => {
- setPick(next);
- if (next.kind === "local") {
- setStep(2);
- return;
- }
- setMethod(recommendedMethod(next.provider));
- setStep(1);
- };
- const finish = (computer: Computer) => {
- upsert(computer);
- setAdded(computer);
- setStep(3);
- };
-
- const steps = [
- t("computers.wz_step_where"),
- t("computers.wz_step_method"),
- t("computers.wz_step_details"),
- t("computers.wz_step_done"),
- ];
- const provider = pick?.kind === "provider" ? pick.provider : null;
- const titles: Record<Step, string> = {
- 0: t("computers.wz_title_where"),
- 1: t("computers.wz_title_method"),
- 2: pick?.kind === "local" ? t("computers.wz_local_title") : t("computers.wz_title_details"),
- 3: t("computers.wz_step_done"),
- };
-
- return (
- <div
- className="fixed inset-0 z-50 flex items-center justify-center bg-scrim/50 p-4 backdrop-blur-sm"
- // Only an untouched first step closes on a click beside the dialog; once
- // the user picked a provider, a stray click (or a layout shift under the
- // pointer) must not throw the half-filled wizard away. X and Esc still close.
- onClick={() => {
- if (step === 0) onClose();
- }}
- >
- <div
- role="dialog"
- aria-modal="true"
- aria-label={t("computers.add_title")}
- data-testid="computers-add-dialog"
- className="flex max-h-[92vh] w-full max-w-3xl flex-col overflow-hidden rounded-xl bg-popover shadow-float"
- onClick={(e) => e.stopPropagation()}
- >
- <header className="border-b border-border px-6 pb-4 pt-5">
- <div className="flex items-start gap-3">
- <div className="min-w-0 flex-1">
- <h2 className="text-lg font-semibold text-foreground-strong">{titles[step]}</h2>
- {provider && step > 0 && step < 3 && (
- <p className="mt-1 flex items-center gap-2 text-sm text-muted-foreground">
- <ProviderLogo providerId={provider.id} label={provider.name} size="sm" />
- {provider.name}
- </p>
- )}
- </div>
- <button
- type="button"
- onClick={onClose}
- aria-label={t("computers.close")}
- className="rounded-md p-1 text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
- >
- <X className="h-4 w-4" />
- </button>
- </div>
- <ol className="mt-4 flex items-center gap-2" aria-label={t("computers.wz_progress")}>
- {steps.map((label, index) => {
- const skipped = pick?.kind === "local" && index === 1;
- const done = index < step && !skipped;
- const current = index === step;
- return (
- <li key={label} className="flex min-w-0 flex-1 items-center gap-2" aria-current={current ? "step" : undefined}>
- <span
- className={cn(
- "flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-xs font-medium tabular-nums",
- current && "border-accent bg-accent text-accent-foreground",
- done && "border-accent text-accent",
- !current && !done && "border-border text-muted-foreground",
- skipped && "opacity-40",
- )}
- >
- {done ? <Check className="h-3.5 w-3.5" aria-hidden /> : index + 1}
- </span>
- <span
- className={cn(
- "hidden truncate text-xs sm:block",
- current ? "font-medium text-foreground-strong" : "text-muted-foreground",
- skipped && "opacity-40",
- )}
- >
- {label}
- </span>
- {index < steps.length - 1 && <span className="h-px min-w-3 flex-1 bg-border" aria-hidden />}
- </li>
- );
- })}
- </ol>
- </header>
-
- <div className="min-h-[420px] flex-1 overflow-y-auto px-6 py-5 scrollbar-jarvis">
- {step === 0 && (
- <div className="flex h-full flex-col">
- <div className="flex-1">
- {catalog.isError && <ErrorNote message={errorText(catalog.error)} />}
- <ProviderStep
- providers={catalog.data ?? []}
- loading={catalog.isLoading}
- selected={pick}
- onPick={choose}
- />
- </div>
- </div>
- )}
- {step === 1 && provider && (
- <div className="flex h-full flex-col">
- <div className="flex-1">
- <MethodStep provider={provider} value={method} onChange={setMethod} />
- </div>
- <StepActions onBack={() => setStep(0)}>
- <Button type="button" onClick={() => setStep(2)} data-testid="wz-continue">
- {t("computers.wz_continue")}
- </Button>
- </StepActions>
- </div>
- )}
- {step === 2 && pick?.kind === "local" && <LocalVmStep onBack={() => setStep(0)} onAdded={finish} />}
- {step === 2 && provider && method === "api" && (
- <ApiImportStep
- provider={provider}
- onBack={() => setStep(1)}
- onAdded={finish}
- onProviderChanged={() => void qc.invalidateQueries({ queryKey: ["computers", "providers"] })}
- />
- )}
- {step === 2 && provider && method !== "api" && (
- <DetailsStep provider={provider} method={method} onBack={() => setStep(1)} onAdded={finish} />
- )}
- {step === 3 && added && <DoneStep computer={added} onOpen={(tab) => onOpen(added, tab)} />}
- </div>
- </div>
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/computers/wizard/DetailsStep.tsx b/jarvis/ui/web/frontend/src/views/computers/wizard/DetailsStep.tsx
deleted file mode 100644
index 011c02b43b..0000000000
--- a/jarvis/ui/web/frontend/src/views/computers/wizard/DetailsStep.tsx
+++ /dev/null
@@ -1,331 +0,0 @@
-/**
- * Step 3 (SSH) — the address, the login and the credential for the chosen
- * method, pre-filled from the provider, then a real connection test.
- *
- * "Add computer" becomes the primary action only after the test succeeded:
- * the user sees that {name} got in (and which system answered) before
- * anything is saved. Every failure comes back as one plain sentence with the
- * fix, keyed on the kind of failure.
- */
-import { useEffect, useRef, useState } from "react";
-import { CheckCircle2, ExternalLink, FileUp, Loader2, PlugZap, XCircle } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { useIdentity } from "@/hooks/useComputers";
-import { useT } from "@/i18n";
-import { openExternalUrl } from "@/lib/openExternal";
-import { cn } from "@/lib/utils";
-import {
- computersApi,
- type AddServerInput,
- type Computer,
- type ConnectionTest,
- type ProviderInfo,
-} from "@/lib/computersApi";
-import { CopyField, Field, inputClass } from "../parts";
-import { ErrorNote, errorText, type Method } from "./shared";
-import { StepActions } from "./StepActions";
-
-const MAX_KEY_FILE_BYTES = 64 * 1024;
-
-export function DetailsStep({
- provider,
- method,
- onBack,
- onAdded,
-}: {
- provider: ProviderInfo;
- method: Exclude<Method, "api">;
- onBack: () => void;
- onAdded: (computer: Computer) => void;
-}) {
- const t = useT();
- const identity = useIdentity();
- const fileRef = useRef<HTMLInputElement>(null);
- const [host, setHost] = useState("");
- const [port, setPort] = useState("22");
- const [username, setUsername] = useState(provider.ssh.default_username || "root");
- const [name, setName] = useState("");
- const [password, setPassword] = useState("");
- const [keepPassword, setKeepPassword] = useState(false);
- const [privateKey, setPrivateKey] = useState("");
- const [passphrase, setPassphrase] = useState("");
- const [testing, setTesting] = useState(false);
- const [adding, setAdding] = useState(false);
- const [result, setResult] = useState<ConnectionTest | null>(null);
- const [error, setError] = useState<string | null>(null);
-
- const portNumber = Number(port);
- const input: AddServerInput = {
- name: name.trim() || host.trim(),
- host: host.trim(),
- port: portNumber,
- username: username.trim(),
- auth: method === "password" ? "password" : method === "private_key" ? "private_key" : "key",
- password: method === "password" ? password : undefined,
- keep_password: method === "password" ? keepPassword : undefined,
- private_key: method === "private_key" ? privateKey : undefined,
- passphrase: method === "private_key" && passphrase ? passphrase : undefined,
- provider: provider.id,
- };
- const valid =
- input.host !== "" &&
- input.username !== "" &&
- Number.isInteger(portNumber) &&
- portNumber >= 1 &&
- portNumber <= 65535 &&
- (method !== "password" || password !== "") &&
- (method !== "private_key" || privateKey.trim() !== "");
- const fingerprint = JSON.stringify(input);
-
- // Any change after a test invalidates it: the next "Add" must be proven again.
- useEffect(() => {
- setResult(null);
- }, [fingerprint]);
-
- async function runTest() {
- if (!valid || testing) return;
- setTesting(true);
- setError(null);
- try {
- setResult(await computersApi.test(input));
- } catch (e) {
- setError(errorText(e));
- } finally {
- setTesting(false);
- }
- }
-
- async function add() {
- if (!result?.ok || adding) return;
- setAdding(true);
- setError(null);
- try {
- onAdded(await computersApi.add(input));
- } catch (e) {
- setError(errorText(e));
- } finally {
- setAdding(false);
- }
- }
-
- async function readKeyFile(file: File | undefined) {
- if (!file) return;
- if (file.size > MAX_KEY_FILE_BYTES) {
- setError(t("computers.wz_key_file_too_big"));
- return;
- }
- setPrivateKey(await file.text());
- }
-
- return (
- <div className="flex h-full flex-col">
- <form
- className="flex-1 space-y-5"
- onSubmit={(e) => {
- e.preventDefault();
- void runTest();
- }}
- >
- <div className="grid gap-4 sm:grid-cols-[minmax(0,1fr)_96px]">
- <Field label={t("computers.field_host")} hint={provider.ssh.ip_hint || t("computers.field_host_hint")}>
- <input
- className={cn(inputClass, "font-mono")}
- value={host}
- onChange={(e) => setHost(e.target.value)}
- placeholder="203.0.113.10"
- autoFocus
- spellCheck={false}
- autoComplete="off"
- data-testid="wz-host"
- />
- </Field>
- <Field label={t("computers.field_port")}>
- <input
- className={cn(inputClass, "font-mono")}
- value={port}
- inputMode="numeric"
- onChange={(e) => setPort(e.target.value.replace(/[^0-9]/g, ""))}
- />
- </Field>
- </div>
- <div className="grid gap-4 sm:grid-cols-2">
- <Field label={t("computers.field_username")}>
- <input
- className={cn(inputClass, "font-mono")}
- value={username}
- onChange={(e) => setUsername(e.target.value)}
- spellCheck={false}
- autoComplete="off"
- />
- </Field>
- <Field label={t("computers.field_name")}>
- <input
- className={inputClass}
- value={name}
- onChange={(e) => setName(e.target.value)}
- placeholder={provider.name}
- />
- </Field>
- </div>
-
- {method === "password" && (
- <div className="space-y-2">
- <Field label={t("computers.field_password")} hint={provider.ssh.password_hint || t("computers.password_once_hint")}>
- <input
- type="password"
- className={inputClass}
- value={password}
- onChange={(e) => setPassword(e.target.value)}
- autoComplete="new-password"
- data-testid="wz-password"
- />
- </Field>
- <label className="flex items-center gap-2 text-sm text-muted-foreground">
- <input
- type="checkbox"
- checked={keepPassword}
- onChange={(e) => setKeepPassword(e.target.checked)}
- className="h-4 w-4 accent-[hsl(var(--accent))]"
- />
- {t("computers.wz_keep_password")}
- </label>
- </div>
- )}
-
- {method === "private_key" && (
- <div className="space-y-3">
- <Field label={t("computers.wz_private_key")} hint={t("computers.wz_private_key_hint")}>
- <textarea
- value={privateKey}
- onChange={(e) => setPrivateKey(e.target.value)}
- rows={5}
- spellCheck={false}
- placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
- data-testid="wz-private-key"
- className="w-full rounded-md border border-border-strong bg-input px-3 py-2 font-mono text-xs text-foreground placeholder:text-foreground-faint focus:border-accent focus:outline-none focus:ring-2 focus:ring-ring"
- />
- </Field>
- <div className="flex flex-wrap items-end gap-4">
- <Button type="button" variant="outline" size="sm" onClick={() => fileRef.current?.click()}>
- <FileUp />
- {t("computers.wz_pick_key_file")}
- </Button>
- <input
- ref={fileRef}
- type="file"
- className="hidden"
- onChange={(e) => void readKeyFile(e.target.files?.[0])}
- />
- <Field label={t("computers.wz_passphrase")} className="min-w-[200px] flex-1">
- <input
- type="password"
- className={inputClass}
- value={passphrase}
- onChange={(e) => setPassphrase(e.target.value)}
- placeholder={t("computers.wz_passphrase_placeholder")}
- autoComplete="off"
- />
- </Field>
- </div>
- </div>
- )}
-
- {method === "jarvis_key" && (
- <div className="space-y-3 rounded-lg border border-border bg-card p-4">
- <p className="text-sm text-foreground-secondary">
- {provider.ssh.key_hint || t("computers.key_paste_hint")}
- </p>
- {identity.data && (
- <CopyField
- multiline
- label={t("computers.jarvis_key")}
- value={identity.data.public_key}
- copyLabel={t("computers.copy")}
- copiedLabel={t("computers.copied")}
- />
- )}
- {provider.ssh.key_url && (
- <button
- type="button"
- onClick={() => void openExternalUrl(provider.ssh.key_url ?? "")}
- className="inline-flex items-center gap-1 text-sm font-medium text-accent underline-offset-4 hover:underline"
- >
- {t("computers.wz_open_key_page").replace("{provider}", provider.name)}
- <ExternalLink className="h-3.5 w-3.5" aria-hidden />
- </button>
- )}
- </div>
- )}
-
- <TestResultRow result={result} />
- <ErrorNote message={error} />
- </form>
-
- <StepActions onBack={onBack}>
- <Button
- type="button"
- variant={result?.ok ? "outline" : "default"}
- disabled={!valid || testing}
- onClick={() => void runTest()}
- data-testid="wz-test"
- >
- {testing ? <Loader2 className="animate-spin" /> : <PlugZap />}
- {testing ? t("computers.connecting") : t("computers.wz_test")}
- </Button>
- <Button
- type="button"
- variant={result?.ok ? "default" : "outline"}
- disabled={!result?.ok || adding}
- onClick={() => void add()}
- data-testid="wz-add"
- >
- {adding && <Loader2 className="animate-spin" />}
- {t("computers.add")}
- </Button>
- </StepActions>
- </div>
- );
-}
-
-function TestResultRow({ result }: { result: ConnectionTest | null }) {
- const t = useT();
- if (!result) return null;
- if (result.ok) {
- const facts = [result.facts?.os_name, result.latency_ms !== null ? `${result.latency_ms} ms` : null]
- .filter(Boolean)
- .join(" · ");
- return (
- <div
- role="status"
- data-testid="wz-test-ok"
- className="flex items-start gap-3 rounded-lg border border-success/40 bg-success/10 px-4 py-3"
- >
- <CheckCircle2 className="mt-0.5 h-4 w-4 shrink-0 text-success" aria-hidden />
- <div className="min-w-0 text-sm">
- <div className="font-medium text-foreground-strong">
- {t("computers.wz_test_ok")}
- {facts && <span className="font-normal text-muted-foreground"> · {facts}</span>}
- </div>
- {result.host_fingerprint && (
- <div className="mt-0.5 truncate font-mono text-xs text-muted-foreground" title={result.host_fingerprint}>
- {t("computers.server_identity")}: {result.host_fingerprint}
- </div>
- )}
- </div>
- </div>
- );
- }
- return (
- <div
- role="alert"
- data-testid="wz-test-failed"
- className="flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3"
- >
- <XCircle className="mt-0.5 h-4 w-4 shrink-0 text-destructive" aria-hidden />
- <div className="min-w-0 text-sm">
- <div className="font-medium text-foreground-strong">{result.message || t("computers.wz_test_failed")}</div>
- {result.kind && <div className="mt-0.5 text-muted-foreground">{t(`computers.wz_fix_${result.kind}`)}</div>}
- </div>
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/computers/wizard/DoneStep.tsx b/jarvis/ui/web/frontend/src/views/computers/wizard/DoneStep.tsx
deleted file mode 100644
index 2cb62bb32a..0000000000
--- a/jarvis/ui/web/frontend/src/views/computers/wizard/DoneStep.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-/** Step 4 — the computer is connected; what to do with it next. */
-import { ArrowRight, Bot, CheckCircle2, SquareTerminal } from "lucide-react";
-import { Button } from "@/components/ui/button";
-import { ProviderLogo } from "@/components/providers/ProviderLogo";
-import { useT } from "@/i18n";
-import type { Computer } from "@/lib/computersApi";
-import { statusLabel } from "../ComputerRow";
-import { StatusLight, statusTone } from "../parts";
-import { StepActions } from "./StepActions";
-
-export function DoneStep({
- computer,
- onOpen,
-}: {
- computer: Computer;
- onOpen: (tab: "overview" | "agents") => void;
-}) {
- const t = useT();
- const provisioning = computer.health.status === "provisioning";
- return (
- <div className="flex h-full flex-col" data-testid="wz-done">
- <div className="flex-1">
- <div className="flex flex-col items-center py-4 text-center">
- <CheckCircle2 className="h-10 w-10 text-success" aria-hidden />
- <h3 className="mt-3 text-lg font-semibold text-foreground-strong">
- {(provisioning ? t("computers.wz_done_provisioning") : t("computers.wz_done_title")).replace(
- "{computer}",
- computer.name,
- )}
- </h3>
- <div className="mt-3 flex items-center gap-3 rounded-lg border border-border px-4 py-2.5">
- <ProviderLogo providerId={computer.provider} label={computer.name} size="sm" />
- <span className="font-mono text-xs text-muted-foreground">
- {computer.username}@{computer.host === "0.0.0.0" ? "…" : computer.host}
- </span>
- <span className="inline-flex items-center gap-1.5 text-sm text-foreground-secondary">
- <StatusLight tone={statusTone(computer.health.status)} />
- {statusLabel(computer, t)}
- </span>
- </div>
- </div>
- <h4 className="mb-2 mt-4 text-xs font-medium uppercase tracking-wide text-foreground-faint">
- {t("computers.wz_next")}
- </h4>
- <ul className="divide-y divide-border rounded-lg border border-border">
- <li>
- <button
- type="button"
- onClick={() => onOpen("agents")}
- className="flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-secondary/50"
- >
- <Bot className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
- <span className="min-w-0 flex-1">
- <span className="block text-sm font-medium text-foreground-strong">{t("computers.wz_next_agents")}</span>
- <span className="block text-xs text-muted-foreground">{t("computers.wz_next_agents_body")}</span>
- </span>
- <ArrowRight className="h-4 w-4 text-foreground-faint" aria-hidden />
- </button>
- </li>
- <li className="flex items-center gap-3 px-4 py-3">
- <SquareTerminal className="h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
- <span className="min-w-0 flex-1">
- <span className="block text-sm font-medium text-foreground-strong">{t("computers.wz_next_ide")}</span>
- <span className="block text-xs text-muted-foreground">
- {t("computers.wz_next_ide_body").replace("{computer}", computer.name)}
- </span>
- </span>
- </li>
- </ul>
- </div>
- <StepActions>
- <Button type="button" onClick={() => onOpen("overview")} data-testid="wz-open">
- {t("computers.wz_open").replace("{computer}", computer.name)}
- </Button>
- </StepActions>
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/computers/wizard/MethodStep.tsx b/jarvis/ui/web/frontend/src/views/computers/wizard/MethodStep.tsx
deleted file mode 100644
index 1ec4b386c0..0000000000
--- a/jarvis/ui/web/frontend/src/views/computers/wizard/MethodStep.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- * Step 2 — "How should {name} connect?": only the ways that work for the
- * chosen provider, the best one marked and pre-selected.
- */
-import { Cloud, FileKey2, KeyRound, LockKeyhole } from "lucide-react";
-import { useT } from "@/i18n";
-import type { ProviderInfo } from "@/lib/computersApi";
-import { OptionCard, type Method } from "./shared";
-
-/** The methods a provider offers, best first. */
-export function methodsFor(provider: ProviderInfo): Method[] {
- const methods: Method[] = [];
- if (provider.api) methods.push("api");
- methods.push("password", "private_key", "jarvis_key");
- return methods;
-}
-
-/** The method to pre-select: API import when the provider plants keys itself. */
-export function recommendedMethod(provider: ProviderInfo): Method {
- return provider.api?.attaches_keys ? "api" : "password";
-}
-
-export function MethodStep({
- provider,
- value,
- onChange,
-}: {
- provider: ProviderInfo;
- value: Method;
- onChange: (method: Method) => void;
-}) {
- const t = useT();
- const best = recommendedMethod(provider);
- const fill = (key: string) => t(key).replace("{provider}", provider.name);
- const icons: Record<Method, JSX.Element> = {
- api: <Cloud />,
- password: <LockKeyhole />,
- private_key: <FileKey2 />,
- jarvis_key: <KeyRound />,
- };
- return (
- <div role="radiogroup" aria-label={t("computers.wz_step_method")} className="space-y-2.5">
- {methodsFor(provider).map((method) => (
- <OptionCard
- key={method}
- testId={`wz-method-${method}`}
- active={value === method}
- onClick={() => onChange(method)}
- icon={icons[method]}
- title={fill(`computers.wz_m_${method}_title`)}
- body={fill(
- method === "api" && provider.api?.attaches_keys
- ? "computers.wz_m_api_body_keys"
- : `computers.wz_m_${method}_body`,
- )}
- badge={method === best ? t("computers.recommended") : undefined}
- />
- ))}
- </div>
- );
-}
diff --git a/jarvis/ui/web/frontend/src/views/computers/wizard/ProviderStep.tsx b/jarvis/ui/web/frontend/src/views/computers/wizard/ProviderStep.tsx
deleted file mode 100644
index 25fbe5a5dc..0000000000
--- a/jarvis/ui/web/frontend/src/views/computers/wizard/ProviderStep.tsx
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * Step 1 — "Where is your server?": the provider gallery.
- *
- * Grouped the way people think about it (a cloud, a web host, a box at home,
- * something else), searchable, with the provider's real mark. Picking one is
- * the whole step; the rest of the wizard adapts to it. A virtual machine on
- * this computer is its own entry at the end.
- */
-import { useMemo, useState } from "react";
-import { Loader2, MonitorSmartphone, Search } from "lucide-react";
-import { ProviderLogo } from "@/components/providers/ProviderLogo";
-import { useT } from "@/i18n";
-import { cn } from "@/lib/utils";
-import type { ProviderCategory, ProviderInfo } from "@/lib/computersApi";
-import type { Pick } from "./shared";
-
-const ORDER: ProviderCategory[] = ["cloud", "hosting", "home", "other"];
-
-export function ProviderStep({
- providers,
- loading,
- selected,
- onPick,
-}: {
- providers: ProviderInfo[];
- loading: boolean;
- selected: Pick | null;
- onPick: (pick: Pick) => void;
-}) {
- const t = useT();
- const [query, setQuery] = useState("");
- const needle = query.trim().toLowerCase();
-
- const groups = useMemo(
- () =>
- ORDER.map((category) => ({
- category,
- items: providers.filter(
- (p) => p.category === category && (!needle || p.name.toLowerCase().includes(needle)),
- ),
- })).filter((group) => group.items.length > 0),
- [providers, needle],
- );
- const localMatches =
- !needle || t("computers.wz_local_title").toLowerCase().includes(needle) || "vm multipass".includes(needle);
-
- return (
- <div className="space-y-6">
- <div className="relative">
- <Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden />
- <input
- type="text"
- role="searchbox"
- value={query}
- autoFocus
- onChange={(e) => setQuery(e.target.value)}
- placeholder={t("computers.wz_search")}
- aria-label={t("computers.wz_search")}
- className="h-10 w-full rounded-md border border-border-strong bg-input pl-9 pr-3 text-base text-foreground placeholder:text-foreground-faint focus:border-accent focus:outline-none focus:ring-2 focus:ring-ring"
- />
- </div>
-
- {loading && (
- <div className="flex items-center gap-2 text-sm text-muted-foreground">
- <Loader2 className="h-4 w-4 animate-spin" aria-hidden /> {t("computers.loading")}
- </div>
- )}
-
- {groups.map((group) => (
- <section key={group.category} aria-labelledby={`wz-group-${group.category}`}>
- <h3
- id={`wz-group-${group.category}`}
- className="mb-2 text-xs font-medium uppercase tracking-wide text-foreground-faint"
- >
- {t(`computers.wz_group_${group.category}`)}
- </h3>
- <ul className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
- {group.items.map((provider) => {
- const active = selected?.kind === "provider" && selected.provider.id === provider.id;
- return (
- <li key={provider.id}>
- <button
- type="button"
- data-testid={`wz-provider-${provider.id}`}
- aria-pressed={active}
- onClick={() => onPick({ kind: "provider", provider })}
- className={cn(
- "flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- active ? "border-accent bg-accent-soft" : "border-border hover:border-border-strong hover:bg-secondary/40",
- )}
- >
- <ProviderLogo providerId={provider.id} label={provider.name} />
- <span className="min-w-0 flex-1">
- <span className="block truncate text-sm font-medium text-foreground-strong">{provider.name}</span>
- <span className="block truncate text-xs text-muted-foreground">
- {provider.api ? t("computers.wz_has_api") : t("computers.wz_ssh_only")}
- </span>
- </span>
- </button>
- </li>
- );
- })}
- </ul>
- </section>
- ))}
-
- {localMatches && (
- <section aria-labelledby="wz-group-local">
- <h3 id="wz-group-local" className="mb-2 text-xs font-medium uppercase tracking-wide text-foreground-faint">
- {t("computers.wz_group_local")}
- </h3>
- <button
- type="button"
- data-testid="wz-provider-local"
- aria-pressed={selected?.kind === "local"}
- onClick={() => onPick({ kind: "local" })}
- className={cn(
- "flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors sm:w-1/2 lg:w-1/3",
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- selected?.kind === "local" ? "border-accent bg-accent-soft" : "border-border hover:border-border-strong hover:bg-secondary/40",
- )}
- >
- <span className="flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-secondary text-muted-foreground">
- <MonitorSmartphone className="h-4 w-4" aria-hidden />
- </span>
- <span className="min-w-0 flex-1">
- <span className="block truncate text-sm font-medium text-foreground-strong">{t("computers.wz_local_title")}</span>
- <span className="block truncate text-xs text-muted-foreground">{t("computers.wz_local_sub")}</span>
- </span>
- </button>
- </section>
- )}
-
- {!loading && groups.length === 0 && !localMatches && (
- <p className="text-sm text-muted-foreground">{t("computers.wz_no_match")}</p>
- )}
- </div>
- );
-}