+ {/* Step 1: Enter URL */}
+ {step === 'url' && (
+ <>
+
Add Remote Instance
+
+ setUrl(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && !isLoading && url.trim() && handleProbe()}
+ placeholder="https://instance.example.com"
+ className="flex-1 px-3 py-2 bg-surface-input rounded text-txt-primary text-sm outline-none focus:ring-2 focus:ring-accent-primary"
+ disabled={isLoading}
+ />
+
+
+
+ >
+ )}
+
+ {/* Step 2: Auth */}
+ {step === 'auth' && probeResult && (
+ <>
+ {/* Instance info card */}
+
+
+
+
{probeResult.name}
+
{probeResult.origin}
+
+
+
+ {/* Auth tabs */}
+
+ {probeResult.registrationOpen && (
+
+ )}
+
+
+
+ {/* Register form */}
+ {authTab === 'register' && (
+
+
+
+
+
+ Your username will be replicated. If taken, it becomes {user?.username}@{window.location.host}
+
+
+
+
+ setPassword(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && !isLoading && password && handleRegister()}
+ placeholder="Create a password for this instance"
+ className="w-full px-3 py-2 bg-surface-input rounded text-txt-primary text-sm outline-none focus:ring-2 focus:ring-accent-primary"
+ disabled={isLoading}
+ />
+
+
+
+ )}
+
+ {/* Login form */}
+ {authTab === 'login' && (
+
+
+
+ setLoginUsername(e.target.value)}
+ placeholder="Your username on this instance"
+ className="w-full px-3 py-2 bg-surface-input rounded text-txt-primary text-sm outline-none focus:ring-2 focus:ring-accent-primary"
+ disabled={isLoading}
+ />
+
+
+
+ setLoginPassword(e.target.value)}
+ onKeyDown={(e) => e.key === 'Enter' && !isLoading && loginUsername && loginPassword && handleLogin()}
+ placeholder="Your password on this instance"
+ className="w-full px-3 py-2 bg-surface-input rounded text-txt-primary text-sm outline-none focus:ring-2 focus:ring-accent-primary"
+ disabled={isLoading}
+ />
+
+
+
+ )}
+
+ {/* Back button */}
+
+
+
+
+ >
+ )}
+
+ {/* Error display */}
+ {error && (
+
+ {error}
+
+ )}
+
+ );
+}
+
+// ─── Main component ──────────────────────────────────────────────────────────
+
+export function ConnectedInstances() {
+ const instances = useInstanceStore((s) => s.instances);
+ const removeInstance = useInstanceStore((s) => s.removeInstance);
+ const [showAddForm, setShowAddForm] = useState(false);
+
+ return (
+