Skip to content

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

fix(review): correct file counts and stabilize history layout

new-Beginner5f101e06cd2d
diff --git a/apps/desktop/src/components/ReviewChangeCard.tsx b/apps/desktop/src/components/ReviewChangeCard.tsx
index 05ee4d200..a6e0ee57c 100644
--- a/apps/desktop/src/components/ReviewChangeCard.tsx
+++ b/apps/desktop/src/components/ReviewChangeCard.tsx
@@ -99,9 +99,9 @@ export function ReviewChangeDetails({ message, compact = false, contextLines = 3
aria-label={reviewLineNumber(line) === null ? undefined : t(line.type === "del" ? "panel.review.oldLine" : "panel.review.newLine", { line: reviewLineNumber(line) })}>
{reviewLineNumber(line)}
</span>}
- <span className="diff-line-sign" aria-hidden>
+ {!numbered && <span className="diff-line-sign" aria-hidden>
{line.type === "add" ? "+" : line.type === "del" ? "−" : " "}
- </span>
+ </span>}
<span className="diff-line-text">{line.text}</span>
</div>
))}
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
index 24c676d15..69c4cc418 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
@@ -26,7 +26,10 @@ export function ReviewHistoryFile({ file, sessionId, context, focusSeq, focusSna
return <section className={cx("review-history-file", open && "open")} data-review-snapshots={file.entries.map(entry => entry.change.snapshotId).join(" ")}>
<div className="review-history-file-heading">
<Button variant="ghost" className="review-history-file-header" aria-expanded={open} aria-controls={detailsId} disabled={disabled} title={/^(?:[a-z]:[\\/]|[\\/])/i.test(file.path) || !file.root ? file.path : `${file.root}/${file.path}`} onClick={() => setOpen(value => !value)}>
- <span className="review-file-disclosure"><IconChevronRight size={11} /></span><ReviewFileIcon path={file.path} /><span className="review-change-card-path" data-outside-path={reviewFilePathLabel(file.path) !== file.path || undefined}>{reviewFilePathLabel(file.path)}</span>
+ <ReviewFileIcon path={file.path} /><span className="review-file-label">
+ <span className="review-change-card-path" data-outside-path={reviewFilePathLabel(file.path) !== file.path || undefined}>{reviewFilePathLabel(file.path)}</span>
+ <span className="review-file-disclosure"><IconChevronRight size={11} /></span>
+ </span>
<span className="diff-counts"><span className="diff-count-add">+{file.additions}</span><span className="diff-count-del">−{file.deletions}</span></span>
</Button>
<TooltipButton className="icon-btn review-file-menu-button" tooltip={t("panel.review.fileActions")} disabled={disabled} aria-haspopup="menu" aria-expanded={!!menu.contextMenu} onClick={event => menu.openContextMenu(event, { label: t("panel.review.fileActions"), anchor: "bottom-end", density: "compact", items: [
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
index 831f166ee..b6828b433 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useRef, useState } from "react";
+import { createElement, useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import type { ReviewChangesPage, ReviewContextLines, ReviewTurnsPage } from "@pi-desktop/shared";
import { api } from "../../lib/api";
@@ -68,7 +68,7 @@ export function ReviewHistoryPanel({ sessionId }: { sessionId: string }) {
finally { if (generation.current === version) setPaging(false); }
};
const selectedId = selection.turnId ?? (selection.snapshotId ? result.turnId ?? "" : "");
- const count = files.reduce((sum, file) => sum + file.entries.length, 0);
+ const count = files.length;
return <div className={`review-tab review-history${wrap ? "" : " is-nowrap"}`} aria-busy={loading}>
<ReviewHistoryToolbar history={history} onHistory={value => {
setHistory(value); setSelection(value && result.turnId ? { turnId: result.turnId } : {});
@@ -80,6 +80,9 @@ export function ReviewHistoryPanel({ sessionId }: { sessionId: string }) {
<span className="review-history-label">{t("panel.review.historyTitle")}</span>
<Select className="review-select review-history-round-select" value={selectedId || result.turnId || ""} aria-label={t("panel.review.historyTitle")}
onChange={event => { setSelection({ turnId: event.target.value }); scroller.current?.scrollTo({ top: 0 }); }}>
+ <Button variant="ghost" className="review-round-selected" tabIndex={-1}>
+ {createElement("selectedcontent")}
+ </Button>
{selectedId && !catalog.turns.some(turn => turn.id === selectedId) && <ReviewTurnOption turn={{ id: selectedId, createdAt: "" }} />}
{catalog.turns.map(turn => <ReviewTurnOption key={turn.id} turn={turn} />)}
</Select>
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
index 9af514772..ccda85d75 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
@@ -19,7 +19,7 @@ export function ReviewHistoryToolbar({ history, onHistory, count, additions, del
<option value="last">{t("panel.review.previousRound")}</option>
<option value="history">{t("panel.review.historyMode")}</option>
</Select>
- <span className="review-summary">{t("panel.review.changes", { count })}</span>
+ <span className="review-summary">{t("chat.toolChipFiles", { count })}</span>
<span className="diff-counts review-toolbar-counts" aria-label={t("chat.reviewChangeCounts", { additions, deletions })}>
<span className="diff-count-add">+{additions}</span><span className="diff-count-del">−{deletions}</span>
</span>
diff --git a/apps/desktop/src/lib/review-history.ts b/apps/desktop/src/lib/review-history.ts
index 67c601009..8f159d788 100644
--- a/apps/desktop/src/lib/review-history.ts
+++ b/apps/desktop/src/lib/review-history.ts
@@ -56,7 +56,7 @@ export function groupReviewFiles(rows: readonly ReviewHistoryChange[]): ReviewFi
group.entries.push({ message: row.message, change });
group.additions += change.additions; group.deletions += change.deletions;
}
- return [...groups.values()];
+ return [...groups.values()].filter(file => file.additions > 0 || file.deletions > 0);
}
export type ReviewReadRequest = { sessionId: string; turnId?: string; snapshotId?: string; offset?: number; limit?: number };
diff --git a/apps/desktop/src/styles/work-panel.css b/apps/desktop/src/styles/work-panel.css
index 15ef3571b..bc271b1b8 100644
--- a/apps/desktop/src/styles/work-panel.css
+++ b/apps/desktop/src/styles/work-panel.css
@@ -961,8 +961,8 @@
color: var(--ds-text-primary);
font-size: var(--text-xs-plus);
}
-.review-select option:first-child { border-start-start-radius: var(--radius-sm); border-start-end-radius: var(--radius-sm); }
-.review-select option:last-child { border-end-start-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
+.review-select option:first-of-type { border-start-start-radius: var(--radius-sm); border-start-end-radius: var(--radius-sm); }
+.review-select option:last-of-type { border-end-start-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.review-select option:hover,
.review-select option:focus-visible {
background: color-mix(in oklab, var(--ds-bg-sidebar) 92%, var(--ds-text-primary));
@@ -977,24 +977,30 @@
.review-history-label { flex: 0 0 auto; white-space: nowrap; color: var(--ds-text-muted); font-size: var(--text-xs-plus); }
.review-history-round-select { flex: 1; min-width: 0; padding: 3px 10px; }
.review-history-round-select option { display: flex; align-items: center; }
+.review-history-round-select .review-round-selected { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; padding: 0; min-height: 0; height: auto; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; }
+.review-round-selected selectedcontent { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.review-history-round-select option::checkmark { margin-inline-start: 0; }
.review-turn-time { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-turn-counts { display: inline-flex; flex: 0 0 auto; gap: 4px; margin-inline-start: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.review-turn-counts.is-unknown { color: var(--ds-text-muted); font-size: var(--text-2xs); }
-.review-history .review-scroll { overflow-y: auto; overflow-x: auto; scroll-padding-top: 36px; }
+.review-history .review-scroll { overflow-y: auto; overflow-x: auto; scrollbar-gutter: stable; scroll-padding-top: 36px; }
.review-history-file { position: relative; min-width: 0; scroll-margin-top: 4px; }
.review-history-file-heading { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 4px; background: var(--ds-bg-dock); }
.review-history-file-header {
display: flex; align-items: center;
- justify-content: flex-start; gap: 6px; flex: 1; min-width: 0;
+ justify-content: flex-start; gap: 12px; flex: 1; min-width: 0;
padding: 5px 6px; border: 0; border-radius: var(--radius-sm); background: transparent;
color: var(--ds-text-primary); text-align: left; font-size: var(--text-xs-plus);
}
-.review-file-disclosure { display: inline-flex; flex: 0 0 11px; }
+.review-file-label { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
+.review-file-disclosure { display: inline-flex; flex: 0 0 11px; visibility: hidden; color: var(--ds-text-muted); }
+.review-history-file-header:hover .review-file-disclosure,
+.review-history-file-header:focus-visible .review-file-disclosure { visibility: visible; }
+.review-history-file-header .diff-counts { min-width: 70px; justify-content: flex-end; }
.review-history-file.open .review-file-disclosure > svg { transform: rotate(90deg); }
.review-history-file-header > svg, .review-history-file-header .diff-counts { flex-shrink: 0; }
-.review-history-file-header .review-change-card-path { flex: 1; min-width: 0; }
-.review-history-file-body { margin: 2px 0 8px 6px; border-radius: var(--radius-sm); background: var(--ds-tile); }
+.review-history-file-header .review-change-card-path { flex: 0 1 auto; min-width: 0; }
+.review-history-file-body { margin: 2px 0 8px; border-radius: var(--radius-sm); background: var(--ds-tile); }
.review-history-record { min-width: 0; }
.review-history .review-change-card-body-content { overflow: visible; max-height: none; }
.review-line-number {
diff --git a/apps/desktop/test/review-history.test.mjs b/apps/desktop/test/review-history.test.mjs
index 15d226595..ed2b616c3 100644
--- a/apps/desktop/test/review-history.test.mjs
+++ b/apps/desktop/test/review-history.test.mjs
@@ -58,3 +58,34 @@ test("one inline gutter uses old numbers only for deletions, new numbers otherwi
const [hunk] = numberedReviewHunks([{ header: "@@ -8,2 +12,2 @@", lines: [{ type: "del", text: "old" }, { type: "add", text: "new" }, { type: "context", text: "same" }, { type: "context", text: "\\ No newline at end of file" }] }]);
assert.deepEqual(hunk.lines.map(reviewLineNumber), [8, 12, 13, null]);
});
+
+test("ten operation records across eight paths remain eight visible files", () => {
+ const rows = Array.from({length:8}, (_, i) => entry(String(i), `file-${i}.ts`, '/project'));
+ rows.push(entry('extra-one', 'file-0.ts', '/project'), entry('extra-two', 'file-1.ts', '/project'));
+ const files = groupReviewFiles(rows);
+ assert.equal(files.length, 8);
+ assert.equal(files.reduce((total, file) => total + file.entries.length, 0), 10);
+});
+
+test("zero-counter files are excluded while either positive counter keeps the file visible", () => {
+ const values = [[0, 0], [3, 0], [0, 4], [2, 5]];
+ const rows = values.map(([additions, deletions], i) => {
+ const row = entry(String(i), `file-${i}.ts`, '/project');
+ Object.assign(row.message.toolResult.details.review, { additions, deletions });
+ return row;
+ });
+ const files = groupReviewFiles(rows);
+ assert.deepEqual(files.map(file => file.path), ['file-1.ts', 'file-2.ts', 'file-3.ts']);
+ assert.deepEqual(groupReviewFiles([rows[0]]), []);
+ assert.equal(rows.length, 4);
+});
+
+test("zero-counter operations remain in a visible file's complete operation chain", () => {
+ const first = entry('zero', 'same.ts', '/project');
+ Object.assign(first.message.toolResult.details.review, { additions: 0, deletions: 0 });
+ const second = entry('positive', 'same.ts', '/project');
+ const files = groupReviewFiles([first, second]);
+ assert.equal(files.length, 1);
+ assert.deepEqual(files[0].entries.map(row => row.change.snapshotId), ['zero', 'positive']);
+ assert.deepEqual([files[0].additions, files[0].deletions], [1, 1]);
+});
diff --git a/apps/desktop/test/review-presentation.test.mjs b/apps/desktop/test/review-presentation.test.mjs
index c58b20ff2..4663bbbca 100644
--- a/apps/desktop/test/review-presentation.test.mjs
+++ b/apps/desktop/test/review-presentation.test.mjs
@@ -34,3 +34,12 @@ test("review and turn summaries share compact decorative file-type glyphs", asyn
assert.match(html, /width="14" height="14"/);
}
});
+
+test("toolbar names the visible file count rather than the operation count", async t => {
+ const ssr = await slotSsr(t);
+ const { ReviewHistoryToolbar } = await ssr.load('/src/components/workpanel/ReviewHistoryToolbar.tsx');
+ const html = ssr.render(createElement(ReviewHistoryToolbar, {history:false,onHistory:()=>{},count:8,additions:302,deletions:2,context:3,onContext:()=>{},wrap:true,onWrap:()=>{}}));
+ assert.match(html, /8 files/);
+ assert.doesNotMatch(html, /recorded changes/);
+ assert.match(html, /\+302/);
+});
diff --git a/crates/host-core/src/review/query.rs b/crates/host-core/src/review/query.rs
index bb4281366..d98a72ad4 100644
--- a/crates/host-core/src/review/query.rs
+++ b/crates/host-core/src/review/query.rs
@@ -280,14 +280,9 @@ fn collect(db: &Database, session_id: &str, workspace_root: Option<&Path>) -> Re
project(db, session_id, record, block, raw, workspace_root)?
{
if seen.insert(snapshot.clone()) {
- // Sum only deduplicated successful evidence. Original preview limits
- // mean unknown counts; transport-only hunk trimming does not.
+ // Match the file list: sum the saved counters once per snapshot.
+ // Preview availability is independent of these recorded values.
turns[turn].totals = turns[turn].totals.and_then(|(adds, dels)| {
- if raw.get("binary").and_then(Value::as_bool) == Some(true)
- || raw.get("truncated").and_then(Value::as_bool) == Some(true)
- {
- return None;
- }
let additions = adds.checked_add(raw.get("additions")?.as_u64()?)?;
let deletions = dels.checked_add(raw.get("deletions")?.as_u64()?)?;
(additions <= 9_007_199_254_740_991 && deletions <= 9_007_199_254_740_991)
diff --git a/crates/host-core/src/rpc/review_rpc_tests.rs b/crates/host-core/src/rpc/review_rpc_tests.rs
index c1e6031f2..02694ba3d 100644
--- a/crates/host-core/src/rpc/review_rpc_tests.rs
+++ b/crates/host-core/src/rpc/review_rpc_tests.rs
@@ -787,19 +787,72 @@ async fn review_rollbacks_wait_for_active_host_file_mutations() {
}
#[tokio::test]
-async fn review_turn_totals_do_not_invent_binary_or_truncated_line_counts() {
+async fn review_turn_totals_match_saved_counts_even_when_previews_are_unavailable() {
let f = Fixture::new().await;
for (id, binary, truncated) in [("binary-round", true, false), ("large-round", false, true)] {
- f.user(id, None).await;
+ f.user(&format!("{id}-user"), None).await;
let mut change = f.capture(f.root.path(), id, id);
change.binary = binary;
change.truncated = truncated;
+ change.additions = 53;
+ change.deletions = 34;
f.tool(id, json!(change), None, None).await;
}
let page = f.call("review.turns", json!({})).await;
+ assert_eq!(page["turns"].as_array().unwrap().len(), 2);
for turn in page["turns"].as_array().unwrap() {
assert_eq!(turn["changeCount"], 1);
- assert!(turn["additions"].is_null());
- assert!(turn["deletions"].is_null());
+ assert_eq!(turn["additions"], 53);
+ assert_eq!(turn["deletions"], 34);
}
}
+
+#[tokio::test]
+async fn review_turn_totals_reject_unsafe_sums_without_discarding_file_evidence() {
+ let f = Fixture::new().await;
+ f.user("unsafe-user", None).await;
+ for (id, additions) in [("safe-limit", 9_007_199_254_740_991_u64), ("overflow", 1)] {
+ let mut change = json!(f.capture(f.root.path(), id, id));
+ change["additions"] = json!(additions);
+ f.tool(id, change, None, None).await;
+ }
+ let page = f.call("review.turns", json!({})).await;
+ assert_eq!(page["turns"].as_array().unwrap().len(), 1);
+ assert_eq!(page["turns"][0]["changeCount"], 2);
+ assert!(page["turns"][0]["additions"].is_null());
+ assert!(page["turns"][0]["deletions"].is_null());
+ assert_eq!(
+ f.call("review.changes", json!({})).await["changes"]
+ .as_array()
+ .unwrap()
+ .len(),
+ 2
+ );
+}
+
+#[tokio::test]
+async fn review_turn_totals_do_not_accept_missing_or_invalid_counters() {
+ let f = Fixture::new().await;
+ f.user("invalid-counts-user", None).await;
+ for (id, value) in [
+ ("missing-count", None),
+ ("negative-count", Some(json!(-1))),
+ ("string-count", Some(json!("53"))),
+ ] {
+ let mut change = json!(f.capture(f.root.path(), id, id));
+ if let Some(value) = value {
+ change["additions"] = value;
+ } else {
+ change.as_object_mut().unwrap().remove("additions");
+ }
+ f.tool(id, change, None, None).await;
+ }
+ assert_eq!(
+ f.call("review.turns", json!({})).await,
+ json!({"turns": []})
+ );
+ assert_eq!(
+ f.call("review.changes", json!({})).await["changes"],
+ json!([])
+ );
+}
diff --git a/docs/public/screenshots/review-history/review-latest.png b/docs/public/screenshots/review-history/review-latest.png
index 776c51dd2..33076fc7d 100644
Binary files a/docs/public/screenshots/review-history/review-latest.png and b/docs/public/screenshots/review-history/review-latest.png differ
diff --git a/docs/public/screenshots/review-history/review-menu.png b/docs/public/screenshots/review-history/review-menu.png
index 4e242a182..e7f3adc3c 100644
Binary files a/docs/public/screenshots/review-history/review-menu.png and b/docs/public/screenshots/review-history/review-menu.png differ
diff --git a/docs/public/screenshots/review-history/review-narrow.png b/docs/public/screenshots/review-history/review-narrow.png
index 95ce10c8a..b86ba0f55 100644
Binary files a/docs/public/screenshots/review-history/review-narrow.png and b/docs/public/screenshots/review-history/review-narrow.png differ
diff --git a/docs/public/screenshots/review-history/review-normal.png b/docs/public/screenshots/review-history/review-normal.png
index c0c1a95c9..9548cf852 100644
Binary files a/docs/public/screenshots/review-history/review-normal.png and b/docs/public/screenshots/review-history/review-normal.png differ
diff --git a/docs/public/screenshots/review-history/review-overview.png b/docs/public/screenshots/review-history/review-overview.png
index 006e93281..ae7071b6f 100644
Binary files a/docs/public/screenshots/review-history/review-overview.png and b/docs/public/screenshots/review-history/review-overview.png differ
diff --git a/docs/spec/03-runtime/06-host-rpc-protocol.md b/docs/spec/03-runtime/06-host-rpc-protocol.md
index f01b1b614..575c9523b 100644
--- a/docs/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md
@@ -1540,8 +1540,9 @@ automatically replayed. See the Host file admission ADR for lifecycle and limits
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
+ diff. Saved valid counters remain available even when binary/truncated previews
+ are unavailable. Unsafe totals yield null for both counts; malformed evidence
+ remains filtered. Preview 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
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index fb4b56e06..8e1864551 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -4650,9 +4650,15 @@ 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.
+The toolbar counts visible distinct root/path file groups, not operation records.
+A file group appears only when its recorded additions or deletions are greater
+than zero. Groups with both counters zero are hidden, including preview-limited
+records, and excluded from the toolbar file count. This presentation filter does
+not delete native evidence or omit operations from a retained file group.
Expanded file content has no fixed-height inner viewport or vertical scrollbar.
-The outer Review scroll owns vertical travel; the current file header sticks
+The outer Review scroll reserves its vertical scrollbar gutter before overflow
+and 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
@@ -4662,9 +4668,15 @@ 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.
+and do not claim a net diff. Binary/truncated preview flags do not erase saved
+valid counters; absent or unsafe totals show unknown instead of invented zeros.
+The closed selector preserves the same left date/time and right green/red totals
+before its arrow. File headings have no permanent button fill or border; their
+file icon leads the row. A reserved disclosure slot immediately follows the
+visible filename, including an ellipsized name, before the right-aligned statistics.
+It appears on hover or keyboard focus, pointing right
+when closed and down when open, without moving content. Filename and statistics
+have a visible gap; 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).
@@ -4700,7 +4712,9 @@ 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
+and context use new coordinates; EOF markers have no number. Numbered Review
+rows omit the separate add/delete sign column but retain change backgrounds and
+summary signs; chat inline rows are unchanged. 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
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 7a0131836..5358fc155 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -19965,7 +19965,19 @@ Scenario: E2E-REVIEW-ROUNDS (local desktop, implemented)
normal/narrow layouts; copy and conflict protection survive; history restores.
Toggle checks trail labels, summary dots have no circle, history options contain
date/time plus true per-round recorded totals before the check and fit an
- arrow-safe field. Unknown/binary/oversized counts are not shown as zero.
+ arrow-safe field, including colored right-aligned totals when closed.
+ The summary counts visible files rather than operation records (five records
+ across four paths, including one zero-counter preview-limited file, show three
+ files). Only file groups with additions or deletions greater than zero remain;
+ both-zero groups are hidden and excluded from the summary, while raw Host
+ evidence and each retained file's complete operation chain remain available.
+ Missing/unsafe totals are not invented as zero;
+ Host regressions retain saved valid counters despite binary/truncated previews.
+ Expanding a long diff does not move header widths or statistics because the
+ outer scrollbar gutter is reserved. File icons lead; the reserved disclosure
+ immediately after the visible filename appears only on hover/focus, right when closed and down
+ when expanded, with a clear gap before statistics. Numbered diff rows have no
+ independent add/delete sign column.
File headers have no idle
fill, and no execution-root row appears. File menus disable internal open when
the plugin is absent, open its loaded view when available, and pass the resolved
diff --git a/scripts/e2e-review-history.mjs b/scripts/e2e-review-history.mjs
index 7cdee5621..660c95e91 100644
--- a/scripts/e2e-review-history.mjs
+++ b/scripts/e2e-review-history.mjs
@@ -43,6 +43,7 @@ ipcMain.handle('fixture:invoke',async(_event,channel,input)=>{if(channel===${JSO
ipcMain.handle('fixture:action',async(_event,name,input)=>{switch(name){
case 'seed':seed=await seedReviewHistory(host,__dirname);return {session:seed.session,other:seed.other,round:seed.round,latest:seed.latest,firstSnapshot:seed.firstSnapshot,late:seed.lateMessage};
case 'currentSeed':return {session:seed.session,firstSnapshot:seed.firstSnapshot};
+case 'hoverReviewFile': {win.showInactive();const rect=await win.webContents.executeJavaScript("document.querySelector("+JSON.stringify(input?'.review-history-file-header':'.fixture-label')+").getBoundingClientRect().toJSON()");win.webContents.debugger.attach('1.3');try{await win.webContents.debugger.sendCommand('Input.dispatchMouseEvent',{type:'mouseMoved',x:rect.x+rect.width/2,y:rect.y+rect.height/2});}finally{win.webContents.debugger.detach();}return;}
case 'late':return seed.appendLate();
case 'runningStart':runningTurn=await seed.startRunning();return;
case 'runningWrite':return seed.writeRunning(runningTurn);
diff --git a/scripts/e2e/review-history-fixture.mjs b/scripts/e2e/review-history-fixture.mjs
index b2a3cd29b..d996314ee 100644
--- a/scripts/e2e/review-history-fixture.mjs
+++ b/scripts/e2e/review-history-fixture.mjs
@@ -33,6 +33,8 @@ export async function seedReviewHistory(host, directory) {
await mutate(firstTurn, "child.md", "# Unified review\n\nDelegate output belongs to this conversation.\n", "review-task");
const outsidePath = join(directory, "outside", "review-open-tests-source.mjs");
await mutate(firstTurn, outsidePath, "export const outside = true;\n");
+ const zero = (await mutate(firstTurn, "zero-preview.txt", "x".repeat(600000))).toolResult.details.review;
+ if (!zero.truncated || zero.additions !== 0 || zero.deletions !== 0) throw new Error("Expected native preview-limited zero counters");
await end(firstTurn);
const second = await begin("round-two", "新增最近修改的测试文件");
await mutate(second, "latest.txt", "Latest modified round\n"); await end(second);
diff --git a/scripts/e2e/review-history.tsx b/scripts/e2e/review-history.tsx
index 65fe9b91d..2cbec5465 100644
--- a/scripts/e2e/review-history.tsx
+++ b/scripts/e2e/review-history.tsx
@@ -39,6 +39,13 @@ async function until(predicate: () => boolean | Promise<boolean>, reason: string
const action = (name: string, input?: unknown) => window.reviewFixture.action(name, input);
Object.defineProperty(navigator, "clipboard", { value: { writeText: (text: string) => action("copy", text) } });
const select = (label: string) => document.querySelector<HTMLSelectElement>(`select[aria-label="${label}"]`)!;
+function assertDisclosureFollowsFilename(header: HTMLElement) {
+ const path = header.querySelector<HTMLElement>('.review-change-card-path')!;
+ const text = document.createRange(); text.selectNodeContents(path);
+ const visibleTextRight = Math.min(path.getBoundingClientRect().right, text.getBoundingClientRect().right);
+ const gap = header.querySelector('.review-file-disclosure')!.getBoundingClientRect().left - visibleTextRight;
+ assert(gap >= 5 && gap <= 7, `Disclosure immediately follows the visible filename: gap=${gap}`);
+}
function checkSelectStyle(node: HTMLSelectElement) {
assert(node?.classList.contains('field-select'), 'Review restores the shared native Select');
assert(getComputedStyle(node).appearance === 'base-select', 'Native picker supports local styling');
@@ -193,7 +200,18 @@ window.reviewProbe = async () => {
}
checks.push('native-review-select-sidebar-colors-and-outer-only-corners');
await choose("对话轮次", seed.round); await ready();
- assert(headers().length === 3, "Workspace, delegated and approved outside changes share one file list");
+ const recorded = await api.workspaceReviewChanges({ sessionId: seed.session.id, turnId: seed.round });
+ assert(recorded.changes.length === 5, "Zero-counter native evidence stays available in the Host response");
+ assert(headers().length === 3, "Workspace, delegated and approved outside changes share one file list, excluding the zero-counter file");
+ assert(!headers().some(header => header.textContent?.includes("zero-preview.txt")), "Both-zero file is absent from Review");
+ assert(document.querySelector('.review-summary')?.textContent === '3 个文件', 'Five records across four paths must report only the three positive-counter files');
+ checks.push("zero-counter-file-hidden-without-losing-native-evidence");
+ const selected = document.querySelector<HTMLElement>('.review-round-selected selectedcontent')!;
+ await until(() => selected?.textContent?.includes('+7') === true, 'Native selectedcontent reflects the chosen round');
+ const time = selected.querySelector<HTMLElement>('.review-turn-time')!, counts = selected.querySelector<HTMLElement>('.review-turn-counts')!;
+ assert(counts.getBoundingClientRect().left > time.getBoundingClientRect().right + 8, 'Closed selection keeps a gap before right-aligned counts');
+ assert(getComputedStyle(counts.querySelector('.diff-count-add')!).color !== getComputedStyle(counts.querySelector('.diff-count-del')!).color, 'Closed selection preserves add/delete colors');
+ assert(selected.getBoundingClientRect().right <= select('对话轮次').getBoundingClientRect().right - 12, 'Closed selected counts reserve the caret lane');
assert(headers()[2].querySelector('.review-change-card-path')?.textContent === '.../review-open-tests-source.mjs', "Real outside Write shows only basename with three-dot prefix");
assert(getComputedStyle(headers()[2].querySelector('.review-change-card-path')!).direction === 'ltr', "Outside prefix must stay before the filename visually");
assert(headers()[2].title.includes('outside') && !headers()[2].title.includes('/workspace/'), "Outside title retains actual path, without prepending workspace");
@@ -212,15 +230,32 @@ window.reviewProbe = async () => {
headers()[2].click(); await frame();
checks.push('real-approved-outside-write-capture-display-and-safe-rollback');
assert(headers()[0].textContent?.includes("long.ts"), "Files preserve original order");
+ const closedWidth = headers()[0].getBoundingClientRect().width;
+ const closedCountRight = headers()[0].querySelector('.diff-counts')!.getBoundingClientRect().right;
+ assert(getComputedStyle(scroller()).scrollbarGutter === 'stable', 'Scroller reserves its gutter before overflow');
+ assert(headers()[0].firstElementChild?.classList.contains('review-file-type'), 'File icon occupies the former left-disclosure space');
+ headers().forEach(assertDisclosureFollowsFilename);
+ await action('hoverReviewFile', true);
+ await until(() => getComputedStyle(headers()[0].querySelector('.review-file-disclosure')!).visibility === 'visible', 'Closed file reveals its right-facing disclosure on hover');
+ assert(getComputedStyle(headers()[0].querySelector('.review-file-disclosure svg')!).transform === 'none', 'Closed disclosure faces right');
headers()[0].click();
await until(() => document.querySelectorAll(".review-history-record").length === 2, "All same-file change records expand together");
assert(document.querySelectorAll('.review-history-file-body .review-change-card-actions').length === 1, "One action bar per file");
assert(document.querySelectorAll('.review-change-copy').length === 1 && document.querySelectorAll('.review-change-rollback').length === 1, "Exactly one copy and rollback for all operations");
assert(!document.querySelector('.review-history-file-body')!.textContent?.includes('修改记录'), "No per-operation title");
+ assert(Math.abs(headers()[0].getBoundingClientRect().width - closedWidth) < 1, 'Expanding an overflowing diff cannot shrink file rows');
+ assert(Math.abs(headers()[0].querySelector('.diff-counts')!.getBoundingClientRect().right - closedCountRight) < 1, 'Statistics stay fixed when the vertical scrollbar appears');
+ assert(getComputedStyle(headers()[0].querySelector('.review-file-disclosure svg')!).transform !== 'none', 'Expanded disclosure faces down');
+ const labelRight = headers()[0].querySelector('.review-file-label')!.getBoundingClientRect().right;
+ assert(headers()[0].querySelector('.diff-counts')!.getBoundingClientRect().left - labelRight >= 11, 'Filename lane has a clear gap before statistics');
+ await action('hoverReviewFile', false);
+ await until(() => getComputedStyle(headers()[0].querySelector('.review-file-disclosure')!).visibility === 'hidden', 'Non-hovered disclosure disappears without consuming new space');
+ checks.push('file-count-closed-select-layout-and-reserved-scrollbar');
checks.push('one-file-one-copy-and-rollback-no-record-titles');
assert(!document.querySelector(".review-history-root"), "No extra execution-root row in the diff");
for (const row of document.querySelectorAll('.review-change-diff .diff-line:not(.hunk)')) {
assert(row.querySelectorAll('.review-line-number').length === 1, 'Inline diff has exactly one line-number gutter');
+ assert(!row.querySelector('.diff-line-sign'), 'Inline gutter has no redundant add/delete sign column');
const gutter = row.querySelector('.review-line-number')!;
assert(gutter.getAttribute('data-side') === (row.classList.contains('del') ? 'old' : 'new'), 'Single gutter preserves the correct source coordinate');
}
@@ -243,6 +278,7 @@ window.reviewProbe = async () => {
await action("screenshot", "review-normal.png");
await action("resize", 420); await frame(); await frame();
assert(scroller().getBoundingClientRect().width <= 420, "Narrow viewport applied");
+ headers().forEach(assertDisclosureFollowsFilename);
assert(headers()[0].getBoundingClientRect().right <= window.innerWidth + 1, "Narrow header fits");
assert(Math.abs(headers()[0].getBoundingClientRect().top - scroller().getBoundingClientRect().top - parseFloat(getComputedStyle(scroller()).paddingTop)) <= 2, "Narrow sticky header is visible");
await fileMenu();