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(review): open the Review panel only on explicit user action
vastsa58b301a1cd62
diff --git a/apps/desktop/src/lib/work-panel-tabs.ts b/apps/desktop/src/lib/work-panel-tabs.tsindex 153598e5a..5f1266c23 100644--- a/apps/desktop/src/lib/work-panel-tabs.ts+++ b/apps/desktop/src/lib/work-panel-tabs.ts@@ -24,12 +24,6 @@ export type WorkPanelContext = WorkPanelTabsState & {fileRequest: { path: string; seq: number; mimeType?: string } | null;};-export type ReviewArtifactEvent = {- toolName?: string;- isError?: boolean;- result: unknown;-};-let newWorkPanelTabSequence = 0;export function emptyWorkPanelContext(): WorkPanelContext {@@ -226,22 +220,6 @@ export function fileWorkPanelTab(path: string, mimeType?: string): WorkPanelTab};}-export function toolResultRoot(result: unknown): string | null {- if (!result || typeof result !== "object") return null;- const details = (result as { details?: unknown }).details;- if (!details || typeof details !== "object") return null;- const root = (details as { root?: unknown }).root;- return typeof root === "string" ? root : null;-}--export function shouldOpenReviewArtifact(event: ReviewArtifactEvent): boolean {- return (- (event.toolName === "Write" || event.toolName === "Edit") &&- event.isError !== true &&- toolResultRoot(event.result) === "workspace"- );-}-export function openWorkPanelTabState(state: WorkPanelTabsState,tab: WorkPanelTab,diff --git a/apps/desktop/src/stores/app-store.ts b/apps/desktop/src/stores/app-store.tsindex c983892e7..72fb489cf 100644--- a/apps/desktop/src/stores/app-store.ts+++ b/apps/desktop/src/stores/app-store.ts@@ -101,11 +101,7 @@ import {import { settleStoppedAssistantMetrics } from "../lib/context-usage";import { formatToolValue } from "../lib/tool-display";import { withReviewChangeState } from "../lib/workspace-review";-import {- fileWorkPanelTab,- shouldOpenReviewArtifact,- toolWorkPanelTab,-} from "../lib/work-panel-tabs";+import { fileWorkPanelTab } from "../lib/work-panel-tabs";import {clearSessionPermissions,enqueuePermission,diff --git a/apps/desktop/src/stores/slices/events-slice.ts b/apps/desktop/src/stores/slices/events-slice.tsindex 88f62453e..9a8d9bca3 100644--- a/apps/desktop/src/stores/slices/events-slice.ts+++ b/apps/desktop/src/stores/slices/events-slice.ts@@ -26,10 +26,6 @@ import {mergePlanCheckpoint,} from "../../lib/plan-mode-state";import { formatToolValue } from "../../lib/tool-display";-import {- shouldOpenReviewArtifact,- toolWorkPanelTab,-} from "../../lib/work-panel-tabs";import type { AppState } from "../app-state";import type { SessionRuntime } from "../runtime/session-runtime";import type { StoreAccess } from "./types";@@ -352,7 +348,9 @@ export function createEventsSlice({...(envelope.agentName ? { agentName: envelope.agentName } : {}),});} else if (event.type === "tool_end") {- const toolName = runtime.getToolStart(event.toolCallId)?.toolName;+ // A tool result never opens or activates a work-panel tab: Review is a+ // user-opened surface (panel toggle or New launcher), so an agent edit+ // cannot reveal the panel even in its own session.set((state) => {const pendingPermissions = removePermissionForToolCall(state.pendingPermissions,@@ -369,18 +367,6 @@ export function createEventsSlice({? {}: { pendingPermissions, pendingAsks };});- if (- shouldOpenReviewArtifact({- toolName,- isError: event.isError,- result: event.result,- })- ) {- get().openWorkPanelTabForSession(- envelope.sessionId,- toolWorkPanelTab("review"),- );- }}if (event.type === "compaction_end" && event.ok && event.mark) {diff --git a/apps/desktop/test/bundled-plugins.test.mjs b/apps/desktop/test/bundled-plugins.test.mjsindex c9c904a0d..6359584d4 100644--- a/apps/desktop/test/bundled-plugins.test.mjs+++ b/apps/desktop/test/bundled-plugins.test.mjs@@ -102,11 +102,13 @@ test("the host no longer offers Files or Browser as built-in tools", () => {assert.match(panelSource, /activeTab\?\.kind === "review"/);});-test("Review still opens itself from workspace edit artifacts", () => {- // Removing the launcher entry must not remove the way Review appears at all.+test("Review opens only from an explicit user action", () => {+ // The New launcher row and the viewport-fixed toggle are the only ways in,+ // so a workspace edit can no longer reveal or activate Review by itself.const storeSource = readStoreSourceSync();- assert.match(storeSource, /shouldOpenReviewArtifact\(\{/);- assert.match(storeSource, /toolWorkPanelTab\("review"\)/);+ assert.doesNotMatch(storeSource, /shouldOpenReviewArtifact/);+ assert.doesNotMatch(storeSource, /toolWorkPanelTab\("review"\)/);+ assert.match(panelSource, /toolWorkPanelTab\("review"\)/);});test("Browser ships as an ordinary plugin over the public CDP API", () => {diff --git a/apps/desktop/test/chat-review-entry.test.mjs b/apps/desktop/test/chat-review-entry.test.mjsindex 4dd7a142b..9754c5543 100644--- a/apps/desktop/test/chat-review-entry.test.mjs+++ b/apps/desktop/test/chat-review-entry.test.mjs@@ -174,9 +174,9 @@ test("chat renders one message-owned card immediately after its tool row", () =>storeSource,/rollbackWorkspaceChange:[\s\S]*api\.workspaceReviewRollback[\s\S]*withReviewChangeState/,);- assert.match(+ assert.doesNotMatch(eventsSource,- /if \(\s*shouldOpenReviewArtifact\([\s\S]*openWorkPanelTabForSession/,+ /shouldOpenReviewArtifact|toolWorkPanelTab\("review"\)/,);assert.doesNotMatch(storeSource, /workspaceReviewSessions/);});diff --git a/apps/desktop/test/work-panel-tabs.test.mjs b/apps/desktop/test/work-panel-tabs.test.mjsindex 2fcded4ed..2a2121b39 100644--- a/apps/desktop/test/work-panel-tabs.test.mjs+++ b/apps/desktop/test/work-panel-tabs.test.mjs@@ -15,7 +15,6 @@ const {pluginWorkPanelTab,replaceWorkPanelTabState,sanitizeWorkPanelTabsState,- shouldOpenReviewArtifact,switchWorkPanelContextState,toolWorkPanelTab,} = await import("../src/lib/work-panel-tabs.ts");@@ -140,26 +139,6 @@ test("only plugin views are launchable tools", () => {assert.equal(isKnownWorkPanelTab(newWorkPanelTab()), true);});-test("review artifacts are recognized independently of the visible session", () => {- const base = {- toolName: "Write",- isError: false,- result: { details: { root: "workspace" } },- };-- assert.equal(shouldOpenReviewArtifact(base), true);- assert.equal(shouldOpenReviewArtifact({ ...base, toolName: "Edit" }), true);- assert.equal(shouldOpenReviewArtifact({ ...base, toolName: "Bash" }), false);- assert.equal(shouldOpenReviewArtifact({ ...base, isError: true }), false);- assert.equal(- shouldOpenReviewArtifact({- ...base,- result: { details: { root: "scratch" } },- }),- false,- );-});-test("empty work panel context has no visible or retained resource state", () => {assert.deepEqual(emptyWorkPanelContext(), {open: false,diff --git a/apps/desktop/test/work-panel.test.mjs b/apps/desktop/test/work-panel.test.mjsindex 34697423e..3bc32f268 100644--- a/apps/desktop/test/work-panel.test.mjs+++ b/apps/desktop/test/work-panel.test.mjs@@ -441,30 +441,17 @@ test("built-in terminal is absent while the work panel keeps its other surfaces"assert.doesNotMatch(transcriptSource, /openTerminal|terminalArtifact|chat\.openTerminal/);});-test("workspace artifacts attach review to their originating session", () => {- const artifactIndex = storeSource.indexOf("shouldOpenReviewArtifact({");- const openReviewMatch = storeSource.match(- /get\(\)\.openWorkPanelTabForSession\(\s*envelope\.sessionId,\s*toolWorkPanelTab\("review"\),?\s*\)/,- );- const openReviewIndex = openReviewMatch?.index ?? -1;- const gateIndex = storeSource.indexOf(- "if (envelope.sessionId !== get().activeSessionId)",- );- assert.ok(artifactIndex > -1, "workspace artifact gate exists");- assert.ok(openReviewIndex > artifactIndex, "review artifact records its session tab");- assert.ok(gateIndex > -1, "cross-session gate exists");- assert.ok(- openReviewIndex < gateIndex,- "background artifacts must be recorded before the cross-session early-return",- );- assert.match(- storeSource,- /shouldOpenReviewArtifact\(\{[\s\S]*toolName,[\s\S]*isError:\s*event\.isError,[\s\S]*result:\s*event\.result/s,- );+test("tool results never open the Review tab on their own", () => {+ // Review opens only from an explicit user action: the viewport toggle+ // reveals the retained context and the `+` launcher lists its row. A+ // successful Write/Edit may not record, activate, or reveal a tab for any+ // session, visible or background.+ assert.doesNotMatch(storeSource, /shouldOpenReviewArtifact/);assert.doesNotMatch(- storeSource.match(/shouldOpenReviewArtifact\(\{[\s\S]*?\}\)/)?.[0] ?? "",- /activeSessionId|sessionId/,+ storeSource,+ /openWorkPanelTabForSession\([\s\S]{0,120}toolWorkPanelTab\("review"\)/,);+ assert.match(storeSource, /openWorkPanelTabForSession:/);});test("work panel context is retained by session instead of cleared on selection", () => {diff --git a/docs/spec/04-ux/01-ui-ia.md b/docs/spec/04-ux/01-ui-ia.mdindex f0358a2b6..7a97679e7 100644--- a/docs/spec/04-ux/01-ui-ia.md+++ b/docs/spec/04-ux/01-ui-ia.md@@ -107,9 +107,10 @@ destination, chat as the home surface, tools and permissions inline.revealing it without creating a resource tab and collapsing it withoutdiscarding one; the create trigger remains unavailable while the panel isclosed. Closing the final tab keeps the panel open and shows the New launcher.- A- successful active-session workspace Write/Edit artifact opens Review;- scratch, failed, and background-session writes never steal focus. The inner+ No agent or tool result opens, activates, or resizes the panel: Review is+ reached only through an explicit user action, so a successful workspace+ Write/Edit leaves the panel exactly as the user left it and shows its+ evidence as a transcript card instead. The innerdivider resizes the panel through the shared three-column budget; moving itleft takes space until MainChat reaches 450px, at which point the expandedsidebar yields immediately, and moving it right gives space back. A manualdiff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 59d6bbf60..0ed92af0a 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -1014,8 +1014,11 @@ entirely inside the plugin's isolated page:- Trigger: file/URL references and BrowserPreview create/activate theirresource tab in the originating session's runtime context. BrowserPreviewevents carry `sessionId`, and the renderer retains that session's preview- path/URL as its Browser resource. Successful workspace Write/Edit artifacts- create/activate Review in the originating session.+ path/URL as its Browser resource. Review is never triggered by a tool+ result: it opens only from the `+` launcher row or from the retained panel+ context the viewport-fixed toggle and `Cmd/Ctrl + J` reveal, so a successful+ workspace Write/Edit cannot open, activate, or resize the panel in any+ session.The viewport-fixed toggle and `Cmd/Ctrl + J` both toggle the active session'sretained panel context: they reveal the panel without creating a resource andcollapse the visible panel without deleting one. With no active session thediff --git a/docs/spec/04-ux/09-interaction-patterns.md b/docs/spec/04-ux/09-interaction-patterns.mdindex c77e59642..7be654eb5 100644--- a/docs/spec/04-ux/09-interaction-patterns.md+++ b/docs/spec/04-ux/09-interaction-patterns.md@@ -468,10 +468,13 @@ may be retained while exactly one workspace supplies the visible shell context.divider updates the renderer-owned panel target from 244px upward, capped bythe live three-column budget, while native window edges resize only the fixedapplication window (ADR 0151).-- A successful workspace Write/Edit creates or activates Review in its- originating session. Failed and scratch writes do not. Background-session- artifacts update only their retained context and never open, activate, resize,- focus, or change the visible panel.+- No tool result creates or activates a work-panel tab. Review opens only from+ an explicit user action — its `+` launcher row, or the retained context the+ viewport-fixed toggle and `Cmd/Ctrl + J` reveal — so a successful workspace+ Write/Edit never takes the panel away from what the user was reading. Failed+ and scratch writes behave the same. Background-session events update only+ their retained context and never open, activate, resize, focus, or change the+ visible panel.- Each successful workspace Write/Edit tool result carries one durable reviewsnapshot. Its compact InlineReviewCard is rendered in the same activitydisclosure, immediately after its tool row; it is never moved to the@@ -486,8 +489,8 @@ may be retained while exactly one workspace supplies the visible shell context.denied, and unstructured results do not render a card. A backgroundsession's card remains with its own transcript and becomes visible onlyafter that session is selected; its event never renders in the currently- visible session. Successful workspace artifacts may still create or- activate the singleton Review tab.+ visible session. A successful workspace artifact cannot create or activate+ the singleton Review tab; it appears only after the user opens it.- Each session retains `{open, tabs, activeTabId, browserResource}` in renderermemory. Selecting another session swaps the visible context atomically andswitching back restores it; selecting a workspace without an activediff --git a/docs/spec/04-ux/10-workbuddy-benchmark-ux.md b/docs/spec/04-ux/10-workbuddy-benchmark-ux.mdindex 595a10e03..8d57eb50c 100644--- a/docs/spec/04-ux/10-workbuddy-benchmark-ux.md+++ b/docs/spec/04-ux/10-workbuddy-benchmark-ux.md@@ -148,8 +148,10 @@ writes results to workspace memory/config — a form disguised as a chat.### 3.7 Artifacts view (from 我的文件)Sessions produce files the user later can't find without scrolling thetranscript. **Adopted first step in D128**: clicking a file artifact creates a-path-keyed, closeable work-panel tab, and successful workspace Write/Edit-artifacts open Review. **Adopted in D179**: the transcript also places a+path-keyed, closeable work-panel tab; its second half — a successful workspace+Write/Edit opening Review by itself — was withdrawn in D451, and Review now+opens only from an explicit user action. **Adopted in D179**: the transcript+also places amessage-scoped review card directly after each successful file mutation; itsstatus, +/− totals, and expandable hunks stay attached to that tool row ratherthan becoming a global footer entry. These renderer tabs and cards arediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex 57c933a8b..725a1dc1e 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -3249,7 +3249,9 @@ identify the platform validation still needed.Repeat with failed, denied, and scratch writes.- **Expected**: Each successful workspace Write/Edit creates one message-ownedreview record and one adjacent keyboard-accessible card; the card is never a- bottom/global entry. Every review card, inline and in the Review tab, is+ bottom/global entry. The completion opens nothing: the panel keeps whatever+ the user left it showing, and Review appears only after the user opens it.+ Every review card, inline and in the Review tab, iscollapsed by default and expands on demand. The Review tab lists A'schronological recorded changes, independent of Git status, repositorypresence, commit state, focus refresh,@@ -4549,7 +4551,8 @@ identify the platform validation still needed.request in A as well. 5) Open B explicitly, resolve only B's request, thenreturn to A and resolve A's request. 6) Rapidly select A then B while sessiondetails load in opposite completion order. 7) While B is loading, resolve A's- Write/Edit request so its tool completion creates Review, then let B emit a+ Write/Edit request so its tool completion records an inline review card, then+ let B emit aBrowserPreview artifact while A is visible. Switch back to each session.- **Expected**: B's background events update only B's row and retained state;they do not change A's active session/project/page, transcript, draft, scroll,@@ -4557,7 +4560,7 @@ identify the platform validation still needed.inline card with its original countdown. Both requests remain independentlyactionable, and resolving B does not clear A. The final rapid selection stayson B even when A's older load finishes later. Only explicit notification or- session activation may navigate. A's post-approval Review is retained only in+ session activation may navigate. A's post-approval review card is retained only inA without a transient open/close flash in B; B's BrowserPreview carries B'ssession identity, updates only B's retained Browser resource, and never opens,navigates, focuses, or resizes A's panel. Explicitly returning to either@@ -7159,8 +7162,8 @@ identify the platform validation still needed.no Uninstall action.2. Reveal the work panel and click `+` to create a New launcher tab. Confirmits rows include Review and the plugin-contributed File Manager and Browser- views. Trigger an agent edit and confirm Review opens itself under Open- resources — it is an artifact surface, not a launcher entry.+ views. Trigger an agent edit and confirm the panel does not open itself:+ Review appears under Open resources only after the user selects its row.3. Open the File Manager view. Confirm the tree lists the project, expandsdirectories lazily, and omits `node_modules`, `.git`, and `.env`. Switchthe view's top-left folder control to the project's second folder and@@ -8479,8 +8482,8 @@ This test plan spec is accepted when:action removes or changes the other card.- Resolve A's Write/Edit permission and switch to B before completion. Expect notransient Review panel in B and no panel/window flash; returning to A restores- A's resulting Review tab and prior panel selection, while B's tabs and Browser- resource remain unchanged.+ A's prior panel selection with the inline review card in its transcript — the+ edit opened no tab — while B's tabs and Browser resource remain unchanged.### US-UI-69 Sidebar type balance (D144/D161)- Open the expanded sidebar in light and dark themes at default and minimumdiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex 3c93690f8..d08dfb891 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -24,6 +24,7 @@ This log freezes previously open questions into concrete decisions.| D374 | Remote Agent Control v1 target amendments | **Amend D373 / ADR 0205: `RACP-WS` is the only normative v1 binding (`RACP-HTTP` is the browser profile, `RACP-GRPC` is reserved); typebox in `packages/shared` is the single contract source; the headless `packages/agent-host` module is the first deliverable and is shared by desktop IPC, local MCP, and RACP; cursors are `{ epoch, sequence }` with ephemeral deltas; the turn queue moves into the Host; host-core exposes `permissions.pending`; remote approvals carry the full local decision vocabulary under a default `ask` ceiling; browser clients use a cookie profile; the first deployment is single-tenant.** | Reviewing the D373 draft against the shipped desktop found the remote approval vocabulary narrower than the local contracts, pending requests held as connection state, per-token deltas exhausting the replay window, and more bindings than v1 can carry (ADR 0205) || D447 | Headless runtime boundary | **Amend ADR 0205 rollout R2 prerequisites (ADR 0284): the Electron-independent runtime layer under the Agent Host module lives in `packages/host-runtime` — the host-core and sidecar stdio transports, the restart supervisor (process-model §4 policy), the durable turn lifecycle (`RuntimeService` as the module's `RuntimePort`: `session.beginTurn` → user row → prompt → `session.endTurn`, abort lock, stale-terminal guard, single-flight finalization), transcript persistence with the D299 checkpoint, a headless launch resolver over host-core's own registries, approved Plan/Goal dispatch (D189), and the host-core adapters for `SessionPort` / `QueueStore` / `permissions.pending`. Electron main keeps thin adapters (binary and bundle locations, `ELECTRON_RUN_AS_NODE`, redacted stderr, schema/glibc diagnoses, renderer status pushes) and its own local prompt path. `TurnStartRequest` gains an optional `userMessageId`. No IPC, sidecar, host-core, Plugin SDK, default, or persisted-data change.** | `pi-host` must run the same lifecycle invariants as the desktop without Electron; a second implementation of abort locks, stale terminal events, and queue release after durable settlement would drift from the one the desktop already fixed || D448 | RACP-WS transport and device pairing | **Amend ADR 0205 rollout R2 (ADR 0285): `packages/racp` holds both ends of the normative `RACP-WS` binding. `RacpServer` dispatches every catalog operation through its role rule onto the Agent Host module and a `RacpHostOperations` interface the Host implements; `RacpClient` correlates requests, answers server-initiated requests, tracks the last durable cursor per session, reconnects with bounded backoff, and fails the dropped connection's in-flight calls with `HOST_DISCONNECTED` instead of re-sending them. Authentication is the header profile with Host-issued `pdt1.` device tokens and single-use, expiring `ppt1.` pairing tokens (hashed, constant-time compared; never in a URL); `connection/pair` mints an `owner` device. `connection/pair`, `project/register`, `project/browse`, `server.hostId`, the `events/closed` notification, and the codes `PAIRING_FAILED`, `PAIRING_TOKEN_EXPIRED`, `CAPABILITY_UNAVAILABLE`, `REMOTE_PATH_NOT_FOUND`, `REMOTE_PATH_FORBIDDEN`, `HOST_DISCONNECTED`, `HOST_BOOTSTRAP_FAILED`, `HOST_VERSION_MISMATCH`, `REMOTE_AUTH_FAILED`, `REMOTE_CONNECTION_FAILED`, `REMOTE_FORWARD_FAILED` join the contract (spec §14a). The bind refuses non-loopback addresses; attachments and the tool relay are advertised unavailable.** | The SSH-tunnel topology needs a server `pi-host` can bind and a client the desktop can run, with the pairing the security spec describes; the conformance behaviors that need no machine boundary become package tests |+| D451 | Review opens only on explicit user action | **A tool result never opens, activates, or resizes the work panel. The `tool_end` artifact gate and `shouldOpenReviewArtifact` are removed; Review is reached only from the `+` New launcher row or from the retained session context the viewport-fixed toggle / `Cmd/Ctrl + J` reveals. A successful workspace Write/Edit still records its message-owned inline review card in the transcript.** | An agent edit silently revealing a side panel competes with the user's own reading and layout, and the transcript card already carries the change evidence. See ADR 0043, `04-ux/01-ui-ia.md`, `04-ux/08-component-spec.md` §5, `04-ux/09-interaction-patterns.md`, E2E-057. || D450 | Signed macOS GitHub Releases | **Amend D078 / ADR 0022: GitHub tag releases Developer ID-sign, notarize (`notarytool` via electron-builder 26), staple, and Gatekeeper-verify macOS DMG/ZIP before upload, using identity `Developer ID Application: XingYu Liu (DUV63RKYTW)` / team `DUV63RKYTW` from Actions secrets (`CSC_LINK`, `CSC_KEY_PASSWORD`, `APPLE_ID`, `APPLE_APP_SPECIFIC_PASSWORD`, `APPLE_TEAM_ID`). Missing secrets fail the job. Local unsigned packaging without a certificate remains. `workflow_dispatch` may set `sign_macos: false` only for unsigned debug artifacts. Packaged macOS uses in-app `electron-updater` (ZIP + merged `latest-mac.yml`); Linux deb/rpm and Windows portable stay notify-and-link. No afterPack/afterSign adhoc codesign (ADR 0278).** | Production DMGs must open without a Gatekeeper warning, and signed macOS installs can download and restart into a new tag. See ADR 0289, E2E-196c, E2E-067A. |## B. Secondary implementation defaults