Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
Hide experimental surfaces in packaged builds
vastsac8a08fe91fbd
diff --git a/apps/desktop/src/components/Composer.tsx b/apps/desktop/src/components/Composer.tsxindex a01675b8e..aa85549b3 100644--- a/apps/desktop/src/components/Composer.tsx+++ b/apps/desktop/src/components/Composer.tsx@@ -444,7 +444,7 @@ export function Composer({submit,} = submitController;- const voiceEnabled = !!settings?.voice?.enabled;+ const voiceEnabled = import.meta.env.DEV && !!settings?.voice?.enabled;const voice = useVoiceInput({enabled: voiceEnabled,onTranscriptionComplete: (text) => {@@ -458,7 +458,6 @@ export function Composer({}},});-const composerAc = useComposerAutocomplete({value,cursor,@@ -601,7 +600,9 @@ export function Composer({persistDraft();}}/>- <VoiceOverlay t={t} state={voice.state} onCancel={voice.cancel} />+ {import.meta.env.DEV && (+ <VoiceOverlay t={t} state={voice.state} onCancel={voice.cancel} />+ )}<ComposerToolbart={t}mode={mode}diff --git a/apps/desktop/src/components/SearchDialog.tsx b/apps/desktop/src/components/SearchDialog.tsxindex e1b389cbb..0e41d6fdc 100644--- a/apps/desktop/src/components/SearchDialog.tsx+++ b/apps/desktop/src/components/SearchDialog.tsx@@ -207,7 +207,11 @@ export function SearchDialog({ open, onClose }: { open: boolean; onClose: () =>}, [query, t]);const settingsHits = useMemo<SettingsSearchHit[]>(- () => searchSettings(query, t, { developerMode }),+ () =>+ searchSettings(query, t, {+ developerMode,+ includeDevelopmentOnly: import.meta.env.DEV,+ }),[query, t, developerMode],);diff --git a/apps/desktop/src/features/settings/SettingsPage.tsx b/apps/desktop/src/features/settings/SettingsPage.tsxindex 248215aab..d3bff1669 100644--- a/apps/desktop/src/features/settings/SettingsPage.tsx+++ b/apps/desktop/src/features/settings/SettingsPage.tsx@@ -90,11 +90,18 @@ export function SettingsPage() {const refreshProviders = useAppStore((s) => s.refreshProviders);const platform = (window.piDesktop?.platform ?? "darwin") as ShortcutPlatform;- // Developer-only destinations (Cloud sync and Remote Hosts) exist only- // while developer mode is on; the rail, page, and search drop them together.+ // Experimental feature surfaces remain available in development builds only.+ const includeDevelopmentOnly = import.meta.env.DEV;const developerMode = settings?.developerMode === true;- const navEntries = useMemo(() => visibleSettingsNav(developerMode), [developerMode]);- const tabHidden = isSettingsDestinationHidden(tab, developerMode);+ const navEntries = useMemo(+ () => visibleSettingsNav(developerMode, includeDevelopmentOnly),+ [developerMode, includeDevelopmentOnly],+ );+ const tabHidden = isSettingsDestinationHidden(+ tab,+ developerMode,+ includeDevelopmentOnly,+ );const [query, setQuery] = useState("");const [recoveringSettings, setRecoveringSettings] = useState(!settings);diff --git a/apps/desktop/src/lib/settings-search.ts b/apps/desktop/src/lib/settings-search.tsindex c61eca514..cc5f7d513 100644--- a/apps/desktop/src/lib/settings-search.ts+++ b/apps/desktop/src/lib/settings-search.ts@@ -49,6 +49,8 @@ export type SettingsNavEntry = {* rail, the page, and settings search drop it together.*/developerOnly?: true;+ /** Surface is omitted from packaged builds; development builds retain it. */+ developmentOnly?: true;/** Localized Experimental badge shown beside the rail row and page title. */experimentalBadgeKey?: string;};@@ -130,6 +132,7 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [titleKey: "settings.voice",group: "preferences",developerOnly: true,+ developmentOnly: true,experimentalBadgeKey: "settings.voiceExperimental",keywordKeys: ["settings.voiceEnable",@@ -275,6 +278,7 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [titleKey: "settings.configSync.title",group: "system",developerOnly: true,+ developmentOnly: true,experimentalBadgeKey: "settings.configSync.experimental",keywordKeys: ["settings.configSync.connectionTitle",@@ -291,6 +295,7 @@ export const SETTINGS_NAV: SettingsNavEntry[] = [titleKey: "settings.remoteHosts.title",group: "system",developerOnly: true,+ developmentOnly: true,experimentalBadgeKey: "settings.remoteHosts.experimental",keywordKeys: ["settings.remoteHosts.title",@@ -327,25 +332,29 @@ 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.+ * Destinations the current mode offers. Unavailable destinations are omitted+ * from navigation and search rather than disabled.*/-export function visibleSettingsNav(developerMode: boolean): SettingsNavEntry[] {- return SETTINGS_NAV.filter((entry) => entry.developerOnly !== true || developerMode);+export function visibleSettingsNav(+ developerMode: boolean,+ includeDevelopmentOnly = true,+): SettingsNavEntry[] {+ return SETTINGS_NAV.filter(+ (entry) =>+ (entry.developerOnly !== true || developerMode) &&+ (entry.developmentOnly !== true || includeDevelopmentOnly),+ );}-/**- * 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.- */+/** True when a stale selection points to a destination the current mode hides. */export function isSettingsDestinationHidden(tab: SettingsTabId,developerMode: boolean,+ includeDevelopmentOnly = true,): boolean {- const entry = SETTINGS_NAV.find((candidate) => candidate.id === tab);- return entry?.developerOnly === true && !developerMode;+ return !visibleSettingsNav(developerMode, includeDevelopmentOnly).some(+ (entry) => entry.id === tab,+ );}export type SettingsSearchHit = {@@ -357,19 +366,25 @@ export type SettingsSearchHit = {export type SettingsSearchOptions = {limit?: number;- /** Search mirrors the rail, so developer-only tabs stay out of the results. */+ /** Search mirrors the rail, so developer-only tabs stay out of results. */developerMode?: boolean;+ /** Packaged builds omit experimental surfaces, even with developer mode on. */+ includeDevelopmentOnly?: boolean;};export function searchSettings(query: string,t: (key: string) => string,- { limit = 8, developerMode = false }: SettingsSearchOptions = {},+ {+ limit = 8,+ developerMode = false,+ includeDevelopmentOnly = true,+ }: SettingsSearchOptions = {},): SettingsSearchHit[] {const q = query.trim().toLowerCase();if (!q) return [];const hits: SettingsSearchHit[] = [];- for (const entry of visibleSettingsNav(developerMode)) {+ for (const entry of visibleSettingsNav(developerMode, includeDevelopmentOnly)) {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.mjsindex 84e2e3677..8d3486dfc 100644--- a/apps/desktop/test/settings-developer-only-destinations.test.mjs+++ b/apps/desktop/test/settings-developer-only-destinations.test.mjs@@ -1,10 +1,7 @@/**- * Developer-only settings destinations contract.- *- * Voice, Cloud sync, and Remote Hosts are experimental surfaces that exist only while- * developer mode is on. The rail, page, and settings search must add and drop- * them together, and a stale selection must fall back to General instead of- * rendering a page the rail no longer offers.+ * Experimental settings destinations are retained in development builds but+ * omitted from packaged builds. Navigation, search, and stale-page handling+ * must all honor the same build visibility.*/import assert from "node:assert/strict";import { readFileSync } from "node:fs";@@ -24,39 +21,43 @@ const searchDialog = readFileSync(new URL("../src/components/SearchDialog.tsx", import.meta.url),"utf8",);+const composer = readFileSync(+ new URL("../src/components/Composer.tsx", import.meta.url),+ "utf8",+);const identity = (key) => key;+const experimentalIds = ["voice", "sync", "remoteHosts"];-test("developer mode alone decides which destinations exist", () => {+test("developer mode retains the experimental destinations in development", () => {const off = visibleSettingsNav(false).map((entry) => entry.id);const on = visibleSettingsNav(true).map((entry) => entry.id);- assert.equal(off.includes("sync"), false);- assert.equal(on.includes("sync"), true);- assert.equal(off.includes("voice"), false);- assert.equal(on.includes("voice"), true);- assert.equal(off.includes("remoteHosts"), false);- assert.equal(on.includes("remoteHosts"), true);- assert.deepEqual(- off,- on.filter((id) => id !== "voice" && id !== "sync" && id !== "remoteHosts"),- );- // Both gated destinations carry the badge rendered by the rail and title.+ for (const id of experimentalIds) {+ assert.equal(off.includes(id), false);+ assert.equal(on.includes(id), true);+ }+ assert.deepEqual(off, on.filter((id) => !experimentalIds.includes(id)));assert.deepEqual(SETTINGS_NAV.filter((entry) => entry.developerOnly === true).map((entry) => entry.id),- ["voice", "sync", "remoteHosts"],+ experimentalIds,);assert.ok(SETTINGS_NAV.filter((entry) => entry.developerOnly === true).every((entry) => entry.experimentalBadgeKey),);- assert.equal(- SETTINGS_NAV.find((entry) => entry.id === "sync")?.experimentalBadgeKey,- "settings.configSync.experimental",- );});-test("settings search mirrors the rail", () => {+test("packaged builds hide voice, cloud sync, and remote hosts", () => {+ const packaged = visibleSettingsNav(true, false).map((entry) => entry.id);+ for (const id of experimentalIds) {+ assert.equal(packaged.includes(id), false);+ assert.equal(isSettingsDestinationHidden(id, true, false), true);+ }+ assert.equal(isSettingsDestinationHidden("general", true, false), false);+});++test("settings search mirrors developer and packaged visibility", () => {assert.deepEqual(searchSettings("configSync.connectionTitle", identity, { developerMode: false }),[],@@ -65,35 +66,31 @@ test("settings search mirrors the rail", () => {searchSettings("configSync.connectionTitle", identity, { developerMode: true }).some((hit) => hit.tab === "sync"),);- assert.deepEqual(searchSettings("remotehosts", identity, { developerMode: false }), []);- assert.deepEqual(searchSettings("voiceEnable", identity, { developerMode: false }), []);- assert.ok(- searchSettings("voiceEnable", identity, { developerMode: true })- .some((hit) => hit.tab === "voice"),- );- 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("sync", false), true);- assert.equal(isSettingsDestinationHidden("sync", true), false);- assert.equal(isSettingsDestinationHidden("remoteHosts", false), true);- assert.equal(isSettingsDestinationHidden("remoteHosts", true), false);- assert.equal(isSettingsDestinationHidden("voice", false), true);- assert.equal(isSettingsDestinationHidden("voice", true), false);- assert.equal(isSettingsDestinationHidden("general", false), false);+ for (const query of ["voiceEnable", "configSync.connectionTitle", "remotehosts"]) {+ assert.ok(+ searchSettings(query, identity, { developerMode: true })+ .some((hit) => experimentalIds.includes(hit.tab)),+ );+ assert.deepEqual(+ searchSettings(query, identity, {+ developerMode: true,+ includeDevelopmentOnly: false,+ }),+ [],+ );+ }+ assert.equal(searchSettings("settings", identity, { limit: 2 }).length, 2);});-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\)/);+test("settings routes, global search, and composer use build visibility", () => {+ assert.match(settingsPage, /const includeDevelopmentOnly = import\.meta\.env\.DEV/);+ assert.match(settingsPage, /visibleSettingsNav\(developerMode, includeDevelopmentOnly\)/);+ assert.match(settingsPage, /isSettingsDestinationHidden\([\s\S]*includeDevelopmentOnly/);assert.match(settingsPage, /setSettingsTab\("general"\)/);assert.match(settingsPage, /tab === "sync" && !tabHidden && <ConfigSyncPage \/>/);- assert.match(settingsPage, /item\.experimentalBadgeKey/);- assert.match(settingsPage, /activeNavItem\?\.experimentalBadgeKey/);assert.match(settingsPage, /tab === "remoteHosts" && !tabHidden && <RemoteHostsPage \/>/);- assert.match(searchDialog, /searchSettings\(query, t, \{ developerMode \}\)/);+ assert.match(searchDialog, /includeDevelopmentOnly: import\.meta\.env\.DEV/);+ assert.match(composer, /const voiceEnabled = import\.meta\.env\.DEV && !!settings\?\.voice\?\.enabled/);+ assert.match(composer, /\{import\.meta\.env\.DEV && \([\s\S]*<VoiceOverlay/);});