Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

merge(main): resolve review branch integration conflicts

new-Beginner05582704b093
diff --cc docs/adr/0339-explicit-reviewed-file-actions.md
index 8789882c7,000000000..f6474a998
mode 100644,000000..100644
--- a/docs/adr/0339-explicit-reviewed-file-actions.md
+++ b/docs/adr/0339-explicit-reviewed-file-actions.md
@@@ -1,61 -1,0 +1,61 @@@
- # ADR 0338: Explicit actions on reviewed files
++# ADR 0339: Explicit actions on reviewed files
+
+- Status: Accepted
+- Date: 2026-10-30
+- Related: [ADR 0043](0043-message-owned-review-snapshots-and-rollback.md)
+
+## Context
+
+Review records approved Write/Edit operations outside the workspace, but the
+normal file-open APIs deliberately accept only project and host-owned roots.
+Widening those APIs would change unrelated filesystem authorization. Separately,
+rendering one footer per operation makes a file with several edits look like
+several independently actionable files.
+
+## Decision
+
+External open and folder reveal for a non-workspace review row use a dedicated
+main-window-only IPC request containing session ID, snapshot ID and destination.
+No renderer-supplied path is accepted. The Rust Host verifies that the snapshot
+belongs to a successful persisted tool message in that session and resolves its
+exact recorded file. Host and Main reject missing files, directories, sensitive
+paths and replacement symlinks. Main then invokes the system default application
+or reveals the file in the system file manager. This explicit user action grants
+neither directory access nor read/write capability to a tool or plugin. Generic
+`fsOpen`, `fsReveal`, permission evaluation and remote-session behavior are unchanged.
+Non-workspace file menus do not offer internal open.
+
+The Review panel renders recorded hunks continuously with one copy/rollback
+footer per file. Copy includes all recorded operations in order and does not
+claim a net diff. File rollback selects the anchor snapshot's owning round and
+file on the Host; the renderer cannot omit intermediate operations. Before one
+file restoration, Host validates the entire active hash chain, captured root,
+restoration bytes and current hash. Conflicts leave the file and record states
+untouched. Success updates each participating snapshot and transcript state.
+Existing single-snapshot rollback and inline chat actions remain unchanged.
+
+File-action menu density is opt-in. Review scope and historical round selection
+reuse the shared native Select with review-only customizable-picker styles.
+Selected fills follow the sidebar color, and only the list's outer top/bottom
+option corners are rounded. The scope trigger is 24px high and the round field
+28px; both vertically center their text and arrow. Shared primitives, Command
+shell and other selectors keep their defaults. History options now include
+Host-recorded operation totals before the check (unknown when unavailable),
+without claiming a net diff. Review action menus opt into trigger-relative
+right/bottom placement; pointer-based context menus remain unchanged.
+
+## Consequences
+
+- Recorded external files can be opened without relaxing the general path sandbox.
+- One file has one action bar, while individual immutable snapshots remain intact.
+- Discontinuous or conflicted chains cannot be partially rolled back.
+- External snapshots remain non-reversible; explicit opening is not write permission.
+- Scope/history retain native selection behavior without changing shared defaults.
+
+## Alternatives rejected
+
+- Add snapshot roots to general filesystem roots: grants more than the clicked file.
+- Accept a raw external path from Renderer: loses binding to native recorded evidence.
+- Repeatedly call single-snapshot rollback: can stop halfway through a file's edits.
+- Merge cached hunks into a purported net diff: bounded historical hunks do not contain
+ arbitrary complete after-images, so they cannot establish that claim.
diff --cc docs/adr/README.md
index 1faffff3a,8f3d83276..213d2f41e
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@@ -395,6 -395,6 +395,7 @@@ Each ADR includes
| 0332 | [macOS keeps its translucent window surface with an opaque opt-out](0332-macos-opaque-window-surface.md) | Accepted (D665, amended by D666 and D667; supersedes the macOS vibrancy window backing from D348; issue #1064) |
| gen-ui-inline-visualization | [Inline generative UI visualizations](gen-ui-inline-visualization.md) | Accepted (D671) |
| 0337 | [Keep the request prefix stable across delegation settlements](0337-stable-prompt-prefix-across-delegation.md) | Accepted (supersedes ADR 0279 §9) |
- | 0338 | [Explicit actions on reviewed files](0338-explicit-reviewed-file-actions.md) | Accepted |
++| 0339 | [Explicit actions on reviewed files](0339-explicit-reviewed-file-actions.md) | Accepted |
+ | 0338 | [A user-supplied video owns the boot surface, served over a host-owned scheme](0338-user-supplied-startup-animation.md) | Accepted (D679) |
| model-reasoning-effort-override | [Model reasoning effort override](model-reasoning-effort-override.md) | Proposed |
diff --cc docs/spec/03-runtime/06-host-rpc-protocol.md
index 6ebbd2042,a89951888..b3b779eac
--- a/docs/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md
@@@ -1529,42 -1529,3 +1529,42 @@@ clients never supply authoritative iden
reports TOOL_CONTEXT_CHANGED; an identity/address change fails before writing.
Close/expiry cannot release a running disk task; no failed/uncertain write is
automatically replayed. See the Host file admission ADR for lifecycle and limits.
+
+## Round review reader
+
+- `review.turns({sessionId, before?, limit?})` returns `turns` (newest user round
+ first, each with `id`, `userMessageId`, `createdAt`, `title`, `changeCount`,
+ `additions`, `deletions`) and
+ optional `nextBefore`. Only rounds with valid successful Write/Edit review
+ evidence are listed, including approved targets outside the workspace.
+ Source `details.root` is preserved; workspace-relative and non-workspace
+ absolute paths retain distinct identities. Limit is bounded to 100; title is a short excerpt.
+ Added/deleted totals sum deduplicated successful operation evidence, not a net
+ diff. Originally truncated/binary records or unsafe totals yield null for both
+ counts. Transport-only hunk trimming does not discard known counts. Older
+ Hosts may omit these additive fields; consumers show unknown.
+- `review.changes({sessionId, turnId?, snapshotId?, offset?, limit?})` returns
+ `turnId`, `changes: [{message, root?}]`, and optional `nextOffset`. Without a
+ selector it resolves the latest modified user round; a snapshot selector locates
+ its owning round, or returns null when absent. Transport omits unrelated tool
+ arguments and result bodies. Oversized previews are explicitly truncated, never
+ silently dropped. Parent Task ancestry and durable message-turn ownership beat
+ arrival order. Duplicate snapshots are emitted once.
+- `review.context({sessionId, snapshotId, context})` accepts only 1, 3 or 5
+ and returns `hunks`, optionally `unavailable: legacy | binary | tooLarge`.
+ Content comes only from bounded immutable context hunks, not current workspace files.
+ Normal containment, session ownership and remote-workspace capability rules apply.
+
+These reads do not replace the chat transcript window or alter execution state.
+
+`review.fileTarget({sessionId, snapshotId})` authenticates a persisted native
+snapshot in the session transcript and returns its exact existing regular file
+path. Replaced symlinks and sensitive targets are rejected. It is used only by
+Main's explicit reviewed-file open/reveal action; it is not a directory grant.
+`review.rollbackFile({sessionId, snapshotId})` selects the complete same-file
+snapshot chain in the anchor's round, returning `{status, changes}`. All active
+links and the current file are checked before one restoration; conflicts leave
+both content and states untouched. Success persists each affected review state.
+The old `review.rollback` contract remains unchanged. Both rollback methods
+participate in Host file-resource exclusion and re-resolve the session root after
- admission. Both new operations reject remote workspaces. See [ADR 0338](../../adr/0338-explicit-reviewed-file-actions.md).
++admission. Both new operations reject remote workspaces. See [ADR 0339](../../adr/0339-explicit-reviewed-file-actions.md).
diff --cc docs/spec/04-ux/08-component-spec.md
index b16144323,0e83a4709..60cc1b0c4
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@@ -4612,67 -4612,3 +4612,67 @@@ Input, selection, submission and dismis
Project-delete descriptions and plugin dialog headings/outcomes also wrap long
project or plugin names instead of overflowing their existing widths. Project
instructions, memory and OAuth dialogs retain their existing bounded layouts.
+
+## Round review reader
+
+Local Review defaults to Last round (the latest modified user round). Its
+scope dropdown also offers History, which reveals a separate user-round selector row,
+independent of the chat's loaded message window. Rounds without changes do not
+replace Latest. Main and delegated Write/Edit evidence share a file list; actual
+execution roots distinguish identically named files. The file header opens all
+of that file's recorded operations in order, without claiming a net diff.
+
+Expanded file content has no fixed-height inner viewport or vertical scrollbar.
+The outer Review scroll owns vertical travel; the current file header sticks
+below the toolbar within its file section. It is not reordered. A borderless ellipsis button after the summary totals opens a menu containing
+only Word wrap and Context lines. Hovering Context lines opens a secondary
+menu with 1/3/5 (first-use default 3); the choice is profile-wide, remembered
+across sessions, panel reopening and application restarts. Invalid or missing
+preferences use 3, and unavailable storage never blocks the current selection.
+No context selector is shown in the main toolbar.
+Toggle checks appear on the right. History options show date/time on the left
+and Host-recorded added/deleted line totals on the right, before the check.
+Totals count each successful native operation once, including delegated evidence,
+and do not claim a net diff. Binary, originally truncated or missing counts show
+unknown instead of invented zeros. The selector reserves arrow space. File headings have no permanent
+button fill or border; execution roots are not rendered as extra diff rows.
+A separate file ellipsis offers Open internally (disabled without the loaded
+File Manager view; never auto-enables it), Open externally (OS default app),
+and Open folder (system file manager, revealing the current file).
+All three resolve the current exact file through session-aware authorized roots, not
+a historical export or a same-named fallback. Stale session/project results are
+discarded; lookup/open failures are visible without changing stored evidence.
+Absolute and outside-root relative path labels use `.../basename`; full paths
+remain in the title and stored evidence. Native review captures successful
+approved Write/Edit mutations inside and outside the workspace, never Bash or
+external-application changes. Outside snapshots do not grant rollback or general filesystem permissions.
+Their file menu omits internal open and offers only external open and folder
- reveal through explicit snapshot-bound user actions (ADR 0338). Other file-open
++reveal through explicit snapshot-bound user actions (ADR 0339). Other file-open
+surfaces retain their existing authorization.
+
+Both scope and historical round selectors reuse the shared native Select.
+Review-only CSS opts into Chromium's customizable native picker: its base follows
+the sidebar color, with a contrasting sidebar-derived selected fill (no system
+blue). Only the first option's upper and last option's lower corners are rounded;
+interior edges are square, including when an interior row is selected or hovered.
+A single option has all four outer corners. The scope trigger is 24px high; the
+round field stays 28px high. Both vertically center their text and arrow. Round
+labels retain date/time and recorded counts with reserved arrow space. Native keyboard selection,
+Escape dismissal and focus remain browser-owned. Shared primitives and the AI
+Command shell selector are unchanged.
+Only file action menus opt into compact density. Recorded operations have no
+numbered title or dividing rule. One footer per file copies all its recorded
+hunks or requests a Host-preflighted file rollback; chat's inline actions remain
+unchanged. The copied sequence is not represented as a net diff.
+Review headings and turn-summary file rows share compact 14px file-type glyphs
+(Markdown, JSON, Python, code and document), while status stays in accessible
+labels. Both Review ellipsis menus anchor to the trigger right edge, 4px below;
+when space is insufficient they flip above and clamp within the viewport.
+Pointer position within a button cannot move the menu. They remain body portals,
+and ordinary right-click menus retain pointer placement.
+Diff rows have one line-number gutter: deletions use old coordinates, additions
+and context use new coordinates; EOF markers have no number. Word wrap toggles wrapping without
+introducing nested vertical scrolling. Unsupported
+historical context has an explicit explanation and retains recorded evidence.
+Remote Review retains its existing presentation. Chat inline review rows retain
+their default layout and hash-guarded rollback; no Git or model behavior changes.