Skip to content

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

feat(remote-hosts): create projects from host inventory

vastsaf9cbbf5c6628
diff --git a/apps/desktop/src/components/ProjectCreateDialog.tsx b/apps/desktop/src/components/ProjectCreateDialog.tsx
index 41b39c1e5..92d9d8b34 100644
--- a/apps/desktop/src/components/ProjectCreateDialog.tsx
+++ b/apps/desktop/src/components/ProjectCreateDialog.tsx
@@ -44,13 +44,14 @@ function samePath(left: string, right: string) {
export function ProjectCreateDialog() {
const { t } = useTranslation();
const open = useAppStore((state) => state.createProjectDialogOpen);
+ const initialRemoteHostKey = useAppStore((state) => state.createProjectDialogRemoteHostKey);
if (open) {
- return <ProjectCreateDialogContent />;
+ return <ProjectCreateDialogContent initialRemoteHostKey={initialRemoteHostKey} />;
}
return null;
}
-function ProjectCreateDialogContent() {
+function ProjectCreateDialogContent({ initialRemoteHostKey }: { initialRemoteHostKey?: string }) {
useBlockingOverlay();
const { t } = useTranslation();
const close = useAppStore((state) => state.closeProjectDialog);
@@ -59,7 +60,7 @@ function ProjectCreateDialogContent() {
(state) => state.createProjectFromGit,
);
const showToast = useAppStore((state) => state.showToast);
- const [source, setSource] = useState<ProjectSource>("local");
+ const [source, setSource] = useState<ProjectSource>(initialRemoteHostKey ? "remote" : "local");
const createProjectFromRemote = useAppStore((state) => state.createProjectFromRemote);
const [remoteBrowseOpen, setRemoteBrowseOpen] = useState(false);
const [remoteProject, setRemoteProject] = useState<RemoteProjectSelection | null>(null);
@@ -87,7 +88,7 @@ function ProjectCreateDialogContent() {
const projectName = resolveProjectName(name, defaultName);
useEffect(() => {
- setSource("local");
+ setSource(initialRemoteHostKey ? "remote" : "local");
setName("");
setFolders([]);
setGitUrl("");
@@ -130,7 +131,7 @@ function ProjectCreateDialogContent() {
document.body.style.overflow = previousOverflow;
if (previouslyFocused?.isConnected) previouslyFocused.focus();
};
- }, [close]);
+ }, [close, initialRemoteHostKey]);
// The first folder or the repository name fills the field until the user
// types their own name; an emptied field still falls back to it on submit.
@@ -347,7 +348,7 @@ function ProjectCreateDialogContent() {
</section>
{source === "remote" ? (
- <RemoteProjectPicker busy={busy} onChange={setRemoteProject} onBrowsingChange={setRemoteBrowseOpen} />
+ <RemoteProjectPicker busy={busy} initialHostKey={initialRemoteHostKey} onChange={setRemoteProject} onBrowsingChange={setRemoteBrowseOpen} />
) : source === "local" ? (
<ProjectFolderPicker folders={folders} busy={busy} pickerBusy={folderPickerBusy}
onAdd={() => void addFolders()}
diff --git a/apps/desktop/src/components/remote/RemoteProjectPicker.tsx b/apps/desktop/src/components/remote/RemoteProjectPicker.tsx
index d97e6b3d9..7863bea17 100644
--- a/apps/desktop/src/components/remote/RemoteProjectPicker.tsx
+++ b/apps/desktop/src/components/remote/RemoteProjectPicker.tsx
@@ -8,14 +8,15 @@ import { RemoteFolderDialog } from "./RemoteFolderDialog";
export type RemoteProjectSelection = { hostKey: string; hostLabel: string; path: string };
-export function RemoteProjectPicker({ busy, onChange, onBrowsingChange }: {
+export function RemoteProjectPicker({ busy, initialHostKey, onChange, onBrowsingChange }: {
busy: boolean;
+ initialHostKey?: string;
onChange: (selection: RemoteProjectSelection | null) => void;
onBrowsingChange: (open: boolean) => void;
}) {
const { t } = useTranslation();
const [hosts, setHosts] = useState<RemoteHostSummary[]>([]);
- const [hostKey, setHostKey] = useState("");
+ const [hostKey, setHostKey] = useState(initialHostKey ?? "");
const [path, setPath] = useState("");
const [loading, setLoading] = useState(true);
const [browseOpen, setBrowseOpen] = useState(false);
@@ -31,12 +32,12 @@ export function RemoteProjectPicker({ busy, onChange, onBrowsingChange }: {
void api.listRemoteHosts().then(({ hosts }) => {
if (!active) return;
setHosts(hosts);
- setHostKey(hosts.find((host) => host.connected)?.hostKey ?? hosts[0]?.hostKey ?? "");
+ setHostKey(hosts.find((host) => host.hostKey === initialHostKey)?.hostKey ?? hosts.find((host) => host.connected)?.hostKey ?? hosts[0]?.hostKey ?? "");
}).catch((error: unknown) => {
if (active) setError(t(remoteHostErrorKey(error)));
}).finally(() => { if (active) setLoading(false); });
return () => { active = false; selectionCallback.current(null); browsingCallback.current(false); };
- }, []);
+ }, [initialHostKey, t]);
useEffect(() => {
selectionCallback.current(host && path.trim().startsWith("/") ? { hostKey, hostLabel: host.label, path: path.trim() } : null);
diff --git a/apps/desktop/src/components/settings/RemoteHostsPage.tsx b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
index 1ee49939a..7d7e29804 100644
--- a/apps/desktop/src/components/settings/RemoteHostsPage.tsx
+++ b/apps/desktop/src/components/settings/RemoteHostsPage.tsx
@@ -16,7 +16,6 @@ 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 { RemoteHostSessions } from "./RemoteHostSessions";
type AddMode = "ssh" | "pair";
@@ -58,11 +57,11 @@ const EMPTY_SSH_FORM: SshForm = {
export function RemoteHostsPage() {
const { t } = useTranslation();
const { t: remoteT } = useTranslation("remote");
- const [selectedHost, setSelectedHost] = useState<RemoteHostSummary | null>(null);
const [reconnecting, setReconnecting] = useState<string | null>(null);
const alive = useRef(true);
const refreshGeneration = useRef(0);
const showToast = useAppStore((state) => state.showToast);
+ const openProject = useAppStore((state) => state.openProject);
const [hosts, setHosts] = useState<RemoteHostSummary[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [form, setForm] = useState<PairForm>(EMPTY_FORM);
@@ -255,8 +254,8 @@ export function RemoteHostsPage() {
<Badge tone={host.connected ? "success" : host.status === "action-required" ? "warning" : "neutral"}>
{t(remoteHostStatusKey(host))}
</Badge>
- <Button variant="secondary" onClick={() => setSelectedHost(host)}>
- {remoteT("sessions")}
+ <Button variant="secondary" onClick={() => void openProject({ remoteHostKey: host.hostKey })}>
+ {remoteT("newProject")}
</Button>
<Button variant="ghost" disabled={reconnecting !== null} onClick={() => void reconnect(host)}>
{reconnecting === host.hostKey ? remoteT("loading") : remoteT("reconnect")}
@@ -276,7 +275,6 @@ export function RemoteHostsPage() {
))
)}
</div>
- {selectedHost && <RemoteHostSessions key={selectedHost.hostKey} host={selectedHost} onClose={() => setSelectedHost(null)} />}
<section className="settings-card-block">
<div className="settings-card-heading-row settings-remote-host-add-heading">
diff --git a/apps/desktop/src/locales/remote.ts b/apps/desktop/src/locales/remote.ts
index e048f9e7d..1b619d6b3 100644
--- a/apps/desktop/src/locales/remote.ts
+++ b/apps/desktop/src/locales/remote.ts
@@ -6,7 +6,7 @@ export const remoteEn = {
openFolder: "Open {{name}}", emptyFolders: "No subfolders in this directory.",
older: "Load older messages", thinking: "Thinking",
newer: "Load newer messages", latest: "Return to latest",
- sessions: "Conversations / New conversation",
+ newProject: "New project",
reconnect: "Reconnect",
refresh: "Refresh",
close: "Close",
@@ -66,7 +66,7 @@ export const remoteZh: typeof remoteEn = {
openFolder: "打开 {{name}}", emptyFolders: "此目录下没有子文件夹。",
older: "加载更早消息", thinking: "思考",
newer: "加载较新消息", latest: "返回最新消息",
- sessions: "会话 / 新建会话", reconnect: "重新连接", refresh: "刷新", close: "关闭", loading: "处理中…",
+ newProject: "新建项目", reconnect: "重新连接", refresh: "刷新", close: "关闭", loading: "处理中…",
offlineHost: "{{label}}(离线)", reconnectOnUse: "主机已离线。浏览或打开项目时会尝试重新连接。",
pathUnavailable: "远程目录不可用,请检查路径后重试。", pathForbidden: "此路径超出允许的远程工作区。",
upgradeRequired: "请将远程 Host 升级到与 Desktop 匹配的版本。",
diff --git a/apps/desktop/src/stores/app-state.ts b/apps/desktop/src/stores/app-state.ts
index c99b4e689..9ad9dea03 100644
--- a/apps/desktop/src/stores/app-state.ts
+++ b/apps/desktop/src/stores/app-state.ts
@@ -122,6 +122,7 @@ export type AppState = {
openProjects: ProjectWorkspace[];
openProjectPaths: string[];
createProjectDialogOpen: boolean;
+ createProjectDialogRemoteHostKey?: string;
activeProjectPath?: string;
projectMeta: Record<string, ProjectMeta>;
/** Kept as a flat map for lightweight consumers (Sidebar). */
@@ -261,7 +262,7 @@ export type AppState = {
snapshotId: string,
) => Promise<ReviewRollbackResult | null>;
abort: () => Promise<void>;
- openProject: () => Promise<void>;
+ openProject: (options?: { remoteHostKey?: string }) => Promise<void>;
closeProjectDialog: () => void;
createProjectFromRemote: (input: {
name: string;
diff --git a/apps/desktop/src/stores/slices/initial-state.ts b/apps/desktop/src/stores/slices/initial-state.ts
index bbbd8655c..486f0ee7d 100644
--- a/apps/desktop/src/stores/slices/initial-state.ts
+++ b/apps/desktop/src/stores/slices/initial-state.ts
@@ -36,6 +36,7 @@ export function createInitialState(): AppStateData {
),
openProjectPaths: initialSidebarPreferences.openProjectPaths,
createProjectDialogOpen: false,
+ createProjectDialogRemoteHostKey: undefined,
activeProjectPath: undefined,
projectMeta: initialSidebarPreferences.projectMeta,
projectCollapsed: Object.fromEntries(
diff --git a/apps/desktop/src/stores/slices/project-slice.ts b/apps/desktop/src/stores/slices/project-slice.ts
index 37d9d4631..3241c4abd 100644
--- a/apps/desktop/src/stores/slices/project-slice.ts
+++ b/apps/desktop/src/stores/slices/project-slice.ts
@@ -113,7 +113,7 @@ async function createNamedProjectGroup(
if (!workspace || !runtime.navigationIntentIsCurrent(intent)) return;
const onboarding = await api.getOnboarding();
if (!runtime.navigationIntentIsCurrent(intent)) return;
- set({ createProjectDialogOpen: false, onboarding, page: "chat" });
+ set({ createProjectDialogOpen: false, createProjectDialogRemoteHostKey: undefined, onboarding, page: "chat" });
return;
}
}
@@ -130,7 +130,7 @@ async function createNamedProjectGroup(
get().renameProject(groupPrimary, normalizedName);
const onboarding = await api.getOnboarding();
if (!runtime.navigationIntentIsCurrent(intent)) return;
- set({ createProjectDialogOpen: false, onboarding, page: "chat" });
+ set({ createProjectDialogOpen: false, createProjectDialogRemoteHostKey: undefined, onboarding, page: "chat" });
}
/**
@@ -385,11 +385,11 @@ export function createProjectSlice({
});
},
- openProject: async () => {
- set({ createProjectDialogOpen: true });
+ openProject: async (options) => {
+ set({ createProjectDialogOpen: true, createProjectDialogRemoteHostKey: options?.remoteHostKey });
},
closeProjectDialog: () => {
- set({ createProjectDialogOpen: false });
+ set({ createProjectDialogOpen: false, createProjectDialogRemoteHostKey: undefined });
},
createProjectFromFolders: async ({ name, folders, primaryPath }) =>
createNamedProjectGroup(
@@ -407,7 +407,7 @@ export function createProjectSlice({
get().renameProject(group.primaryPath, normalizedName);
const onboarding = await api.getOnboarding();
if (!runtime.navigationIntentIsCurrent(intent)) return;
- set({ createProjectDialogOpen: false, onboarding, page: "chat" });
+ set({ createProjectDialogOpen: false, createProjectDialogRemoteHostKey: undefined, onboarding, page: "chat" });
},
createProjectFromGit: async ({ name, url, parentPath }) => {
// Clone first, then create the project through the same group path, so a
diff --git a/apps/desktop/test/remote-project-dialog-user-path.test.mjs b/apps/desktop/test/remote-project-dialog-user-path.test.mjs
index 969817955..58828a839 100644
--- a/apps/desktop/test/remote-project-dialog-user-path.test.mjs
+++ b/apps/desktop/test/remote-project-dialog-user-path.test.mjs
@@ -18,6 +18,7 @@ import { initReactI18next } from "react-i18next";
import { catalogs, flattenCatalog } from "@pi-desktop/i18n";
import { IPC } from "@pi-desktop/shared";
import { ProjectCreateDialog } from "../../apps/desktop/src/components/ProjectCreateDialog";
+import { RemoteHostsPage } from "../../apps/desktop/src/components/settings/RemoteHostsPage";
import { FilesTab } from "../../apps/desktop/src/components/workpanel/FilesTab";
import { ProjectEditDialog } from "../../apps/desktop/src/components/ProjectEditDialog";
import { useAppStore } from "../../apps/desktop/src/stores/app-store";
@@ -67,18 +68,25 @@ function choose(node, value) { flushSync(() => { Object.getOwnPropertyDescriptor
function input(node, value) { flushSync(() => { Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set.call(node, value); node.dispatchEvent(new Event("input", { bubbles: true })); }); }
const picker = () => document.querySelector(".remote-folder-dialog");
window.remoteProjectProbe = async () => {
- useAppStore.setState({ workspace: { path: "/local/app", name: "app" }, activeProjectPath: "/local/app", openProjectPaths: ["/local/app"], openProjects: [{ path: "/local/app", name: "app" }], sessions: [], page: "chat" });
- await useAppStore.getState().openProject();
- flushSync(() => view.render(React.createElement(ProjectCreateDialog)));
- await until(() => button("Remote"), "remote source button missing");
+ useAppStore.setState({ workspace: { path: "/local/app", name: "app" }, activeProjectPath: "/local/app", openProjectPaths: ["/local/app"], openProjects: [{ path: "/local/app", name: "app" }], sessions: [], page: "settings" });
+ flushSync(() => view.render(React.createElement(React.Fragment, null, React.createElement(RemoteHostsPage), React.createElement(ProjectCreateDialog))));
+ await until(() => document.querySelectorAll(".settings-remote-host-card").length === 3, "remote host inventory did not load");
+ const hostCard = [...document.querySelectorAll(".settings-remote-host-card")].find((card) => card.textContent.includes("Server 2"));
+ check(hostCard, "requested host card missing");
+ const createButton = button("New project", hostCard);
+ check(createButton, "host card has no new project action");
+ createButton.click();
+ await until(() => document.querySelector(".project-create-dialog") && document.querySelector("select")?.value === "h2", "new project did not preselect remote source and host");
+ check(document.querySelector('.project-create-dialog [data-project-source="remote"]')?.getAttribute("aria-pressed") === "true", "remote project source was not selected");
+ check(!document.querySelector(".remote-host-workbench"), "remote host page still opens a session workbench");
+ check(!calls.some((entry) => entry.channel === IPC.invoke.remoteHostSessions), "opening project management listed remote sessions");
input(document.querySelector("#project-create-name"), "My server app");
- button("Remote").click();
- await until(() => document.querySelector('select')?.value === "h1", "hosts did not load");
check(document.querySelector("#project-create-name").value === "My server app", "remote source lost editable local name");
check(document.querySelector('option[value="offline"]'), "disconnected paired host not offered");
- check(document.querySelectorAll('select').length === 1, "host project catalog still required");
+ check(document.querySelectorAll("select").length === 1, "host project catalog still required");
check(!calls.some((entry) => entry.channel === IPC.invoke.remoteHostProjects), "host project catalog was fetched");
check(!calls.some((entry) => entry.channel === IPC.invoke.remoteHostBrowseProjects), "browse loaded inside project form");
+ choose(document.querySelector("select"), "h1");
button("Browse folders").click();
await until(() => releaseOldBrowse && picker(), "folder dialog missing");
check(document.querySelector('.project-create-dialog').inert, "project form was interactive behind folder dialog");
@@ -130,7 +138,7 @@ window.remoteProjectProbe = async () => {
input(document.querySelector(".remote-project-picker input"), "relative"); await settle();
check(document.querySelector('button[type="submit"]').disabled, "relative remote path accepted");
input(document.querySelector(".remote-project-picker input"), "/home/user/app"); await settle();
- const form = document.querySelector("form");
+ const form = document.querySelector(".project-create-dialog form");
form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
form.dispatchEvent(new Event("submit", { bubbles: true, cancelable: true }));
await until(() => releaseCreate, "local remote-bound project creation did not start");
@@ -168,10 +176,9 @@ window.remoteProjectProbe = async () => {
check(unexpectedCalls.length === 0, "unexpected IPC calls: " + unexpectedCalls.join(", "));
return { passed: true };
};
-
`;
-test("home project dialog chooses remote folders and creates and renames a local project", {
+test("remote host page opens a preselected remote project and creates a local project", {
skip: process.platform === "linux" && !process.env.DISPLAY ? "Electron requires a display" : false,
}, async () => {
const temp = await mkdtemp(join(root, "apps/desktop/.remote-project-ui-"));
diff --git a/apps/desktop/test/settings-remote-hosts.test.mjs b/apps/desktop/test/settings-remote-hosts.test.mjs
index b7d185cd5..84d443c8f 100644
--- a/apps/desktop/test/settings-remote-hosts.test.mjs
+++ b/apps/desktop/test/settings-remote-hosts.test.mjs
@@ -41,12 +41,17 @@ test("remote hosts is an inventory plus one SSH/Pair add form", () => {
assert.match(page, /api\.pairRemoteHost\(/);
assert.match(page, /api\.listRemoteHosts\(/);
assert.match(page, /api\.removeRemoteHost\(/);
-
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\)/);
});
+test("remote host cards open project creation instead of a session workbench", () => {
+ assert.match(page, /openProject\(\{ remoteHostKey: host\.hostKey \}\)/);
+ assert.match(page, /remoteT\("newProject"\)/);
+ assert.doesNotMatch(page, /RemoteHostSessions|selectedHost|remoteT\("sessions"\)/);
+});
+
test("remote hosts omits instructional copy", () => {
assert.doesNotMatch(page, /role="note"/);
assert.doesNotMatch(page, /settings-row-desc/);
diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.md
index 3ef3082ef..352c54a71 100644
--- a/docs/spec/04-ux/01-ui-ia.md
+++ b/docs/spec/04-ux/01-ui-ia.md
@@ -181,9 +181,10 @@ destination, chat as the home surface, tools and permissions inline.
- Create project uses one dialog with local folder, Git, and remote host sources.
The project name is editable for every source and remains locally managed.
Remote selection chooses a connected host and an absolute directory, without
- a Host project catalog. Browse opens a separate directory dialog with path
+ a Host project catalog; Settings → Remote Hosts opens the same dialog with the
+ clicked host preselected. Browse opens a separate directory dialog with path
entry, parent navigation, directory rows and explicit confirmation. Cancel
- returns to the project form and restores focus; a stale host response cannot
+ returns to the project form and restores focus; stale host responses cannot
replace the current selection. The same sidebar, switcher, archive and chat
workflow manage created projects. Model choices and requests use local settings;
remote machines execute admitted workspace tools only. Actual remote paths
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index 5fcb526eb..6f9303ffa 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -82,8 +82,11 @@ 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
+ each host offers **New project**, reconnect, and remove. New project opens the
+ unified Create project dialog with Remote selected and that host preselected;
+ selecting an absolute directory creates a locally managed project bound to
+ the remote workspace. The inventory does not list or create conversations.
+ 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.
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 76d9ab096..c47be6c20 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -14606,9 +14606,9 @@ browser milestones are scheduled.
turn execute once, in the Host project only; stale routing never falls back
locally. Snapshot recovery restores pending requests and clears peer-resolved
cards. Local workspace/model state is unchanged.
-- **Component path**: Open existing remote Agent history, verify model-copy and
- remote-create controls are absent, type/send, approve, resolve from another
- peer, and retry a failed reconnect. New projects follow E2E-REMOTE-HOME.
+- **Compatibility coverage**: Existing remote Agent session routing remains
+ covered by `remote-mvp-renderer.test.mjs`; the Settings inventory exposes no
+ session-list or new-session controls. New projects follow E2E-REMOTE-HOME.
- **Automation**: `scripts/e2e-remote-mvp.mjs` (packaged Host, real Rust/Agent
runtime and Desktop main routing, mocked model); `scripts/e2e-remote-mvp-ui.mjs`
(real components, mocked IPC). Neither is a full SSH/Desktop acceptance result.
@@ -14620,11 +14620,13 @@ browser milestones are scheduled.
- **Preconditions**: Isolated Desktop profile, connected Host directory fixtures,
a local provider fixture, and local/remote directories with the same basename.
No user profile, production host, credentials or paid model calls.
-- **Steps**: Open Create project, choose Remote, browse through a separate folder
- dialog, cancel/reopen, navigate parent/child and confirm a directory. Enter a
- custom name, create, rename and reopen the project. Start a normal local chat,
- choose a local model and send a request that invokes Read and Bash remotely.
- Approve locally, cancel a command, disconnect/reconnect and retry explicitly.
+- **Steps**: Open Settings → Remote Hosts and click **New project** on the
+ intended host. Confirm the shared Create project dialog has Remote selected
+ and that host preselected. Browse through a separate folder dialog,
+ cancel/reopen, navigate parent/child and confirm a directory. Enter a custom
+ name, create, rename and reopen the project. Start a normal local chat, choose
+ a local model and send a request that invokes Read and Bash remotely. Approve
+ locally, cancel a command, disconnect/reconnect and retry explicitly.
- **Expected**: Focus and drafts survive picker cancellation. Late host responses
cannot replace the current host selection. Project metadata and sessions are
local and stable after reload, including name/memory/instructions and ordinary