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.

chore: merge origin/main into main

rubenluetke10-beep57ea3e652a13
diff --cc jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
index aa19c95f70,e45443551d..236d31cb6c
--- a/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/ComputersView.test.tsx
@@@ -209,15 -207,12 +214,15 @@@ describe("ComputersView", () =>
fireEvent.change(await screen.findByTestId("cx-address"), { target: { value: answer } });
expect(screen.queryByTestId("cx-password")).toBeNull();
- expect(screen.getByTestId("cx-detected").textContent).toContain("[email protected]");
+ expect(screen.getByTestId("cx-detected").textContent).toContain("[email protected]");
+ // A pasted key switches the login to "SSH key" by itself.
+ expect(screen.getByTestId("cx-method-key").getAttribute("aria-selected")).toBe("true");
fireEvent.click(screen.getByTestId("cx-connect"));
+ fireEvent.click(await screen.findByTestId("cx-open"));
expect(await screen.findByTestId("computer-detail")).toBeTruthy();
const post = calls.find((c) => c.method === "POST" && c.url === "/api/computers");
- expect(post?.body).toMatchObject({ host: "192.168.178.132", username: "Administrator", auth: "private_key" });
+ expect(post?.body).toMatchObject({ host: "192.0.2.10", username: "dev", auth: "private_key" });
expect((post?.body as { private_key: string }).private_key).toContain("BEGIN OPENSSH PRIVATE KEY");
});
diff --cc jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx
index 37c42c13b3,eb55477128..faf8929342
--- a/jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx
+++ b/jarvis/ui/web/frontend/src/views/computers/ConnectDialog.tsx
@@@ -40,70 -24,15 +40,70 @@@ import { cn } from "@/lib/utils"
import { robustCopy } from "@/lib/clipboard";
import { useEventStore } from "@/store/events";
import { computersApi, type AddServerInput, type Computer, type ProviderInfo } from "@/lib/computersApi";
- import { parseConnection, setupPrompt } from "./connection";
+ import { parseConnection, setupPrompt, PRIVATE_KEY_PLACEHOLDER } from "./connection";
-import { Field, inputClass } from "./parts";
+import { checkFailed, ConnectCheck, startCheck, type CheckState, type StepId } from "./ConnectCheck";
+import { CopyField, Field, inputClass } from "./parts";
import { ApiImportStep } from "./wizard/ApiImportStep";
import { LocalVmStep } from "./wizard/LocalVmStep";
-import { ErrorNote, errorText } from "./wizard/shared";
+import { errorText } from "./wizard/shared";
-type Screen = { kind: "form" } | { kind: "account"; provider: ProviderInfo } | { kind: "vm" };
+type Screen = { kind: "form" } | { kind: "check" } | { kind: "account"; provider: ProviderInfo } | { kind: "vm" };
+type Method = "password" | "ssh_key" | "agent";
+type KeySource = "own" | "assistant";
type Login = "password" | "private_key" | "key";
+const REACH_FAILURES = new Set(["unreachable", "timeout", "protocol", "host_key_changed"]);
+
+/** One tab of the "how to log in" switch. */
+function MethodTab({
+ active,
+ onClick,
+ icon,
+ label,
+ testId,
+}: {
+ active: boolean;
+ onClick: () => void;
+ icon: ReactNode;
+ label: string;
+ testId: string;
+}) {
+ return (
+ <button
+ type="button"
+ role="tab"
+ aria-selected={active}
+ onClick={onClick}
+ data-testid={testId}
+ className={cn(
+ "flex min-w-0 flex-1 items-center justify-center gap-2 rounded-md px-2 py-2 text-sm font-medium transition-colors",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&>svg]:h-4 [&>svg]:w-4 [&>svg]:shrink-0",
+ active
+ ? "bg-popover text-foreground-strong shadow-sm ring-1 ring-border"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {icon}
+ <span className="truncate">{label}</span>
+ </button>
+ );
+}
+
+/** A numbered instruction row for the agent route. */
+function AgentStep({ n, children }: { n: number; children: ReactNode }) {
+ return (
+ <li className="flex gap-3">
+ <span
+ aria-hidden
+ className="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-border-strong text-xs font-medium tabular-nums text-foreground-secondary"
+ >
+ {n}
+ </span>
+ <div className="min-w-0 flex-1 pt-0.5 text-sm text-foreground-secondary">{children}</div>
+ </li>
+ );
+}
+
export function ConnectDialog({
onClose,
onOpen,
@@@ -355,241 -196,117 +355,241 @@@
void connect();
}}
>
- <div className="rounded-lg border border-border bg-secondary/40 p-4" data-testid="cx-setup">
- <div className="flex items-start gap-3">
- <Sparkles className="mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" aria-hidden />
- <div className="min-w-0 flex-1">
- <div className="text-sm font-medium text-foreground-strong">{t("computers.cx_setup_title")}</div>
- <p className="mt-0.5 text-xs text-muted-foreground">{t("computers.cx_setup_body")}</p>
+ <div>
+ <Field label={t("computers.cx_paste")} hint={t("computers.cx_paste_hint")}>
+ <textarea
+ className={cn(inputClass, "h-auto min-h-[40px] resize-none py-2 font-mono text-sm")}
+ rows={pasted.includes("\n") ? 4 : 1}
+ value={pasted}
+ onChange={(e) => setPasted(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && !e.shiftKey && !pasted.includes("\n")) {
+ e.preventDefault();
+ void connect();
+ }
+ }}
+ placeholder="203.0.113.10"
+ autoFocus
+ spellCheck={false}
+ autoComplete="off"
+ data-testid="cx-address"
+ />
+ </Field>
+ {detected.host && (
+ <div className="mt-2 flex flex-wrap items-center gap-1.5 text-xs" data-testid="cx-detected">
+ <span className="text-muted-foreground">{t("computers.cx_detected")}</span>
+ <span className="rounded bg-secondary px-1.5 py-0.5 font-mono text-foreground-secondary">
+ {effectiveUser}@{detected.host}
+ {effectivePort !== 22 ? `:${effectivePort}` : ""}
+ </span>
+ {pastedKey && (
+ <span className="inline-flex items-center gap-1 rounded bg-success/15 px-1.5 py-0.5 text-success">
+ <KeyRound className="h-3 w-3" aria-hidden />
+ {t("computers.cx_key_found")}
+ </span>
+ )}
</div>
- <Button
- type="button"
- variant="outline"
- size="sm"
- disabled={!identity.data}
- onClick={() => void copyPrompt()}
- data-testid="cx-copy-prompt"
- >
- {promptCopied ? <Check className="text-success" /> : <Copy />}
- {promptCopied ? t("computers.copied") : t("computers.cx_setup_copy")}
- </Button>
- </div>
+ )}
</div>
- <Field label={t("computers.cx_paste")} hint={t("computers.cx_paste_hint")}>
- <textarea
- className={cn(inputClass, "h-auto min-h-[40px] resize-none py-2 font-mono text-sm")}
- rows={pasted.includes("\n") ? 4 : 1}
- value={pasted}
- onChange={(e) => setPasted(e.target.value)}
- placeholder="203.0.113.10"
- autoFocus
- spellCheck={false}
- autoComplete="off"
- data-testid="cx-address"
- />
- </Field>
+ <div>
+ <div className="mb-1.5 text-sm font-medium text-foreground-secondary" id="cx-login-label">
+ {t("computers.cx_login_title")}
+ </div>
+ <div
+ role="tablist"
+ aria-labelledby="cx-login-label"
+ className="flex gap-1 rounded-lg bg-secondary p-1"
+ >
+ <MethodTab
+ active={method === "password"}
+ onClick={() => setMethod("password")}
+ icon={<Lock />}
+ label={t("computers.cx_method_password")}
+ testId="cx-method-password"
+ />
+ <MethodTab
+ active={method === "ssh_key"}
+ onClick={() => setMethod("ssh_key")}
+ icon={<KeyRound />}
+ label={t("computers.cx_method_key")}
+ testId="cx-method-key"
+ />
+ <MethodTab
+ active={method === "agent"}
+ onClick={() => setMethod("agent")}
+ icon={<SquareTerminal />}
+ label={t("computers.cx_method_agent")}
+ testId="cx-method-agent"
+ />
+ </div>
- {detected.host && (
- <div className="flex flex-wrap items-center gap-1.5 text-xs" data-testid="cx-detected">
- <span className="text-muted-foreground">{t("computers.cx_detected")}</span>
- <span className="rounded bg-secondary px-1.5 py-0.5 font-mono text-foreground-secondary">
- {effectiveUser}@{detected.host}
- {effectivePort !== 22 ? `:${effectivePort}` : ""}
- </span>
- {login === "private_key" && (
- <span className="inline-flex items-center gap-1 rounded bg-success/15 px-1.5 py-0.5 text-success">
- <KeyRound className="h-3 w-3" aria-hidden />
- {t("computers.cx_key_found")}
- </span>
- )}
- {login === "key" && (
- <span className="inline-flex items-center gap-1 rounded bg-success/15 px-1.5 py-0.5 text-success">
- <Check className="h-3 w-3" aria-hidden />
- {t("computers.cx_setup_done")}
- </span>
+ <div className="mt-4" role="tabpanel">
+ {method === "password" && (
+ <div className="space-y-3">
+ <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>
+ <label className="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>
- )}
- {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>
- )}
+ {method === "ssh_key" && (
+ <div className="space-y-4">
+ <div role="radiogroup" className="grid grid-cols-2 gap-2">
+ {(["own", "assistant"] as const).map((source) => (
+ <button
+ key={source}
+ type="button"
+ role="radio"
+ aria-checked={keySource === source}
+ onClick={() => setKeySource(source)}
+ data-testid={`cx-key-${source}`}
+ className={cn(
+ "rounded-md border px-3 py-2 text-left text-sm transition-colors",
+ keySource === source
+ ? "border-accent bg-accent-soft text-foreground-strong"
+ : "border-border text-foreground-secondary hover:border-border-strong",
+ )}
+ >
+ <span className="block font-medium">
+ {source === "own" ? t("computers.cx_key_own") : t("computers.cx_key_assistant")}
+ </span>
+ <span className="mt-0.5 block text-xs text-muted-foreground">
+ {source === "own"
+ ? t("computers.cx_key_own_body")
+ : t("computers.cx_key_assistant_body")}
+ </span>
+ </button>
+ ))}
+ </div>
- {manualKey && login === "private_key" && !pastedKey && (
- <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={PRIVATE_KEY_PLACEHOLDER}
- spellCheck={false}
- data-testid="cx-private-key"
- />
- </Field>
- <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])} />
- </div>
- )}
+ {keySource === "own" && pastedKey && (
+ <p className="flex items-center gap-2 text-sm text-foreground-secondary">
+ <Check className="h-4 w-4 text-success" aria-hidden />
+ {t("computers.cx_key_from_paste")}
+ </p>
+ )}
- {login === "private_key" && (
- <input
- type="password"
- className={cn(inputClass, "h-9 text-sm")}
- value={passphrase}
- onChange={(e) => setPassphrase(e.target.value)}
- placeholder={t("computers.cx_passphrase")}
- aria-label={t("computers.cx_passphrase")}
- autoComplete="off"
- />
- )}
+ {keySource === "own" && !pastedKey && (
+ <div className="space-y-2">
+ <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-----"
++ placeholder={PRIVATE_KEY_PLACEHOLDER}
+ spellCheck={false}
+ data-testid="cx-private-key"
+ />
+ </Field>
+ <Button type="button" variant="outline" size="sm" onClick={() => fileInput.current?.click()}>
+ <FileKey />
+ {t("computers.cx_key_file")}
+ </Button>
+ <input
+ ref={fileInput}
+ type="file"
+ className="hidden"
+ onChange={(e) => void pickKeyFile(e.target.files?.[0])}
+ />
+ {keyError && (
+ <p role="alert" className="text-sm text-destructive">
+ {keyError}
+ </p>
+ )}
+ </div>
+ )}
- <div className="flex flex-wrap items-center gap-x-4 gap-y-1 text-xs">
- {!pastedKey && !detected.fromSetupPrompt && (
- <button
- type="button"
- onClick={() => setManualKey((v) => !v)}
- className="text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
- >
- {manualKey ? t("computers.cx_use_password") : t("computers.cx_have_key")}
- </button>
- )}
+ {keySource === "own" && (
+ <input
+ type="password"
+ className={cn(inputClass, "h-9 text-sm")}
+ value={passphrase}
+ onChange={(e) => setPassphrase(e.target.value)}
+ placeholder={t("computers.cx_passphrase")}
+ aria-label={t("computers.cx_passphrase")}
+ autoComplete="off"
+ />
+ )}
+
+ {keySource === "assistant" && identity.data && (
+ <div className="space-y-2" data-testid="cx-assistant-key">
+ <CopyField
+ value={identity.data.public_key}
+ label={t("computers.jarvis_key")}
+ copyLabel={t("computers.copy")}
+ copiedLabel={t("computers.copied")}
+ />
+ <p className="text-xs text-muted-foreground">{t("computers.cx_key_assistant_hint")}</p>
+ </div>
+ )}
+ </div>
+ )}
+
+ {method === "agent" && (
+ <div className="space-y-4" data-testid="cx-agent">
+ {detected.fromSetupPrompt ? (
+ <p className="flex items-start gap-2 rounded-md bg-success/10 px-3 py-2.5 text-sm text-foreground">
+ <Check className="mt-0.5 h-4 w-4 shrink-0 text-success" aria-hidden />
+ {t("computers.cx_agent_done")}
+ </p>
+ ) : (
+ <ol className="space-y-3">
+ <AgentStep n={1}>
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-2">
+ <span>{t("computers.cx_agent_step1")}</span>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ disabled={!identity.data}
+ onClick={() => void copyPrompt()}
+ data-testid="cx-copy-prompt"
+ >
+ {promptCopied ? <Check className="text-success" /> : <Copy />}
+ {promptCopied ? t("computers.copied") : t("computers.cx_agent_copy")}
+ </Button>
+ <button
+ type="button"
+ onClick={() => setShowPrompt((v) => !v)}
+ aria-expanded={showPrompt}
+ className="text-xs text-muted-foreground underline-offset-4 hover:text-foreground hover:underline"
+ >
+ {showPrompt ? t("computers.cx_agent_hide") : t("computers.cx_agent_show")}
+ </button>
+ </div>
+ {showPrompt && identity.data && (
+ <pre className="mt-2 max-h-48 overflow-auto whitespace-pre-wrap rounded-md border border-border bg-surface-raised p-3 font-mono text-xs text-foreground-secondary scrollbar-jarvis">
+ {setupPrompt(assistantName, identity.data.public_key)}
+ </pre>
+ )}
+ </AgentStep>
+ <AgentStep n={2}>{t("computers.cx_agent_step2")}</AgentStep>
+ <AgentStep n={3}>{t("computers.cx_agent_step3")}</AgentStep>
+ </ol>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+
+ <div>
<button
type="button"
onClick={() => setMore((v) => !v)}