Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 3 additions & 28 deletions src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { FilesPane } from "./components/panes/FilesPane";
import { PaneDivider } from "./components/panes/PaneDivider";
import { useHunkSessionBridge } from "./hooks/useHunkSessionBridge";
import { useMenuController } from "./hooks/useMenuController";
import { getSelectedAnnotations } from "./lib/agentAnnotations";
import { buildAppMenus } from "./lib/appMenus";
import { buildFileListEntry } from "./lib/files";
import { buildHunkCursors, findNextHunkCursor } from "./lib/hunks";
Expand Down Expand Up @@ -94,7 +93,6 @@ function AppShell({
const [filesPaneWidth, setFilesPaneWidth] = useState(34);
const [resizeDragOriginX, setResizeDragOriginX] = useState<number | null>(null);
const [resizeStartWidth, setResizeStartWidth] = useState<number | null>(null);
const [dismissedAgentNoteIds, setDismissedAgentNoteIds] = useState<string[]>([]);
const [selectedFileId, setSelectedFileId] = useState(bootstrap.changeset.files[0]?.id ?? "");
const [selectedHunkIndex, setSelectedHunkIndex] = useState(0);
const deferredFilter = useDeferredValue(filter);
Expand All @@ -109,7 +107,6 @@ function AppShell({
}, []);

const openAgentNotes = useCallback(() => {
setDismissedAgentNoteIds([]);
setShowAgentNotes(true);
}, []);

Expand Down Expand Up @@ -176,8 +173,6 @@ function AppShell({
(responsiveLayout.showFilesPane || (forceSidebarOpen && canForceShowFilesPane));
const centerWidth = bodyWidth;
const resolvedLayout = responsiveLayout.layout;
const currentHunk = selectedFile?.metadata.hunks[selectedHunkIndex];
const activeAnnotations = getSelectedAnnotations(selectedFile, currentHunk);
const availableCenterWidth = showFilesPane
? Math.max(0, centerWidth - DIVIDER_WIDTH)
: Math.max(0, centerWidth);
Expand Down Expand Up @@ -247,11 +242,6 @@ function AppShell({
filesScrollRef.current?.scrollChildIntoView(fileRowId(selectedFile.id));
}, [selectedFile]);

useEffect(() => {
// Dismissed notes are hunk-local, so reset them when the review focus moves.
setDismissedAgentNoteIds([]);
}, [selectedFile?.id, selectedHunkIndex]);

/** Move the review focus across hunks in stream order. */
const moveHunk = (delta: number) => {
const nextCursor = findNextHunkCursor(hunkCursors, selectedFile?.id, selectedHunkIndex, delta);
Expand Down Expand Up @@ -287,20 +277,9 @@ function AppShell({
jumpToFile(nextFile.id);
};

/** Toggle the note layer while keeping dismissals scoped to the visible hunk. */
/** Toggle the global agent note layer on or off. */
const toggleAgentNotes = () => {
if (showAgentNotes) {
setShowAgentNotes(false);
setDismissedAgentNoteIds([]);
return;
}

openAgentNotes();
};

/** Hide one visible note card until the selection changes. */
const dismissAgentNote = (noteId: string) => {
setDismissedAgentNoteIds((current) => [...current, noteId]);
setShowAgentNotes((current) => !current);
};

/** Toggle line-number gutters without changing the diff content itself. */
Expand Down Expand Up @@ -337,10 +316,9 @@ function AppShell({
setShowHunkHeaders((current) => !current);
};

/** Jump to the annotated hunk before opening the note layer. */
/** Jump to an annotated hunk without changing the global note visibility toggle. */
const openAgentNotesAtHunk = (fileId: string, hunkIndex: number) => {
jumpToFile(fileId, hunkIndex);
openAgentNotes();
};

/** Leave the app through the shell-owned shutdown path. */
Expand Down Expand Up @@ -784,9 +762,7 @@ function AppShell({
) : null}

<DiffPane
activeAnnotations={activeAnnotations}
diffContentWidth={diffContentWidth}
dismissedAgentNoteIds={dismissedAgentNoteIds}
files={filteredFiles}
pagerMode={pagerMode}
headerLabelWidth={diffHeaderLabelWidth}
Expand All @@ -802,7 +778,6 @@ function AppShell({
wrapLines={wrapLines}
theme={activeTheme}
width={diffPaneWidth}
onDismissAgentNote={dismissAgentNote}
onOpenAgentNotesAtHunk={openAgentNotesAtHunk}
onSelectFile={jumpToFile}
/>
Expand Down
48 changes: 18 additions & 30 deletions src/ui/components/panes/DiffPane.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ScrollBoxRenderable } from "@opentui/core";
import { useCallback, useEffect, useLayoutEffect, useMemo, useState, type RefObject } from "react";
import type { AgentAnnotation, DiffFile, LayoutMode } from "../../../core/types";
import type { DiffFile, LayoutMode } from "../../../core/types";
import type { VisibleAgentNote } from "../../lib/agentAnnotations";
import { measureDiffSectionMetrics } from "../../lib/sectionHeights";
import { diffHunkId, diffSectionId } from "../../lib/ids";
Expand All @@ -12,9 +12,7 @@ const EMPTY_VISIBLE_AGENT_NOTES: VisibleAgentNote[] = [];

/** Render the main multi-file review stream. */
export function DiffPane({
activeAnnotations,
diffContentWidth,
dismissedAgentNoteIds,
files,
headerLabelWidth,
headerStatsWidth,
Expand All @@ -30,13 +28,10 @@ export function DiffPane({
wrapLines,
theme,
width,
onDismissAgentNote,
onOpenAgentNotesAtHunk,
onSelectFile,
}: {
activeAnnotations: AgentAnnotation[];
diffContentWidth: number;
dismissedAgentNoteIds: string[];
files: DiffFile[];
headerLabelWidth: number;
headerStatsWidth: number;
Expand All @@ -52,7 +47,6 @@ export function DiffPane({
wrapLines: boolean;
theme: AppTheme;
width: number;
onDismissAgentNote: (id: string) => void;
onOpenAgentNotesAtHunk: (fileId: string, hunkIndex: number) => void;
onSelectFile: (fileId: string) => void;
}) {
Expand Down Expand Up @@ -100,25 +94,27 @@ export function DiffPane({
const visibleAgentNotesByFile = useMemo(() => {
const next = new Map<string, VisibleAgentNote[]>();

if (!showAgentNotes || !selectedFileId) {
if (!showAgentNotes) {
return next;
}

const dismissedIdSet = new Set(dismissedAgentNoteIds);
const visibleNotes = activeAnnotations
.map((annotation, index) => ({
id: `annotation:${selectedFileId}:${selectedHunkIndex}:${index}`,
annotation,
}))
.filter((note) => !dismissedIdSet.has(note.id));

// Notes only render for the currently selected file/hunk so they stay spatially anchored.
if (visibleNotes.length > 0) {
next.set(selectedFileId, visibleNotes);
}
files.forEach((file) => {
const annotations = file.agent?.annotations ?? [];
if (annotations.length === 0) {
return;
}

next.set(
file.id,
annotations.map((annotation, index) => ({
id: `annotation:${file.id}:${annotation.id ?? index}`,
annotation,
})),
);
});

return next;
}, [activeAnnotations, dismissedAgentNoteIds, selectedFileId, selectedHunkIndex, showAgentNotes]);
}, [files, showAgentNotes]);

// Keep exact row rendering for wrapped lines and visible notes; otherwise reserve
// offscreen section height and only materialize rows near the viewport.
Expand Down Expand Up @@ -292,14 +288,7 @@ export function DiffPane({
verticalScrollbarOptions={{ visible: false }}
horizontalScrollbarOptions={{ visible: false }}
>
<box
style={{
width: "100%",
flexDirection: "column",
position: "relative",
overflow: "visible",
}}
>
<box style={{ width: "100%", flexDirection: "column", overflow: "visible" }}>
{files.map((file, index) => {
const shouldRenderSection = visibleWindowedFileIds?.has(file.id) ?? true;
const shouldPrefetchVisibleHighlight =
Expand Down Expand Up @@ -334,7 +323,6 @@ export function DiffPane({
visibleAgentNotes={
visibleAgentNotesByFile.get(file.id) ?? EMPTY_VISIBLE_AGENT_NOTES
}
onDismissAgentNote={onDismissAgentNote}
onOpenAgentNotesAtHunk={(hunkIndex) => onOpenAgentNotesAtHunk(file.id, hunkIndex)}
onSelect={() => onSelectFile(file.id)}
/>
Expand Down
3 changes: 0 additions & 3 deletions src/ui/components/panes/DiffSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface DiffSectionProps {
theme: AppTheme;
visibleAgentNotes: VisibleAgentNote[];
viewWidth: number;
onDismissAgentNote: (id: string) => void;
onOpenAgentNotesAtHunk: (hunkIndex: number) => void;
onSelect: () => void;
}
Expand All @@ -47,7 +46,6 @@ function DiffSectionComponent({
theme,
visibleAgentNotes,
viewWidth,
onDismissAgentNote,
onOpenAgentNotesAtHunk,
onSelect,
}: DiffSectionProps) {
Expand Down Expand Up @@ -117,7 +115,6 @@ function DiffSectionComponent({
width={viewWidth}
annotatedHunkIndices={annotatedHunkIndices}
visibleAgentNotes={visibleAgentNotes}
onDismissAgentNote={onDismissAgentNote}
onOpenAgentNotesAtHunk={onOpenAgentNotesAtHunk}
onHighlightReady={onHighlightReady}
selectedHunkIndex={selectedHunkIndex}
Expand Down
10 changes: 2 additions & 8 deletions src/ui/diff/PierreDiffView.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from "react";
import type { DiffFile, LayoutMode } from "../../core/types";
import { AgentInlineNote, AgentInlineNoteGuideCap } from "../components/panes/AgentInlineNote";
import { type VisibleAgentNote } from "../lib/agentAnnotations";
import type { VisibleAgentNote } from "../lib/agentAnnotations";
import type { AppTheme } from "../themes";
import { buildSplitRows, buildStackRows } from "./pierre";
import { buildReviewRenderPlan } from "./reviewRenderPlan";
Expand All @@ -16,7 +16,6 @@ export function PierreDiffView({
annotatedHunkIndices = EMPTY_ANNOTATED_HUNK_INDICES,
file,
layout,
onDismissAgentNote,
onOpenAgentNotesAtHunk,
onHighlightReady,
showLineNumbers = true,
Expand All @@ -32,7 +31,6 @@ export function PierreDiffView({
annotatedHunkIndices?: Set<number>;
file: DiffFile | undefined;
layout: Exclude<LayoutMode, "auto">;
onDismissAgentNote?: (id: string) => void;
onOpenAgentNotesAtHunk?: (hunkIndex: number) => void;
onHighlightReady?: () => void;
showLineNumbers?: boolean;
Expand Down Expand Up @@ -67,12 +65,11 @@ export function PierreDiffView({
? buildReviewRenderPlan({
fileId: file.id,
rows,
selectedHunkIndex,
showHunkHeaders,
visibleAgentNotes,
})
: [],
[file, rows, selectedHunkIndex, showHunkHeaders, visibleAgentNotes],
[file, rows, showHunkHeaders, visibleAgentNotes],
);
const lineNumberDigits = useMemo(() => String(file ? findMaxLineNumber(file) : 1).length, [file]);

Expand Down Expand Up @@ -106,9 +103,6 @@ export function PierreDiffView({
noteIndex={plannedRow.noteIndex}
theme={theme}
width={width}
onClose={
onDismissAgentNote ? () => onDismissAgentNote(plannedRow.annotationId) : undefined
}
/>
);
}
Expand Down
Loading
Loading