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): gate the Remote Hosts destination behind developer mode
vastsa5cc22e68795d
diff --git a/apps/desktop/src/components/SearchDialog.tsx b/apps/desktop/src/components/SearchDialog.tsxindex 5df82a269..b514bb9cd 100644--- a/apps/desktop/src/components/SearchDialog.tsx+++ b/apps/desktop/src/components/SearchDialog.tsx@@ -84,6 +84,9 @@ export function SearchDialog({ open, onClose }: { open: boolean; onClose: () =>const setSettingsAnchor = useAppStore((s) => s.setSettingsAnchor);const setPage = useAppStore((s) => s.setPage);const showToast = useAppStore((s) => s.showToast);+ // Settings search mirrors the rail: developer-only destinations stay out of+ // the result list while developer mode is off.+ const developerMode = useAppStore((s) => s.settings?.developerMode === true);const query = useSessionSearchState((state) => state.query);const setQuery = useSessionSearchState((state) => state.setQuery);@@ -204,8 +207,8 @@ export function SearchDialog({ open, onClose }: { open: boolean; onClose: () =>}, [query, t]);const settingsHits = useMemo<SettingsSearchHit[]>(- () => searchSettings(query, t),- [query, t],+ () => searchSettings(query, t, { developerMode }),+ [query, t, developerMode],);const sessionOptionCount = rows.reduce(diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsxindex e49c3f0c2..f49fcaad6 100644--- a/apps/desktop/src/features/settings/SettingsPage.tsx+++ b/apps/desktop/src/features/settings/SettingsPage.tsx@@ -9,8 +9,9 @@ import type {import { useAppStore } from "../../stores/app-store";import { api } from "../../lib/api";import {- SETTINGS_NAV,+ isSettingsDestinationHidden,SETTINGS_NAV_GROUP_LABELS,+ visibleSettingsNav,type SettingsNavGroupId,} from "../../lib/settings-search";import { pluginViewIcon } from "../../lib/plugin-view-icons";@@ -83,6 +84,12 @@ export function SettingsPage() {const refreshProviders = useAppStore((s) => s.refreshProviders);const platform = (window.piDesktop?.platform ?? "darwin") as ShortcutPlatform;+ // Developer-only destinations (Remote Hosts) exist only while developer+ // mode is on; the rail, the page, and settings search drop them together.+ const developerMode = settings?.developerMode === true;+ const navEntries = useMemo(() => visibleSettingsNav(developerMode), [developerMode]);+ const tabHidden = isSettingsDestinationHidden(tab, developerMode);+const [query, setQuery] = useState("");const [recoveringSettings, setRecoveringSettings] = useState(!settings);const [settingsRecoveryFailed, setSettingsRecoveryFailed] = useState(false);@@ -102,6 +109,14 @@ export function SettingsPage() {}}, [activeExtension, extensions, setSettingsTab]);+ // A hidden destination must not keep rendering: leave the page the rail no+ // longer offers (for example Remote Hosts once developer mode is switched+ // off) and fall back to General.+ useEffect(() => {+ if (!settings || !tabHidden) return;+ setSettingsTab("general");+ }, [settings, tabHidden, setSettingsTab]);+const recoverSettings = useCallback(async () => {setRecoveringSettings(true);setSettingsRecoveryFailed(false);@@ -192,7 +207,7 @@ export function SettingsPage() {remoteHosts: <IconGlobe size={14} />,about: <IconInfo size={14} />,};- return SETTINGS_NAV.map((entry) => ({+ return navEntries.map((entry) => ({id: entry.id,labelKey: entry.labelKey,titleKey: entry.titleKey,@@ -200,7 +215,7 @@ export function SettingsPage() {group: entry.group,keywordKeys: entry.keywordKeys,}));- }, []);+ }, [navEntries]);// Search matches the tab label and the titles of the rows inside it, so// typing e.g. "theme" or "主题" surfaces Basics even though the tab is@@ -325,7 +340,7 @@ export function SettingsPage() {<div className="settings-content-enter"><h1 className="settings-section-title"><span>{activeExtension?.label ?? t(activeTitleKey)}</span>- {!activeExtension && tab === "remoteHosts" ? (+ {!activeExtension && tab === "remoteHosts" && !tabHidden ? (<Badge tone="warning">{t("settings.remoteHosts.experimental")}</Badge>) : null}</h1>@@ -483,7 +498,7 @@ export function SettingsPage() {{tab === "projects" && <ProjectsPage />}- {tab === "remoteHosts" && <RemoteHostsPage />}+ {tab === "remoteHosts" && !tabHidden && <RemoteHostsPage />}{tab === "about" && (<div className="settings-stack">diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.tsindex 04fc8713a..455ac2959 100644--- a/apps/desktop/src/lib/settings-search.ts+++ b/apps/desktop/src/lib/settings-search.ts@@ -42,6 +42,11 @@ export type SettingsNavEntry = {group: SettingsNavGroupId;/** i18n keys of the rows inside the tab; search matches their translations. */keywordKeys: string[];+ /**+ * Destination only exists while `AppSettings.developerMode` is on; the+ * rail, the page, and settings search drop it together.+ */+ developerOnly?: true;};export const SETTINGS_NAV: SettingsNavEntry[] = [@@ -233,6 +238,7 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [labelKey: "settings.nav.remoteHosts",titleKey: "settings.remoteHosts.title",group: "system",+ developerOnly: true,keywordKeys: ["settings.remoteHosts.title","settings.remoteHosts.addTitle",@@ -266,6 +272,28 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [},];+/**+ * Destinations the current mode offers, in rail order. `developerMode` comes+ * from `AppSettings.developerMode`; when it is off the developer-only rows are+ * absent rather than disabled.+ */+export function visibleSettingsNav(developerMode: boolean): SettingsNavEntry[] {+ return SETTINGS_NAV.filter((entry) => entry.developerOnly !== true || developerMode);+}++/**+ * True when `tab` is a destination the current mode hides, so a caller holding+ * a stale selection can fall back instead of rendering a page the rail no+ * longer offers.+ */+export function isSettingsDestinationHidden(+ tab: SettingsTabId,+ developerMode: boolean,+): boolean {+ const entry = SETTINGS_NAV.find((candidate) => candidate.id === tab);+ return entry?.developerOnly === true && !developerMode;+}+export type SettingsSearchHit = {tab: SettingsTabId;tabLabelKey: string;@@ -273,15 +301,21 @@ export type SettingsSearchHit = {rowKey: string | null;};+export type SettingsSearchOptions = {+ limit?: number;+ /** Search mirrors the rail, so developer-only tabs stay out of the results. */+ developerMode?: boolean;+};+export function searchSettings(query: string,t: (key: string) => string,- limit = 8,+ { limit = 8, developerMode = false }: SettingsSearchOptions = {},): SettingsSearchHit[] {const q = query.trim().toLowerCase();if (!q) return [];const hits: SettingsSearchHit[] = [];- for (const entry of SETTINGS_NAV) {+ for (const entry of visibleSettingsNav(developerMode)) {if (t(entry.labelKey).toLowerCase().includes(q)) {hits.push({ tab: entry.id, tabLabelKey: entry.labelKey, rowKey: null });}diff --git a/apps/desktop/test/settings-developer-only-destinations.test.mjs b/apps/desktop/test/settings-developer-only-destinations.test.mjsnew file mode 100644index 000000000..376d832a5--- /dev/null+++ b/apps/desktop/test/settings-developer-only-destinations.test.mjs@@ -0,0 +1,65 @@+/**+ * Developer-only settings destinations contract.+ *+ * Remote Hosts is an experimental surface that exists only while developer+ * mode is on. The rail, the page, and settings search must add and drop it+ * together, and a stale selection must fall back to General instead of+ * rendering a page the rail no longer offers.+ */+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import test from "node:test";+import {+ SETTINGS_NAV,+ isSettingsDestinationHidden,+ searchSettings,+ visibleSettingsNav,+} from "../src/lib/settings-search.ts";++const settingsPage = readFileSync(+ new URL("../src/features/settings/SettingsPage.tsx", import.meta.url),+ "utf8",+);+const searchDialog = readFileSync(+ new URL("../src/components/SearchDialog.tsx", import.meta.url),+ "utf8",+);++const identity = (key) => key;++test("developer mode alone decides which destinations exist", () => {+ const off = visibleSettingsNav(false).map((entry) => entry.id);+ const on = visibleSettingsNav(true).map((entry) => entry.id);++ assert.equal(off.includes("remoteHosts"), false);+ assert.equal(on.includes("remoteHosts"), true);+ assert.deepEqual(off, on.filter((id) => id !== "remoteHosts"));+ // Remote Hosts is the only gated destination today, and it carries the+ // Experimental badge that the rail renders.+ assert.deepEqual(+ SETTINGS_NAV.filter((entry) => entry.developerOnly === true).map((entry) => entry.id),+ ["remoteHosts"],+ );+});++test("settings search mirrors the rail", () => {+ assert.deepEqual(searchSettings("remotehosts", identity, { developerMode: false }), []);+ const hits = searchSettings("remotehosts", identity, { developerMode: true });+ assert.ok(hits.some((hit) => hit.tab === "remoteHosts"));+ assert.equal(searchSettings("settings", identity, { limit: 2 }).length, 2);+});++test("a stale developer-only selection is reported as hidden", () => {+ assert.equal(isSettingsDestinationHidden("remoteHosts", false), true);+ assert.equal(isSettingsDestinationHidden("remoteHosts", true), false);+ assert.equal(isSettingsDestinationHidden("general", false), false);+});++test("the rail, the page, and the search dialog follow developer mode", () => {+ assert.match(settingsPage, /const developerMode = settings\?\.developerMode === true/);+ assert.match(settingsPage, /visibleSettingsNav\(developerMode\)/);+ assert.match(settingsPage, /isSettingsDestinationHidden\(tab, developerMode\)/);+ assert.match(settingsPage, /setSettingsTab\("general"\)/);+ assert.match(settingsPage, /tab === "remoteHosts" && !tabHidden && <RemoteHostsPage \/>/);+ assert.match(searchDialog, /searchSettings\(query, t, \{ developerMode \}\)/);+});diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex fa27eb52d..76d2209e4 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -49,17 +49,25 @@ Settings is a **full-window page** that replaces the app sidebar + main chrome (8. **Subagents / 子智能体** — Lucide `Bot` (built-in and personal parallel agents)9. **Import / 导入** — Lucide `Download` (bring sessions and model configuration in from other tools)10. **Projects / 项目** — Lucide `Archive` (durable project index)- 11. **Info / 信息** — Lucide `Info` (versions, logs, updates, developer)+ 11. **Remote Hosts / 远程主机** — Lucide `Globe` (SSH bootstrap and pairing inventory; developer mode only)+ 12. **Info / 信息** — Lucide `Info` (versions, logs, updates, developer)Icons are decorative (`aria-hidden` via the SVG default) and stay monochromewith the rail label; do not reuse refresh/rotate glyphs here.- The directory remains a flat searchable list in the same exact order. Forscanability, the destinations are shown in four titled visual clusters:`Preferences` / `偏好` (General, AI, Shortcuts), `Agent` / `智能体`(Instructions, Models, Skills, MCP, Subagents), `Workspace` / `工作区`- (Import, Projects), and `System` / `系统` (Info). Headings are muted,- non-interactive labels and use whitespace for separation; no divider lines are- rendered. These are visual landmarks only, not a second navigation level.+ (Import, Projects), and `System` / `系统` (Remote Hosts, Info). Headings are+ muted, non-interactive labels and use whitespace for separation; no divider+ lines are rendered. These are visual landmarks only, not a second navigation+ level.When search filters the directory, empty clusters and their headings disappear.+- **Remote Hosts / 远程主机** is a developer-only, Experimental destination: its+ rail row, its page, and its settings-search hits exist only while+ `AppSettings.developerMode` is `true`. With developer mode off the row is+ absent rather than disabled, settings search returns no hit for it, and a+ rail position left on it falls back to General. The row and the page title+ carry the Experimental badge (`settings.remoteHosts.experimental`)- Loaded plugin Settings entries may appear only in a final **Extensions** groupafter all core groups. The host owns their ordering, search result, titlebarand fallback to General. The rail icon is the destination's host token@@ -652,8 +660,8 @@ system while preserving their different data ownership:`AppSettings.developerMode` value is `true`- the developer mode switch unlocks the Open console button, F12 on everyplatform, Ctrl+Shift+I on Windows/Linux, the macOS View-menu developer- tools item, and Copy conversation ID / Open session path on the- conversation overflow menu+ tools item, Copy conversation ID / Open session path on the conversation+ overflow menu, and the Remote Hosts destination on the rail- disabling developer mode closes an open console and disables or removesevery entry point; Settings search indexes the card, switch, and consoleaction@@ -680,6 +688,10 @@ system while preserving their different data ownership:- Project archive is indexed by Settings search and is not duplicated as a homesidebar destination or standalone global-search page- Back to app returns to chat shell from the rail's pinned footer action+- Developer-only destinations join and leave the rail, the page, and settings+ search as one unit: while developer mode is off the rail omits the row,+ settings search returns no hit for it, and an open Remote Hosts page returns+ to General## 4. Acceptance@@ -688,8 +700,10 @@ system while preserving their different data ownership:foot on the main sidebar's footer icon line, and exactly General / 常规, AI,Shortcuts / 快捷键, Instructions / 指令, Models / 模型, Skills / 技能, MCP,Subagents / 子智能体, Import / 导入, Projects / 项目, and Info / 信息 in- that order. The rows are grouped under Preferences / 偏好, Agent / 智能体,- Workspace / 工作区, and System / 系统. There is no Usage / 用量 destination.+ that order, with Remote Hosts / 远程主机 between Projects and Info only+ while developer mode is on. The rows are grouped under Preferences / 偏好,+ Agent / 智能体, Workspace / 工作区, and System / 系统. There is no+ Usage / 用量 destination.3. Appearance is part of General and has no standalone rail destination4. Providers is part of Agent and has no standalone rail destination5. Plugins has no Settings destination; the app-shell Plugins page supportsdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex f7fa42c4d..460d3386e 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -12028,7 +12028,8 @@ browser milestones are scheduled.#### E2E-REMOTE-HOST-ssh-password-authentication-- **Preconditions**: A Linux test machine runs `sshd` with+- **Preconditions**: Developer mode is enabled (Settings → Info → Developer),+ so the Remote Hosts destination exists. A Linux test machine runs `sshd` with`PasswordAuthentication yes` and `PubkeyAuthentication no`, so the login isonly reachable with a password; the user's local SSH agent holds no usable keyfor it. A GitHub Releases fixture serves the `pi-host` bundle for that platform@@ -12073,22 +12074,30 @@ browser milestones are scheduled.#### E2E-REMOTE-HOST-settings-compact-inventory- **Preconditions**: The desktop Settings window can open. No paired remote- host is required.-- **Steps**: 1) Open Settings. 2) Confirm Remote Hosts shows an Experimental- badge on the rail. 3) Open it and confirm the page title carries the same- badge, with a host inventory and one Add form (SSH / Pair) and no- instructional copy. 4) Switch Add to Pair and back to SSH; confirm both- forms stay filled.-- **Expected**: The whole destination is marked Experimental. Field labels- and placeholders remain; overview, body, and hint copy are absent. There- is no Experimental switch list. SSH stays the default Add tab. Pairing and- SSH bootstrap keep their existing success and failure toasts.-- **Specs linked**: `06-delivery/07-remote-control-rollout.md` §2 R2,+ host is required. Developer mode is off in persisted settings.+- **Steps**: 1) Open Settings and confirm the rail has no Remote Hosts row and+ that searching settings for it returns nothing. 2) Enable developer mode in+ Info → Developer and confirm Remote Hosts appears on the rail between+ Projects and Info with an Experimental badge. 3) Open it and confirm the page+ title carries the same badge, with a host inventory and one Add form+ (SSH / Pair) and no instructional copy. 4) Switch Add to Pair and back to+ SSH; confirm both forms stay filled. 5) Disable developer mode while the+ destination is open and confirm the page returns to General and the rail row+ is gone.+- **Expected**: The whole destination is marked Experimental and is reachable+ only while developer mode is on; the rail row, the page, and settings search+ add and drop it together. Field labels and placeholders remain; overview,+ body, and hint copy are absent. There is no Experimental switch list. SSH+ stays the default Add tab. Pairing and SSH bootstrap keep their existing+ success and failure toasts.+- **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**: Draft; covered offline by- `apps/desktop/test/settings-remote-hosts.test.mjs`.+ `apps/desktop/test/settings-remote-hosts.test.mjs` and+ `apps/desktop/test/settings-developer-only-destinations.test.mjs`.#### E2E-232: The outbound messaging integration relays events and commandsdiff --git a/docs/spec/06-delivery/07-remote-control-rollout.md b/docs/spec/06-delivery/07-remote-control-rollout.mdindex ec9af3c13..83ba7f4ff 100644--- a/docs/spec/06-delivery/07-remote-control-rollout.md+++ b/docs/spec/06-delivery/07-remote-control-rollout.md@@ -144,7 +144,9 @@ Deliverables:the remote machine; and- the Settings → Remote Hosts destination: a compact host inventory and oneAdd form with SSH and Pair tabs, no instructional copy, marked Experimental- on the settings rail and page title because the topology may still fail.+ on the settings rail and page title because the topology may still fail, and+ shown — with its settings-search hits — only while developer mode is on+ (`04-ux/06-settings-ia.md` §1, §3).Design decisions (D375, recorded 2026-09-10):diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.mdindex 051979d0f..ef0a09976 100644--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md@@ -31,14 +31,19 @@8. **子智能体** — Lucide `Bot`(内置与自建的并行工作智能体)9. **导入** — Lucide `Download`(从其他工具引入会话和模型配置)10. **项目** — Lucide `Archive`(持久项目索引)- 11. **信息** — Lucide `Info`(版本、日志、更新、开发人员)+ 11. **远程主机** — Lucide `Globe`(SSH 引导与配对清单;仅开发者模式)+ 12. **信息** — Lucide `Info`(版本、日志、更新、开发人员)图标具有装饰性(通过 SVG 默认设置为 `aria-hidden`)并保持单色带有导轨标签;不要在此处重复使用 refresh/rotate 字形。- 目录仍是保持相同顺序的可搜索扁平列表。为便于扫描,目的地分为四个带标题的视觉分组:“偏好”(常规、AI、快捷键)、“智能体”(指令、模型、技能、- MCP、子智能体)、“工作区”(导入、项目)和“系统”(信息)。标题使用柔和+ MCP、子智能体)、“工作区”(导入、项目)和“系统”(远程主机、信息)。标题使用柔和的非交互文字,分组之间只使用留白,不绘制分割线;搜索过滤后,空分组及其标题一并隐藏。+- **远程主机**是仅开发者可用的实验性目的地:其导轨行、页面和设置搜索命中仅在+ `AppSettings.developerMode` 为 `true` 时存在。开发者模式关闭时该行是缺失而不是+ 禁用,设置搜索不会返回它的命中,导轨位置停在该项时会回落到常规。该行和页面标题+ 都带有实验性徽章(`settings.remoteHosts.experimental`)- 不显示其他设置目的地或占位符导航行- 主表面上的主要内容窗格,带有大部分标题+升高圆形的行卡。其内容使用后可用的完整宽度@@ -287,7 +292,7 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历`AppSettings.developerMode` 值是 `true`- 开发者模式开关解锁“打开控制台”按钮,每个按钮上按 F12平台、Windows/Linux 上的 Ctrl+Shift+I 以及 macOS 查看菜单开发人员-工具项+工具项,以及导轨上的远程主机目的地- 禁用开发者模式会关闭打开的控制台并禁用或删除每个入口点;设置搜索索引卡、交换机和控制台行动@@ -314,13 +319,17 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历- 项目档案由设置搜索索引,不会复制为主页侧边栏目标或独立的全局搜索页面- 返回应用程序从导轨固定的底部操作返回聊天外壳+- 仅开发者可用的目的地作为一个整体加入导轨、页面和设置搜索,也同样一起离开:+ 开发者模式关闭时导轨省略该行,设置搜索不返回它的命中,打开的远程主机页面会+ 返回到常规## 4. 验收1.打开设置隐藏编码应用侧边栏(全页接管)2. 导轨顶部显示搜索药丸,底部固定返回应用程序操作并与主侧边栏底部图标行同一条线,并精确显示常规、AI、快捷键、指令、模型、技能、MCP、- 子智能体、导入、项目和信息,并按偏好、智能体、工作区、系统分组。没有+ 子智能体、导入、项目和信息(开发者模式开启时,远程主机位于项目与信息之间),+ 并按偏好、智能体、工作区、系统分组。没有用量设置目的地。3.外观是常规的一部分,没有独立的导轨目的地4. Providers 是 Agent 的一部分,没有独立的导轨目的地diff --git a/docs/zh-CN/spec/06-delivery/07-remote-control-rollout.md b/docs/zh-CN/spec/06-delivery/07-remote-control-rollout.mdindex 6abca3e2b..11cc7923e 100644--- a/docs/zh-CN/spec/06-delivery/07-remote-control-rollout.md+++ b/docs/zh-CN/spec/06-delivery/07-remote-control-rollout.md@@ -49,7 +49,7 @@ Linux 或 WSL 机器上的项目,即 SSH 隧道远端 Host 拓扑;#100 要`workspace/list`、`workspace/read`、`workspace/diff`);以及远程会话归属划分;反向工具中继(`tools/advertise` 与 `tool/execute` 服务端请求,让桌面 MCP 服务器和不需工作区的插件工具在远程会话中于桌面执行);终端(`terminal/open`、`terminal/input`、`terminal/resize`、`terminal/close`、- `terminal.output` 与有界回放环,在远端机器运行);设置 → 远程主机为紧凑主机清单加一个 SSH/配对添加表单、不含说明性文案;整项功能在导航与标题上标为实验性,因为远程连接仍可能失败。+ `terminal.output` 与有界回放环,在远端机器运行);设置 → 远程主机为紧凑主机清单加一个 SSH/配对添加表单、不含说明性文案;整项功能在导航与标题上标为实验性,因为远程连接仍可能失败,仅在开发者模式开启时显示(连同其在设置搜索中的命中)(`04-ux/06-settings-ia.md` §1、§3)。- R3:出站消息集成(#100)。Host 进程内的又一个模块调用方,无传输、无入站监听:订阅 Host 范围与会话事件,把 `turn.completed`、`turn.failed`、`approval.requested`、`input.requested` 的脱敏摘要转发到出站渠道(先 Webhook,