Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(remote-hosts): choose SSH identity files

vastsa6704e16d2098
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
index 7d7e29804..31b267717 100644
--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx
+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
@@ -70,6 +70,7 @@ export function RemoteHostsPage() {
const [sshForm, setSshForm] = useState<SshForm>(EMPTY_SSH_FORM);
const [installing, setInstalling] = useState(false);
const [addMode, setAddMode] = useState<AddMode>("ssh");
+ const sshIdentityFileInput = useRef<HTMLInputElement>(null);
const refresh = useCallback(async () => {
const generation = ++refreshGeneration.current;
@@ -160,6 +161,24 @@ export function RemoteHostsPage() {
}));
}, []);
+ const handleSshIdentityFileChange = useCallback(
+ (event: React.ChangeEvent<HTMLInputElement>) => {
+ const input = event.currentTarget;
+ const file = input.files?.[0] ?? null;
+ // Reset so the same identity file can be selected again after a change.
+ input.value = "";
+ if (!file) return;
+
+ const identityFile = api.getDroppedFilePath(file);
+ if (!identityFile) {
+ showToast(t("settings.remoteHosts.sshIdentityFileError"), { variant: "error" });
+ return;
+ }
+ setSshForm((prev) => ({ ...prev, identityFile }));
+ },
+ [showToast, t],
+ );
+
const submitSsh = useCallback(
async (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
@@ -173,7 +192,7 @@ export function RemoteHostsPage() {
if (passwordMode && !password) return;
const user = sshForm.user.trim();
const port = sshForm.port.trim();
- const identityFile = sshForm.identityFile.trim();
+ const identityFile = sshForm.identityFile;
setInstalling(true);
try {
// Empty optional fields are dropped rather than sent blank, so main
@@ -380,17 +399,44 @@ export function RemoteHostsPage() {
{sshForm.auth === "key" ? (
<Field label={t("settings.remoteHosts.sshIdentityFile")}>
- <Input
- value={sshForm.identityFile}
- onChange={(event) =>
- setSshForm((prev) => ({ ...prev, identityFile: event.target.value }))
- }
- aria-label={t("settings.remoteHosts.sshIdentityFile")}
- autoComplete="off"
- autoCapitalize="off"
- spellCheck={false}
- disabled={installing}
- />
+ <div className="settings-remote-host-identity-file">
+ <Input
+ value={sshForm.identityFile}
+ placeholder={t("settings.remoteHosts.sshIdentityFilePlaceholder")}
+ aria-label={t("settings.remoteHosts.sshIdentityFile")}
+ autoComplete="off"
+ readOnly
+ disabled={installing}
+ />
+ <Button
+ type="button"
+ variant="secondary"
+ onClick={() => sshIdentityFileInput.current?.click()}
+ disabled={installing}
+ >
+ {t("settings.remoteHosts.sshIdentityFileChoose")}
+ </Button>
+ {sshForm.identityFile && (
+ <Button
+ type="button"
+ variant="ghost"
+ onClick={() => setSshForm((prev) => ({ ...prev, identityFile: "" }))}
+ disabled={installing}
+ >
+ {t("settings.remoteHosts.sshIdentityFileClear")}
+ </Button>
+ )}
+ {/* Key files often have no extension, so do not restrict file types. */}
+ <input
+ ref={sshIdentityFileInput}
+ className="settings-remote-host-identity-file-input"
+ type="file"
+ tabIndex={-1}
+ aria-hidden="true"
+ onChange={handleSshIdentityFileChange}
+ disabled={installing}
+ />
+ </div>
</Field>
) : (
<Field label={t("settings.remoteHosts.sshPassword")}>
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index 89609046b..07b18a857 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -1038,6 +1038,17 @@
grid-template-columns: minmax(0, 1fr) minmax(120px, 0.4fr);
}
+.settings-remote-host-identity-file {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto auto;
+ align-items: center;
+ gap: 8px;
+}
+
+.settings-remote-host-identity-file-input {
+ display: none;
+}
+
.settings-remote-host-form-auth {
display: grid;
gap: 6px;
diff --git a/apps/desktop/test/settings-remote-hosts.test.mjs b/apps/desktop/test/settings-remote-hosts.test.mjs
index 84d443c8f..d5e9ee4a2 100644
--- a/apps/desktop/test/settings-remote-hosts.test.mjs
+++ b/apps/desktop/test/settings-remote-hosts.test.mjs
@@ -52,6 +52,32 @@ test("remote host cards open project creation instead of a session workbench", (
assert.doesNotMatch(page, /RemoteHostSessions|selectedHost|remoteT\("sessions"\)/);
});
+test("SSH key mode selects a local identity file instead of accepting a typed path", () => {
+ const start = page.indexOf('<Field label={t("settings.remoteHosts.sshIdentityFile")}>');
+ const end = page.indexOf(") : (", start);
+ assert.ok(start >= 0 && end > start, "key-auth identity field should exist");
+ const identityField = page.slice(start, end);
+ const displayInput = identityField.match(/<Input[\s\S]*?\/>/)?.[0];
+ assert.ok(displayInput, "selected path should use the shared Input primitive");
+ assert.match(displayInput, /readOnly/);
+ assert.doesNotMatch(displayInput, /onChange=/);
+ assert.match(identityField, /sshIdentityFileChoose/);
+ assert.match(identityField, /sshIdentityFileClear/);
+ assert.match(identityField, /type="file"/);
+ assert.match(identityField, /onChange={handleSshIdentityFileChange}/);
+ assert.match(page, /api\.getDroppedFilePath\(file\)/);
+ assert.match(page, /input\.value = ""/);
+ assert.match(page, /if \(!file\) return/);
+ assert.match(page, /const identityFile = sshForm\.identityFile;/);
+ assert.match(page, /sshIdentityFileError/);
+ assert.match(
+ cssRule(".settings-remote-host-identity-file"),
+ /grid-template-columns: minmax\(0, 1fr\) auto auto/,
+ );
+ assert.match(cssRule(".settings-remote-host-identity-file-input"), /display: none/);
+});
+});
+
test("remote hosts omits instructional copy", () => {
assert.doesNotMatch(page, /role="note"/);
assert.doesNotMatch(page, /settings-row-desc/);
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index c47be6c20..63ac8bd8c 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -14745,10 +14745,13 @@ browser milestones are scheduled.
only reachable with a password; the user's local SSH agent holds no usable key
for it. A GitHub Releases fixture serves the `pi-host` bundle for that platform
at the desktop's version. A second machine accepts the user's key only.
-- **Steps**: 1) In Settings → Remote Hosts, open the Add form's SSH tab and install over SSH with key
- authentication and confirm the form shows the identity-file field.
- 2) Switch the authentication mode to password, confirm the identity-file field
- is replaced by a masked password field, and reveal it once.
+- **Steps**: 1) In Settings → Remote Hosts, open the Add form's SSH tab, choose
+ a local private-key file in key mode, and confirm its path is displayed. Cancel
+ a second file selection and confirm the existing choice remains; select the
+ same file again and confirm it can be reselected. Clear the selection once to
+ confirm the SSH agent/config fallback is available, then choose the key again.
+ 2) Switch the authentication mode to password, confirm the identity-file
+ picker is replaced by a masked password field, and reveal it once.
3) Try to submit an empty password. 4) Point the form at the
password-only machine, enter the password, and bootstrap it.
5) Quit the desktop, relaunch it, and let the host reconnect.
@@ -14757,9 +14760,13 @@ browser milestones are scheduled.
8) Inspect the desktop's process arguments and `remote-hosts.json` while a
password-authenticated host is connected. 9) Attempt to submit a password
containing a newline through the IPC channel directly.
-- **Expected**: Key mode is byte-for-byte today's behaviour — `BatchMode=yes` and
- no credential file anywhere. In password mode the password field replaces the
- identity-file field, the reveal toggle shows and re-hides the value, and an
+- **Expected**: Key mode lets the user choose a local identity file; its path
+ is read-only in the form and is passed to the existing `ssh -i` flow. The app
+ never reads or uploads the key contents. Cancel preserves the prior choice, the
+ same file can be selected again, and Clear returns to SSH agent/config lookup.
+ The key-authenticated SSH behavior remains unchanged: `BatchMode=yes` and no
+ credential file anywhere. In password mode the picker is replaced by a masked
+ password field, the reveal toggle shows and re-hides the value, and an
empty password keeps the submit disabled. The password-only machine installs
and pairs. After the relaunch the host reconnects with no prompt, proving the
saved credential is used. The wrong password yields exactly one failed attempt
@@ -14778,8 +14785,9 @@ browser milestones are scheduled.
- **Acceptance**: Security, D (surfaces), Quality
- **Milestone**: Post-MVP (rollout R2b)
- **Status**: Draft; remote harness with a password-only Linux SSH target
- required. The credential seam itself is covered offline by
- `apps/desktop/test/remote-host-ssh-password.test.mjs`.
+ required. The chooser control is covered by
+ `apps/desktop/test/settings-remote-hosts.test.mjs`; the SSH credential seam is
+ covered offline by `apps/desktop/test/remote-host-ssh-password.test.mjs`.
#### E2E-REMOTE-HOST-settings-compact-inventory
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 8ed9297e7..6892caeab 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1226,6 +1226,10 @@ sklm: {
"sshUser": "Benutzer",
"sshPort": "Port",
"sshIdentityFile": "Identitätsdatei",
+ "sshIdentityFileChoose": "Datei auswählen",
+ "sshIdentityFilePlaceholder": "Keine Datei ausgewählt",
+ "sshIdentityFileClear": "Auswahl löschen",
+ "sshIdentityFileError": "Der Pfad der ausgewählten Datei ist nicht verfügbar.",
"sshAuthMode": "Auth",
"sshAuthKey": "Schlüssel",
"sshAuthPassword": "Passwort",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 96aa72a25..5d0f49987 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1078,6 +1078,10 @@ sklm: {
sshUser: "User",
sshPort: "Port",
sshIdentityFile: "Identity file",
+ sshIdentityFileChoose: "Choose file",
+ sshIdentityFilePlaceholder: "No file selected",
+ sshIdentityFileClear: "Clear",
+ sshIdentityFileError: "Could not access the selected file path.",
sshAuthMode: "Auth",
sshAuthKey: "Key",
sshAuthPassword: "Password",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index e2e6c1d65..27c6bfcf9 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1226,6 +1226,10 @@ sklm: {
"sshUser": "Usuario",
"sshPort": "Puerto",
"sshIdentityFile": "Archivo de identidad",
+ "sshIdentityFileChoose": "Elegir archivo",
+ "sshIdentityFilePlaceholder": "Ningún archivo seleccionado",
+ "sshIdentityFileClear": "Borrar selección",
+ "sshIdentityFileError": "No se pudo obtener la ruta del archivo seleccionado.",
"sshAuthMode": "Auth",
"sshAuthKey": "Clave",
"sshAuthPassword": "Contraseña",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index c21ac5b00..1eccc83db 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1226,6 +1226,10 @@ sklm: {
"sshUser": "Utilisateur",
"sshPort": "Port",
"sshIdentityFile": "Fichier d'identité",
+ "sshIdentityFileChoose": "Choisir un fichier",
+ "sshIdentityFilePlaceholder": "Aucun fichier sélectionné",
+ "sshIdentityFileClear": "Effacer la sélection",
+ "sshIdentityFileError": "Impossible d’accéder au chemin du fichier sélectionné.",
"sshAuthMode": "Auth",
"sshAuthKey": "Clé",
"sshAuthPassword": "Mot de passe",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index be8d63933..0381cda6b 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1234,6 +1234,10 @@ sklm: {
sshUser: "사용자",
sshPort: "포트",
sshIdentityFile: "개인 키",
+ sshIdentityFileChoose: "파일 선택",
+ sshIdentityFilePlaceholder: "선택된 파일 없음",
+ sshIdentityFileClear: "선택 해제",
+ sshIdentityFileError: "선택한 파일 경로를 가져올 수 없습니다.",
sshAuthMode: "인증",
sshAuthKey: "키",
sshAuthPassword: "비밀번호",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index a2d66e415..da771c4b1 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1046,6 +1046,10 @@ export const ptBR = {
sshUser: "Usuário",
sshPort: "Porta",
sshIdentityFile: "Arquivo de chave privada SSH",
+ sshIdentityFileChoose: "Selecionar arquivo",
+ sshIdentityFilePlaceholder: "Nenhum arquivo selecionado",
+ sshIdentityFileClear: "Limpar seleção",
+ sshIdentityFileError: "Não foi possível obter o caminho do arquivo selecionado.",
sshAuthMode: "Autenticação",
sshAuthKey: "Chave",
sshAuthPassword: "Senha",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 936c91661..65d6146bd 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1228,6 +1228,10 @@ sklm: {
sshUser: "Kullanıcı",
sshPort: "Bağlantı noktası",
sshIdentityFile: "Kimlik dosyası",
+ sshIdentityFileChoose: "Dosya seç",
+ sshIdentityFilePlaceholder: "Dosya seçilmedi",
+ sshIdentityFileClear: "Seçimi temizle",
+ sshIdentityFileError: "Seçilen dosyanın yolu alınamadı.",
sshAuthMode: "Kimlik doğrulama",
sshAuthKey: "Anahtar",
sshAuthPassword: "Parola",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 974c26891..91d3e7817 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1218,6 +1218,10 @@ sklm: {
sshUser: "用户",
sshPort: "端口",
sshIdentityFile: "私钥",
+ sshIdentityFileChoose: "选择文件",
+ sshIdentityFilePlaceholder: "未选择文件",
+ sshIdentityFileClear: "清除",
+ sshIdentityFileError: "无法读取所选文件的路径。",
sshAuthMode: "认证",
sshAuthKey: "密钥",
sshAuthPassword: "密码",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index b3a4f5107..9f1a16b1f 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1218,6 +1218,10 @@ sklm: {
sshUser: "使用者",
sshPort: "連接埠",
sshIdentityFile: "私密金鑰",
+ sshIdentityFileChoose: "選擇檔案",
+ sshIdentityFilePlaceholder: "未選擇檔案",
+ sshIdentityFileClear: "清除",
+ sshIdentityFileError: "無法讀取所選檔案的路徑。",
sshAuthMode: "認證",
sshAuthKey: "金鑰",
sshAuthPassword: "密碼",