Skip to content

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

feat(review): show recorded turn totals and refine file reading

new-Beginnerd27c0b45c87b
diff --git a/apps/desktop/src/components/ContextMenu.tsx b/apps/desktop/src/components/ContextMenu.tsx
index d2761d81b..d1c77d790 100644
--- a/apps/desktop/src/components/ContextMenu.tsx
+++ b/apps/desktop/src/components/ContextMenu.tsx
@@ -32,6 +32,8 @@ import { portalToBody } from "../lib/portal-visibility";
import { IconCheck, IconChevronRight } from "./icons";
import {
placeContextMenu,
+ placeControlContextMenu,
+ type ContextMenuAnchor,
type ContextMenuPlacement,
type ContextMenuPoint,
} from "../lib/context-menu";
@@ -67,12 +69,15 @@ export type ContextMenuRequest = {
*/
label?: string;
density?: "compact";
+ /** Opt-in ellipsis/action button alignment; right-click menus remain pointer-based. */
+ anchor?: "bottom-end";
items: ContextMenuItem[];
};
export type ContextMenuState = ContextMenuRequest & {
/** Where the pointer asked for the surface. */
point: ContextMenuPoint;
+ anchorRect?: ContextMenuAnchor;
/** Live selection at open time; empty when the caret was collapsed. */
selection: string;
};
@@ -183,7 +188,9 @@ export function useContextMenu() {
target, is stored as empty so Copy still falls back.
*/
const selection = snapshotSelection(event.currentTarget);
- setState({ ...request, point: pointForEvent(event), selection });
+ const rect = request.anchor ? event.currentTarget.getBoundingClientRect() : undefined;
+ const anchorRect = rect ? { left: rect.left, right: rect.right, top: rect.top, bottom: rect.bottom } : undefined;
+ setState({ ...request, point: pointForEvent(event), anchorRect, selection });
},
[],
);
@@ -215,11 +222,11 @@ export function ContextMenu({
const menu = menuRef.current;
if (!menu) return;
const rect = menu.getBoundingClientRect();
- const next = placeContextMenu(
- request.point,
- { width: rect.width, height: rect.height },
- { width: window.innerWidth, height: window.innerHeight },
- );
+ const surface = { width: rect.width, height: rect.height };
+ const viewport = { width: window.innerWidth, height: window.innerHeight };
+ const next = request.anchorRect
+ ? placeControlContextMenu(request.anchorRect, surface, viewport)
+ : placeContextMenu(request.point, surface, viewport);
setPlacement((previous) =>
previous && previous.top === next.top && previous.left === next.left
? previous
diff --git a/apps/desktop/src/components/ReviewChangeCard.tsx b/apps/desktop/src/components/ReviewChangeCard.tsx
index f4a501741..05ee4d200 100644
--- a/apps/desktop/src/components/ReviewChangeCard.tsx
+++ b/apps/desktop/src/components/ReviewChangeCard.tsx
@@ -9,7 +9,7 @@ import type {
ReviewContextResult,
} from "@pi-desktop/shared";
import { api } from "../lib/api";
-import { numberedReviewHunks, reviewFilePathLabel } from "../lib/review-history";
+import { numberedReviewHunks, reviewFilePathLabel, reviewLineNumber } from "../lib/review-history";
import { reviewChangeFromMessage } from "../lib/workspace-review";
import { useAppStore } from "../stores/app-store";
import { useCopy } from "./Markdown";
@@ -95,10 +95,10 @@ export function ReviewChangeDetails({ message, compact = false, contextLines = 3
</div>
{hunk.lines.map((line, lineIndex) => (
<div className={cx("diff-line", line.type)} key={lineIndex}>
- {numbered && <>
- <span className="review-line-number" data-side="old" aria-label={line.oldLine === null ? undefined : t("panel.review.oldLine", { line: line.oldLine })}>{line.oldLine}</span>
- <span className="review-line-number" data-side="new" aria-label={line.newLine === null ? undefined : t("panel.review.newLine", { line: line.newLine })}>{line.newLine}</span>
- </>}
+ {numbered && <span className="review-line-number" data-side={line.type === "del" ? "old" : "new"}
+ 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>
{line.type === "add" ? "+" : line.type === "del" ? "−" : " "}
</span>
diff --git a/apps/desktop/src/components/ReviewFileIcon.tsx b/apps/desktop/src/components/ReviewFileIcon.tsx
new file mode 100644
index 000000000..e369ea0b8
--- /dev/null
+++ b/apps/desktop/src/components/ReviewFileIcon.tsx
@@ -0,0 +1,17 @@
+/** Small file-type glyphs shared by review headings and turn summaries. */
+export function ReviewFileIcon({ path }: { path: string }) {
+ const extension = path.split(/[\\/]/).pop()?.split(".").pop()?.toLowerCase() ?? "";
+ const kind = /^(md|mdx|markdown)$/.test(extension) ? "markdown"
+ : /^(json|jsonc|json5)$/.test(extension) ? "json"
+ : /^(py|pyw)$/.test(extension) ? "python"
+ : /^(ts|tsx|js|jsx|mjs|cjs|html|css|scss|less|vue|svelte|rs|go|java|c|h|cpp|sh|ps1|toml|yaml|yml)$/.test(extension) ? "code" : "document";
+ return <span className={`review-file-type is-${kind}`} aria-hidden="true">
+ <svg viewBox="0 0 20 20" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" strokeLinejoin="round">
+ {kind === "markdown" ? <path d="M2 13V7l3 3 3-3v6M11 9v5m-2-2 2 2 2-2" strokeWidth="1.8" />
+ : kind === "json" ? <path d="M7 3H5.5C4 3 4 4.5 4 6v1c0 2-2 2-2 3s2 1 2 3v1c0 1.5 0 3 1.5 3H7m6-14h1.5C16 3 16 4.5 16 6v1c0 2 2 2 2 3s-2 1-2 3v1c0 1.5 0 3-1.5 3H13" />
+ : kind === "python" ? <><path d="M10 2c-4 0-4 1-4 4h5v1H4c-3 0-3 7 0 7h2v-3c0-2 1-3 3-3h4c2 0 3-1 3-3V4c0-2-2-2-6-2Z" fill="currentColor" stroke="none" /><path d="M10 18c4 0 4-1 4-4H9v-1h7c3 0 3-7 0-7h-1v3c0 2-1 3-3 3H8c-2 0-3 1-3 3v1c0 2 2 2 5 2Z" fill="currentColor" opacity=".65" stroke="none" /></>
+ : kind === "code" ? <path d="m6 6-4 4 4 4m8-8 4 4-4 4m-3-9-2 10" />
+ : <path d="M12 2.5v4h4M5 2.5h7l4 4V17H5zM7.5 10h6m-6 2.5h6m-6 2.5h4" />}
+ </svg>
+ </span>;
+}
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
index 45939d79a..24c676d15 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryFile.tsx
@@ -7,6 +7,7 @@ import { Button, TooltipButton, cx } from "../ui";
import { ContextMenu, useContextMenu } from "../ContextMenu";
import { useReviewFileOpen } from "../../hooks/use-review-file-open";
import { IconChevronRight, IconMore } from "../icons";
+import { ReviewFileIcon } from "../ReviewFileIcon";
import { ReviewFileActions } from "./ReviewFileActions";
export function ReviewHistoryFile({ file, sessionId, context, focusSeq, focusSnapshots, expandFocus, disabled, onChanged }: {
@@ -25,10 +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)}>
- <IconChevronRight size={11} /><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><ReviewFileIcon path={file.path} /><span className="review-change-card-path" data-outside-path={reviewFilePathLabel(file.path) !== file.path || undefined}>{reviewFilePathLabel(file.path)}</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"), density: "compact", items: [
+ <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: [
...(!outside ? [{ id: "review-open-internal", label: t("panel.review.openInternal"), disabled: !canOpenInternal, onSelect: () => void openFile("internal") }] : []),
{ id: "review-open-external", label: t("panel.review.openExternal"), disabled: !canOpenFile, onSelect: () => void openFile("external") },
{ id: "review-open-folder", label: t("panel.review.openFolder"), disabled: !canOpenFile, onSelect: () => void openFile("folder") },
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
index 0bc62dd84..831f166ee 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryPanel.tsx
@@ -8,6 +8,7 @@ import { readReviewContextLines, rememberReviewContextLines } from "../../lib/re
import { useAppStore } from "../../stores/app-store";
import { Button, Select } from "../ui";
import { ReviewHistoryFile } from "./ReviewHistoryFile";
+import { ReviewTurnOption } from "./ReviewTurnOption";
import { ReviewHistoryToolbar } from "./ReviewHistoryToolbar";
type Selection = { turnId?: string; snapshotId?: string; focusSeq?: number };
@@ -79,8 +80,8 @@ 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 }); }}>
- {selectedId && !catalog.turns.some(turn => turn.id === selectedId) && <option value={selectedId}>{selectedId}</option>}
- {catalog.turns.map(turn => <option key={turn.id} value={turn.id}>{new Date(turn.createdAt).toLocaleString()}</option>)}
+ {selectedId && !catalog.turns.some(turn => turn.id === selectedId) && <ReviewTurnOption turn={{ id: selectedId, createdAt: "" }} />}
+ {catalog.turns.map(turn => <ReviewTurnOption key={turn.id} turn={turn} />)}
</Select>
{catalog.nextBefore !== undefined && <Button size="sm" disabled={paging} onClick={() => void older()}>{t("panel.review.moreHistory")}</Button>}
</div>}
diff --git a/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx b/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
index d33708491..9af514772 100644
--- a/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
+++ b/apps/desktop/src/components/workpanel/ReviewHistoryToolbar.tsx
@@ -24,7 +24,7 @@ export function ReviewHistoryToolbar({ history, onHistory, count, additions, del
<span className="diff-count-add">+{additions}</span><span className="diff-count-del">−{deletions}</span>
</span>
<TooltipButton className="icon-btn review-settings-button" tooltip={t("panel.review.reviewSettings")} aria-haspopup="menu" aria-expanded={!!settingsMenu.contextMenu} onClick={event => {
- settingsMenu.openContextMenu(event, { label: t("panel.review.reviewSettings"), items: [
+ settingsMenu.openContextMenu(event, { label: t("panel.review.reviewSettings"), anchor: "bottom-end", items: [
{ id: "review-wrap", label: t("panel.review.wordWrap"), checked: wrap, onSelect: onWrap },
{ id: "review-context", label: t("panel.review.contextDisplay"), submenu: ([1, 3, 5] as const).map(lines => ({
id: `review-context-${lines}`, label: t("panel.review.contextLineOption", { count: lines }), checked: context === lines, onSelect: () => onContext(lines),
diff --git a/apps/desktop/src/components/workpanel/ReviewTurnOption.tsx b/apps/desktop/src/components/workpanel/ReviewTurnOption.tsx
new file mode 100644
index 000000000..05f3f694a
--- /dev/null
+++ b/apps/desktop/src/components/workpanel/ReviewTurnOption.tsx
@@ -0,0 +1,17 @@
+import type { ReviewTurn } from "@pi-desktop/shared";
+import { useTranslation } from "react-i18next";
+
+/** Only Host-recorded totals are displayed; missing/unsafe values stay unknown. */
+export function ReviewTurnOption({ turn }: { turn: Pick<ReviewTurn, "id" | "createdAt" | "additions" | "deletions"> }) {
+ const { t } = useTranslation();
+ const { additions, deletions } = turn;
+ const known = typeof additions === "number" && Number.isSafeInteger(additions) && additions >= 0
+ && typeof deletions === "number" && Number.isSafeInteger(deletions) && deletions >= 0;
+ const date = turn.createdAt ? new Date(turn.createdAt).toLocaleString() : turn.id;
+ return <option value={turn.id} title={t("panel.review.recordedTotals")}>
+ <span className="review-turn-time">{date}</span>{" "}
+ {known ? <span className="review-turn-counts" aria-label={t("chat.reviewChangeCounts", { additions, deletions })}>
+ <span className="diff-count-add">+{additions}</span>{" "}<span className="diff-count-del">−{deletions}</span>
+ </span> : <span className="review-turn-counts is-unknown">{t("panel.review.unknownTotals")}</span>}
+ </option>;
+}
diff --git a/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx b/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx
index bab52c7be..b2128922c 100644
--- a/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx
+++ b/apps/desktop/src/features/chat/transcript/TurnChangesCard.tsx
@@ -1,8 +1,9 @@
import { memo, useId, useMemo } from "react";
import { useTranslation } from "react-i18next";
-import type { ReviewChangeStatus, UiMessage } from "@pi-desktop/shared";
+import type { UiMessage } from "@pi-desktop/shared";
import { IconChevronDown, IconChevronRight } from "../../../components/icons";
import { Button, cx } from "../../../components/ui";
+import { ReviewFileIcon } from "../../../components/ReviewFileIcon";
import { reviewFilePathLabel } from "../../../lib/review-history";
import { requestReviewFocus } from "../../../lib/review-focus-request";
import {
@@ -17,14 +18,6 @@ import { useAppStore } from "../../../stores/app-store";
import { disclosureKey, useAutomaticDisclosure } from "./disclosure";
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>
@@ -120,9 +113,7 @@ export const TurnChangesCard = memo(function TurnChangesCard({
title={label}
onClick={() => openReview(file.snapshotIds, true)}
>
- <span className="turn-changes-mark" aria-hidden>
- {STATUS_MARKS[file.status]}
- </span>
+ <ReviewFileIcon path={file.path} />
<span className="turn-changes-path" data-outside-path={reviewFilePathLabel(file.path) !== file.path || undefined}>{reviewFilePathLabel(file.path)}</span>
<Counts additions={file.additions} deletions={file.deletions} />
</button>
diff --git a/apps/desktop/src/lib/context-menu.ts b/apps/desktop/src/lib/context-menu.ts
index 44feb9d98..aa9b6d941 100644
--- a/apps/desktop/src/lib/context-menu.ts
+++ b/apps/desktop/src/lib/context-menu.ts
@@ -14,6 +14,7 @@
/** Keeps a floating surface off the window edge it would otherwise touch. */
export const CONTEXT_MENU_MARGIN = 8;
+export type ContextMenuAnchor = { left: number; right: number; top: number; bottom: number };
export type ContextMenuPoint = { x: number; y: number };
export type ContextMenuSize = { width: number; height: number };
export type ContextMenuPlacement = { top: number; left: number };
@@ -42,3 +43,17 @@ export function placeContextMenu(
top: Math.round(clamp(point.y, margin, maxTop)),
};
}
+
+/** Opt-in control menus are independent of where inside the button was clicked. */
+export function placeControlContextMenu(
+ anchor: ContextMenuAnchor,
+ surface: ContextMenuSize,
+ viewport: ContextMenuSize,
+): ContextMenuPlacement {
+ const gap = 4;
+ const below = viewport.height - CONTEXT_MENU_MARGIN - anchor.bottom - gap;
+ const above = anchor.top - gap - CONTEXT_MENU_MARGIN;
+ const top = surface.height > below && above > below
+ ? anchor.top - gap - surface.height : anchor.bottom + gap;
+ return placeContextMenu({ x: anchor.right - surface.width, y: top }, surface, viewport);
+}
diff --git a/apps/desktop/src/lib/review-history.ts b/apps/desktop/src/lib/review-history.ts
index 82f03d12f..67c601009 100644
--- a/apps/desktop/src/lib/review-history.ts
+++ b/apps/desktop/src/lib/review-history.ts
@@ -15,6 +15,11 @@ export function numberedReviewHunks(hunks: readonly DiffHunk[]): { header: strin
});
}
+/** One unified gutter: removed lines use old coordinates; others use new. */
+export function reviewLineNumber(line: NumberedReviewLine): number | null {
+ return line.type === "del" ? line.oldLine : line.newLine;
+}
+
export type ReviewFileGroup = {
id: string; path: string; root?: string; entries: ReviewChangeEntry[];
additions: number; deletions: number;
diff --git a/apps/desktop/src/styles/messages.css b/apps/desktop/src/styles/messages.css
index e8a37f727..92af1bd04 100644
--- a/apps/desktop/src/styles/messages.css
+++ b/apps/desktop/src/styles/messages.css
@@ -3907,3 +3907,11 @@
opacity: 0.7;
}
}
+
+/* File-type identity is shared by native Review and the transcript summary. */
+.review-file-type { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 14px; width: 14px; height: 14px; color: var(--ds-text-muted); }
+.review-file-type > svg { display: block; width: 14px; height: 14px; }
+.review-file-type.is-markdown { color: var(--ds-success); }
+.review-file-type.is-json { color: var(--ds-warning); }
+.review-file-type.is-code, .review-file-type.is-python { color: var(--ds-text-secondary); }
+.turn-changes-row[data-rolled-back] .review-file-type { color: var(--ds-text-faint); }
diff --git a/apps/desktop/src/styles/turn-changes.css b/apps/desktop/src/styles/turn-changes.css
index 3adc46670..4d7033423 100644
--- a/apps/desktop/src/styles/turn-changes.css
+++ b/apps/desktop/src/styles/turn-changes.css
@@ -86,24 +86,6 @@
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;
@@ -119,10 +101,6 @@
}
/* 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;
diff --git a/apps/desktop/src/styles/work-panel.css b/apps/desktop/src/styles/work-panel.css
index a9faebc6e..15ef3571b 100644
--- a/apps/desktop/src/styles/work-panel.css
+++ b/apps/desktop/src/styles/work-panel.css
@@ -976,6 +976,11 @@
.review-history-selector { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; padding: 4px 10px 10px; }
.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 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-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); }
@@ -985,7 +990,8 @@
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-history-file.open > .review-history-file-heading > .review-history-file-header > svg { transform: rotate(90deg); }
+.review-file-disclosure { display: inline-flex; flex: 0 0 11px; }
+.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); }
diff --git a/apps/desktop/test/chat-context-menu.test.mjs b/apps/desktop/test/chat-context-menu.test.mjs
index 6d3fa36e7..31cfb16eb 100644
--- a/apps/desktop/test/chat-context-menu.test.mjs
+++ b/apps/desktop/test/chat-context-menu.test.mjs
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { placeContextMenu } from "../src/lib/context-menu.ts";
+import { placeControlContextMenu, placeContextMenu } from "../src/lib/context-menu.ts";
import { conversationPlainText, copySelectionOrFallback } from "../src/lib/chat-transcript-text.ts";
test("a menu that fits the viewport stays at the pointer", () => {
@@ -53,3 +53,11 @@ test("copy prefers a live selection over the whole turn", () => {
assert.equal(copySelectionOrFallback("", "whole message"), "whole message");
assert.equal(copySelectionOrFallback(undefined, "whole message"), "whole message");
});
+
+test("control menus align to the button right/bottom, not the click point", () => {
+ assert.deepEqual(placeControlContextMenu({ left: 700, right: 724, top: 40, bottom: 64 }, { width: 160, height: 120 }, { width: 800, height: 600 }), { left: 564, top: 68 });
+});
+test("control menus flip upward at the bottom and stay reachable in tiny viewports", () => {
+ assert.deepEqual(placeControlContextMenu({ left: 770, right: 794, top: 560, bottom: 584 }, { width: 160, height: 120 }, { width: 800, height: 600 }), { left: 632, top: 436 });
+ assert.deepEqual(placeControlContextMenu({ left: 10, right: 34, top: 30, bottom: 54 }, { width: 160, height: 120 }, { width: 100, height: 80 }), { left: 8, top: 8 });
+});
diff --git a/apps/desktop/test/review-history.test.mjs b/apps/desktop/test/review-history.test.mjs
index d8178a1c3..15d226595 100644
--- a/apps/desktop/test/review-history.test.mjs
+++ b/apps/desktop/test/review-history.test.mjs
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
-import { numberedReviewHunks, groupReviewFiles, readReviewPages, reviewFilePathLabel } from "../src/lib/review-history.ts";
+import { reviewLineNumber, numberedReviewHunks, groupReviewFiles, readReviewPages, reviewFilePathLabel } from "../src/lib/review-history.ts";
function entry(id, path = "a.ts", root) {
return { root, message: { id, role: "tool", content: "", createdAt: "2026-10-30", toolName: "Edit", toolStatus: "success", toolResult: { details: { root: "workspace", review: { version: 1, snapshotId: id, messageId: id, path, operation: "edit", status: "modified", state: "active", additions: 1, deletions: 1, hunks: [], reversible: true } } } } };
@@ -53,3 +53,8 @@ test("outside-workspace path labels keep only three dots, slash and basename", (
assert.equal(reviewFilePathLabel("src/local.ts"), "src/local.ts");
assert.equal(reviewFilePathLabel("src/../local.ts"), "src/../local.ts");
});
+
+test("one inline gutter uses old numbers only for deletions, new numbers otherwise", () => {
+ 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]);
+});
diff --git a/apps/desktop/test/review-presentation.test.mjs b/apps/desktop/test/review-presentation.test.mjs
new file mode 100644
index 000000000..c58b20ff2
--- /dev/null
+++ b/apps/desktop/test/review-presentation.test.mjs
@@ -0,0 +1,36 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { createElement } from "react";
+import { slotSsr } from "./helpers/slot-ssr.mjs";
+
+test("history option totals retain recorded values, including real zero counts", async t => {
+ const ssr = await slotSsr(t);
+ const { ReviewTurnOption } = await ssr.load("/src/components/workpanel/ReviewTurnOption.tsx");
+ const html = ssr.render(createElement(ReviewTurnOption, { turn: { id: "u1", createdAt: "2026-10-31T00:00:00Z", additions: 10, deletions: 0 } }));
+ assert.match(html, /review-turn-time/);
+ assert.match(html, /diff-count-add">\+10/);
+ assert.match(html, /diff-count-del">−0/);
+ assert.ok(html.indexOf('review-turn-time') < html.indexOf('review-turn-counts'));
+});
+
+test("missing, unsafe or partial totals stay unknown rather than becoming fictional zeros", async t => {
+ const ssr = await slotSsr(t);
+ const { ReviewTurnOption } = await ssr.load("/src/components/workpanel/ReviewTurnOption.tsx");
+ for (const totals of [{}, { additions: null, deletions: null }, { additions: 1 }, { additions: -1, deletions: 0 }, { additions: 0.5, deletions: 0 }, { additions: Number.MAX_SAFE_INTEGER + 1, deletions: 0 }]) {
+ const html = ssr.render(createElement(ReviewTurnOption, { turn: { id: "u", createdAt: "", ...totals } }));
+ assert.match(html, /review-turn-counts is-unknown/);
+ assert.match(html, /Line counts unknown/);
+ assert.doesNotMatch(html, /diff-count-add|diff-count-del/);
+ }
+});
+
+test("review and turn summaries share compact decorative file-type glyphs", async t => {
+ const ssr = await slotSsr(t);
+ const { ReviewFileIcon } = await ssr.load("/src/components/ReviewFileIcon.tsx");
+ for (const [path, kind] of [["docs/a.md", "markdown"], ["D:\\x\\data.JSON", "json"], ["a.py", "python"], ["src/review.rs", "code"], ["README", "document"]]) {
+ const html = ssr.render(createElement(ReviewFileIcon, { path }));
+ assert.match(html, new RegExp(`review-file-type is-${kind}`));
+ assert.match(html, /aria-hidden="true"/);
+ assert.match(html, /width="14" height="14"/);
+ }
+});
diff --git a/crates/host-core/src/review/query.rs b/crates/host-core/src/review/query.rs
index 4117f195d..bb4281366 100644
--- a/crates/host-core/src/review/query.rs
+++ b/crates/host-core/src/review/query.rs
@@ -53,6 +53,7 @@ struct Turn {
title: String,
changes: Vec<Value>,
snapshots: HashSet<String>,
+ totals: Option<(u64, u64)>,
}
fn field<'a>(value: &'a Value, name: &str) -> Option<&'a str> {
@@ -237,6 +238,7 @@ fn collect(db: &Database, session_id: &str, workspace_root: Option<&Path>) -> Re
title,
changes: Vec::new(),
snapshots: HashSet::new(),
+ totals: Some((0, 0)),
});
if let Some(turn) = indexed.get(&record.id) {
turn_users.entry(turn.clone()).or_insert(turns.len() - 1);
@@ -278,6 +280,19 @@ 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.
+ 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)
+ .then_some((additions, deletions))
+ });
turns[turn].snapshots.insert(snapshot);
turns[turn].changes.push(projected);
}
@@ -325,7 +340,9 @@ pub(crate) fn execute(
.map(|turn| {
json!({
"id": turn.id, "userMessageId": turn.id, "createdAt": turn.created_at,
- "title": turn.title, "changeCount": turn.changes.len()
+ "title": turn.title, "changeCount": turn.changes.len(),
+ "additions": turn.totals.map(|totals| totals.0),
+ "deletions": turn.totals.map(|totals| totals.1)
})
})
.collect();
diff --git a/crates/host-core/src/rpc/review_rpc_tests.rs b/crates/host-core/src/rpc/review_rpc_tests.rs
index d633a056b..c1e6031f2 100644
--- a/crates/host-core/src/rpc/review_rpc_tests.rs
+++ b/crates/host-core/src/rpc/review_rpc_tests.rs
@@ -146,6 +146,16 @@ async fn review_rpc_latest_turn_late_delegate_dedup_roots_and_restart() {
.await;
assert_eq!(older["turns"][0]["id"], "u1");
assert_eq!(older["turns"][0]["changeCount"], 3);
+ assert_eq!(page["turns"][0]["additions"], second.additions);
+ assert_eq!(page["turns"][0]["deletions"], second.deletions);
+ assert_eq!(
+ older["turns"][0]["additions"],
+ first.additions + late.additions + old.additions
+ );
+ assert_eq!(
+ older["turns"][0]["deletions"],
+ first.deletions + late.deletions + old.deletions
+ );
assert!(older.get("nextBefore").is_none());
let changes = f
.call("review.changes", json!({"snapshotId":late.snapshot_id}))
@@ -282,6 +292,9 @@ async fn review_rpc_filters_invalid_evidence_and_marks_oversized_hunks() {
true
);
assert!(serde_json::to_vec(&result).unwrap().len() < 32 * 1024);
+ let catalog = f.call("review.turns", json!({})).await;
+ assert_eq!(catalog["turns"][0]["additions"], review.additions);
+ assert_eq!(catalog["turns"][0]["deletions"], review.deletions);
let orphan = f.capture(f.root.path(), "orphan", "orphan result\n");
f.tool("orphan", json!(orphan), Some("missing-legacy-task"), None)
.await;
@@ -772,3 +785,21 @@ async fn review_rollbacks_wait_for_active_host_file_mutations() {
assert_eq!(budget.snapshot().queued, 0);
}
}
+
+#[tokio::test]
+async fn review_turn_totals_do_not_invent_binary_or_truncated_line_counts() {
+ let f = Fixture::new().await;
+ for (id, binary, truncated) in [("binary-round", true, false), ("large-round", false, true)] {
+ f.user(id, None).await;
+ let mut change = f.capture(f.root.path(), id, id);
+ change.binary = binary;
+ change.truncated = truncated;
+ f.tool(id, json!(change), None, None).await;
+ }
+ let page = f.call("review.turns", json!({})).await;
+ for turn in page["turns"].as_array().unwrap() {
+ assert_eq!(turn["changeCount"], 1);
+ assert!(turn["additions"].is_null());
+ assert!(turn["deletions"].is_null());
+ }
+}
diff --git a/docs/adr/0338-explicit-reviewed-file-actions.md b/docs/adr/0338-explicit-reviewed-file-actions.md
index 3e71617da..8789882c7 100644
--- a/docs/adr/0338-explicit-reviewed-file-actions.md
+++ b/docs/adr/0338-explicit-reviewed-file-actions.md
@@ -39,7 +39,10 @@ reuse the shared native Select with review-only customizable-picker styles.
Selected fills follow the sidebar color, and only the list's outer top/bottom
option corners are rounded. The scope trigger is 24px high and the round field
28px; both vertically center their text and arrow. Shared primitives, Command
-shell and other selectors keep their defaults.
+shell and other selectors keep their defaults. History options now include
+Host-recorded operation totals before the check (unknown when unavailable),
+without claiming a net diff. Review action menus opt into trigger-relative
+right/bottom placement; pointer-based context menus remain unchanged.
## Consequences
diff --git a/docs/public/screenshots/review-history/review-latest.png b/docs/public/screenshots/review-history/review-latest.png
index 5c6077282..776c51dd2 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-narrow.png b/docs/public/screenshots/review-history/review-narrow.png
index aed8c7c16..95ce10c8a 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 96ee6243d..c0c1a95c9 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 808e2c775..006e93281 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/public/screenshots/review-history/review-updated-file-menu.png b/docs/public/screenshots/review-history/review-updated-file-menu.png
new file mode 100644
index 000000000..cce565f97
Binary files /dev/null and b/docs/public/screenshots/review-history/review-updated-file-menu.png differ
diff --git a/docs/public/screenshots/review-history/review-updated-history.png b/docs/public/screenshots/review-history/review-updated-history.png
new file mode 100644
index 000000000..b5977f8c5
Binary files /dev/null and b/docs/public/screenshots/review-history/review-updated-history.png differ
diff --git a/docs/public/screenshots/review-history/review-updated-settings.png b/docs/public/screenshots/review-history/review-updated-settings.png
new file mode 100644
index 000000000..d9112a213
Binary files /dev/null and b/docs/public/screenshots/review-history/review-updated-settings.png differ
diff --git a/docs/public/screenshots/review-history/review-updated-single-gutter.png b/docs/public/screenshots/review-history/review-updated-single-gutter.png
new file mode 100644
index 000000000..65e914584
Binary files /dev/null and b/docs/public/screenshots/review-history/review-updated-single-gutter.png differ
diff --git a/docs/public/screenshots/review-history/review-updated-turn-summary.png b/docs/public/screenshots/review-history/review-updated-turn-summary.png
new file mode 100644
index 000000000..f92c90c70
Binary files /dev/null and b/docs/public/screenshots/review-history/review-updated-turn-summary.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 b7f1abba8..6ebbd2042 100644
--- a/docs/spec/03-runtime/06-host-rpc-protocol.md
+++ b/docs/spec/03-runtime/06-host-rpc-protocol.md
@@ -1533,11 +1533,16 @@ automatically replayed. See the Host file admission ADR for lifecycle and limits
## Round review reader
- `review.turns({sessionId, before?, limit?})` returns `turns` (newest user round
- first, each with `id`, `userMessageId`, `createdAt`, `title`, `changeCount`) and
+ first, each with `id`, `userMessageId`, `createdAt`, `title`, `changeCount`,
+ `additions`, `deletions`) and
optional `nextBefore`. Only rounds with valid successful Write/Edit review
evidence are listed, including approved targets outside the workspace.
Source `details.root` is preserved; workspace-relative and non-workspace
absolute paths retain distinct identities. Limit is bounded to 100; title is a short excerpt.
+ Added/deleted totals sum deduplicated successful operation evidence, not a net
+ diff. Originally truncated/binary records or unsafe totals yield null for both
+ counts. Transport-only hunk trimming does not discard known counts. Older
+ Hosts may omit these additive fields; consumers show unknown.
- `review.changes({sessionId, turnId?, snapshotId?, offset?, limit?})` returns
`turnId`, `changes: [{message, root?}]`, and optional `nextOffset`. Without a
selector it resolves the latest modified user round; a snapshot selector locates
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index d0749ff20..b16144323 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -4630,8 +4630,11 @@ menu with 1/3/5 (first-use default 3); the choice is profile-wide, remembered
across sessions, panel reopening and application restarts. Invalid or missing
preferences use 3, and unavailable storage never blocks the current selection.
No context selector is shown in the main toolbar.
-Toggle checks appear on the right. History options show only date and time in
-a compact selector with reserved arrow space. File headings have no permanent
+Toggle checks appear on the right. History options show date/time on the left
+and Host-recorded added/deleted line totals on the right, before the check.
+Totals count each successful native operation once, including delegated evidence,
+and do not claim a net diff. Binary, originally truncated or missing counts show
+unknown instead of invented zeros. The selector reserves arrow space. File headings have no permanent
button fill or border; execution roots are not rendered as extra diff rows.
A separate file ellipsis offers Open internally (disabled without the loaded
File Manager view; never auto-enables it), Open externally (OS default app),
@@ -4654,14 +4657,21 @@ blue). Only the first option's upper and last option's lower corners are rounded
interior edges are square, including when an interior row is selected or hovered.
A single option has all four outer corners. The scope trigger is 24px high; the
round field stays 28px high. Both vertically center their text and arrow. Round
-labels show date/time only with reserved arrow space. Native keyboard selection,
+labels retain date/time and recorded counts with reserved arrow space. Native keyboard selection,
Escape dismissal and focus remain browser-owned. Shared primitives and the AI
Command shell selector are unchanged.
Only file action menus opt into compact density. Recorded operations have no
numbered title or dividing rule. One footer per file copies all its recorded
hunks or requests a Host-preflighted file rollback; chat's inline actions remain
unchanged. The copied sequence is not represented as a net diff.
-Diff rows show old/new line numbers, and Word wrap toggles wrapping without
+Review headings and turn-summary file rows share compact 14px file-type glyphs
+(Markdown, JSON, Python, code and document), while status stays in accessible
+labels. Both Review ellipsis menus anchor to the trigger right edge, 4px below;
+when space is insufficient they flip above and clamp within the viewport.
+Pointer position within a button cannot move the menu. They remain body portals,
+and ordinary right-click menus retain pointer placement.
+Diff rows have one line-number gutter: deletions use old coordinates, additions
+and context use new coordinates; EOF markers have no number. Word wrap toggles wrapping without
introducing nested vertical scrolling. Unsupported
historical context has an explicit explanation and retains recorded evidence.
Remote Review retains its existing presentation. Chat inline review rows retain
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 90a1905f2..7116edc5c 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -19465,10 +19465,15 @@ Scenario: E2E-REVIEW-ROUNDS (local desktop, implemented)
`apps/desktop/test/review-preferences.test.mjs`.
- Expected: latest skips no-edit rounds; delegates belong to their original user
round; all file records are accessible; old/new numbers and bounded immutable context
- agree; no full after-image is cached; only the outer review scrolls; headers stick without toolbar overlap in
+ agree; one gutter uses old numbers for deletions and new numbers otherwise;
+ file-type glyphs match between Review and turn summaries; both ellipsis menus
+ retain trigger-relative placement across click points and fit narrow windows;
+ no full after-image is cached; only the outer review scrolls; headers stick without toolbar overlap in
normal/narrow layouts; copy and conflict protection survive; history restores.
Toggle checks trail labels, summary dots have no circle, history options contain
- only date/time and fit a compact arrow-safe field, file headers have no idle
+ 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.
+ 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
current file and session to external open. The third action, Open folder,
@@ -19485,7 +19490,7 @@ Scenario: E2E-REVIEW-ROUNDS (local desktop, implemented)
interior edges are square, and a single row has all four corners. Verify native
ArrowUp/ArrowDown, Enter, Escape/focus retention and close-after-selection;
the scope trigger is 24px high, the round field stays 28px high, and both
- vertically center their text and arrow. Round labels show only date/time with
+ vertically center their text and arrow. Round labels show date/time and recorded totals with
reserved trigger-arrow space.
The long-file fixture has 3100 lines with local edits: unchanged head/tail do
not consume the LCS matrix budget, while original hunk coordinates, 1/3/5-line
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 6d11f59fe..233c78f42 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -2154,6 +2154,8 @@ sklm: {
"rollingBack": "Rollback…",
"rolledBack": "Rollback",
historyTitle: "Conversation round",
+ unknownTotals: "Zeilenzahlen unbekannt",
+ recordedTotals: "Erfasste hinzugefügte/gelöschte Zeilen dieser Runde, keine Nettodifferenz",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index 9a967b084..afa20fecf 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -2174,6 +2174,8 @@ sklm: {
rollingBack: "Rolling back…",
rolledBack: "Rolled back",
historyTitle: "Conversation round",
+ unknownTotals: "Line counts unknown",
+ recordedTotals: "Recorded additions/deletions across this round’s operations, not a net diff",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index 74b7405ff..ba2dc304d 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -2154,6 +2154,8 @@ sklm: {
"rollingBack": "Revertir…",
"rolledBack": "Revertir",
historyTitle: "Conversation round",
+ unknownTotals: "Recuento desconocido",
+ recordedTotals: "Líneas añadidas/eliminadas registradas en esta ronda, no diferencia neta",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index e2fbdc3e8..37ed6dd29 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -2154,6 +2154,8 @@ sklm: {
"rollingBack": "Restauration…",
"rolledBack": "Restauration",
historyTitle: "Conversation round",
+ unknownTotals: "Nombre de lignes inconnu",
+ recordedTotals: "Ajouts/suppressions enregistrés pour ce tour, pas une différence nette",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index be945a2f5..e56d06805 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -2170,6 +2170,8 @@ sklm: {
rollingBack: "되돌리는 중…",
rolledBack: "되돌림",
historyTitle: "Conversation round",
+ unknownTotals: "줄 수 알 수 없음",
+ recordedTotals: "이 라운드에 기록된 작업의 추가/삭제 줄 합계이며 순변경은 아닙니다",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 39ca01554..1eee2c058 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -2120,6 +2120,8 @@ export const ptBR = {
rollingBack: "Revertendo…",
rolledBack: "Revertida",
historyTitle: "Conversation round",
+ unknownTotals: "Contagem desconhecida",
+ recordedTotals: "Adições/exclusões registradas nesta rodada, não a diferença líquida",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index 3c00b7dd4..3561d17bd 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -2164,6 +2164,8 @@ sklm: {
rollingBack: "Geri alınıyor…",
rolledBack: "Geri alındı",
historyTitle: "Conversation round",
+ unknownTotals: "Satır sayısı bilinmiyor",
+ recordedTotals: "Bu turda kaydedilen eklenen/silinen satırlar; net fark değildir",
loadingHistory: "Loading review history…",
historyError: "Could not load review history. Retry.",
retryHistory: "Retry",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index b00f3fd54..66317bc60 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -2149,6 +2149,8 @@ sklm: {
rollingBack: "正在回退…",
rolledBack: "已回退",
historyTitle: "对话轮次",
+ unknownTotals: "行数未知",
+ recordedTotals: "本轮已记录操作的累计新增/删除行数,非净差",
loadingHistory: "正在读取审阅记录…",
historyError: "审阅记录读取失败,请重试。",
retryHistory: "重试",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index a66e78612..4a27aa2e1 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -2149,6 +2149,8 @@ sklm: {
rollingBack: "正在回退…",
rolledBack: "已回退",
historyTitle: "对话轮次",
+ unknownTotals: "行數未知",
+ recordedTotals: "本輪已記錄操作的累計新增/刪除行數,非淨差",
loadingHistory: "正在读取审阅记录…",
historyError: "审阅记录读取失败,请重试。",
retryHistory: "重试",
diff --git a/packages/shared/src/types/workpanel.ts b/packages/shared/src/types/workpanel.ts
index 98ec7dcc4..cb3ce6cd5 100644
--- a/packages/shared/src/types/workpanel.ts
+++ b/packages/shared/src/types/workpanel.ts
@@ -50,6 +50,9 @@ export type ReviewTurn = {
createdAt: string;
title: string;
changeCount: number;
+ /** Deduplicated recorded operation totals, not a net diff; null/absent means unknown. */
+ additions?: number | null;
+ deletions?: number | null;
};
export type ReviewTurnsPage = { turns: ReviewTurn[]; nextBefore?: number };
export type ReviewHistoryChange = { message: UiMessage; root?: string };
diff --git a/scripts/e2e/review-history.tsx b/scripts/e2e/review-history.tsx
index f52db59a3..65fe9b91d 100644
--- a/scripts/e2e/review-history.tsx
+++ b/scripts/e2e/review-history.tsx
@@ -121,10 +121,36 @@ window.reviewProbe = async () => {
assert(settingsStyle.borderTopWidth === "0px", "Settings dots have no circular border");
assert(getComputedStyle(headers()[0]).backgroundColor === "rgba(0, 0, 0, 0)", "File buttons have no permanent fill");
checks.push("latest-skips-no-edit-round");
+ const assertAnchored = (button: HTMLElement) => {
+ const menu = document.querySelector<HTMLElement>('.context-menu.is-open')!;
+ const box = menu.getBoundingClientRect(), anchor = button.getBoundingClientRect();
+ assert(Math.abs(box.right - Math.min(anchor.right, innerWidth - 8)) <= 2, 'Menu right edge follows the trigger, not pointer position');
+ assert(Math.abs(box.top - (anchor.bottom + 4)) <= 2 || box.bottom <= anchor.top - 2, 'Menu opens below its trigger or flips above');
+ assert(box.left >= 7 && box.top >= 7 && box.bottom <= innerHeight - 7, 'Whole root menu stays inside viewport');
+ assert(document.elementFromPoint(box.left + box.width / 2, box.top + 12)?.closest('.context-menu'), 'Root menu is not obscured');
+ };
const fileMenu = async (index = 0) => {
document.querySelectorAll<HTMLButtonElement>('.review-file-menu-button')[index].click();
- await until(() => !!document.querySelector('[data-context-menu-item="review-open-external"]'), "File menu opens");
+ await until(() => !!document.querySelector('.context-menu.is-open [data-context-menu-item="review-open-external"]'), "File menu opens");
+ assertAnchored(document.querySelectorAll<HTMLElement>('.review-file-menu-button')[index]);
};
+ // The same button must not move its menu with different pointer coordinates.
+ for (const selector of ['.review-file-menu-button', '.review-settings-button']) {
+ let previous: { left: number; top: number } | undefined;
+ for (const fraction of [0.2, 0.8]) {
+ const trigger = document.querySelector<HTMLElement>(selector)!;
+ const anchor = trigger.getBoundingClientRect();
+ trigger.dispatchEvent(new MouseEvent('click', { bubbles: true, clientX: anchor.left + anchor.width * fraction, clientY: anchor.top + 3 }));
+ await until(() => !!document.querySelector('.context-menu.is-open'), 'Anchored menu opens at either pointer position');
+ assertAnchored(trigger);
+ const { left, top } = document.querySelector('.context-menu')!.getBoundingClientRect();
+ if (previous) assert(Math.abs(previous.left - left) < 1 && Math.abs(previous.top - top) < 1, 'Pointer offsets cannot move a review menu');
+ previous = { left, top };
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
+ await until(() => !document.querySelector('.context-menu'), 'Escape dismisses the anchored menu');
+ }
+ }
+ checks.push('review-menu-stable-trigger-anchoring');
await fileMenu();
assert(document.querySelector<HTMLButtonElement>('[data-context-menu-item="review-open-internal"]')!.disabled, "Missing file manager disables internal open");
assert(headers()[0].getAttribute('aria-expanded') === 'false', "Menu does not expand the file");
@@ -154,6 +180,9 @@ window.reviewProbe = async () => {
await mode(true);
await until(() => !!select('对话轮次'), "History adds its own row");
const roundSelect = select("对话轮次");
+ const totals = [...roundSelect.options].map(option => [option.value, option.querySelector('.review-turn-counts')?.textContent]);
+ assert(totals.some(([id, text]) => id === seed.latest && text === '+1 −0'), 'Latest history option shows actual recorded +1/-0');
+ assert(totals.some(([id, text]) => id === seed.round && text === '+7 −3'), 'Older option totals include parent and delegate edits only once');
assert(roundSelect.getBoundingClientRect().height <= 30, "History selector stays compact");
assert(parseFloat(getComputedStyle(roundSelect).columnGap) >= 10, 'Native trigger reserves space before its arrow');
for (const count of [1, 3]) {
@@ -190,7 +219,12 @@ window.reviewProbe = async () => {
assert(!document.querySelector('.review-history-file-body')!.textContent?.includes('修改记录'), "No per-operation title");
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");
- assert(document.querySelectorAll(".review-line-number").length > 0, "Old and new line numbers render");
+ 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');
+ 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');
+ }
+ assert(headers().every(header => header.querySelector('.review-file-type svg')), 'Each review heading has a file-type icon after its disclosure');
await contextLines(5);
await until(() => document.querySelector('.review-change-diff')?.textContent?.includes("line_025") === true, "5-line context is loaded from bounded history");
assert(!document.querySelector('.review-change-diff')?.textContent?.includes("line_001"), "No full-file context is rendered");
@@ -211,6 +245,19 @@ window.reviewProbe = async () => {
assert(scroller().getBoundingClientRect().width <= 420, "Narrow viewport applied");
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();
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
+ await until(() => !document.querySelector('.context-menu'), 'Narrow file menu closes');
+ document.querySelector<HTMLButtonElement>('.review-settings-button')!.click();
+ await until(() => !!document.querySelector('.context-menu.is-open'), 'Narrow settings menu opens');
+ assertAnchored(document.querySelector<HTMLElement>('.review-settings-button')!);
+ document.querySelector('[data-context-menu-item="review-context"]')!.dispatchEvent(new MouseEvent('mouseover', { bubbles: true }));
+ await until(() => document.querySelectorAll('[data-context-menu-submenu-item]').length === 3, 'Narrow context submenu opens');
+ const sub = document.querySelector<HTMLElement>('.context-menu-submenu.is-open')!.getBoundingClientRect();
+ assert(sub.left >= 7 && sub.right <= innerWidth - 7, 'Narrow secondary menu stays visible');
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })); await frame();
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
+ await until(() => !document.querySelector('.context-menu'), 'Narrow settings menu closes');
await action("screenshot", "review-narrow.png");
checks.push("single-outer-scroll-normal-narrow-sticky-uncovered");
await action("resize", 920); scroller().scrollTop = 0; await frame();