Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(plan): preserve the owning session permission on approval
Linuxdazhao7a7827727091
diff --git a/apps/desktop/src/components/PlanApprovalBar.tsx b/apps/desktop/src/components/PlanApprovalBar.tsxindex 391dac5a6..13fb69327 100644--- a/apps/desktop/src/components/PlanApprovalBar.tsx+++ b/apps/desktop/src/components/PlanApprovalBar.tsx@@ -9,10 +9,7 @@ import type {import { useAppStore } from "../stores/app-store";import { preferredFileWorkPanelTab } from "../lib/work-panel-tabs";import { PLAN_APPROVAL_DEFAULT_MODE } from "../lib/plan-mode-state";-import {- readPlanApprovalMode,- rememberPlanApprovalMode,-} from "../lib/plan-approval-preferences";+import { readPlanApprovalMode } from "../lib/plan-approval-preferences";import {IconCheck,IconChevronDown,@@ -56,6 +53,12 @@ export function PlanApprovalBar({ proposal }: { proposal: PlanProposal }) {const { t } = useTranslation();const resolvePlan = useAppStore((state) => state.resolvePlan);const showToast = useAppStore((state) => state.showToast);+ const permissionMode = useAppStore((state) =>+ state.sessions.find((session) => session.id === proposal.sessionId)?.permissionMode,+ );+ const defaultPermissionMode = useAppStore(+ (state) => state.settings?.defaultPermissionMode,+ );const pluginViews = useAppStore((state) => state.pluginViews);const openWorkPanelTabForSession = useAppStore((state) => state.openWorkPanelTabForSession,@@ -63,7 +66,7 @@ export function PlanApprovalBar({ proposal }: { proposal: PlanProposal }) {const [menuOpen, setMenuOpen] = useState(false);const [resolving, setResolving] = useState(false);const [approvalMode, setApprovalMode] = useState<GlobalPermissionMode>(- readPlanApprovalMode(),+ readPlanApprovalMode(permissionMode, defaultPermissionMode),);const kind: ProposalKind = proposal.kind === "goal" ? "goal" : "plan";const copy = (name: string) => t(copyKey(kind, name));@@ -72,9 +75,9 @@ export function PlanApprovalBar({ proposal }: { proposal: PlanProposal }) {const busy = resolving;useEffect(() => {- setApprovalMode(readPlanApprovalMode());+ setApprovalMode(readPlanApprovalMode(permissionMode, defaultPermissionMode));setMenuOpen(false);- }, [proposal.id]);+ }, [proposal.id, permissionMode, defaultPermissionMode]);useEffect(() => {setResolving(false);@@ -96,7 +99,6 @@ export function PlanApprovalBar({ proposal }: { proposal: PlanProposal }) {if (action === "approve") {const selectedMode = targetPermissionMode ?? PLAN_APPROVAL_DEFAULT_MODE;setApprovalMode(selectedMode);- rememberPlanApprovalMode(selectedMode);}setResolving(true);try {diff --git a/apps/desktop/src/lib/plan-approval-preferences.ts b/apps/desktop/src/lib/plan-approval-preferences.tsindex b81ff5a54..edd68a8c4 100644--- a/apps/desktop/src/lib/plan-approval-preferences.ts+++ b/apps/desktop/src/lib/plan-approval-preferences.ts@@ -1,39 +1,17 @@-import type { GlobalPermissionMode } from "@pi-desktop/shared";+import type { GlobalPermissionMode, PermissionMode } from "@pi-desktop/shared";-export const PLAN_APPROVAL_MODE_STORAGE_KEY = "pi.desktop.planApprovalMode";export const PLAN_APPROVAL_FALLBACK_MODE: GlobalPermissionMode = "ask";function isApprovalMode(value: unknown): value is GlobalPermissionMode {return value === "ask" || value === "accept-edits" || value === "auto";}-function storage(): Storage | null {- try {- return typeof globalThis !== "undefined" && "localStorage" in globalThis- ? globalThis.localStorage- : null;- } catch {- return null;- }-}--export function readPlanApprovalMode(): GlobalPermissionMode {- const store = storage();- if (!store) return PLAN_APPROVAL_FALLBACK_MODE;- try {- const value = store.getItem(PLAN_APPROVAL_MODE_STORAGE_KEY);- return isApprovalMode(value) ? value : PLAN_APPROVAL_FALLBACK_MODE;- } catch {- return PLAN_APPROVAL_FALLBACK_MODE;- }-}--export function rememberPlanApprovalMode(mode: GlobalPermissionMode): void {- const store = storage();- if (!store) return;- try {- store.setItem(PLAN_APPROVAL_MODE_STORAGE_KEY, mode);- } catch {- // A blocked or full localStorage must not prevent approval.- }+export function readPlanApprovalMode(+ permissionMode?: PermissionMode,+ defaultPermissionMode?: GlobalPermissionMode,+): GlobalPermissionMode {+ if (isApprovalMode(permissionMode)) return permissionMode;+ return isApprovalMode(defaultPermissionMode)+ ? defaultPermissionMode+ : PLAN_APPROVAL_FALLBACK_MODE;}diff --git a/apps/desktop/src/lib/plan-mode-state.ts b/apps/desktop/src/lib/plan-mode-state.tsindex c8e69f8ea..84162b868 100644--- a/apps/desktop/src/lib/plan-mode-state.ts+++ b/apps/desktop/src/lib/plan-mode-state.ts@@ -4,7 +4,7 @@ import type {PlanningStateEvent,} from "@pi-desktop/shared";-/** Every new approval is an explicit, per-proposal Ask decision. */+/** Fail closed when no effective session permission is available. */export const PLAN_APPROVAL_DEFAULT_MODE: GlobalPermissionMode = "ask";export type PlanCheckpointStatus =diff --git a/apps/desktop/test/plan-approval-permission.test.mjs b/apps/desktop/test/plan-approval-permission.test.mjsnew file mode 100644index 000000000..eda38f934--- /dev/null+++ b/apps/desktop/test/plan-approval-permission.test.mjs@@ -0,0 +1,122 @@+import assert from "node:assert/strict";+import { readFileSync } from "node:fs";+import { createRequire } from "node:module";+import test from "node:test";+import vm from "node:vm";+import ts from "typescript";++const require = createRequire(import.meta.url);+const source = path => readFileSync(new URL(`../src/${path}`, import.meta.url), "utf8");+const compile = text => ts.transpileModule(text, {+ compilerOptions: { module: ts.ModuleKind.CommonJS, jsx: ts.JsxEmit.ReactJSX },+}).outputText;++function harness(permissionMode, defaultPermissionMode = "ask", remembered = "ask") {+ const preferences = { exports: {} };+ vm.runInNewContext(compile(source("lib/plan-approval-preferences.ts")), {+ exports: preferences.exports,+ localStorage: { getItem: () => remembered, setItem: () => {} },+ });+ const session = { id: "owner", mode: "agent", permissionMode };+ const resolutions = [];+ const state = {+ activeSessionId: "other",+ sessions: [session, { id: "other", permissionMode: "ask" }],+ settings: { defaultPermissionMode },+ resolvePlan: async resolution => {+ resolutions.push(resolution);+ if (resolution.action === "approve") {+ session.mode = "agent";+ session.permissionMode = resolution.targetPermissionMode;+ }+ },+ };+ const store = selector => selector(state);+ store.getState = () => state;+ const hooks = [];+ let cursor = 0;+ const effects = [];+ const component = { exports: {} };+ vm.runInNewContext(compile(source("components/PlanApprovalBar.tsx")), {+ exports: component.exports,+ require: id => {+ if (id === "react") return {+ useState: initial => {+ const index = cursor++;+ if (!(index in hooks)) hooks[index] = typeof initial === "function" ? initial() : initial;+ return [hooks[index], value => { hooks[index] = value; }];+ },+ useEffect: effect => effects.push(effect),+ };+ if (id === "react-i18next") return { useTranslation: () => ({ t: key => key }) };+ if (id.endsWith("/app-store")) return { useAppStore: store };+ if (id.endsWith("/plan-approval-preferences")) return preferences.exports;+ if (id.endsWith("/plan-mode-state")) return { PLAN_APPROVAL_DEFAULT_MODE: "ask" };+ if (id === "react/jsx-runtime") return require(id);+ return {};+ },+ });+ const proposal = { id: "proposal", sessionId: session.id, turnId: "turn", toolCallId: "call", version: 1, kind: "plan", title: "Synthetic plan", status: "pending" };+ const render = () => { cursor = 0; return component.exports.PlanApprovalBar({ proposal }); };+ return {+ session, resolutions, proposal,+ mount: () => { session.mode = "plan"; render(); effects.splice(0).forEach(effect => effect()); return render(); },+ };+}++function find(node, predicate) {+ if (!node) return;+ if (predicate(node)) return node;+ for (const child of [node.props?.children].flat()) {+ const match = find(child, predicate);+ if (match) return match;+ }+ // AnchoredMenu renders the approval button through its trigger callback.+ if (node.props?.trigger) return find(node.props.trigger(null), predicate);+}++test("Agent bypass survives Plan submission and approval in the owning session", async () => {+ const h = harness("auto");+ const tree = h.mount();+ const button = find(tree, node => node.props?.className === "plan-approval-approve-main");+ await button.props.onClick();+ assert.equal(h.resolutions[0].targetPermissionMode, "auto");+ assert.equal(button.props["aria-label"], "plan.approveAuto");+ assert.equal(h.session.mode, "agent");+ assert.equal(h.session.permissionMode, "auto");+});++test("approval follows session overrides and inherited settings, ignoring another session's remembered choice", async () => {+ for (const [permissionMode, globalMode, remembered, expected] of [+ ["ask", "auto", "auto", "ask"],+ ["accept-edits", "auto", "ask", "accept-edits"],+ ["inherit", "auto", "ask", "auto"],+ ["inherit", "accept-edits", "auto", "accept-edits"],+ ["inherit", "ask", "auto", "ask"],+ [undefined, undefined, "auto", "ask"],+ ]) {+ const h = harness(permissionMode, globalMode, remembered);+ const tree = h.mount();+ await find(tree, node => node.props?.className === "plan-approval-approve-main").props.onClick();+ assert.equal(h.resolutions[0].targetPermissionMode, expected);+ assert.equal(h.session.permissionMode, expected);+ }+});++test("an explicit approval choice still changes the execution permission", async () => {+ const h = harness("auto");+ const tree = h.mount();+ await find(tree, node => node.props?.["data-approval-mode"] === "ask").props.onClick();+ assert.equal(h.resolutions[0].targetPermissionMode, "ask");+ assert.equal(h.session.permissionMode, "ask");+});++test("reject does not send or change the session permission", async () => {+ const h = harness("auto");+ const tree = h.mount();+ await find(tree, node => node.props?.className === "plan-approval-reject").props.onClick();+ assert.equal(h.resolutions[0].action, "reject");+ assert.equal("targetPermissionMode" in h.resolutions[0], false);+ assert.equal(h.session.permissionMode, "auto");+ assert.equal(h.session.mode, "plan");+});diff --git a/apps/desktop/test/plan-approval-settings.test.mjs b/apps/desktop/test/plan-approval-settings.test.mjsindex c4cda21d2..85672647c 100644--- a/apps/desktop/test/plan-approval-settings.test.mjs+++ b/apps/desktop/test/plan-approval-settings.test.mjs@@ -30,7 +30,7 @@ const [approvalBar, approvalPreferences, apiSource, storeSource, settingsPage, s]);const interactionSource = readStoreModuleSync("slices/interaction-slice.ts");-test("plan approval exposes only the artifact and remembers the selected mode", () => {+test("plan approval exposes only the artifact and follows the session permission", () => {assert.match(approvalBar, /proposal\.title/);assert.match(approvalBar,@@ -39,10 +39,8 @@ test("plan approval exposes only the artifact and remembers the selected mode",assert.match(approvalBar, /openWorkPanelTabForSession/);assert.match(approvalBar, /const isPending = proposal\.status === "pending"/);assert.match(approvalBar, /PLAN_APPROVAL_DEFAULT_MODE/);- assert.match(approvalBar, /readPlanApprovalMode\(\)/);- assert.match(approvalBar, /rememberPlanApprovalMode\(selectedMode\)/);- assert.match(approvalPreferences, /PLAN_APPROVAL_MODE_STORAGE_KEY/);- assert.match(approvalPreferences, /store\.setItem\(PLAN_APPROVAL_MODE_STORAGE_KEY, mode\)/);+ assert.match(approvalBar, /readPlanApprovalMode\(permissionMode, defaultPermissionMode\)/);+ assert.doesNotMatch(approvalPreferences, /localStorage|rememberPlanApprovalMode/);assert.match(approvalPreferences, /PLAN_APPROVAL_FALLBACK_MODE/);assert.doesNotMatch(approvalBar, /proposal\.question|proposal\.expiresAt|autoWarning|expiresAt|statusText/);assert.doesNotMatch(approvalBar, /planApprovalPermissionMode|feedback|changes_requested/);diff --git a/apps/desktop/test/plan-renderer-flow.test.mjs b/apps/desktop/test/plan-renderer-flow.test.mjsindex cb036947f..3b3568db8 100644--- a/apps/desktop/test/plan-renderer-flow.test.mjs+++ b/apps/desktop/test/plan-renderer-flow.test.mjs@@ -43,12 +43,13 @@ test("terminal proposals and execution states stay session-scoped and readable",assert.doesNotMatch(store, /planApprovalPermissionMode/);});-test("each pending proposal restores the remembered approval choice", () => {- assert.match(approvalBar, /useState<GlobalPermissionMode>\(\s*readPlanApprovalMode\(\)/);- assert.match(approvalBar, /setApprovalMode\(readPlanApprovalMode\(\)\)/);- assert.match(approvalBar, /rememberPlanApprovalMode\(selectedMode\)/);- assert.match(approvalBar, /\}, \[proposal\.id\]\);/);- assert.doesNotMatch(approvalBar, /state\.settings|planApprovalPermissionMode/);+test("each pending proposal follows its owning session's effective permission", () => {+ assert.match(approvalBar, /useState<GlobalPermissionMode>\(\s*readPlanApprovalMode\(permissionMode, defaultPermissionMode\)/);+ assert.match(approvalBar, /setApprovalMode\(readPlanApprovalMode\(permissionMode, defaultPermissionMode\)\)/);+ assert.match(approvalBar, /session\.id === proposal\.sessionId/);+ assert.match(approvalBar, /state\.settings\?\.defaultPermissionMode/);+ assert.match(approvalBar, /\[proposal\.id, permissionMode, defaultPermissionMode\]/);+ assert.doesNotMatch(approvalBar, /rememberPlanApprovalMode|planApprovalPermissionMode/);});test("pending input is retained but every composer/model mutation control is gated", () => {diff --git a/docs/adr/README.md b/docs/adr/README.mdindex 2556b891b..303b579d5 100644--- a/docs/adr/README.md+++ b/docs/adr/README.md@@ -413,3 +413,4 @@ Each ADR includes:| 0345 | [One settings destination owns one subject](0345-one-settings-destination-one-subject.md) | Accepted (D684; amends D143, D166, D678) || 0346 | [`@agent` mentions route a turn to a named subagent](0346-composer-agent-mentions.md) | Accepted (issue #986; extends 0024 / 0062) || composer-local-file-references | [Pasted local files are live references](composer-local-file-references.md) | Accepted (issue #2314) |+| plan-approval-session-permission | [Plan approval defaults to the owning Session's permission](plan-approval-session-permission.md) | Accepted; amends ADR 0053 and ADR 0158 |diff --git a/docs/adr/plan-approval-session-permission.md b/docs/adr/plan-approval-session-permission.mdnew file mode 100644index 000000000..4b136613c--- /dev/null+++ b/docs/adr/plan-approval-session-permission.md@@ -0,0 +1,36 @@+# Plan approval defaults to the owning Session's permission++- Status: Accepted+- Date: 2026-11-13+- Amends: ADR 0053, ADR 0158++## Context++The approval card used a device-wide remembered execution mode, falling back+to Ask independently of the Session. An Auto Session could enter Plan, approve+with the main button, and return to Agent in Ask. Conversely, another Session's+remembered Auto choice could replace an Ask Session's execution policy.++## Decision++Initialize Plan and legacy Goal approval from the proposal's owning Session's+effective permission: explicit Session mode, global default for inherit or+unavailable values, then Ask. Refresh the default when the proposal or effective+permission inputs change. Ignore and stop writing the legacy renderer-local+`pi.desktop.planApprovalMode` preference; no storage migration is required.++Keep the explicit Ask / Accept edits / Auto split-button choices. The displayed+choice remains part of the user approval request. Host validation, matching+proposal identity, artifact ownership, and the atomic approved-mode write to+the Session remain unchanged. Reject carries no permission mode.++## Alternatives and consequences++Keeping device-wide history as the default would retain cross-Session policy+changes. Changing Host resolution to ignore the submitted mode would instead+break explicit approval choices. Reading the existing Session projection fixes+the default at its UI owner without changing protocol or storage schema.++The same Session now carries its effective permission through Plan approval.+An explicit approval choice still changes that Session's permission. This does+not restore already-changed Sessions or install a new application build.diff --git a/docs/spec/00-baseline.md b/docs/spec/00-baseline.mdindex 2894ff0b2..260490f55 100644--- a/docs/spec/00-baseline.md+++ b/docs/spec/00-baseline.md@@ -1,5 +1,9 @@# PI-Desktop Baseline Freeze+> [Session-owned Plan approval permissions](../adr/plan-approval-session-permission.md)+> makes the Plan/legacy Goal approval default follow the owning Session's effective+> permission. Device-wide approval history no longer overrides that Session.+> [Pasted directory references](../adr/composer-pasted-directory-references.md) add> folder cards and lazy dir prompt context without copying trees or granting access.> [Pasted local file references](../adr/composer-local-file-references.md) extend@@ -211,7 +215,8 @@structured fields in the existing `plan_approvals` row. The row records theartifact path/hash/size and execution fields. Approve/reject are the onlyactions; approval explicitly selects `ask`, `accept-edits`, or `auto` with- Ask as the UI default, opens the artifact for review, and expires after 30+ the Session's effective permission as the UI default (Ask when unavailable),+ opens the artifact for review, and expires after 30absolute minutes with `PLAN_APPROVAL_TIMEOUT`.**46. Plan recovery and shells: **a startup transaction marks prior pending,queued, and running Plan work interrupted before serving RPC, with nodiff --git a/docs/spec/03-runtime/01-ipc-protocol.md b/docs/spec/03-runtime/01-ipc-protocol.mdindex 0a6b093e7..1f812758d 100644--- a/docs/spec/03-runtime/01-ipc-protocol.md+++ b/docs/spec/03-runtime/01-ipc-protocol.md@@ -538,8 +538,10 @@ current renderer lifetime while live `plans.changed` events arrive.For `approve`, host-core and Electron require an explicit`targetPermissionMode`; Electron never fills it from stored settings. The-renderer initializes each approval to Ask, which remains the product default,-and the host does not persist the selection as the next approval default.+renderer initializes each approval from its owning Session's effective+permission (Session override, then global default, then Ask), and ignores old+device-wide approval preferences. The Host still persists the explicitly+approved mode on the Session; it does not change the global default.`reject` carries no permission mode.Responses with a wrong proposal, session, turn, tool-call, version, or expiredhost-owned deadline fail with a stable Plan/Goal approval error. There is nodiff --git a/docs/spec/03-runtime/06-host-rpc-protocol.md b/docs/spec/03-runtime/06-host-rpc-protocol.mdindex d0bd41e8c..7e8b0e53d 100644--- a/docs/spec/03-runtime/06-host-rpc-protocol.md+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md@@ -1215,7 +1215,8 @@ explicit permission mode and atomically commits the `plan_approvals` row to`status = approved`, assigns `execution_id`, sets `execution_state = queued`,sets `sessions.mode = agent`, and stores the selected`sessions.permission_mode`; that selection is not written into app settings-as the next approval default. Ask remains the product default. The same Agent then receives a new provider+as the next approval default. The renderer defaults approval to the owning+Session's effective permission, with Ask as the final fallback. The same Agent then receives a new providerrequest with Agent tools.`reject` records `rejected` and leaves the session in its contract mode (Plan ordiff --git a/docs/spec/04-ux/03-permission-ux.md b/docs/spec/04-ux/03-permission-ux.mdindex f2cfbbd77..84b1a062a 100644--- a/docs/spec/04-ux/03-permission-ux.md+++ b/docs/spec/04-ux/03-permission-ux.md@@ -154,8 +154,11 @@ path. It does not render the submitted question/description, status, orapproval validity/deadline. It offers only:- **Approve** with an explicit target permission mode (`Ask`, `Accept edits`,- or `Auto`; the last selected mode is remembered on this device and is the- default for the next approval)+ or `Auto`). The default follows the proposal's owning Session, resolving+ `inherit` through the global permission default and falling back to Ask.+ Device-wide approval history is ignored. Clicking the main button preserves+ that effective permission; choosing a mode from the menu explicitly changes+ the Session's execution permission when approval succeeds.- **Reject**, which stops the run and leaves the contract state active; a laterturn must submit a new complete snapshot/artifact@@ -187,8 +190,8 @@ after a full Host/app restart.6. concurrent session requests remain isolated and never take over the visibleconversation or its work panel; post-approval artifacts remain assigned tothe request's originating session-7. Plan/Goal approval displays only the title and artifact opener, remembers the- selected permission mode for the next approval on this device, and sends that+7. Plan/Goal approval displays only the title and artifact opener, defaults to+ its owning Session's effective permission mode, and sends thatmode only on approval; no question/description, validity/deadline, status,inline Markdown/hash/byte-size, or revision/feedback action is rendered8. reject, expiry, abort, crash, stale response, and persistence failure closediff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 8ee2fa60d..1dab3f13b 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -3041,8 +3041,11 @@ is rejected and resubmitted.| Rejected | no actions | run stops and session remains in its contract mode || Expired / Interrupted | no actions | failed closed; a new contract must be submitted unless approval already committed, in which case session remains Agent |-Approve opens the explicit Ask / Accept edits / Auto choice with the last selected-mode remembered on this device. Reject carries no permission mode. The renderer keeps the latest proposal/execution snapshot per+Approve opens the explicit Ask / Accept edits / Auto choice defaulting to the+effective mode of the proposal's owning Session (`inherit` resolves through the+global default, then Ask). Previous device-wide approval choices are ignored;+explicit menu choices still set execution permission. Reject carries no+permission mode. The renderer keeps the latest proposal/execution snapshot persession only for the current renderer lifetime from live Host events, while onlya pending snapshot has actions or gates the Composer. Renderer reload calls`plans.pending` and restores a still-pending row with its original deadline while@@ -3486,7 +3489,7 @@ reasoning-level control.The control does not imply that Write/Edit/plugin tools are available.- Goal shares the Plan approval surface (D198). The bar reads its copy from theproposal's `kind`, so a goal contract shows the matching approval label and- artifact opener while the layout and remembered permission split-button stay+ artifact opener while the layout and Session-default permission split-button stayidentical. The bar sits in the transparent composer dock, so it paints`--ds-bg-composer` with `--ds-shadow-composer` like queued prompt rows ratherthan the in-flow `--ds-tile` wash.diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex c74157719..bb59a20ae 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -8552,7 +8552,8 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.#### E2E-106: SubmitPlan rejects into editable planning and resubmits a new artifact-- **Preconditions**: A project-bound session is idle in Plan with a provider;+- **Preconditions**: A project-bound session starts in Agent with Auto permission,+ then enters Plan with a provider;`.pi/plan/` is absent or empty and the workspace permits host artifactcreation.- **Steps**: 1) Let the Agent call `SubmitPlan` with fixed title, Markdown, and@@ -8561,12 +8562,16 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.the opener uses the bundled file view when it is launchable and the hostfile tab otherwise (D452), and that the question/description,validity/deadline, and status are absent with only Approve and Reject- offered. 4) Open the approval mode menu, choose Auto,- and verify the next approval defaults to Auto. 5) Reject the+ offered. 4) Verify the main approval button defaults to Auto even if an older+ device-wide preference was Ask. 5) Reject theproposal. 6) Confirm durable mode is Plan, live state is editable `planning`,the approval gate is cleared, and a later prompt is accepted. 7) Let theAgent revise and call `SubmitPlan` once in that new turn with a complete- snapshot. 8) Approve the second proposal with the remembered Auto mode.+ snapshot. 8) Approve the second proposal using the main Auto button.+ 9) Repeat with Ask and Accept edits Sessions, and an inherit Session whose+ global default is Auto; verify each card follows its own Session even when+ another Session is active. 10) In an Auto Session, explicitly approve with+ Ask from the menu and verify the return to Agent uses Ask.- **Expected**: Host preserves the exact submitted Markdown bytes in a newunique artifact, records its relative path/hash/size with structuredtitle/question, and never lets the renderer or sidecar write or replace it.@@ -8575,13 +8580,15 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.the bundled file view, falling back to the host file tab when that view is notlaunchable (D452);it does not require inline question/Markdown/hash/size or a validity/deadline- indicator. The selected approval mode is remembered locally for the next- approval.+ indicator. The approval default follows the owning Session's effective+ permission, ignoring legacy device-wide approval history. Main-button+ approval preserves Auto across Plan → Agent; an explicit menu choice changes+ the execution permission. Reject sends no mode and preserves it.Rejection is terminal for the first row, leaves durable mode Plan, and returnslive state to editable planning. The later prompt/resubmission creates asecond complete Markdown snapshot and a different `.pi/plan/*.md` artifact;the first artifact bytes remain unchanged. Approving the second proposal with- the remembered Auto mode still changes the same Agent to Agent and queues execution.+ the Session's Auto mode still changes the same Agent to Agent and queues execution.- **Specs linked**: `03-runtime/01-ipc-protocol.md`,`03-runtime/02-agent-runtime.md`, `03-runtime/04-data-storage.md`,`03-runtime/06-host-rpc-protocol.md`, `04-ux/03-permission-ux.md`,