Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
test(modes): preserve Plan coverage and reject legacy Goal activation
vastsa233022a49997
diff --git a/crates/host-core/src/mode_runs/snapshot.rs b/crates/host-core/src/mode_runs/snapshot.rsindex 4e7577701..6df352098 100644--- a/crates/host-core/src/mode_runs/snapshot.rs+++ b/crates/host-core/src/mode_runs/snapshot.rs@@ -171,8 +171,7 @@ pub fn validate(value: &Value, mode: &str) -> Result<Snapshot> {if json.len() > MAX_SNAPSHOT_BYTES {return Err(invalid("modeSnapshot is larger than 256 KiB"));}- let definition: ModeDefinition =- serde_json::from_value(value.clone()).map_err(|error| invalid(error))?;+ let definition: ModeDefinition = serde_json::from_value(value.clone()).map_err(invalid)?;check(&definition, mode)?;Ok(Snapshot {hash: sha256_hex(json.as_bytes()),@@ -393,9 +392,8 @@ pub fn load(conn: &Connection, hash: &str) -> Result<Option<Snapshot>> {let Some(json) = json else {return Ok(None);};- let value: Value = serde_json::from_str(&json).map_err(|error| invalid(error))?;- let definition: ModeDefinition =- serde_json::from_value(value.clone()).map_err(|error| invalid(error))?;+ let value: Value = serde_json::from_str(&json).map_err(invalid)?;+ let definition: ModeDefinition = serde_json::from_value(value.clone()).map_err(invalid)?;Ok(Some(Snapshot {hash: hash.to_string(),json,diff --git a/scripts/e2e-plan.mjs b/scripts/e2e-plan.mjsindex 7cfc8ce57..abd9e824f 100644--- a/scripts/e2e-plan.mjs+++ b/scripts/e2e-plan.mjs@@ -199,6 +199,19 @@ async function scenarioWorkspaceRequired(binary, tempRoot) {for (const kind of ["plan", "goal"]) {const session = await createSession(ctx.host, undefined, "Temporary contract", "agent");const turnId = await beginTurn(ctx.host, session.id);+ if (kind === "goal") {+ await expectRpcError(() => ctx.host.call("plans.enter", {+ sessionId: session.id, turnId, toolCallId: "enter", kind,+ }), ["PLAN_GOAL_ACTIVATION_DISABLED"]);+ await expectRpcError(() => ctx.host.call("plans.submit", {+ sessionId: session.id, turnId, toolCallId: "submit", kind,+ title: "Legacy Goal", markdown: "# Goal", question: "Proceed?",+ }), ["PLAN_GOAL_ACTIVATION_DISABLED"]);+ const pending = await ctx.host.call("plans.pending", { sessionId: session.id });+ assert(pending.plans.length === 0, "disabled Goal created an approval");+ await endTurn(ctx.host, turnId);+ continue;+ }const entered = await ctx.host.call("plans.enter", {sessionId: session.id, turnId, toolCallId: "enter", kind,});@@ -212,7 +225,7 @@ async function scenarioWorkspaceRequired(binary, tempRoot) {assert(pending.plans.length === 0, "failed submission created an approval");await endTurn(ctx.host, turnId);}- return "Plan/Goal allow planning without a workspace but reject approval submission";+ return "Plan permits planning but needs a workspace for submission; legacy Goal activation is denied";}, binary, tempRoot);}