Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
chore(network): keep main/index.ts inside its line budget, and rustfmt
vastsad19007e8697d
diff --git a/apps/desktop/electron/main/index.ts b/apps/desktop/electron/main/index.tsindex 3696802be..f346f35ac 100644--- a/apps/desktop/electron/main/index.ts+++ b/apps/desktop/electron/main/index.ts@@ -12,7 +12,7 @@ import {currentNetworkProxy,testNetworkProxy,} from "./network-proxy";-import { setInsecureEndpointNoticeSink } from "./endpoint-policy";+import { installInsecureEndpointNotice } from "./network-notice";import {APP_ID,APP_NAME,@@ -836,17 +836,10 @@ function sendToRenderer(channel: string, payload: unknown) {// it. Notifying a gone frame is routine teardown, never an error:// supervision must keep running with no window attached.}+}-/**- * The relaxed network mode may carry one plaintext hop to an endpoint the user- * typed. Tell the shell once, through the same channel as every other- * host-originated event; the shell owns the wording and records the- * acknowledgement in settings (ADR 0304).- */-setInsecureEndpointNoticeSink((host) => {- sendToRenderer(IPC.event.insecureEndpointNotice, { host });-});+installInsecureEndpointNotice(sendToRenderer);let appliedMenuSettings: string | null = null;diff --git a/apps/desktop/electron/main/network-notice.ts b/apps/desktop/electron/main/network-notice.tsnew file mode 100644index 000000000..8dd2f359d--- /dev/null+++ b/apps/desktop/electron/main/network-notice.ts@@ -0,0 +1,24 @@+/**+ * The one-time plaintext notice for the relaxed network mode (ADR 0304).+ *+ * The mode is on by default, so the first `http` hop to an endpoint the user+ * typed is worth saying out loud once: whatever that endpoint accepts travels+ * unencrypted across the local network. `endpoint-policy.ts` decides *when* —+ * it already holds the mode and the acknowledgement — and this module turns that+ * decision into the renderer event, keeping the wiring out of `main/index.ts`,+ * which owns a hard line budget.+ */+import { IPC } from "@pi-desktop/shared";+import { setInsecureEndpointNoticeSink } from "./endpoint-policy";++export type RendererSend = (channel: string, payload: unknown) => void;++/**+ * Point the policy at the renderer. The shell owns the wording and records+ * `networkPolicy.insecureNoticeAcknowledged` in settings after showing it.+ */+export function installInsecureEndpointNotice(send: RendererSend): void {+ setInsecureEndpointNoticeSink((host) => {+ send(IPC.event.insecureEndpointNotice, { host });+ });+}diff --git a/crates/host-core/src/network_proxy.rs b/crates/host-core/src/network_proxy.rsindex 2d34995b4..d0a8cf061 100644--- a/crates/host-core/src/network_proxy.rs+++ b/crates/host-core/src/network_proxy.rs@@ -19,7 +19,8 @@ static MARKET_PROXY: RwLock<ProxyMode> = RwLock::new(ProxyMode::System);/// Mirrors `DEFAULT_NETWORK_PROXY_BYPASS` in `packages/shared`: loopback plus/// the private ranges a user's own LAN devices live in, so a custom proxy never/// swallows a local model server, NAS or MCP endpoint.-const DEFAULT_BYPASS: &str = "localhost,127.0.0.1,::1,<local>,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16";+const DEFAULT_BYPASS: &str =+ "localhost,127.0.0.1,::1,<local>,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16";pub fn apply_from_settings(value: Option<&Value>) {let next = proxy_from_settings(value);diff --git a/crates/host-core/src/rpc/mod.rs b/crates/host-core/src/rpc/mod.rsindex d26004e56..a01663aec 100644--- a/crates/host-core/src/rpc/mod.rs+++ b/crates/host-core/src/rpc/mod.rs@@ -766,9 +766,10 @@ fn validate_settings_value(value: &Value) -> Result<(), JsonRpcError> {"INVALID_PARAMS",));};- if policy.get("mode").is_some_and(|mode| {- !matches!(mode.as_str(), Some("relaxed") | Some("strict"))- }) {+ if policy+ .get("mode")+ .is_some_and(|mode| !matches!(mode.as_str(), Some("relaxed") | Some("strict")))+ {return Err(rpc_err(1002,"networkPolicy.mode must be relaxed or strict",