Skip to content

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

feat(settings): make remote host forms action-driven

vastsa93833e2e9237
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
index 1ee49939a..f6f86013e 100644
--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx
+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
@@ -2,10 +2,10 @@
* Settings destination for paired remote `pi-host` machines (R2b pairing UX,
* ADR 0286 §Registry).
*
- * Inventory of `<dataDir>/remote-hosts.json` plus one Add form: SSH install
- * first, URL + pairing token second. Instructional copy stays out of the
- * renderer. The destination is marked Experimental on the settings rail and
- * page title; pairing and SSH bootstrap still call the same IPC. A password
+ * Inventory of `<dataDir>/remote-hosts.json` plus two Add actions that reveal
+ * the SSH install or URL + pairing-token form on demand. Instructional copy
+ * stays out of the renderer. The destination is marked Experimental on the
+ * rail and page title; pairing and SSH bootstrap still call the same IPC. A password
* typed into the SSH form lives in this component's state only; it is never
* persisted or logged here.
*/
@@ -70,7 +70,7 @@ export function RemoteHostsPage() {
const [removing, setRemoving] = useState<string | null>(null);
const [sshForm, setSshForm] = useState<SshForm>(EMPTY_SSH_FORM);
const [installing, setInstalling] = useState(false);
- const [addMode, setAddMode] = useState<AddMode>("ssh");
+ const [addMode, setAddMode] = useState<AddMode | null>(null);
const refresh = useCallback(async () => {
const generation = ++refreshGeneration.current;
@@ -93,6 +93,12 @@ export function RemoteHostsPage() {
return () => { alive.current = false; refreshGeneration.current++; unsubscribe(); };
}, [refresh]);
+ const closeAddForm = useCallback(() => {
+ setAddMode(null);
+ setForm(EMPTY_FORM);
+ setSshForm(EMPTY_SSH_FORM);
+ }, []);
+
const reconnect = async (host: RemoteHostSummary) => {
if (reconnecting) return;
setReconnecting(host.hostKey);
@@ -120,7 +126,7 @@ export function RemoteHostsPage() {
showToast(t("settings.remoteHosts.pairSucceeded", { label: result.host.label }), {
variant: "info",
});
- setForm(EMPTY_FORM);
+ closeAddForm();
await refresh();
} catch (caught) {
const message = t(remoteHostErrorKey(caught));
@@ -129,7 +135,7 @@ export function RemoteHostsPage() {
setPairing(false);
}
},
- [form, refresh, showToast, t],
+ [closeAddForm, form, refresh, showToast, t],
);
const remove = useCallback(
@@ -191,8 +197,7 @@ export function RemoteHostsPage() {
showToast(t("settings.remoteHosts.sshSucceeded", { label: result.host.label }), {
variant: "info",
});
- // Drops the password with the rest of the draft.
- setSshForm(EMPTY_SSH_FORM);
+ closeAddForm();
await refresh();
} catch (caught) {
const message = t(remoteHostErrorKey(caught));
@@ -201,7 +206,7 @@ export function RemoteHostsPage() {
setInstalling(false);
}
},
- [sshForm, refresh, showToast, t],
+ [closeAddForm, sshForm, refresh, showToast, t],
);
const busy = installing || pairing;
const sshSubmitDisabled =
@@ -281,22 +286,38 @@ export function RemoteHostsPage() {
<section className="settings-card-block">
<div className="settings-card-heading-row settings-remote-host-add-heading">
<h3 className="settings-card-heading">{t("settings.remoteHosts.addTitle")}</h3>
- <SegmentedControl
- value={addMode}
- onChange={(mode) => setAddMode(mode)}
- options={[
- { value: "ssh", label: t("settings.remoteHosts.addSsh"), id: "remote-host-add-ssh", controls: "remote-host-add-panel-ssh" },
- { value: "pair", label: t("settings.remoteHosts.addPair"), id: "remote-host-add-pair", controls: "remote-host-add-panel-pair" },
- ]}
- label={t("settings.remoteHosts.addTitle")}
- role="tablist"
- disabled={busy}
- />
+ <div className="settings-remote-host-add-actions">
+ <Button
+ id="remote-host-add-ssh"
+ type="button"
+ variant={addMode === "ssh" ? "secondary" : "ghost"}
+ aria-expanded={addMode === "ssh"}
+ aria-controls="remote-host-add-panel-ssh"
+ onClick={() => setAddMode("ssh")}
+ disabled={busy}
+ >
+ {t("settings.remoteHosts.addSsh")}
+ </Button>
+ <Button
+ id="remote-host-add-pair"
+ type="button"
+ variant={addMode === "pair" ? "secondary" : "ghost"}
+ aria-expanded={addMode === "pair"}
+ aria-controls="remote-host-add-panel-pair"
+ onClick={() => setAddMode("pair")}
+ disabled={busy}
+ >
+ {t("settings.remoteHosts.addPair")}
+ </Button>
+ </div>
</div>
- <div className="settings-panel">
+ <div
+ className="settings-panel settings-remote-host-add-shell"
+ hidden={addMode === null}
+ >
<form
id="remote-host-add-panel-ssh"
- role="tabpanel"
+ role="region"
aria-labelledby="remote-host-add-ssh"
hidden={addMode !== "ssh"}
className="settings-remote-host-form settings-remote-host-add-panel"
@@ -413,6 +434,9 @@ export function RemoteHostsPage() {
)}
<div className="settings-remote-host-form-actions">
+ <Button type="button" variant="ghost" disabled={installing} onClick={closeAddForm}>
+ {t("common.cancel")}
+ </Button>
<Button type="submit" variant="primary" disabled={sshSubmitDisabled}>
{installing
? t("settings.remoteHosts.sshRunning")
@@ -423,7 +447,7 @@ export function RemoteHostsPage() {
<form
id="remote-host-add-panel-pair"
- role="tabpanel"
+ role="region"
aria-labelledby="remote-host-add-pair"
hidden={addMode !== "pair"}
className="settings-remote-host-form settings-remote-host-add-panel"
@@ -475,6 +499,9 @@ export function RemoteHostsPage() {
/>
</Field>
<div className="settings-remote-host-form-actions">
+ <Button type="button" variant="ghost" disabled={pairing} onClick={closeAddForm}>
+ {t("common.cancel")}
+ </Button>
<Button type="submit" variant="primary" disabled={pairSubmitDisabled}>
{pairing
? t("settings.remoteHosts.pairing")
diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.css
index 89609046b..b216d389f 100644
--- a/apps/desktop/src/styles/settings.css
+++ b/apps/desktop/src/styles/settings.css
@@ -931,9 +931,9 @@
}
/*
- Remote hosts: inventory tiles, one Add form with SSH/Pair tabs, and
- Experimental rows. The form keeps a two-column grid; host cards are
- inventory rows rather than settings-copy + control.
+ Remote hosts: inventory tiles, explicit Add actions with on-demand SSH/Pair
+ forms, and Experimental rows. The form keeps a two-column grid; host cards
+ are inventory rows rather than settings-copy + control.
*/
.settings-remote-host-list {
display: grid;
@@ -1018,6 +1018,18 @@
margin-bottom: 0;
}
+.settings-remote-host-add-actions {
+ display: inline-flex;
+ align-items: center;
+ flex-wrap: wrap;
+ justify-content: flex-end;
+ gap: 8px;
+}
+
+.settings-remote-host-add-shell[hidden] {
+ display: none;
+}
+
.settings-remote-host-form {
display: grid;
gap: 12px;
diff --git a/apps/desktop/test/settings-remote-hosts.test.mjs b/apps/desktop/test/settings-remote-hosts.test.mjs
index b7d185cd5..234158206 100644
--- a/apps/desktop/test/settings-remote-hosts.test.mjs
+++ b/apps/desktop/test/settings-remote-hosts.test.mjs
@@ -1,9 +1,9 @@
/**
* Settings ▸ Remote Hosts page contract.
*
- * Guards the compact inventory + Add (SSH/Pair) layout: no instructional
- * copy, both add modes stay mounted behind `hidden`, and the destination is
- * marked Experimental on the rail and page title.
+ * Guards the compact inventory + on-demand Add (SSH/Pair) forms: no
+ * instructional copy, both forms are hidden until selected, and the
+ * destination is marked Experimental on the rail and page title.
*/
import { readFileSync } from "node:fs";
import assert from "node:assert/strict";
@@ -28,20 +28,26 @@ function cssRule(selector) {
return styles.slice(from, styles.indexOf("}", from));
}
-test("remote hosts is an inventory plus one SSH/Pair add form", () => {
- assert.match(page, /role="tablist"/);
+test("remote hosts keeps Add actions visible and reveals one form on demand", () => {
+ assert.match(page, /useState<AddMode \| null>\(null\)/);
+ assert.doesNotMatch(page, /role="tablist"/);
for (const mode of ["ssh", "pair"]) {
- assert.ok(page.includes(`id: "remote-host-add-${mode}"`));
- assert.ok(page.includes(`controls: "remote-host-add-panel-${mode}"`));
+ assert.ok(page.includes(`id="remote-host-add-${mode}"`));
+ assert.ok(page.includes(`aria-expanded={addMode === "${mode}"}`));
+ assert.ok(page.includes(`aria-controls="remote-host-add-panel-${mode}"`));
+ assert.ok(page.includes(`onClick={() => setAddMode("${mode}")}`));
+ assert.ok(page.includes(`id="remote-host-add-panel-${mode}"`));
+ assert.ok(page.includes(`hidden={addMode !== "${mode}"}`));
}
- assert.match(page, /id={`remote-host-add-panel-\$\{mode\}`}|id="remote-host-add-panel-ssh"/);
- assert.match(page, /hidden=\{addMode !== "ssh"\}/);
- assert.match(page, /hidden=\{addMode !== "pair"\}/);
+ assert.match(page, /className="settings-panel settings-remote-host-add-shell"\s+hidden=\{addMode === null\}/);
+ assert.match(page, /onClick=\{closeAddForm\}/);
+ assert.match(page, /setSshForm\(EMPTY_SSH_FORM\)/);
assert.match(page, /api\.bootstrapRemoteHost\(/);
assert.match(page, /api\.pairRemoteHost\(/);
assert.match(page, /api\.listRemoteHosts\(/);
assert.match(page, /api\.removeRemoteHost\(/);
+ assert.match(cssRule(".settings-remote-host-add-shell[hidden]"), /display:\s*none/);
assert.match(cssRule(".settings-remote-host-add-panel[hidden]"), /display:\s*none/);
assert.match(cssRule(".settings-remote-host-card"), /background:\s*var\(--ds-tile\)/);
assert.match(cssRule(".settings-remote-host-name"), /font-size:\s*var\(--text-md-plus\)/);
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 5fcb526eb..3080d88ea 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -82,9 +82,12 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (
- **Remote Hosts / 远程主机** is an Experimental destination in all builds,
independent of developer mode. The rail, page and search hits remain available.
The row and title carry `settings.remoteHosts.experimental`. After pairing,
- each host offers reconnect and an inline project/session workbench. SSH hosts
- offer eligible-provider copy with empty selection and explicit credential-copy
- consent. Remote chat uses Host defaults and never activates local workspaces.
+ each host offers reconnect and an inline project/session workbench. The
+ inventory is the default view; SSH installation and existing-host pairing are
+ explicit actions that reveal one form on demand. Cancel and successful submission
+ close the form and clear its draft. SSH hosts offer eligible-provider copy with
+ empty selection and explicit credential-copy consent. Remote chat uses Host
+ defaults and never activates local workspaces.
The narrow MVP supports text, tool/input responses and read-only files/diffs;
terminal, attachments, local model controls and local plugin/MCP actions are absent.
- Loaded plugin Settings entries may appear only in a final **Extensions** group
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 76d9ab096..8b4a77575 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -9781,6 +9781,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| Security (plugin real-time capabilities) | E2E-PLUGIN-global-shortcut-owns-only-its-own-command, E2E-PLUGIN-permission-gate-for-real-time-capabilities, E2E-PLUGIN-background-audio-and-realtime-connection |
| C — Conversation & stream (disclosure reading position) | E2E-CHAT-disclosure-toggle-keeps-reading-position |
| E — Tools & permissions (disclosure reading position) | E2E-CHAT-disclosure-toggle-keeps-reading-position |
+| D (surfaces) / Quality — Remote-host Add and Pair form disclosure | E2E-REMOTE-HOST-settings-compact-inventory |
| E — Tools & permissions (capability level move) | E2E-CAPABILITY-move-across-levels |
| F — Persistence (capability level move) | E2E-CAPABILITY-move-across-levels |
| Quality (capability level move) | E2E-CAPABILITY-move-across-levels |
@@ -9812,7 +9813,7 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.
| Post-MVP | E2E-022A, E2E-022B, E2E-022C, E2E-024I, E2E-024J, E2E-024K, E2E-024L, E2E-024M (plugin roadmap R2/R3/R6) |
| Post-baseline local automation | E2E-220 |
| Post-baseline local automation (MCP `pi_session_get` large compaction) | E2E-MCP-session-get-projects-large-compaction |
-| Post-MVP remote control | E2E-221, E2E-222, E2E-223, E2E-224, E2E-225, E2E-226, E2E-227, E2E-228, E2E-229, E2E-230, E2E-231, E2E-232 |
+| Post-MVP remote control | E2E-221, E2E-222, E2E-223, E2E-224, E2E-225, E2E-226, E2E-227, E2E-228, E2E-229, E2E-230, E2E-231, E2E-232, E2E-REMOTE-HOST-settings-compact-inventory |
| Trusted extensions (R7 v1) | E2E-DIALOG-long-text-boundaries, E2E-241, E2E-242, E2E-HOOKS-prompt-chain, E2E-HOOKS-cancel-and-dispose, E2E-TRUSTED-EXTENSION-custom-agent-stream-and-binding, E2E-243, E2E-TRUSTED-EXTENSION-temporary-session-cwd-is-scratch, E2E-244, E2E-245, E2E-PLUGIN-imported-pi-package-skills, E2E-PLUGIN-import-extension-installs-dependencies, E2E-PLUGIN-import-extension-reports-missing-dependency, E2E-PLUGIN-declared-provider-appears-in-the-native-provider-list, E2E-PLUGIN-provider-catalog-add-service |
| Trusted extensions (R7 v1 npm recovery) | E2E-PLUGIN-import-extension-recovers-missing-npm |
| Post-MVP regression coverage (plugin tool dispatch) | E2E-PLUGIN-slow-tool-is-not-cut-off-by-host-dispatch |
@@ -14783,27 +14784,35 @@ browser milestones are scheduled.
#### E2E-REMOTE-HOST-settings-compact-inventory
- **Preconditions**: The desktop Settings window can open. No paired remote
- host is required. Developer mode is off in persisted settings.
+ host is required. Developer mode is off in persisted settings. The isolated
+ renderer harness can return a successful pair result without network access.
- **Steps**: 1) Open Settings with developer mode off and confirm Remote Hosts
and its search hits are available. 2) Open the page and confirm the rail and
- title carry the Experimental badge. 3) Switch Add between SSH and Pair and
- confirm both forms stay filled and their ARIA tab/panel associations remain
- correct after changing language. 4) Toggle developer mode and confirm the
- destination stays selected and available. 5) On a paired SSH host, open the
- historical sessions browser and verify model-copy and remote-create controls
- are absent. New workspace creation stays on Home.
+ title carry the Experimental badge. 3) Confirm both Add actions are visible
+ while both forms start collapsed. Open SSH, then Pair, and verify only the
+ selected form is visible with its expanded state exposed to assistive
+ technology. Submit the fixture Pair form and confirm success closes it; reopen
+ Pair, enter a draft, cancel, and confirm it closes and clears the draft. 4)
+ Change language and confirm the action/panel associations remain correct.
+ Toggle developer mode and confirm the destination stays selected and available.
+ 5) On a paired SSH host, open the historical sessions browser and verify
+ model-copy and remote-create controls are absent. New workspace creation
+ stays on Home.
- **Expected**: Experimental availability is consistent across packaged and
- development builds. SSH remains the default Add tab. Existing pairing toasts
- remain. The inline browser preserves existing remote histories; new SSH workspace
- projects use the local model and project controls from Home.
+ development builds. No Add mode is selected by default; SSH installation and
+ pairing are explicit actions. Only the chosen form is exposed; cancel and
+ successful submission close it and clear its draft. Existing pairing toasts
+ remain. The inline browser preserves existing remote histories; new SSH
+ workspace projects use the local model and project controls from Home.
- **Specs linked**: `04-ux/06-settings-ia.md` §1, §3,
`06-delivery/07-remote-control-rollout.md` §2 R2,
`02-architecture/05-remote-agent-control.md` §5.2
- **Acceptance**: D (surfaces), Quality
- **Milestone**: Post-MVP (rollout R2b)
- **Status**: Offline coverage in `settings-remote-hosts.test.mjs` and
- `remote-mvp-renderer.test.mjs`; interaction coverage in
- `scripts/e2e-remote-mvp-ui.mjs`. Real SSH acceptance is separate.
+ `remote-mvp-renderer.test.mjs`; isolated Electron/Chromium interaction coverage
+ in `scripts/e2e-remote-mvp-ui.mjs`, including disclosure, success and cancel
+ paths. Real SSH acceptance is separate.
#### E2E-232: The outbound messaging integration relays events and commands
diff --git a/scripts/e2e/remote-mvp-ui.jsx b/scripts/e2e/remote-mvp-ui.jsx
index 91d8386e0..c2276cbd6 100644
--- a/scripts/e2e/remote-mvp-ui.jsx
+++ b/scripts/e2e/remote-mvp-ui.jsx
@@ -3,9 +3,10 @@ import { createRoot } from "react-dom/client";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import { IPC } from "@pi-desktop/shared";
-import { remoteEn } from "../../apps/desktop/src/locales/remote";
+import { remoteEn, remoteZh } from "../../apps/desktop/src/locales/remote";
import { useAppStore } from "../../apps/desktop/src/stores/app-store";
import { RemoteHostSessions } from "../../apps/desktop/src/components/settings/RemoteHostSessions";
+import { RemoteHostsPage } from "../../apps/desktop/src/components/settings/RemoteHostsPage";
import { ChatSurface } from "../../apps/desktop/src/components/ChatSurface";
import { catalogs } from "@pi-desktop/i18n";
import { api } from "../../apps/desktop/src/lib/api";
@@ -28,7 +29,9 @@ window.piDesktop = {
async invoke(channel, input) {
calls.push({ channel, input });
let data = {};
- if (channel === IPC.invoke.remoteHostProjects) data = { projects: [] };
+ if (channel === IPC.invoke.remoteHostList) data = { hosts: [host] };
+ else if (channel === IPC.invoke.remoteHostPair) data = { host: { ...host, hostKey: "paired-fixture", label: input.label, url: input.url, transport: "direct" } };
+ else if (channel === IPC.invoke.remoteHostProjects) data = { projects: [] };
else if (channel === IPC.invoke.remoteHostSessions) data = { sessions: [session] };
else if (channel === IPC.invoke.remoteHostSyncProviders) data = { imported: [{ sourceId: provider.id, providerId: "remote-provider" }], skipped: [], defaultSet: true };
else if (channel === IPC.invoke.remoteHostRegisterProject) data = { project: { id: "project", label: "Project" } };
@@ -74,7 +77,15 @@ function Fixture() {
}
globalThis.remoteMvpProbe = async () => {
- await i18n.use(initReactI18next).init({ lng: "en", fallbackLng: "en", resources: { en: { remote: remoteEn, translation: catalogs.en } }, interpolation: { escapeValue: false } });
+ await i18n.use(initReactI18next).init({
+ lng: "en",
+ fallbackLng: "en",
+ resources: {
+ en: { remote: remoteEn, translation: catalogs.en },
+ "zh-CN": { remote: remoteZh, translation: catalogs["zh-CN"] },
+ },
+ interpolation: { escapeValue: false },
+ });
useAppStore.setState({ sessions: [], activeSessionId: undefined, selectingSessionId: undefined, messages: [], retainedSessionIds: [], retainedTranscripts: {}, sessionHistory: {}, sessionMeta: {}, runningSessions: {}, pendingPlans: {}, pendingPermissions: {}, pendingAsks: {}, planningStates: {}, providers: [provider], workspace: { path: "/local/private", name: "Local only" }, activeProjectPath: "/local/private", page: "settings", settings: { defaultMode: "agent" } });
const unsubscribe = subscribeRemoteInteractions();
const root = createRoot(document.getElementById("root"));
@@ -112,5 +123,75 @@ globalThis.remoteMvpProbe = async () => {
assert(!calls.some(call => [IPC.invoke.projectActivate, IPC.invoke.sessionConfigure].includes(call.channel)), "remote UI called a local workspace/model operation");
root.unmount(); unsubscribe();
assert(listeners.size === 0, "component listeners leaked");
- return { ok: true, scenarios: ["history without model transfer", "open", "send", "approve", "peer resolution", "reconnect without replay", "local isolation", "cleanup"] };
+
+ const settingsRoot = createRoot(document.getElementById("root"));
+ settingsRoot.render(<RemoteHostsPage />);
+ await until(() => document.querySelector(".settings-remote-host-list")?.getAttribute("aria-busy") === "false", "remote hosts did not load");
+ const addShell = document.querySelector(".settings-remote-host-add-shell");
+ const sshAction = document.getElementById("remote-host-add-ssh");
+ const pairAction = document.getElementById("remote-host-add-pair");
+ const sshPanel = document.getElementById("remote-host-add-panel-ssh");
+ const pairPanel = document.getElementById("remote-host-add-panel-pair");
+ assert(addShell?.hidden && sshAction && pairAction && sshPanel && pairPanel, "add actions or initially collapsed forms are missing");
+
+ sshAction.click();
+ await until(() => !sshPanel.hidden, "SSH action did not reveal its form");
+ assert(sshAction.getAttribute("aria-expanded") === "true" && pairPanel.hidden, "SSH form state is not exposed correctly");
+ pairAction.click();
+ await until(() => !addShell.hidden && !pairPanel.hidden, "Pair action did not reveal its form");
+ assert(pairAction.getAttribute("aria-expanded") === "true" && sshPanel.hidden, "Pair form did not replace SSH form");
+
+ const pairLabel = [...pairPanel.querySelectorAll("input")].find(field => field.getAttribute("aria-label") === catalogs.en.settings.remoteHosts.fieldLabel);
+ const pairUrl = [...pairPanel.querySelectorAll("input")].find(field => field.getAttribute("aria-label") === catalogs.en.settings.remoteHosts.fieldUrl);
+ const pairToken = [...pairPanel.querySelectorAll("input")].find(field => field.getAttribute("aria-label") === catalogs.en.settings.remoteHosts.fieldPairingToken);
+ assert(pairLabel && pairUrl && pairToken, "Pair form fields are missing");
+ type(pairLabel, "Fixture host");
+ type(pairUrl, "ws://127.0.0.1:4000");
+ type(pairToken, "ppt1.fixture-token");
+ pairPanel.querySelector('button[type="submit"]').click();
+ await until(() => addShell.hidden && calls.some(call => call.channel === IPC.invoke.remoteHostPair), "successful pairing did not close the form");
+ assert(pairAction.getAttribute("aria-expanded") === "false", "Pair action remained expanded after success");
+ await i18n.changeLanguage("zh-CN");
+ const localizedPairAction = catalogs["zh-CN"].settings.remoteHosts.addPair;
+ await until(
+ () => pairAction.textContent.trim() === localizedPairAction,
+ `Pair action did not localize in ${i18n.language}: ${pairAction.textContent.trim()}`,
+ );
+ assert(pairAction.getAttribute("aria-controls") === "remote-host-add-panel-pair", "Pair association changed with locale");
+
+ pairAction.click();
+ await until(() => !pairPanel.hidden, "Pair form did not reopen");
+ assert(pairLabel.value === "", "successful pairing retained the previous draft");
+ type(pairLabel, "Discarded draft");
+ pairPanel.querySelector('.settings-remote-host-form-actions button[type="button"]').click();
+ await until(() => addShell.hidden, "Cancel did not close the Pair form");
+ pairAction.click();
+ await until(() => !pairPanel.hidden, "Pair form did not reopen after cancel");
+ assert(pairLabel.value === "", "Cancel retained the previous draft");
+ sshAction.click();
+ await until(() => !sshPanel.hidden, "SSH action did not switch back to its form");
+ const passwordModeLabel = catalogs["zh-CN"].settings.remoteHosts.sshAuthPassword;
+ const passwordLabel = catalogs["zh-CN"].settings.remoteHosts.sshPassword;
+ const passwordModeAction = () => [...sshPanel.querySelectorAll("button")]
+ .find(action => action.textContent.trim() === passwordModeLabel);
+ const sshPasswordInput = () => [...sshPanel.querySelectorAll("input")]
+ .find(field => field.getAttribute("aria-label") === passwordLabel);
+ sshAction.click();
+ await until(() => !sshPanel.hidden, "SSH action did not reveal its form");
+ await until(() => passwordModeAction(), "SSH password mode was missing");
+ passwordModeAction().click();
+ await until(() => sshPasswordInput(), "SSH password field did not appear");
+ type(sshPasswordInput(), "temporary-fixture-password");
+ sshPanel.querySelector('.settings-remote-host-form-actions button[type="button"]').click();
+ await until(() => addShell.hidden, "Cancel did not close the SSH form");
+ sshAction.click();
+ await until(() => !sshPanel.hidden, "SSH form did not reopen after cancel");
+ passwordModeAction().click();
+ await until(() => sshPasswordInput(), "SSH password field did not reopen");
+ assert(sshPasswordInput().value === "", "Cancel retained the SSH password draft");
+ sshPanel.querySelector('.settings-remote-host-form-actions button[type="button"]').click();
+ await until(() => addShell.hidden, "Cancel did not close the SSH form");
+ settingsRoot.unmount();
+ assert(listeners.size === 0, "remote hosts page listeners leaked");
+ return { ok: true, scenarios: ["history without model transfer", "open", "send", "approve", "peer resolution", "reconnect without replay", "local isolation", "host Add actions reveal one form", "pair success and cancel clear drafts", "SSH password draft clears on cancel", "cleanup"] };
};