Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(settings): present remote host forms in dialogs
vastsa043c71548f53
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsxindex c25e6485a..2bb5ae35d 100644--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx@@ -15,7 +15,17 @@ import type { RemoteHostSshAuth, RemoteHostSummary } from "@pi-desktop/shared";import { api } from "../../lib/api";import { remoteHostErrorKey } from "../../lib/remote-host-errors";import { useAppStore } from "../../stores/app-store";-import { Badge, Button, Field, Input, PasswordInput, SegmentedControl, cx } from "../ui";+import {+ Badge,+ Button,+ Field,+ Input,+ PasswordInput,+ SegmentedControl,+ cx,+ portalOverlay,+} from "../ui";+import { IconLink, IconPlus } from "../icons";type AddMode = "ssh" | "pair";@@ -70,6 +80,9 @@ export function RemoteHostsPage() {const [sshForm, setSshForm] = useState<SshForm>(EMPTY_SSH_FORM);const [installing, setInstalling] = useState(false);const [addMode, setAddMode] = useState<AddMode | null>(null);+ const sshAddActionRef = useRef<HTMLButtonElement>(null);+ const pairAddActionRef = useRef<HTMLButtonElement>(null);+ const pendingAddFocus = useRef<HTMLButtonElement | null>(null);const sshIdentityFileInput = useRef<HTMLInputElement>(null);const refresh = useCallback(async () => {@@ -94,10 +107,11 @@ export function RemoteHostsPage() {}, [refresh]);const closeAddForm = useCallback(() => {+ pendingAddFocus.current = addMode === "pair" ? pairAddActionRef.current : sshAddActionRef.current;setAddMode(null);setForm(EMPTY_FORM);setSshForm(EMPTY_SSH_FORM);- }, []);+ }, [addMode]);const reconnect = async (host: RemoteHostSummary) => {if (reconnecting) return;@@ -227,6 +241,24 @@ export function RemoteHostsPage() {[closeAddForm, sshForm, refresh, showToast, t],);const busy = installing || pairing;++ useEffect(() => {+ if (addMode !== null || busy) return;+ const trigger = pendingAddFocus.current;+ if (!trigger) return;+ pendingAddFocus.current = null;+ trigger.focus();+ }, [addMode, busy]);++ useEffect(() => {+ if (addMode === null) return;+ const onKeyDown = (event: KeyboardEvent) => {+ if (event.key === "Escape" && !busy) closeAddForm();+ };+ window.addEventListener("keydown", onKeyDown);+ return () => window.removeEventListener("keydown", onKeyDown);+ }, [addMode, busy, closeAddForm]);+const sshSubmitDisabled =installing ||!sshForm.host.trim() ||@@ -238,6 +270,41 @@ export function RemoteHostsPage() {return (<div className="settings-stack">{error && hosts !== null && <p role="alert">{error}</p>}+ <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>+ <div className="settings-remote-host-add-actions">+ <Button+ ref={sshAddActionRef}+ id="remote-host-add-ssh"+ type="button"+ variant="primary"+ aria-haspopup="dialog"+ onClick={() => setAddMode("ssh")}+ disabled={busy}+ >+ <span className="settings-remote-host-add-button-content">+ <IconPlus size={14} />+ <span>{t("settings.remoteHosts.addSsh")}</span>+ </span>+ </Button>+ <Button+ ref={pairAddActionRef}+ id="remote-host-add-pair"+ type="button"+ variant="secondary"+ aria-haspopup="dialog"+ onClick={() => setAddMode("pair")}+ disabled={busy}+ >+ <span className="settings-remote-host-add-button-content">+ <IconLink size={14} />+ <span>{t("settings.remoteHosts.addPair")}</span>+ </span>+ </Button>+ </div>+ </div>+ </section><divclassName="settings-remote-host-list"role="list"@@ -300,261 +367,254 @@ export function RemoteHostsPage() {)}</div>- <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>- <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 settings-remote-host-add-shell"- hidden={addMode === null}- >- <form- id="remote-host-add-panel-ssh"- role="region"- aria-labelledby="remote-host-add-ssh"- hidden={addMode !== "ssh"}- className="settings-remote-host-form settings-remote-host-add-panel"- onSubmit={submitSsh}+ {addMode !== null &&+ portalOverlay(+ <div+ className="overlay settings-remote-host-add-overlay"+ role="presentation"+ onClick={(event) => {+ if (event.target === event.currentTarget && !busy) closeAddForm();+ }}>- <div className="settings-remote-host-form-row">- <Field label={t("settings.remoteHosts.fieldLabel")}>- <Input- value={sshForm.label}- onChange={(event) =>- setSshForm((prev) => ({ ...prev, label: event.target.value }))- }- placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}- aria-label={t("settings.remoteHosts.fieldLabel")}- autoComplete="off"- spellCheck={false}- disabled={installing}- />- </Field>- <Field label={t("settings.remoteHosts.sshHost")}>- <Input- value={sshForm.host}- onChange={(event) =>- setSshForm((prev) => ({ ...prev, host: event.target.value }))- }- placeholder={t("settings.remoteHosts.sshHostPlaceholder")}- aria-label={t("settings.remoteHosts.sshHost")}- autoComplete="off"- autoCapitalize="off"- spellCheck={false}- disabled={installing}- />- </Field>- </div>-- <div className="settings-remote-host-form-row is-narrow-port">- <Field label={t("settings.remoteHosts.sshUser")}>- <Input- value={sshForm.user}- onChange={(event) =>- setSshForm((prev) => ({ ...prev, user: event.target.value }))- }- aria-label={t("settings.remoteHosts.sshUser")}- autoComplete="off"- autoCapitalize="off"- spellCheck={false}- disabled={installing}- />- </Field>- <Field label={t("settings.remoteHosts.sshPort")}>- <Input- value={sshForm.port}- onChange={(event) =>- setSshForm((prev) => ({ ...prev, port: event.target.value }))- }- aria-label={t("settings.remoteHosts.sshPort")}- inputMode="numeric"- autoComplete="off"- spellCheck={false}- disabled={installing}- />- </Field>- </div>-- <div className="settings-remote-host-form-auth">- <div- className="text-sm text-text-secondary"- id="settings-remote-host-auth-label"+ <div+ className="dialog settings-remote-host-add-dialog"+ role="dialog"+ aria-modal="true"+ aria-labelledby="settings-remote-host-add-dialog-title"+ onClick={(event) => event.stopPropagation()}+ >+ <h3+ id="settings-remote-host-add-dialog-title"+ className="settings-remote-host-add-dialog-title">- {t("settings.remoteHosts.sshAuthMode")}- </div>- <SegmentedControl- value={sshForm.auth}- onChange={(auth) => selectSshAuth(auth)}- options={[- { value: "key", label: t("settings.remoteHosts.sshAuthKey") },- { value: "password", label: t("settings.remoteHosts.sshAuthPassword") },- ]}- label={t("settings.remoteHosts.sshAuthMode")}- disabled={installing}- />- </div>+ {t("settings.remoteHosts.addTitle")} · {t(+ addMode === "ssh" ? "settings.remoteHosts.addSsh" : "settings.remoteHosts.addPair",+ )}+ </h3>+ <form+ id="remote-host-add-panel-ssh"+ aria-labelledby="settings-remote-host-add-dialog-title"+ hidden={addMode !== "ssh"}+ className="settings-remote-host-form settings-remote-host-add-panel"+ onSubmit={submitSsh}+ >+ <div className="settings-remote-host-form-row">+ <Field label={t("settings.remoteHosts.fieldLabel")}>+ <Input+ value={sshForm.label}+ autoFocus={addMode === "ssh"}+ onChange={(event) =>+ setSshForm((prev) => ({ ...prev, label: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}+ aria-label={t("settings.remoteHosts.fieldLabel")}+ autoComplete="off"+ spellCheck={false}+ disabled={installing}+ />+ </Field>+ <Field label={t("settings.remoteHosts.sshHost")}>+ <Input+ value={sshForm.host}+ onChange={(event) =>+ setSshForm((prev) => ({ ...prev, host: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.sshHostPlaceholder")}+ aria-label={t("settings.remoteHosts.sshHost")}+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ disabled={installing}+ />+ </Field>+ </div>- {sshForm.auth === "key" ? (- <Field label={t("settings.remoteHosts.sshIdentityFile")}>- <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: "" }))}+ <div className="settings-remote-host-form-row is-narrow-port">+ <Field label={t("settings.remoteHosts.sshUser")}>+ <Input+ value={sshForm.user}+ onChange={(event) =>+ setSshForm((prev) => ({ ...prev, user: event.target.value }))+ }+ aria-label={t("settings.remoteHosts.sshUser")}+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ disabled={installing}+ />+ </Field>+ <Field label={t("settings.remoteHosts.sshPort")}>+ <Input+ value={sshForm.port}+ onChange={(event) =>+ setSshForm((prev) => ({ ...prev, port: event.target.value }))+ }+ aria-label={t("settings.remoteHosts.sshPort")}+ inputMode="numeric"+ autoComplete="off"+ spellCheck={false}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}+ />+ </Field>+ </div>++ <div className="settings-remote-host-form-auth">+ <div+ className="text-sm text-text-secondary"+ id="settings-remote-host-auth-label"+ >+ {t("settings.remoteHosts.sshAuthMode")}+ </div>+ <SegmentedControl+ value={sshForm.auth}+ onChange={(auth) => selectSshAuth(auth)}+ options={[+ { value: "key", label: t("settings.remoteHosts.sshAuthKey") },+ { value: "password", label: t("settings.remoteHosts.sshAuthPassword") },+ ]}+ label={t("settings.remoteHosts.sshAuthMode")}disabled={installing}/></div>- </Field>- ) : (- <Field label={t("settings.remoteHosts.sshPassword")}>- <PasswordInput- value={sshForm.password}- onChange={(event) =>- setSshForm((prev) => ({ ...prev, password: event.target.value }))- }- placeholder={t("settings.remoteHosts.sshPasswordPlaceholder")}- aria-label={t("settings.remoteHosts.sshPassword")}- autoComplete="off"- spellCheck={false}- disabled={installing}- showLabel={t("settings.remoteHosts.sshShowPassword")}- hideLabel={t("settings.remoteHosts.sshHidePassword")}- />- </Field>- )}- <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")- : t("settings.remoteHosts.sshAction")}- </Button>- </div>- </form>+ {sshForm.auth === "key" ? (+ <Field label={t("settings.remoteHosts.sshIdentityFile")}>+ <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")}>+ <PasswordInput+ value={sshForm.password}+ onChange={(event) =>+ setSshForm((prev) => ({ ...prev, password: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.sshPasswordPlaceholder")}+ aria-label={t("settings.remoteHosts.sshPassword")}+ autoComplete="off"+ spellCheck={false}+ disabled={installing}+ showLabel={t("settings.remoteHosts.sshShowPassword")}+ hideLabel={t("settings.remoteHosts.sshHidePassword")}+ />+ </Field>+ )}- <form- id="remote-host-add-panel-pair"- role="region"- aria-labelledby="remote-host-add-pair"- hidden={addMode !== "pair"}- className="settings-remote-host-form settings-remote-host-add-panel"- onSubmit={submit}- >- <div className="settings-remote-host-form-row">- <Field label={t("settings.remoteHosts.fieldLabel")}>- <Input- value={form.label}- onChange={(event) =>- setForm((prev) => ({ ...prev, label: event.target.value }))- }- placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}- aria-label={t("settings.remoteHosts.fieldLabel")}- autoComplete="off"- spellCheck={false}- disabled={pairing}- />- </Field>- <Field label={t("settings.remoteHosts.fieldUrl")}>- <Input- value={form.url}- onChange={(event) =>- setForm((prev) => ({ ...prev, url: event.target.value }))- }- placeholder={t("settings.remoteHosts.fieldUrlPlaceholder")}- aria-label={t("settings.remoteHosts.fieldUrl")}- inputMode="url"- autoComplete="off"- autoCapitalize="off"- spellCheck={false}- disabled={pairing}- />- </Field>- </div>- <Field label={t("settings.remoteHosts.fieldPairingToken")}>- <Input- value={form.pairingToken}- onChange={(event) =>- setForm((prev) => ({ ...prev, pairingToken: event.target.value }))- }- placeholder={t("settings.remoteHosts.fieldPairingTokenPlaceholder")}- aria-label={t("settings.remoteHosts.fieldPairingToken")}- autoComplete="off"- autoCapitalize="off"- spellCheck={false}- type="password"- disabled={pairing}- />- </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")- : t("settings.remoteHosts.pair")}- </Button>+ <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")+ : t("settings.remoteHosts.sshAction")}+ </Button>+ </div>+ </form>++ <form+ id="remote-host-add-panel-pair"+ aria-labelledby="settings-remote-host-add-dialog-title"+ hidden={addMode !== "pair"}+ className="settings-remote-host-form settings-remote-host-add-panel"+ onSubmit={submit}+ >+ <div className="settings-remote-host-form-row">+ <Field label={t("settings.remoteHosts.fieldLabel")}>+ <Input+ value={form.label}+ autoFocus={addMode === "pair"}+ onChange={(event) =>+ setForm((prev) => ({ ...prev, label: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.fieldLabelPlaceholder")}+ aria-label={t("settings.remoteHosts.fieldLabel")}+ autoComplete="off"+ spellCheck={false}+ disabled={pairing}+ />+ </Field>+ <Field label={t("settings.remoteHosts.fieldUrl")}>+ <Input+ value={form.url}+ onChange={(event) =>+ setForm((prev) => ({ ...prev, url: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.fieldUrlPlaceholder")}+ aria-label={t("settings.remoteHosts.fieldUrl")}+ inputMode="url"+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ disabled={pairing}+ />+ </Field>+ </div>+ <Field label={t("settings.remoteHosts.fieldPairingToken")}>+ <Input+ value={form.pairingToken}+ onChange={(event) =>+ setForm((prev) => ({ ...prev, pairingToken: event.target.value }))+ }+ placeholder={t("settings.remoteHosts.fieldPairingTokenPlaceholder")}+ aria-label={t("settings.remoteHosts.fieldPairingToken")}+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ type="password"+ disabled={pairing}+ />+ </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")+ : t("settings.remoteHosts.pair")}+ </Button>+ </div>+ </form></div>- </form>- </div>- </section>+ </div>,+ )}</div>);}diff --git a/apps/desktop/src/styles/settings.css b/apps/desktop/src/styles/settings.cssindex 4dfda13c1..27f0e985d 100644--- a/apps/desktop/src/styles/settings.css+++ b/apps/desktop/src/styles/settings.css@@ -1026,8 +1026,40 @@gap: 8px;}-.settings-remote-host-add-shell[hidden] {- display: none;+.settings-remote-host-add-button-content {+ display: inline-flex;+ align-items: center;+ gap: 8px;+}++.settings-remote-host-add-overlay {+ z-index: 45;+}++.settings-remote-host-add-dialog {+ display: flex;+ flex-direction: column;+ gap: 12px;+ width: min(100%, 640px);+ max-height: min(90vh, 760px);+ overflow: hidden;+ padding: 16px;+}++.settings-remote-host-add-dialog-title {+ margin: 0;+ color: var(--ds-text-primary);+ font-size: var(--text-base-plus);+ font-weight: var(--font-weight-semibold);+ line-height: var(--leading-tight);+}++.settings-remote-host-add-dialog .settings-remote-host-form {+ min-height: 0;+ overflow-x: hidden;+ overflow-y: auto;+ padding: 2px 2px 2px 0;+ overscroll-behavior: contain;}.settings-remote-host-form {diff --git a/apps/desktop/test/settings-remote-hosts.test.mjs b/apps/desktop/test/settings-remote-hosts.test.mjsindex 30aa4bc4c..d513c980f 100644--- a/apps/desktop/test/settings-remote-hosts.test.mjs+++ b/apps/desktop/test/settings-remote-hosts.test.mjs@@ -28,26 +28,35 @@ function cssRule(selector) {return styles.slice(from, styles.indexOf("}", from));}-test("remote hosts keeps Add actions visible and reveals one form on demand", () => {+test("remote hosts puts Add actions before the inventory and opens dialog forms", () => {assert.match(page, /useState<AddMode \| null>\(null\)/);assert.doesNotMatch(page, /role="tablist"/);+ const actionsIndex = page.indexOf('className="settings-remote-host-add-actions"');+ const inventoryIndex = page.indexOf('className="settings-remote-host-list"');+ assert.ok(actionsIndex >= 0 && actionsIndex < inventoryIndex, "Add actions should precede the inventory");for (const mode of ["ssh", "pair"]) {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('aria-haspopup="dialog"'));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, /className="settings-panel settings-remote-host-add-shell"\s+hidden=\{addMode === null\}/);+ assert.match(page, /portalOverlay\(/);+ assert.match(page, /className="dialog settings-remote-host-add-dialog"/);+ assert.match(page, /aria-modal="true"/);+ assert.match(page, /aria-labelledby="settings-remote-host-add-dialog-title"/);+ assert.match(page, /event.key === "Escape"/);+ assert.match(page, /pendingAddFocus\.current = addMode === "pair"/);+ assert.match(page, /pendingAddFocus\.current = null;\s+trigger\.focus\(\)/);assert.match(page, /onClick=\{closeAddForm\}/);assert.match(page, /setSshForm\(EMPTY_SSH_FORM\)/);+ assert.doesNotMatch(page, /settings-remote-host-add-shell/);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-dialog"), /width:\s*min\(100%, 640px\)/);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.mdindex 33051b273..4008c550a 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -86,9 +86,10 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (unified Create project dialog with Remote selected and that host preselected;selecting an absolute directory creates a locally managed project bound tothe remote workspace. The inventory does not list or create conversations.- 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+ The Add action row precedes the inventory; SSH installation and existing-host+ pairing open an accessible dialog. Cancel, Escape, backdrop dismissal, and+ successful submission close it and clear the draft, returning focus to its+ trigger. SSH hosts offer eligible-providercopy with empty selection and explicit credential-copy consent. Remote chatuses Host defaults and never activates local workspaces.The narrow MVP supports text, tool/input responses and read-only files/diffs;diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 04f9fb006..e9357dd67 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -14798,22 +14798,25 @@ browser milestones are scheduled.renderer harness can return a successful pair result without network access.- **Steps**: 1) Open Settings with developer mode off and confirm Remote Hostsand its search hits are available. 2) Open the page and confirm the rail and- 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.+ title carry the Experimental badge. 3) Confirm the SSH and Pair action row is+ above the inventory and neither dialog is open. Open SSH; verify the dialog is+ named, modal, and focuses its first field. Cancel and confirm focus returns to+ SSH. Open Pair, submit the fixture pairing form, and confirm success closes+ the dialog and clears the draft. Change language and confirm action labels+ update. Reopen Pair, enter a draft, cancel, and confirm the dialog closes and+ the draft clears. Open SSH password mode, enter a fixture password, cancel,+ reopen, and confirm the password is empty. Press Escape and verify the dialog+ closes and focus returns to SSH. 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.- **Expected**: Experimental availability is consistent across packaged and- 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.+ development builds. Add actions precede inventory; the forms open in the+ shared modal surface, one at a time. Cancel, Escape, backdrop dismissal, and+ successful submission close the dialog and clear drafts; focus returns to the+ initiating action. 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.2diff --git a/scripts/e2e/remote-mvp-ui.jsx b/scripts/e2e/remote-mvp-ui.jsxindex c2276cbd6..7c43a219e 100644--- a/scripts/e2e/remote-mvp-ui.jsx+++ b/scripts/e2e/remote-mvp-ui.jsx@@ -70,6 +70,34 @@ function type(node, value) {node.dispatchEvent(new Event("input", { bubbles: true }));}function emit(payload) { for (const listener of listeners.get(IPC.event.remoteInteractions) ?? []) listener(payload); }+function waitForFocus(target, message) {+ if (document.activeElement === target) return Promise.resolve();+ return new Promise((resolve, reject) => {+ let frame = 0;+ const cleanup = () => {+ document.removeEventListener("focusin", check);+ clearTimeout(timer);+ if (frame) cancelAnimationFrame(frame);+ };+ const finishIfFocused = () => {+ if (document.activeElement !== target) return false;+ cleanup();+ resolve();+ return true;+ };+ const check = () => {+ if (finishIfFocused()) return;+ frame = requestAnimationFrame(check);+ };+ const timer = setTimeout(() => {+ cleanup();+ const active = document.activeElement;+ reject(new Error(`${message}; active=${active?.outerHTML ?? "none"}; target=${target.outerHTML}; connected=${target.isConnected}; disabled=${target.disabled}`));+ }, 5000);+ document.addEventListener("focusin", check);+ frame = requestAnimationFrame(check);+ });+}function Fixture() {const active = useAppStore(state => state.activeSessionId);const current = useAppStore(state => state.sessions.find(item => item.id === active));@@ -127,71 +155,91 @@ globalThis.remoteMvpProbe = async () => {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 addActions = document.querySelector(".settings-remote-host-add-actions");+ const hostList = document.querySelector(".settings-remote-host-list");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");+ const dialog = () => document.querySelector('.settings-remote-host-add-dialog[role="dialog"]');+ const sshPanel = () => dialog()?.querySelector("#remote-host-add-panel-ssh");+ const pairPanel = () => dialog()?.querySelector("#remote-host-add-panel-pair");+ const settingsLabels = () => catalogs[i18n.language === "zh-CN" ? "zh-CN" : "en"].settings.remoteHosts;+ const inputFor = (panel, key) => [...(panel?.querySelectorAll("input") ?? [])]+ .find(field => field.getAttribute("aria-label") === settingsLabels()[key]);+ const cancelButton = panel => panel?.querySelector('.settings-remote-host-form-actions button[type="button"]');+ assert(addActions && hostList && sshAction && pairAction && !dialog(), "Add actions or initial inventory state are missing");+ assert(addActions.compareDocumentPosition(hostList) & Node.DOCUMENT_POSITION_FOLLOWING, "Add actions should precede the inventory");+ assert(sshAction.getAttribute("aria-haspopup") === "dialog" && pairAction.getAttribute("aria-haspopup") === "dialog", "Add actions are not dialog triggers");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");+ await until(() => dialog() && sshPanel() && !sshPanel().hidden, "SSH action did not open its dialog form");+ assert(dialog().getAttribute("aria-modal") === "true", "SSH form is not modal");+ await waitForFocus(inputFor(sshPanel(), "fieldLabel"), "SSH dialog did not focus its first field");+ cancelButton(sshPanel()).click();+ await until(() => !dialog(), "Cancel did not close the SSH dialog");+ await waitForFocus(sshAction, "Closing SSH dialog did not restore trigger focus");- 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");+ pairAction.click();+ await until(() => dialog() && pairPanel() && !pairPanel().hidden, "Pair action did not open its dialog form");+ assert(sshPanel().hidden, "SSH form remained exposed in the Pair dialog");+ const pairLabel = () => inputFor(pairPanel(), "fieldLabel");+ const pairUrl = () => inputFor(pairPanel(), "fieldUrl");+ const pairToken = () => inputFor(pairPanel(), "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(() => !dialog() && calls.some(call => call.channel === IPC.invoke.remoteHostPair), "successful pairing did not close the dialog");+ await waitForFocus(pairAction, "Pair success did not restore trigger focus");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");+ assert(pairAction.getAttribute("aria-haspopup") === "dialog", "Pair action lost dialog semantics after locale change");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");+ await until(() => dialog() && pairPanel() && !pairPanel().hidden, "Pair dialog did not reopen");+ assert(pairLabel().value === "", "Successful pairing retained the previous draft");+ type(pairLabel(), "Discarded draft");+ cancelButton(pairPanel()).click();+ await until(() => !dialog(), "Cancel did not close the Pair dialog");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);+ await until(() => dialog() && pairPanel() && !pairPanel().hidden, "Pair dialog did not reopen after cancel");+ assert(pairLabel().value === "", "Cancel retained the Pair draft");+ window.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));+ await until(() => !dialog(), "Escape did not close the Pair dialog");+ await waitForFocus(pairAction, "Escape did not restore Pair trigger focus");++ const passwordModeAction = () => [...(sshPanel()?.querySelectorAll("button") ?? [])]+ .find(action => action.textContent.trim() === settingsLabels().sshAuthPassword);+ const sshPasswordInput = () => inputFor(sshPanel(), "sshPassword");sshAction.click();- await until(() => !sshPanel.hidden, "SSH action did not reveal its form");- await until(() => passwordModeAction(), "SSH password mode was missing");+ await until(() => dialog() && sshPanel() && !sshPanel().hidden, "SSH dialog did not reopen");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");+ cancelButton(sshPanel()).click();+ await until(() => !dialog(), "Cancel did not close the SSH password dialog");sshAction.click();- await until(() => !sshPanel.hidden, "SSH form did not reopen after cancel");+ await until(() => dialog() && sshPanel() && !sshPanel().hidden, "SSH password dialog did not reopen");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");+ type(sshPasswordInput(), "temporary-backdrop-password");+ document.querySelector(".settings-remote-host-add-overlay").click();+ await until(() => !dialog(), "Backdrop click did not close the dialog");+ await waitForFocus(sshAction, "Backdrop dismissal did not restore SSH trigger focus");+ sshAction.click();+ await until(() => dialog() && sshPanel() && !sshPanel().hidden, "SSH dialog did not reopen after backdrop dismissal");+ passwordModeAction().click();+ await until(() => sshPasswordInput(), "SSH password field did not reopen after backdrop dismissal");+ assert(sshPasswordInput().value === "", "Backdrop dismissal retained the SSH password draft");+ window.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));+ await until(() => !dialog(), "Escape did not close the SSH dialog");+ await waitForFocus(sshAction, "Final Escape did not restore SSH trigger focus");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"] };+ return { ok: true, scenarios: ["history without model transfer", "open", "send", "approve", "peer resolution", "reconnect without replay", "local isolation", "Add actions precede inventory", "SSH and Pair dialog flows", "success and cancel clear drafts", "Escape and backdrop dismissal", "focus restoration", "cleanup"] };};