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
3 changes: 2 additions & 1 deletion src/components/RightSidebar/CodeReview/HunkViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export const HunkViewer = React.memo<HunkViewerProps>(
{isRead ? "○" : "◉"}
</button>
<Tooltip align="right" position="top">
Mark as read ({formatKeybind(KEYBINDS.TOGGLE_HUNK_READ)})
Mark as read ({formatKeybind(KEYBINDS.TOGGLE_HUNK_READ)}) · Mark file (
{formatKeybind(KEYBINDS.MARK_FILE_READ)})
</Tooltip>
</TooltipWrapper>
)}
Expand Down
32 changes: 32 additions & 0 deletions src/components/RightSidebar/CodeReview/ReviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,33 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
toggleExpandFnsRef.current.set(hunkId, toggleFn);
}, []);

// Handle marking all hunks in a file as read
const handleMarkFileAsRead = useCallback(
(hunkId: string) => {
// Find the hunk to determine its file path
const hunk = hunks.find((h) => h.id === hunkId);
if (!hunk) return;

// Find all hunks in the same file
const fileHunkIds = hunks.filter((h) => h.filePath === hunk.filePath).map((h) => h.id);

// Mark all hunks in the file as read
markAsRead(fileHunkIds);

// If marking the selected hunk's file as read and hunks will be filtered out, navigate
if (hunkId === selectedHunkId && !filters.showReadHunks) {
// Find the next visible hunk that's not in the same file
const currentFiltered = hunks.filter((h) => !isRead(h.id) && h.filePath !== hunk.filePath);
if (currentFiltered.length > 0) {
setSelectedHunkId(currentFiltered[0].id);
} else {
setSelectedHunkId(null);
}
}
},
[hunks, markAsRead, isRead, filters.showReadHunks, selectedHunkId]
);

// Calculate stats
const stats = useMemo(() => {
const total = hunks.length;
Expand Down Expand Up @@ -534,6 +561,10 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
// Mark selected hunk as unread
e.preventDefault();
handleMarkAsUnread(selectedHunkId);
} else if (matchesKeybind(e, KEYBINDS.MARK_FILE_READ)) {
// Mark entire file (all hunks) as read
e.preventDefault();
handleMarkFileAsRead(selectedHunkId);
} else if (matchesKeybind(e, KEYBINDS.TOGGLE_HUNK_COLLAPSE)) {
// Toggle expand/collapse state of selected hunk
e.preventDefault();
Expand All @@ -553,6 +584,7 @@ export const ReviewPanel: React.FC<ReviewPanelProps> = ({
handleToggleRead,
handleMarkAsRead,
handleMarkAsUnread,
handleMarkFileAsRead,
]);

// Global keyboard shortcuts (Ctrl+R / Cmd+R for refresh, Ctrl+F / Cmd+F for search)
Expand Down
3 changes: 3 additions & 0 deletions src/utils/ui/keybinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ export const KEYBINDS = {
/** Mark selected hunk as unread in Code Review panel */
MARK_HUNK_UNREAD: { key: "h" },

/** Mark entire file (all hunks) as read in Code Review panel */
MARK_FILE_READ: { key: "M", shift: true },

/** Toggle hunk expand/collapse in Code Review panel */
TOGGLE_HUNK_COLLAPSE: { key: " " },
} as const;