Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
feat(chat): summarize each turn's changed files under the reply
vastsa73b714ed2806
diff --git a/apps/desktop/electron/main/bootstrap/window.ts b/apps/desktop/electron/main/bootstrap/window.tsindex 0b5044e88..5e3be3bca 100644--- a/apps/desktop/electron/main/bootstrap/window.ts+++ b/apps/desktop/electron/main/bootstrap/window.ts@@ -1408,6 +1408,39 @@ export async function createWindow({`void window.__PI_DESKTOP__?.seedReviewChanges?.(0)`,);await new Promise((r) => setTimeout(r, 250));+ // Per-turn changed-files card (D674): relaxed rows for a few+ // files, dense rows plus `+N more` for many.+ const shootTurnChanges = async (files: number, name: string) => {+ await windowState.mainWindow!.webContents.executeJavaScript(+ `void window.__PI_DESKTOP__?.seedTurnChanges?.(${files})`,+ );+ await new Promise((r) => setTimeout(r, 450));+ await windowState.mainWindow!.webContents.executeJavaScript(+ `document.querySelector(".turn-changes-card")?.scrollIntoView({ block: "center" })`,+ );+ await new Promise((r) => setTimeout(r, 250));+ await shot(name);+ };+ await shootTurnChanges(3, "pi-turn-changes");+ await shootTurnChanges(15, "pi-turn-changes-dense");+ await windowState.mainWindow!.webContents.executeJavaScript(+ `window.__PI_DESKTOP__?.setThemeAttr("dark")`,+ );+ await new Promise((r) => setTimeout(r, 350));+ await shot("pi-turn-changes-dense-dark");+ await windowState.mainWindow!.webContents.executeJavaScript(+ `window.__PI_DESKTOP__?.setThemeAttr("light")`,+ );+ // A row click opens Review on that file with its change expanded.+ await windowState.mainWindow!.webContents.executeJavaScript(+ `document.querySelectorAll(".turn-changes-row")[1]?.click()`,+ );+ await new Promise((r) => setTimeout(r, 600));+ await shot("pi-turn-changes-open-review");+ await windowState.mainWindow!.webContents.executeJavaScript(+ `void window.__PI_DESKTOP__?.seedTurnChanges?.(0)`,+ );+ await new Promise((r) => setTimeout(r, 250));// A run row keeps its command in the head and only its output in the// body (D226). Seed one row per state, open the activity groups, and// hover the open row so its copy control and caret are on screen.diff --git a/apps/desktop/src/capture/capture-rig.ts b/apps/desktop/src/capture/capture-rig.tsindex 89d78ba5e..5a2b4750c 100644--- a/apps/desktop/src/capture/capture-rig.ts+++ b/apps/desktop/src/capture/capture-rig.ts@@ -33,6 +33,7 @@ export type CaptureRigMethods = {setWorkPanelWidth: (width: number) => void;seedTranscript: (count?: number) => void;seedReviewChanges: (count?: number) => void;+ seedTurnChanges: (files?: number) => void;seedRunRows: (count?: number) => void;seedDelegationRows: (count?: number) => void;seedPlugins: (count?: number) => void;@@ -287,6 +288,68 @@ export function installCaptureRig(): CaptureRig {);useAppStore.setState({ messages: messages as any });},+ seedTurnChanges: (files = 3) => {+ // Capture-only per-turn changed-files fixture (D674 scenes): one+ // finished turn whose tools wrote `files` workspace files, so the+ // summary card renders under the reply. 0 restores the empty transcript.+ if (!window.__PI_CAPTURE__) return;+ if (files <= 0) {+ useAppStore.setState({ messages: [] });+ return;+ }+ const base = Date.parse("2026-10-28T09:00:00Z");+ const at = (offset: number) => new Date(base + offset * 1_000).toISOString();+ const dirs = ["apps/desktop/src/lib", "packages/i18n/src/locales/en", "docs/spec/04-ux"];+ const tools = Array.from({ length: files }, (_, i) => {+ const status = i === 0 ? "added" : i === files - 1 && files > 3 ? "deleted" : "modified";+ const path = `${dirs[i % dirs.length]}/turn-change-${i + 1}.ts`;+ return {+ id: `capture-turn-tool-${i}`,+ role: "tool" as const,+ content: "",+ createdAt: at(2 + i),+ toolName: i === 0 ? "Write" : "Edit",+ toolStatus: "success" as const,+ toolArgs: { path },+ toolResult: {+ details: {+ root: "workspace",+ review: {+ version: 1,+ snapshotId: `capture-turn-snapshot-${i}`,+ messageId: `capture-turn-tool-${i}`,+ path,+ operation: status === "added" ? "write" : status === "deleted" ? "delete" : "edit",+ status,+ state: i === 2 ? "rolledBack" : "active",+ additions: status === "deleted" ? 0 : 3 + ((i * 7) % 29),+ deletions: status === "added" ? 0 : (i * 3) % 11,+ hunks: [],+ reversible: true,+ },+ },+ },+ };+ });+ const messages = [+ {+ id: "capture-turn-user",+ role: "user" as const,+ content: "把发送按钮的禁用条件补上",+ createdAt: at(0),+ status: "complete" as const,+ },+ ...tools,+ {+ id: "capture-turn-reply",+ role: "assistant" as const,+ content: "已改:草稿为空或流式时禁用发送。",+ createdAt: at(2 + files),+ status: "complete" as const,+ },+ ];+ useAppStore.setState({ messages: messages as any });+ },seedRunRows: (count = 3) => {// Capture-only run-row fixture (D226/D227 head scenes). A Bash tool// message per state: a command that exits 1 while its call reportsdiff --git a/apps/desktop/src/capture/renderer-api.ts b/apps/desktop/src/capture/renderer-api.tsindex 383968f34..f6e1e29be 100644--- a/apps/desktop/src/capture/renderer-api.ts+++ b/apps/desktop/src/capture/renderer-api.ts@@ -47,6 +47,7 @@ const CAPTURE_RIG_METHODS = ["setWorkPanelWidth","seedTranscript","seedReviewChanges",+ "seedTurnChanges","seedRunRows","seedDelegationRows","seedPlugins",diff --git a/apps/desktop/src/components/ReviewChangeCard.tsx b/apps/desktop/src/components/ReviewChangeCard.tsxindex 1276cd1c4..4a754c0ed 100644--- a/apps/desktop/src/components/ReviewChangeCard.tsx+++ b/apps/desktop/src/components/ReviewChangeCard.tsx@@ -1,5 +1,5 @@import { useChatSessionCapability } from "../hooks/use-chat-session-capability";-import { memo, useId, useState } from "react";+import { memo, useEffect, useId, useState } from "react";import { useTranslation } from "react-i18next";import type {ReviewChange,@@ -124,16 +124,22 @@ export const ReviewChangeCard = memo(function ReviewChangeCard({message,compact = false,asToolRow = false,+ openRequest,}: {message: UiMessage;compact?: boolean;/** The card is the tool-level row: one file header and its diff body. */asToolRow?: boolean;+ /** Each new value expands the diff once; the user can collapse it again. */+ openRequest?: number;}) {const { t } = useTranslation();const change = reviewChangeFromMessage(message);const detailsId = useId();const [open, setOpen] = useState(false);+ useEffect(() => {+ if (openRequest !== undefined) setOpen(true);+ }, [openRequest]);if (!change) return null;@@ -162,6 +168,7 @@ export const ReviewChangeCard = memo(function ReviewChangeCard({data-state={change.state}data-status={change.status}data-message-id={asToolRow ? message.id : undefined}+ data-snapshot-id={change.snapshotId}><buttontype="button"diff --git a/apps/desktop/src/components/workpanel/ReviewTab.tsx b/apps/desktop/src/components/workpanel/ReviewTab.tsxindex 866c6b53e..b7f5e7d82 100644--- a/apps/desktop/src/components/workpanel/ReviewTab.tsx+++ b/apps/desktop/src/components/workpanel/ReviewTab.tsx@@ -1,16 +1,55 @@-import { useMemo } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";+import { useReviewFocusRequest } from "../../lib/review-focus-request";import { reviewChangesFromMessages, summarizeReviewChanges } from "../../lib/workspace-review";import { useAppStore } from "../../stores/app-store";import { IconDiff } from "../icons";import { ReviewChangeCard } from "../ReviewChangeCard";import { WorkTabEmpty } from "./WorkTabEmpty";+/* Module-level like the Files tab's request dedup: a remounted tab must not+ re-apply a focus request it already honored. */+let handledFocusSeq = 0;++type AppliedFocus = {+ snapshotIds: ReadonlySet<string>;+ /** The earliest focused change in the list, scrolled to the top. */+ anchor: string;+ expand: boolean;+ seq: number;+};+export function ReviewTab() {const { t } = useTranslation();const messages = useAppStore((state) => state.messages);const entries = useMemo(() => reviewChangesFromMessages(messages), [messages]);const summary = useMemo(() => summarizeReviewChanges(entries), [entries]);+ const focusRequest = useReviewFocusRequest();+ const [focus, setFocus] = useState<AppliedFocus | null>(null);+ const scrollRef = useRef<HTMLDivElement>(null);++ // A request names snapshots of one session; it waits until this tab shows+ // that session's changes, then applies once.+ useEffect(() => {+ if (!focusRequest || focusRequest.seq === handledFocusSeq) return;+ const wanted = new Set(focusRequest.snapshotIds);+ const anchor = entries.find((entry) => wanted.has(entry.change.snapshotId));+ if (!anchor) return;+ handledFocusSeq = focusRequest.seq;+ setFocus({+ snapshotIds: wanted,+ anchor: anchor.change.snapshotId,+ expand: focusRequest.expand,+ seq: focusRequest.seq,+ });+ }, [focusRequest, entries]);++ useEffect(() => {+ if (!focus) return;+ scrollRef.current+ ?.querySelector<HTMLElement>(`[data-snapshot-id="${CSS.escape(focus.anchor)}"]`)+ ?.scrollIntoView({ block: "start" });+ }, [focus]);if (entries.length === 0) {return (@@ -32,12 +71,17 @@ export function ReviewTab() {<span className="diff-count-del">−{summary.deletions}</span></span></div>- <div className="review-scroll">+ <div className="review-scroll" ref={scrollRef}>{entries.map((entry) => (<ReviewChangeCardkey={entry.change.snapshotId}message={entry.message}compact+ openRequest={+ focus?.expand && focus.snapshotIds.has(entry.change.snapshotId)+ ? focus.seq+ : undefined+ }/>))}</div>diff --git a/apps/desktop/src/features/chat/transcript/AssistantTurn.tsx b/apps/desktop/src/features/chat/transcript/AssistantTurn.tsxindex 87c6091c0..4ad175139 100644--- a/apps/desktop/src/features/chat/transcript/AssistantTurn.tsx+++ b/apps/desktop/src/features/chat/transcript/AssistantTurn.tsx@@ -56,6 +56,7 @@ import { AssistantTurnParts } from "./AssistantTurnParts";import { TurnProcess } from "./TurnProcess";import { ActionSlotSide } from "./ActionBarSlots";import { EntryExtraStack } from "./EntryExtraStack";+import { TurnChangesCard } from "./TurnChangesCard";import { slotMessage } from "../../../plugins/renderer-slots/slot-message";type AssistantTurnProps = {@@ -419,6 +420,9 @@ export const AssistantTurn = memo(function AssistantTurn({produced, not part of what it did. */}<AssistantTurnParts parts={responses} {...partContext} />{generatedImages}+ {/* Mounted with the reply slots, so a streaming turn never grows it;+ plugin entry extras stay beneath it. */}+ {slotReply ? <TurnChangesCard tools={tools} /> : null}{!isActive && metaMessage ? (<MessageMetamodelId={modelId}diff --git a/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx b/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsxnew file mode 100644index 000000000..f36dbe019--- /dev/null+++ b/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx@@ -0,0 +1,131 @@+import { memo, useMemo } from "react";+import { useTranslation } from "react-i18next";+import type { ReviewChangeStatus, UiMessage } from "@pi-desktop/shared";+import { cx } from "../../../components/ui";+import { requestReviewFocus } from "../../../lib/review-focus-request";+import {+ summarizeTurnChanges,+ TURN_CHANGES_RELAXED_LIMIT,+ TURN_CHANGES_VISIBLE_LIMIT,+ type TurnChangedFile,+} from "../../../lib/turn-changed-files";+import { toolWorkPanelTab } from "../../../lib/work-panel-tabs";+import { useSlotSessionId } from "../../../plugins/renderer-slots/use-slots";+import { useAppStore } from "../../../stores/app-store";+import "../../../styles/turn-changes.css";++/* Same Git-style letters as the per-call review row, so status never relies+ on color alone. */+const STATUS_MARKS: Record<ReviewChangeStatus, string> = {+ added: "A",+ modified: "M",+ deleted: "D",+};++function Counts({ additions, deletions }: { additions: number; deletions: number }) {+ return (+ <span className="turn-changes-counts diff-counts" aria-hidden>+ {additions > 0 && <span className="diff-count-add">+{additions}</span>}+ {deletions > 0 && <span className="diff-count-del">−{deletions}</span>}+ </span>+ );+}++/**+ * The read-only "what did this turn change" summary under a completed reply.+ * Each row opens the existing Review tab on that file's recorded changes; the+ * card has no diff body and no rollback of its own.+ */+export const TurnChangesCard = memo(function TurnChangesCard({+ tools,+}: {+ tools: readonly UiMessage[];+}) {+ const { t } = useTranslation();+ const sessionId = useSlotSessionId();+ const openTabForSession = useAppStore((state) => state.openWorkPanelTabForSession);+ const openTab = useAppStore((state) => state.openWorkPanelTab);+ const summary = useMemo(() => summarizeTurnChanges(tools), [tools]);+ const { files } = summary;+ if (files.length === 0) return null;++ const dense = files.length > TURN_CHANGES_RELAXED_LIMIT;+ const visible = files.slice(0, TURN_CHANGES_VISIBLE_LIMIT);+ const hidden = files.length - visible.length;++ const openReview = (snapshotIds: readonly string[], expand: boolean) => {+ requestReviewFocus(snapshotIds, { expand });+ const tab = toolWorkPanelTab("review");+ if (sessionId) openTabForSession(sessionId, tab);+ else openTab(tab);+ };++ const rowLabel = (file: TurnChangedFile) => {+ const label = t("chat.turnChangesOpen", {+ status: t(`panel.review.status.${file.status}`),+ path: file.path,+ additions: file.additions,+ deletions: file.deletions,+ });+ return file.rolledBack ? `${label} · ${t("panel.review.rolledBack")}` : label;+ };++ return (+ <section className="turn-changes-card" aria-label={t("chat.turnChangesLabel")}>+ <div className="turn-changes-head">+ <span className="turn-changes-title">{t("chat.turnChangesTitle")}</span>+ <span className="turn-changes-meta">+ {t("chat.toolChipFiles", { count: files.length })}+ {dense ? ` · ${t("chat.turnChangesDirs", { count: summary.directoryCount })}` : null}+ </span>+ <span+ className="turn-changes-total"+ aria-label={t("chat.reviewChangeCounts", summary)}+ >+ <Counts additions={summary.additions} deletions={summary.deletions} />+ </span>+ </div>+ <ul className={cx("turn-changes-body", dense && "is-dense")}>+ {visible.map((file) => {+ const label = rowLabel(file);+ return (+ <li key={file.path}>+ <button+ type="button"+ className="turn-changes-row"+ data-status={file.status}+ data-rolled-back={file.rolledBack || undefined}+ aria-label={label}+ title={label}+ onClick={() => openReview(file.snapshotIds, true)}+ >+ <span className="turn-changes-mark" aria-hidden>+ {STATUS_MARKS[file.status]}+ </span>+ <span className="turn-changes-path">{file.path}</span>+ <Counts additions={file.additions} deletions={file.deletions} />+ </button>+ </li>+ );+ })}+ {hidden > 0 ? (+ <li className="turn-changes-more">+ <span aria-hidden>···</span>+ {t("chat.turnChangesMore", { count: hidden })}+ </li>+ ) : null}+ </ul>+ {hidden > 0 ? (+ <div className="turn-changes-foot">+ <button+ type="button"+ className="turn-changes-view-all"+ onClick={() => openReview(files.flatMap((file) => file.snapshotIds), false)}+ >+ {t("chat.turnChangesViewAll", { count: files.length })}+ </button>+ </div>+ ) : null}+ </section>+ );+});diff --git a/apps/desktop/src/lib/review-focus-request.ts b/apps/desktop/src/lib/review-focus-request.tsnew file mode 100644index 000000000..0cdea569d--- /dev/null+++ b/apps/desktop/src/lib/review-focus-request.ts@@ -0,0 +1,45 @@+import { useSyncExternalStore } from "react";++/**+ * A one-shot "show these recorded changes" request from the transcript's+ * per-turn change summary to the Review tab. Snapshot ids are unique per+ * change, so the request needs no session key: a Review tab that does not+ * hold the ids simply ignores it. Kept out of the app store because it is+ * transient UI intent, not session or panel state.+ */+export type ReviewFocusRequest = {+ /** Scrolled into view in order; the first one found becomes the anchor. */+ snapshotIds: readonly string[];+ /** Open each named change's diff, or only reveal the rows. */+ expand: boolean;+ seq: number;+};++let current: ReviewFocusRequest | null = null;+let sequence = 0;+const listeners = new Set<() => void>();++export function requestReviewFocus(+ snapshotIds: readonly string[],+ { expand }: { expand: boolean },+): void {+ if (snapshotIds.length === 0) return;+ sequence += 1;+ current = { snapshotIds: [...snapshotIds], expand, seq: sequence };+ for (const listener of listeners) listener();+}++export function currentReviewFocusRequest(): ReviewFocusRequest | null {+ return current;+}++function subscribe(listener: () => void): () => void {+ listeners.add(listener);+ return () => {+ listeners.delete(listener);+ };+}++export function useReviewFocusRequest(): ReviewFocusRequest | null {+ return useSyncExternalStore(subscribe, currentReviewFocusRequest, () => null);+}diff --git a/apps/desktop/src/lib/turn-changed-files.ts b/apps/desktop/src/lib/turn-changed-files.tsnew file mode 100644index 000000000..911b4ac5e--- /dev/null+++ b/apps/desktop/src/lib/turn-changed-files.ts@@ -0,0 +1,73 @@+import type { ReviewChangeStatus, UiMessage } from "@pi-desktop/shared";+import { reviewChangeFromMessage } from "./workspace-review.ts";++/** Rows shown before the per-turn summary folds the rest into `+N more`. */+export const TURN_CHANGES_VISIBLE_LIMIT = 12;+/** Above this many files the summary switches to its dense row metrics. */+export const TURN_CHANGES_RELAXED_LIMIT = 4;++/** One workspace file touched by a turn, merged across all of its edits. */+export type TurnChangedFile = {+ path: string;+ status: ReviewChangeStatus;+ additions: number;+ deletions: number;+ /** Every recorded change of this file in the turn was rolled back. */+ rolledBack: boolean;+ /** The turn's snapshots for this file, in chronological order. */+ snapshotIds: string[];+};++export type TurnChangesSummary = {+ files: TurnChangedFile[];+ directoryCount: number;+ additions: number;+ deletions: number;+};++function directoryOf(path: string): string {+ const index = path.lastIndexOf("/");+ return index > 0 ? path.slice(0, index) : "";+}++/**+ * Aggregate the message-owned review records of one turn's tool messages by+ * path. Counts add up across edits; a file the turn ends by deleting is `D`,+ * otherwise any creation makes it `A`, and everything else is `M`.+ */+export function summarizeTurnChanges(tools: readonly UiMessage[]): TurnChangesSummary {+ const byPath = new Map<string, TurnChangedFile>();+ const created = new Set<string>();+ for (const message of tools) {+ const change = reviewChangeFromMessage(message);+ if (!change) continue;+ const rolledBack = change.state === "rolledBack";+ if (change.status === "added") created.add(change.path);+ const existing = byPath.get(change.path);+ if (!existing) {+ byPath.set(change.path, {+ path: change.path,+ status: change.status,+ additions: change.additions,+ deletions: change.deletions,+ rolledBack,+ snapshotIds: [change.snapshotId],+ });+ continue;+ }+ existing.additions += change.additions;+ existing.deletions += change.deletions;+ existing.rolledBack &&= rolledBack;+ existing.snapshotIds.push(change.snapshotId);+ existing.status = change.status === "deleted"+ ? "deleted"+ : created.has(change.path) ? "added" : "modified";+ }+ const files = [...byPath.values()];+ return {+ files,+ directoryCount: new Set(files.map((file) => directoryOf(file.path))).size,+ additions: files.reduce((total, file) => total + file.additions, 0),+ deletions: files.reduce((total, file) => total + file.deletions, 0),+ };+}diff --git a/apps/desktop/src/styles/turn-changes.css b/apps/desktop/src/styles/turn-changes.cssnew file mode 100644index 000000000..eb835240f--- /dev/null+++ b/apps/desktop/src/styles/turn-changes.css@@ -0,0 +1,160 @@+/* Per-turn changed-files summary under a completed reply (D297 tile scheme:+ one soft tile, no border or rules; spacing separates head, rows, and foot).+ Up to four files use relaxed 25px rows; more switch to dense 21px rows. */+.turn-changes-card {+ box-sizing: border-box;+ width: min(100%, var(--chat-prose-max-width, 720px));+ min-width: 0;+ margin: 8px 0 2px;+ padding: 8px 6px 6px;+ border-radius: var(--radius-lg);+ background: var(--ds-tile);+}++.turn-changes-head {+ display: flex;+ min-width: 0;+ align-items: center;+ gap: 8px;+ padding: 0 6px 4px;+}++.turn-changes-title {+ color: var(--ds-text-primary);+ font-size: var(--text-sm);+ font-weight: var(--font-weight-semibold);+}++.turn-changes-meta {+ min-width: 0;+ overflow: hidden;+ color: var(--ds-text-faint);+ font-family: var(--font-mono);+ font-size: var(--text-2xs);+ text-overflow: ellipsis;+ white-space: nowrap;+}++.turn-changes-total {+ display: inline-flex;+ margin-left: auto;+}++.turn-changes-body {+ margin: 0;+ padding: 0;+ list-style: none;+}++.turn-changes-row {+ display: flex;+ width: 100%;+ min-width: 0;+ min-height: 25px;+ align-items: center;+ gap: 8px;+ padding: 2px 6px;+ border-radius: var(--radius-sm);+ color: var(--ds-text-secondary);+ text-align: left;+ transition:+ background var(--motion-duration-fast) var(--motion-ease-out),+ color var(--motion-duration-fast) var(--motion-ease-out);+}++.turn-changes-row:hover {+ background: var(--ds-bg-hover);+ color: var(--ds-text-primary);+}++.turn-changes-row:focus-visible {+ outline: 1.5px solid color-mix(in oklab, var(--ds-focus) 78%, transparent);+ outline-offset: -2px;+}++.turn-changes-mark {+ width: 10px;+ flex: 0 0 auto;+ color: var(--ds-warning);+ font-family: var(--font-mono);+ font-size: var(--text-2xs);+ font-weight: var(--font-weight-medium);+ text-align: center;+}++.turn-changes-row[data-status="added"] .turn-changes-mark {+ color: var(--ds-success);+}++.turn-changes-row[data-status="deleted"] .turn-changes-mark {+ color: var(--ds-error);+}++.turn-changes-path {+ min-width: 0;+ flex: 1;+ overflow: hidden;+ font-family: var(--font-mono);+ font-size: var(--text-sm);+ text-overflow: ellipsis;+ white-space: nowrap;+}++.turn-changes-counts {+ margin-left: auto;+}++/* Rolled-back files stay listed, struck through like the review row. */+.turn-changes-row[data-rolled-back] .turn-changes-mark {+ color: var(--ds-text-faint);+}++.turn-changes-row[data-rolled-back] .turn-changes-path {+ color: var(--ds-text-faint);+ text-decoration: line-through;+}++.turn-changes-row[data-rolled-back] .turn-changes-counts {+ opacity: 0.55;+}++.turn-changes-body.is-dense .turn-changes-row {+ min-height: 21px;+ padding-block: 1px;+}++.turn-changes-body.is-dense .turn-changes-path {+ font-size: var(--text-xs-plus);+}++.turn-changes-more {+ display: flex;+ align-items: center;+ gap: 8px;+ padding: 2px 6px;+ color: var(--ds-text-faint);+ font-family: var(--font-mono);+ font-size: var(--text-2xs);+}++.turn-changes-foot {+ padding: 4px 6px 2px;+}++.turn-changes-view-all {+ padding: 0;+ color: var(--ds-text-secondary);+ font-size: var(--text-2xs);+ text-decoration: underline;+ text-underline-offset: 2px;+}++.turn-changes-view-all:hover {+ color: var(--ds-text-primary);+}++@media (prefers-reduced-motion: reduce) {+ .turn-changes-row {+ transition-duration: 0.01ms;+ }+}diff --git a/apps/desktop/test/turn-changes-card.test.mjs b/apps/desktop/test/turn-changes-card.test.mjsnew file mode 100644index 000000000..186367f5f--- /dev/null+++ b/apps/desktop/test/turn-changes-card.test.mjs@@ -0,0 +1,212 @@+import assert from "node:assert/strict";+import { readFile } from "node:fs/promises";+import test from "node:test";+import { createElement } from "react";+import { slotSsr, propsProbe } from "./helpers/slot-ssr.mjs";+import { summarizeTurnChanges } from "../src/lib/turn-changed-files.ts";+import {+ currentReviewFocusRequest,+ requestReviewFocus,+} from "../src/lib/review-focus-request.ts";++/*+ * The per-turn changed-files summary (issue #1891, design 10): one card under+ * a finished reply, built only from the turn's message-owned review records.+ */++let sequence = 0;++function edit(path, review = {}, overrides = {}) {+ sequence += 1;+ const id = `tool-${sequence}`;+ return {+ id,+ role: "tool",+ content: "",+ status: "complete",+ createdAt: `2026-10-28T00:00:${String(sequence % 60).padStart(2, "0")}.000Z`,+ toolName: "Edit",+ toolCallId: `call-${sequence}`,+ toolStatus: "success",+ toolArgs: { path },+ toolResult: {+ details: {+ root: "workspace",+ review: {+ version: 1,+ snapshotId: `snap-${sequence}`,+ messageId: id,+ path,+ operation: "edit",+ status: "modified",+ state: "active",+ additions: 1,+ deletions: 1,+ hunks: [],+ reversible: true,+ ...review,+ },+ },+ },+ ...overrides,+ };+}++test("one file edited several times is one row with merged counts and status", () => {+ const summary = summarizeTurnChanges([+ edit("src/new.ts", { status: "added", operation: "write", additions: 10, deletions: 0 }),+ edit("src/new.ts", { additions: 3, deletions: 2 }),+ edit("src/app.ts", { additions: 4, deletions: 1 }),+ edit("src/app.ts", { additions: 1, deletions: 0 }),+ edit("src/old.ts", { additions: 2, deletions: 0 }),+ edit("src/old.ts", { status: "deleted", operation: "delete", additions: 0, deletions: 9 }),+ ]);+ assert.deepEqual(+ summary.files.map(({ path, status, additions, deletions, snapshotIds }) => [+ path, status, additions, deletions, snapshotIds.length,+ ]),+ [+ ["src/new.ts", "added", 13, 2, 2],+ ["src/app.ts", "modified", 5, 1, 2],+ ["src/old.ts", "deleted", 2, 9, 2],+ ],+ );+ assert.equal(summary.additions, 20);+ assert.equal(summary.deletions, 12);+ assert.equal(summary.directoryCount, 1);+});++test("rolled-back changes stay listed; a file is rolled back only when every edit is", () => {+ const summary = summarizeTurnChanges([+ edit("a.ts", { state: "rolledBack" }),+ edit("b.ts", { state: "rolledBack" }),+ edit("b.ts"),+ ]);+ assert.deepEqual(+ summary.files.map((file) => [file.path, file.rolledBack]),+ [["a.ts", true], ["b.ts", false]],+ );+});++test("failed, scratch, and non-file tool messages add nothing", () => {+ const summary = summarizeTurnChanges([+ edit("a.ts", {}, { toolStatus: "error" }),+ edit("b.ts", {}, { toolResult: { details: { root: "scratch", review: {} } } }),+ { id: "r", role: "tool", content: "", createdAt: "", toolName: "Read", toolStatus: "success" },+ ]);+ assert.deepEqual(summary.files, []);+});++test("a focus request carries its snapshots, expansion, and a fresh sequence", () => {+ requestReviewFocus([], { expand: true });+ const before = currentReviewFocusRequest();+ requestReviewFocus(["s1", "s2"], { expand: true });+ const first = currentReviewFocusRequest();+ assert.deepEqual(first.snapshotIds, ["s1", "s2"]);+ assert.equal(first.expand, true);+ assert.notEqual(first, before, "an empty request is ignored, a real one replaces it");+ requestReviewFocus(["s1"], { expand: false });+ assert.ok(currentReviewFocusRequest().seq > first.seq);+});++function turnMessages(tools, replyOverrides = {}) {+ return [+ { id: "u1", role: "user", content: "fix it", status: "complete", createdAt: "2026-10-28T00:00:00.000Z" },+ ...tools,+ {+ id: "a-reply",+ role: "assistant",+ content: "Done.",+ status: "complete",+ createdAt: "2026-10-28T00:01:00.000Z",+ ...replyOverrides,+ },+ ];+}++async function renderer(t) {+ const ssr = await slotSsr(t);+ const { AssistantTurn } = await ssr.load("/src/features/chat/transcript/AssistantTurn.tsx");+ const { buildTranscriptEntries } = await ssr.load("/src/lib/assistant-turns.ts");+ const turnOf = (messages) =>+ buildTranscriptEntries(messages).entries.find((entry) => entry.kind === "assistant-turn");+ return {+ ...ssr,+ turn: (messages, props = {}) =>+ ssr.render(createElement(AssistantTurn, { entry: turnOf(messages), isActive: false, ...props })),+ };+}++function rows(html) {+ return [...html.matchAll(/class="turn-changes-row"[^>]*>[\s\S]*?<\/button>/g)];+}++test("a finished turn with a few files gets relaxed rows below the reply, above entry extras", async (t) => {+ const ssr = await renderer(t);+ ssr.register("demo.a", { slot: "entryExtra", component: propsProbe("extra") });+ const html = ssr.turn(turnMessages([+ edit("src/a.ts", { status: "added", operation: "write", additions: 19, deletions: 0 }),+ edit("src/b.ts", { additions: 12, deletions: 4 }),+ ]));+ assert.match(html, /<section class="turn-changes-card" aria-label="Files changed this turn">/);+ assert.match(html, /Changes this turn/);+ assert.match(html, /2 files/);+ assert.match(html, /class="turn-changes-body"/, "two files use the relaxed rows");+ assert.equal(rows(html).length, 2);+ assert.match(html, /data-status="added"[^>]*aria-label="Open Added changes for src[^"]*a\.ts in Review \(19 additions, 0 deletions\)"/);+ assert.doesNotMatch(html, /turn-changes-more|turn-changes-view-all/);+ const reply = html.indexOf("Done.");+ const card = html.indexOf("turn-changes-card");+ const extra = html.indexOf("pi-entry-extra-stack");+ assert.ok(reply < card && card < extra, "reply, then the card, then plugin extras");+});++test("many files switch to dense rows, cap at twelve, and offer the Review panel", async (t) => {+ const ssr = await renderer(t);+ const tools = Array.from({ length: 15 }, (_, index) =>+ edit(`pkg/dir${index % 3}/file${index}.ts`, { additions: 2, deletions: 1 }));+ const html = ssr.turn(turnMessages(tools));+ assert.match(html, /class="turn-changes-body is-dense"/);+ assert.match(html, /15 files · 3 dirs/);+ assert.equal(rows(html).length, 12);+ assert.match(html, /\+3 more/);+ assert.match(html, /View all 15 files in Review/);+ assert.match(html, /\+30/);+ assert.match(html, /−15/);+});++test("rolled-back files are marked in the row and its accessible name", async (t) => {+ const ssr = await renderer(t);+ const html = ssr.turn(turnMessages([edit("src/a.ts", { state: "rolledBack" })]));+ assert.match(html, /data-rolled-back="true"/);+ assert.match(html, /class="turn-changes-row"[^>]*aria-label="[^"]*a\.ts[^"]*· Rolled back"/);+});++test("no card for a turn without file writes, a live turn, or a failed turn", async (t) => {+ const ssr = await renderer(t);+ assert.doesNotMatch(ssr.turn(turnMessages([])), /turn-changes-card/);+ const tools = [edit("src/a.ts")];+ assert.doesNotMatch(+ ssr.turn(turnMessages(tools), { isActive: true }),+ /turn-changes-card/,+ "streaming keeps the reply-slot mount condition",+ );+ assert.doesNotMatch(+ ssr.turn(turnMessages(tools, { error: { code: "X", message: "boom" } })),+ /turn-changes-card/,+ );+});++test("the card stays borderless and the Review tab honors focus requests", async () => {+ const css = await readFile(new URL("../src/styles/turn-changes.css", import.meta.url), "utf8");+ assert.doesNotMatch(css, /^\s*border(-top|-bottom|-left|-right)?\s*:/m);+ assert.doesNotMatch(css, /box-shadow/);+ assert.match(css, /\.turn-changes-card \{[\s\S]*?background: var\(--ds-tile\)/);+ const reviewTab = await readFile(+ new URL("../src/components/workpanel/ReviewTab.tsx", import.meta.url),+ "utf8",+ );+ assert.match(reviewTab, /useReviewFocusRequest\(\)/);+ assert.match(reviewTab, /openRequest=\{/);+ assert.match(reviewTab, /scrollIntoView/);+});diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.mdindex 188f8ebb9..feefb8530 100644--- a/docs/spec/04-ux/08-component-spec.md+++ b/docs/spec/04-ux/08-component-spec.md@@ -995,11 +995,12 @@ pending action cards remain reachable outside a hidden process. See| Empty | Restrained hero + optional onboarding checklist in a scrollable content region, with a bottom-reserved home composer and no starter-card or contextual quick-action layer (D111/D204/D206). An open project underlines the project name, including before its first session exists; the control opens a searchable switcher of the sidebar's open projects, with clone-git-project and open-project actions. || Streaming | Auto-scroll follows while pinned; new tokens append || Active progress | Immediately after send, before the first assistant or tool event, a compact localized `Working…` status with elapsed time appears inline. Its model and subagent elapsed labels use the carried-unit format in §9.1. When the runtime names a quiet interval, that same row identifies starting, waiting for the model, preparing the next request, compacting context, recovering an empty response, retrying, or waiting for delegated work (with each running subagent's latest coarse action). It remains visible through thinking, tool execution, completed-tool gaps, and partial answers until the turn ends. Runtime phases take precedence over the Planning/Goal or Working fallback. Pending permissions, questions, and plan/goal approvals suppress the row; history reading never shows live status; no large generic progress card is rendered. The row lives in the reserved tail lane, so it appears and clears mid-turn without changing the transcript's content height. A retrying row remains compact at rest; hovering or focusing it reveals an error-styled tooltip with the localized error summary, stable code/HTTP status, and bounded provider message. The tooltip mixes the error tint over `--ds-bg-elevated-opaque` so transcript text does not show through. |-| Turn outcome | After a failed turn, a session-scoped recovery card summarizes the interruption and tool evidence. Completed turns use the existing transcript and message-scoped review rows without an extra success card; failed turns can continue through one localized prompt without losing the transcript. |+| Turn outcome | After a failed turn, a session-scoped recovery card summarizes the interruption and tool evidence. Completed turns use the existing transcript and message-scoped review rows without an extra success card; a completed turn that wrote workspace files also shows the per-turn changed-files summary below (D674). Failed turns can continue through one localized prompt without losing the transcript. || Session switch | A first-opened session paints at its latest record; a revisited pane paints at its own retained position. Bounded first commit and full-history expansion show the same position: no post-paint height correction may shift the visible rows, in either direction || Turn start (send / retry / regenerate) | Re-pins and positions the latest content before paint, even if the user had scrolled up; the later persisted user-message event does not flash the transcript at its top, and the composer collapse / indicator layout clamps during the send never release follow mode || Idle (after stream) | Auto-scroll unlocked; user can scroll freely || Message-scoped review snapshot | Each successful workspace Write/Edit renders as one tool-level review row (`ReviewChangeCard`) carrying that message's added/modified/deleted status and explicit addition/deletion totals. The row itself is the file header — Git-style status letter (`A`/`M`/`D`), path, addition/deletion counts, disclosure caret — with no separate generic tool row above it, so the file header appears exactly once. It keeps the tool-row rhythm with no card border, status rail, icon plate, or status pill; hover fill is the only row chrome, and a rolled-back change is struck through. Its hunks sit in the diff body directly beneath that header behind the row's expandable disclosure: every review row (inline and in the Review tab) is collapsed by default, and the user expands it on demand. The diff body's action row keeps hash-guarded rollback and adds Copy for the hunks. The card remains after a Git commit, never becomes a bottom/global entry, and does not leak into another session's transcript. |+| Per-turn changed files | A completed reply (same mount condition as the reply plugin slots, so never while streaming and never after a failed turn) whose turn recorded at least one workspace review change shows one read-only `TurnChangesCard` below its answer and above `entryExtra` blocks (D674). It is built only from that turn's message-owned review records: one row per path in first-touched order, counts summed across edits, status `D` when the turn ends by deleting the file, else `A` if any edit created it, else `M`; a file whose every edit was rolled back stays listed, struck through, with the state in its accessible name. The header shows `Changes this turn`, the file count, and the summed `+`/`−`. Up to four files use relaxed 25px rows; more switch to dense 21px rows and add the directory count; rows past 12 fold into `+N more` plus a link that opens Review. The card is one `--ds-tile` surface with no border or rules. Clicking a row opens the originating session's Review tab, scrolls to that file's first recorded change, and expands its changes there — the card has no diff body or rollback of its own. A turn without workspace writes renders nothing. |### 4.5 Accessibility@@ -1273,7 +1274,9 @@ entirely inside the plugin's isolated page:resize the window, or change visible selection/focus. The transcript doesnot create a global Review changes launcher: each successful workspaceWrite/Edit renders only its own tool-level review row, and another session- cannot render that card in its transcript. Repeated resources deduplicate+ cannot render that card in its transcript. The per-turn changed-files card+ (D674) is scoped to one finished turn and opens Review only on a user+ click. Repeated resources deduplicatewithin the originating session.- Review truth: host-core adds one bounded `details.review` record to eachsuccessful workspace Write/Edit result. The renderer reads that record fromdiff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex ef4975ded..5974da72a 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -4923,6 +4923,31 @@ window; opening a normal panel afterward must still work.- **Milestone**: M5- **Status**: Unit-covered (`chat-review-entry.test.mjs`); full UI scenario Draft+#### E2E-CHAT-turn-changed-files-summary: A finished turn lists the files it changed++- **Preconditions**: A project-bound Agent session with a writable workspace.+- **Steps**: 1) Ask the agent to create one file and edit another; watch the+ turn while it streams. 2) After the reply finishes, inspect the area below+ the answer. 3) Ask for a change touching more than twelve files across+ several directories. 4) Click a row, then the `View all N files in Review`+ link. 5) Roll back one file's change in Review and return to the turn.+ 6) Ask a question that writes no files. 7) Switch sessions and come back.+- **Expected**: No summary appears while a turn streams or after a failed+ turn. A finished turn that wrote workspace files shows one borderless+ `Changes this turn` card below its answer and above plugin `entryExtra`+ blocks, with the file count and summed `+`/`−`. Each path appears once with+ its merged status letter and counts; up to four files use relaxed rows,+ more use dense rows with a directory count, and rows past 12 fold into+ `+N more`. A row click opens the session's Review tab scrolled to that file+ with its changes expanded; the link opens Review without expanding. The+ rolled-back file stays listed, struck through. Every earlier finished turn+ keeps its own card, a turn without writes has none, and a session switch+ fetches nothing extra. The per-call review rows are unchanged.+- **Specs linked**: `04-ux/08-component-spec.md` §4.4, D674+- **Acceptance**: D (workspace), Quality+- **Milestone**: M5+- **Status**: Unit-covered (`turn-changes-card.test.mjs`); full UI scenario Draft+#### E2E-058: Built-in interactive terminal is absent- **Preconditions**: A workspace is open and the Agent has completed a Bashdiff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.mdindex e17fe616b..9713cc201 100644--- a/docs/spec/08-meta/decisions-log.md+++ b/docs/spec/08-meta/decisions-log.md@@ -335,6 +335,7 @@ Gold source: local Codex electron captures; latest row wins where rows conflict.| D668 | One process disclosure per turn, with three transcript display modes | **Amend D661 / the `turn-process-and-thinking-display` ADR. A turn renders exactly one top-level process disclosure holding every pre-answer row; the answer stays outside it. `AppSettings.transcriptDisplayMode` selects the layout: `flat` renders no nested activity groups, `command-first` renders `Bash`/run rows as standalone rows beside activity groups, and `fully-folded` (the default for absent or invalid values) keeps commands inside their groups and lets only ordinary assistant progress text split them. The mode is read while rendering, so switching repaints immediately - the projection cache is keyed by messages and compactions only. The disclosure header reports failed / stopped / running / finished with precedence in that order and never echoes the current item, and the disclosure shares one left edge with the levels it reveals. `transcriptDisplayMode` joins the portable application fields; `keepCommandsExpanded` is deprecated, retained only for persisted-settings compatibility, and no longer exposed or read for rendering. No host protocol, persistence schema, permission, or plugin contract change. See the amended ADR, `04-ux/06-settings-ia.md`, `04-ux/08-component-spec.md`, `04-ux/09-interaction-patterns.md`, and E2E-CHAT-turn-process-and-thinking-display.** | Chronological segmentation split one turn into several sibling disclosures above the answer, and the boolean command-folding preference could only express two layouts; a three-mode setting covers flat, command-first, and the released grouped view without changing what a tool received or stored. || D669 | `@` queries search past a truncated file index | **Amend D124: while the 8000-entry `fs/index` snapshot is truncated, a non-empty `@` query is also searched over the root's full listing through the read-only Electron channel `pi-desktop/fs/search` once typing pauses, and its best 50 rows merge with the local matches. A complete index never searches. Remote sessions keep their snapshot. No host RPC, storage, or schema change.** | The shallowest-8000-entry index left a script several folders down matching no query at all, even though the truncation note invited the reader to refine it (issue #1781). || D671 | Inline generative UI visualizations | **Amend D114: local sessions get a second host-owned contained root `<data_dir>/visualizations/<sessionId>/` for `.html` fragments only (Read/Write/Edit, auto-allowed like scratch, never in remote or contract sessions). A standalone `::visualize{"path","title"}` reply line renders the fragment inline through a sandboxed `pi-genui://session/<sid>/<file>` iframe (`sandbox="allow-scripts"`, strict CSP, no network). Builtin skill `pi-desktop/visualize`. No schema change.** | Interactive explanations need an embedded page; ADR gen-ui-inline-visualization. |+| D674 | Per-turn changed-files summary under a finished reply | **A completed reply whose turn recorded workspace review changes renders one read-only `TurnChangesCard` below its answer and above `entryExtra`, built only from that turn's message-owned `details.review` records (no new capture, IPC, or persistence). Rows merge edits per path (`D` if the turn ends by deleting, else `A` if any edit created the file, else `M`; counts summed; rolled-back files stay listed and struck through). Up to four files use relaxed rows, more use dense rows, and rows past 12 fold into `+N more`. Clicking a row opens Review on that file's recorded changes; the per-call review rows and the Review tab are unchanged.** | Issue #1891, design 10 (adaptive density): the per-call review rows answer "what did this call change", and Review answers it for the whole session, but nothing answered "what did this turn change" without counting rows. |## M0. Model catalog decisions@@ -7994,3 +7995,24 @@ must keep splitting are covered by `markdown-blocks.test.mjs`.`turn-process-and-thinking-display`, `04-ux/08-component-spec.md` §9,`04-ux/09-interaction-patterns.md` §4.2, andE2E-CHAT-turn-process-and-thinking-display.++## 2026-10-28 — Per-turn changed-files summary (D674)++- D674 adds a read-only `TurnChangesCard` under every completed reply whose+ turn recorded at least one workspace review change (issue #1891, design 10).+ It mounts with the reply plugin slots, so it never appears while streaming or+ after a failed turn, and `entryExtra` blocks stay beneath it.+- The card reads only the turn's message-owned `details.review` records through+ `reviewChangeFromMessage`; no capture, IPC, persistence, or host-core change.+ Rows merge edits per path: `D` when the turn ends by deleting the file, else+ `A` when any edit created it, else `M`; counts add up; a file whose every edit+ was rolled back stays listed and struck through.+- Adaptive density: up to four files use relaxed 25px rows; more switch to dense+ 21px rows with a directory count; rows past 12 fold into `+N more` with a link+ to Review. The card is one `--ds-tile` surface with no border (D297).+- Clicking a row opens the originating session's Review tab, scrolls to that+ file's first recorded change, and expands it, through a transient renderer+ focus request (`lib/review-focus-request.ts`) rather than app-store state.+ The per-call review rows and the Review tab otherwise keep their behavior.+- Covered by `apps/desktop/test/turn-changes-card.test.mjs`. See+ `04-ux/08-component-spec.md` §4.4 and E2E-CHAT-turn-changed-files-summary.diff --git a/docs/zh-CN/spec/04-ux/08-component-spec.md b/docs/zh-CN/spec/04-ux/08-component-spec.mdindex f0ab14b8c..65939fcfa 100644--- a/docs/zh-CN/spec/04-ux/08-component-spec.md+++ b/docs/zh-CN/spec/04-ux/08-component-spec.md@@ -638,11 +638,12 @@ expanded/collapsed 侧边栏仍为 20px/18px 且启动画面为 64 像素。| 空 | 可滚动内容区域中的受约束的英雄+可选的入门清单,带有底部保留的主页输入框,没有入门卡或上下文快速操作层(D111/D204/D206)。打开的项目会给项目名加下划线,即使该项目还没有任何会话;点击可打开侧边栏已打开项目的可搜索切换菜单,并带有克隆 Git 项目与打开项目操作。 || 流媒体 | 固定时自动滚动;追加新标记 || 积极进展 | 发送后,在第一个助手或工具事件之前,会内联显示一个紧凑的本地化 `Working…` 状态以及经过的时间。思考、工具执行、工具完成后的空档和部分回答都不会隐藏该行。具体运行时阶段优先于规划/目标或工作中提示;等待权限、提问或计划/目标批准时隐藏状态,历史阅读窗口不显示实时状态;不会渲染大型通用进度卡。重试行在静止时保持紧凑;悬停或聚焦会弹出错误色 tooltip,底板为 `--ds-bg-elevated-opaque`,避免透出记录正文。 |-| 回合结果 | 回合失败后,会话范围的恢复卡会总结中断和工具证据。已完成的轮次使用现有的记录和消息范围的审核行,无需额外的成功卡;失败的回合可以重试而不会丢失转录本。 |+| 回合结果 | 回合失败后,会话范围的恢复卡会总结中断和工具证据。已完成的轮次使用现有的记录和消息范围的审核行,无需额外的成功卡;写过工作区文件的已完成回合还会在下方显示按轮文件变更汇总(D674)。失败的回合可以重试而不会丢失转录本。 || 会话切换 | 首次打开的会话在它最新的记录处绘制;重新访问的面板在它自己保留的位置处绘制。有界的首次提交与全量历史展开显示同一个位置:绘制之后的高度校正不得在任何方向上移动可见行 || 启动(发送/重试/重新生成) | 即使用户向上滚动,在绘制之前重新固定和定位最新内容;后来保留的用户消息事件不会在其顶部闪烁记录,并且发送期间的输入框折叠/指示器布局夹紧永远不会释放跟随模式 || 空闲(流后) | 自动滚动解锁;用户可以自由滚动 || 消息范围的审核快照 | 每个成功的工作区 Write/Edit 渲染为一条工具级审核行(`ReviewChangeCard`),其中包含该消息的 added/modified/deleted 状态和显式 addition/deletion 总计。该行本身就是文件标题——Git 风格状态字母(`A`/`M`/`D`)、路径、增删计数、披露 caret——上方不再渲染通用工具行,因此文件标题只出现一次。它沿用工具行的节奏,没有卡片边框、状态竖线、图标底板或状态药丸;悬停填充是唯一的行装饰,已回滚的更改显示删除线。hunks 位于标题正下方的 diff 正文中,由该行自身的披露控制:默认情况下,每条审核行(转录内与“审核”选项卡)都收起,用户按需展开。diff 正文的操作行保留哈希保护的回滚,并新增复制 hunks 的 Copy。该卡在 Git 提交后保留,永远不会成为 bottom/global 条目,也不会泄漏到另一个会话的转录中。 |+| 按轮文件变更 | 已完成的回复(与回复插件槽相同的挂载条件,因此流式期间和失败回合都不显示)若其回合记录了至少一条工作区审核变更,就在回答下方、`entryExtra` 块上方显示一张只读的 `TurnChangesCard`(D674)。它只由该回合消息拥有的审核记录构建:每个路径一行,按首次改动顺序排列,计数在多次编辑间累加;回合以删除该文件结束时状态为 `D`,否则只要有一次创建即为 `A`,其余为 `M`;所有编辑都已回滚的文件仍保留在列表中,显示删除线,并在可访问名称中带上该状态。标题显示 `本轮改动`、文件数和合计 `+`/`−`。不超过四个文件时用 25px 宽松行;更多时切换为 21px 密集行并补充目录数;超过 12 行的部分折叠为 `+N more`,并提供打开审阅的链接。卡片是一个 `--ds-tile` 平面,没有边框或分割线。点击一行会打开来源会话的审阅选项卡,滚动到该文件的第一条记录并展开其变更——卡片本身没有 diff 正文,也不提供回滚。没有工作区写入的回合不渲染任何内容。 |### 4.5 辅助功能@@ -840,7 +841,8 @@ vendor 进来的 `pi.file-manager` 视图在插件自己的隔离页面内完成调整窗口大小,或更改可见的 selection/focus。抄本确实不创建全局审核更改启动器:每个成功的工作区Write/Edit 仅渲染自己的工具级审核行,而另一个会话- 无法在其记录中呈现该卡。重复资源去重+ 无法在其记录中呈现该卡。按轮文件变更卡(D674)只属于一个已完成的+ 回合,并且只在用户点击时打开审阅。重复资源去重在原始会话内。- 回顾事实:host-core 为每个 `details.review` 添加一条有界 `details.review` 记录成功的工作区 Write/Edit 结果。渲染器读取该记录diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.mdindex 5e48a18c8..d81d00726 100644--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md@@ -2508,6 +2508,26 @@ MainChat 弥补了缺口。 Maximized/fullscreen 调用保留最新的- **里程碑**:M5- **状态**:单位覆盖(`chat-review-entry.test.mjs`);完整的 UI 场景草稿+#### E2E-CHAT-turn-changed-files-summary:已完成的回合列出它改动的文件++- **先决条件**:具有可写工作空间的项目绑定 Agent 会话。+- **步骤**:1) 让代理创建一个文件并编辑另一个文件;观察流式中的回合。+ 2) 回复完成后,检查回答下方区域。3) 请求一次跨多个目录、超过十二个文件的+ 改动。4) 点击一行,再点击 `在「审阅」面板查看全部 N 个文件` 链接。+ 5) 在审阅中回滚一个文件的变更后回到该回合。6) 提一个不写文件的问题。+ 7) 切换会话后再切回来。+- **预期**:回合流式期间或失败后不显示汇总。写过工作区文件的已完成回合在回答+ 下方、插件 `entryExtra` 块上方显示一张无边框的 `本轮改动` 卡片,带文件数和合计+ `+`/`−`。每个路径只出现一次,带合并后的状态字母和计数;不超过四个文件用宽松行,+ 更多时用带目录数的密集行,超过 12 行折叠为 `+N more`。点击一行会打开该会话的+ 审阅选项卡,滚动到该文件并展开其变更;链接只打开审阅、不展开。已回滚的文件仍在+ 列表中并显示删除线。每个更早的已完成回合保留自己的卡片,没有写入的回合没有卡片,+ 切换会话不会额外取数。逐次调用的审核行保持不变。+- **链接规格**:`04-ux/08-component-spec.md` §4.4,D674+- **验收**:D(工作空间),质量+- **里程碑**:M5+- **状态**:单元覆盖(`turn-changes-card.test.mjs`);完整的 UI 场景草稿+#### E2E-058:内置交互式终端已移除- **前提**:已打开工作区,Agent 已完成一次 Bash 工具调用。diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.mdindex 03f57b51d..bb8c2fea6 100644--- a/docs/zh-CN/spec/08-meta/decisions-log.md+++ b/docs/zh-CN/spec/08-meta/decisions-log.md@@ -338,6 +338,7 @@| D668 | 每回合一个过程披露,并提供三种转录显示模式 | **修订 D661 / `turn-process-and-thinking-display` ADR:每个回合渲染一个顶层过程披露,包含回答前的全部行;回答留在披露之外。`AppSettings.transcriptDisplayMode` 选择布局:`flat` 不渲染嵌套活动组,`command-first` 将 `Bash`/run 行作为活动组旁的独立行,`fully-folded`(缺失或无效值的默认)让命令留在所属组内,且只有普通助手进度文字会拆分活动组。该模式在渲染时读取,因此切换后立即重绘——投影缓存只以消息和压缩为键。披露标题按失败/停止/执行中/已完成的优先级报告,且绝不回显当前条目;披露与它展开的层级共用一条左边缘。`transcriptDisplayMode` 加入可移植应用字段;`keepCommandsExpanded` 已弃用,仅为持久化设置兼容性保留,不再暴露,也不再参与渲染读取。无 Host 协议、持久化 schema、权限或插件契约变更。见修订后的 ADR、`04-ux/06-settings-ia.md`、`04-ux/08-component-spec.md`、`04-ux/09-interaction-patterns.md` 与 E2E-CHAT-turn-process-and-thinking-display。** | 按时间顺序的分段把同一回合拆成答案上方多个并列披露,而布尔命令折叠偏好只能表达两种布局;三种模式覆盖平铺、命令优先与已发布的分组视图,且不改变工具收到的内容或持久化内容。 || D669 | `@` 查询越过被截断的文件索引 | **修订 D124:8000 条的 `fs/index` 快照被截断时,非空的 `@` 查询会在输入停顿后,通过只读的 Electron 通道 `pi-desktop/fs/search` 在该根目录的完整清单中搜索,最好的 50 行与本地匹配合并。完整的索引从不搜索。远程会话保持使用快照。不改变主机 RPC、存储或 schema。** | 只保留最浅 8000 条的索引,会让深几层目录里的脚本对任何查询都匹配不到,而截断提示还在邀请用户细化查询(issue #1781)。 || D671 | 对话内联生成式 UI 可视化 | **修订 D114:本地会话新增第二个由宿主拥有的受控根目录 `<data_dir>/visualizations/<sessionId>/`,仅用于 `.html` 片段(Read/Write/Edit,与 scratch 一样免确认,远程会话和合约会话中不提供)。回复中单独一行 `::visualize{"path","title"}` 会通过沙箱化的 `pi-genui://session/<sid>/<file>` iframe(`sandbox="allow-scripts"`、严格 CSP、无网络)内联渲染该片段。内置 skill `pi-desktop/visualize`。不改变 schema。** | 交互式讲解需要内嵌页面;见 ADR gen-ui-inline-visualization。 |+| D674 | 已完成回复下方的按轮文件变更汇总 | **回合记录了工作区审核变更的已完成回复,会在回答下方、`entryExtra` 上方渲染一张只读的 `TurnChangesCard`,只由该回合消息拥有的 `details.review` 记录构建(不新增采集、IPC 或持久化)。按路径合并多次编辑(回合以删除结束为 `D`,否则有创建即为 `A`,其余为 `M`;计数累加;已回滚文件保留并显示删除线)。不超过四个文件用宽松行,更多用密集行,超过 12 行折叠为 `+N more`。点击一行会在审阅中打开该文件的记录变更;逐次调用的审核行和审阅选项卡保持不变。** | Issue #1891,设计 10(自适应密度):逐次调用的审核行回答“这次调用改了什么”,审阅回答整个会话的问题,但回答“这一轮改了什么”仍需自己数工具行。 |## M0. 模型目录决策@@ -5566,3 +5567,21 @@ Markdown 源码,不是 `text/html` 负载;对禁用行内 HTML 的外部编`packages/agent-runtime/src/provider-binding.test.ts` 的请求抓取测试,以及`packages/agent-runtime/src/provider-reasoning-effort.test.ts` 的官方线路用例覆盖。见`03-runtime/11-provider-model-system.md` 与 E2E-005E。++## 2026-10-28 — 按轮文件变更汇总(D674)++- D674 在每条回合记录了至少一条工作区审核变更的已完成回复下方,新增只读的+ `TurnChangesCard`(issue #1891,设计 10)。它与回复插件槽一起挂载,因此流式期间+ 和失败回合都不会出现,`entryExtra` 块始终在它下方。+- 卡片只通过 `reviewChangeFromMessage` 读取该回合消息拥有的 `details.review`+ 记录;不改变采集、IPC、持久化或 host-core。按路径合并多次编辑:回合以删除该文件+ 结束时为 `D`,否则只要有一次创建即为 `A`,其余为 `M`;计数累加;所有编辑都已+ 回滚的文件保留在列表中并显示删除线。+- 自适应密度:不超过四个文件用 25px 宽松行;更多时切换为 21px 密集行并显示目录数;+ 超过 12 行折叠为 `+N more`,并附打开审阅的链接。卡片是一个无边框的 `--ds-tile`+ 平面(D297)。+- 点击一行会打开来源会话的审阅选项卡,滚动到该文件的第一条记录变更并展开;+ 通过渲染层的临时聚焦请求(`lib/review-focus-request.ts`)实现,而不是 app-store+ 状态。逐次调用的审核行和审阅选项卡的其他行为不变。+- 由 `apps/desktop/test/turn-changes-card.test.mjs` 覆盖。见+ `04-ux/08-component-spec.md` §4.4 与 E2E-CHAT-turn-changed-files-summary。diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.tsindex ebd700a90..09ff6581b 100644--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@ -519,6 +519,15 @@ export const de = {"reviewChangeShow": "{{status}} Änderungen für {{path}} anzeigen ({{additions}} Ergänzungen, {{deletions}} Löschungen)","reviewChangeHide": "{{status}} Änderungen für {{path}} ausblenden ({{additions}} Ergänzungen, {{deletions}} Löschungen)","reviewChangeCounts": "{{additions}} Ergänzungen, {{deletions}} Löschungen",+ "turnChangesTitle": "Änderungen in diesem Durchlauf",+ "turnChangesLabel": "In diesem Durchlauf geänderte Dateien",+ "turnChangesDirs_one": "1 Ordner",+ "turnChangesDirs_other": "{{count}} Ordner",+ "turnChangesMore_one": "+1 weitere",+ "turnChangesMore_other": "+{{count}} weitere",+ "turnChangesViewAll_one": "Alle {{count}} Dateien in „Überprüfen“ anzeigen",+ "turnChangesViewAll_other": "Alle {{count}} Dateien in „Überprüfen“ anzeigen",+ "turnChangesOpen": "{{status}} Änderungen für {{path}} in „Überprüfen“ öffnen ({{additions}} Ergänzungen, {{deletions}} Löschungen)","toolFailed": "Fehlgeschlagen","toolDenied": "Abgelehnt","toolCompleted": "Fertig",diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.tsindex 83efc7dec..32957c327 100644--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@ -531,6 +531,15 @@ export const en = {reviewChangeShow: "Show {{status}} changes for {{path}} ({{additions}} additions, {{deletions}} deletions)",reviewChangeHide: "Hide {{status}} changes for {{path}} ({{additions}} additions, {{deletions}} deletions)",reviewChangeCounts: "{{additions}} additions, {{deletions}} deletions",+ turnChangesTitle: "Changes this turn",+ turnChangesLabel: "Files changed this turn",+ turnChangesDirs_one: "1 dir",+ turnChangesDirs_other: "{{count}} dirs",+ turnChangesMore_one: "+1 more",+ turnChangesMore_other: "+{{count}} more",+ turnChangesViewAll_one: "View all {{count}} files in Review",+ turnChangesViewAll_other: "View all {{count}} files in Review",+ turnChangesOpen: "Open {{status}} changes for {{path}} in Review ({{additions}} additions, {{deletions}} deletions)",toolFailed: "Failed",toolDenied: "Denied",toolCompleted: "Done",diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.tsindex a75f76083..0fa1e1b96 100644--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@ -519,6 +519,15 @@ export const es = {"reviewChangeShow": "Mostrar {{status}} cambios para {{path}} ({{additions}} adiciones, {{deletions}} eliminaciones)","reviewChangeHide": "Ocultar {{status}} cambios para {{path}} ({{additions}} adiciones, {{deletions}} eliminaciones)","reviewChangeCounts": "{{additions}} adiciones, {{deletions}} eliminaciones",+ "turnChangesTitle": "Cambios de este turno",+ "turnChangesLabel": "Archivos cambiados en este turno",+ "turnChangesDirs_one": "1 carpeta",+ "turnChangesDirs_other": "{{count}} carpetas",+ "turnChangesMore_one": "+1 más",+ "turnChangesMore_other": "+{{count}} más",+ "turnChangesViewAll_one": "Ver los {{count}} archivos en Revisar",+ "turnChangesViewAll_other": "Ver los {{count}} archivos en Revisar",+ "turnChangesOpen": "Abrir {{status}} cambios para {{path}} en Revisar ({{additions}} adiciones, {{deletions}} eliminaciones)","toolFailed": "Fallido","toolDenied": "Denegado","toolCompleted": "Hecho",diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.tsindex a2e12d541..207dd2320 100644--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@ -519,6 +519,15 @@ export const fr = {"reviewChangeShow": "Afficher {{status}} modifications pour {{path}} ({{additions}} ajouts, {{deletions}} suppressions)","reviewChangeHide": "Masquer {{status}} modifications pour {{path}} ({{additions}} ajouts, {{deletions}} suppressions)","reviewChangeCounts": "{{additions}} ajouts, {{deletions}} suppressions",+ "turnChangesTitle": "Modifications de ce tour",+ "turnChangesLabel": "Fichiers modifiés pendant ce tour",+ "turnChangesDirs_one": "1 dossier",+ "turnChangesDirs_other": "{{count}} dossiers",+ "turnChangesMore_one": "+1 autre",+ "turnChangesMore_other": "+{{count}} autres",+ "turnChangesViewAll_one": "Voir les {{count}} fichiers dans Réviser",+ "turnChangesViewAll_other": "Voir les {{count}} fichiers dans Réviser",+ "turnChangesOpen": "Ouvrir {{status}} modifications pour {{path}} dans Réviser ({{additions}} ajouts, {{deletions}} suppressions)","toolFailed": "Échec","toolDenied": "Refusé","toolCompleted": "Terminé",diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.tsindex e10c30d86..209884578 100644--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@ -528,6 +528,15 @@ export const ko = {reviewChangeShow: "{{path}}의 {{status}} 변경 사항 표시 (추가 {{additions}}개, 삭제 {{deletions}}개)",reviewChangeHide: "{{path}}의 {{status}} 변경 사항 숨기기 (추가 {{additions}}개, 삭제 {{deletions}}개)",reviewChangeCounts: "추가 {{additions}}개, 삭제 {{deletions}}개",+ turnChangesTitle: "이번 턴의 변경",+ turnChangesLabel: "이번 턴에서 변경된 파일",+ turnChangesDirs_one: "폴더 1개",+ turnChangesDirs_other: "폴더 {{count}}개",+ turnChangesMore_one: "1개 더",+ turnChangesMore_other: "{{count}}개 더",+ turnChangesViewAll_one: "검토에서 파일 {{count}}개 모두 보기",+ turnChangesViewAll_other: "검토에서 파일 {{count}}개 모두 보기",+ turnChangesOpen: "검토에서 {{path}}의 {{status}} 변경 사항 열기 (추가 {{additions}}개, 삭제 {{deletions}}개)",toolFailed: "실패",toolDenied: "거부됨",toolCompleted: "완료",diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.tsindex 135824602..dbbc1c2c1 100644--- a/packages/i18n/src/locales/pt-BR/index.ts+++ b/packages/i18n/src/locales/pt-BR/index.ts@@ -518,6 +518,15 @@ export const ptBR = {reviewChangeShow: "Mostrar alterações {{status}} em {{path}} ({{additions}} adições, {{deletions}} exclusões)",reviewChangeHide: "Ocultar alterações {{status}} em {{path}} ({{additions}} adições, {{deletions}} exclusões)",reviewChangeCounts: "{{additions}} adições, {{deletions}} exclusões",+ turnChangesTitle: "Alterações deste turno",+ turnChangesLabel: "Arquivos alterados neste turno",+ turnChangesDirs_one: "1 pasta",+ turnChangesDirs_other: "{{count}} pastas",+ turnChangesMore_one: "+1 outro",+ turnChangesMore_other: "+{{count}} outros",+ turnChangesViewAll_one: "Ver todos os {{count}} arquivos em Revisar",+ turnChangesViewAll_other: "Ver todos os {{count}} arquivos em Revisar",+ turnChangesOpen: "Abrir alterações {{status}} em {{path}} em Revisar ({{additions}} adições, {{deletions}} exclusões)",toolFailed: "Falhou",toolDenied: "Negada",toolCompleted: "Concluída",diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.tsindex f6cbfc2d4..e4a0c87e5 100644--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@ -528,6 +528,15 @@ export const tr = {reviewChangeShow: "{{path}} için {{status}} değişikliklerini göster ({{additions}} ekleme, {{deletions}} silme)",reviewChangeHide: "{{path}} için {{status}} değişikliklerini gizle ({{additions}} ekleme, {{deletions}} silme)",reviewChangeCounts: "{{additions}} ekleme, {{deletions}} silme",+ turnChangesTitle: "Bu turdaki değişiklikler",+ turnChangesLabel: "Bu turda değişen dosyalar",+ turnChangesDirs_one: "1 klasör",+ turnChangesDirs_other: "{{count}} klasör",+ turnChangesMore_one: "+1 daha",+ turnChangesMore_other: "+{{count}} daha",+ turnChangesViewAll_one: "{{count}} dosyanın tümünü İnceleme'de görüntüle",+ turnChangesViewAll_other: "{{count}} dosyanın tümünü İnceleme'de görüntüle",+ turnChangesOpen: "{{path}} için {{status}} değişikliklerini İnceleme'de aç ({{additions}} ekleme, {{deletions}} silme)",toolFailed: "Başarısız",toolDenied: "Reddedildi",toolCompleted: "Bitti",diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.tsindex 5b825c6e9..f3824659a 100644--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@ -521,6 +521,15 @@ export const zhCN = {reviewChangeShow: "显示 {{path}} 的{{status}}改动(新增 {{additions}} 行,删除 {{deletions}} 行)",reviewChangeHide: "隐藏 {{path}} 的{{status}}改动(新增 {{additions}} 行,删除 {{deletions}} 行)",reviewChangeCounts: "新增 {{additions}} 行,删除 {{deletions}} 行",+ turnChangesTitle: "本轮改动",+ turnChangesLabel: "本轮改动的文件",+ turnChangesDirs_one: "1 个目录",+ turnChangesDirs_other: "{{count}} 个目录",+ turnChangesMore_one: "还有 1 个",+ turnChangesMore_other: "还有 {{count}} 个",+ turnChangesViewAll_one: "在「审阅」面板查看全部 {{count}} 个文件",+ turnChangesViewAll_other: "在「审阅」面板查看全部 {{count}} 个文件",+ turnChangesOpen: "在审阅中打开 {{path}} 的{{status}}改动(新增 {{additions}} 行,删除 {{deletions}} 行)",toolFailed: "失败",toolDenied: "已拒绝",toolCompleted: "已完成",diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.tsindex d26060510..d3651e8e7 100644--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@ -521,6 +521,15 @@ export const zhTW = {reviewChangeShow: "顯示 {{path}} 的{{status}}改動(新增 {{additions}} 行,刪除 {{deletions}} 行)",reviewChangeHide: "隱藏 {{path}} 的{{status}}改動(新增 {{additions}} 行,刪除 {{deletions}} 行)",reviewChangeCounts: "新增 {{additions}} 行,刪除 {{deletions}} 行",+ turnChangesTitle: "本輪改動",+ turnChangesLabel: "本輪改動的檔案",+ turnChangesDirs_one: "1 個目錄",+ turnChangesDirs_other: "{{count}} 個目錄",+ turnChangesMore_one: "還有 1 個",+ turnChangesMore_other: "還有 {{count}} 個",+ turnChangesViewAll_one: "在「審閱」面板查看全部 {{count}} 個檔案",+ turnChangesViewAll_other: "在「審閱」面板查看全部 {{count}} 個檔案",+ turnChangesOpen: "在審閱中開啟 {{path}} 的{{status}}改動(新增 {{additions}} 行,刪除 {{deletions}} 行)",toolFailed: "失敗",toolDenied: "已拒絕",toolCompleted: "已完成",