Skip to content

Add range selection functionality to repository page#843

Merged
nicotsx merged 6 commits into
nicotsx:mainfrom
Rajdave69:main
Jun 10, 2026
Merged

Add range selection functionality to repository page#843
nicotsx merged 6 commits into
nicotsx:mainfrom
Rajdave69:main

Conversation

@Rajdave69

@Rajdave69 Rajdave69 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

This is a small addition that lets a user shift click to select a range of snapshots, on the repositories' snapshot page.

Summary by CodeRabbit

  • New Features

    • Shift-click range selection for snapshot checkboxes: hold Shift between two clicks to select the contiguous range (range replaces current selection; select-all sets the last-selected anchor).
  • Bug Fixes

    • Checkbox clicks no longer trigger row click actions.
    • Clearing selection (bulk actions, re-tag, select-all toggles, clear button) resets range/anchor state.
  • Style

    • Minor text and duration formatting tweaks in snapshot rows and dialogs.

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f6a61a0-d739-4dd9-8f3a-80029646fc4b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds Shift‑click multi-range selection to the snapshots table by introducing lastSelectedId and handleSnapshotSelection. Checkbox clicks stop row click propagation and use the helper for single and contiguous-range selection. lastSelectedId is cleared on bulk delete success, re‑tag success, select‑all toggle clearing, and the clear-selection button.

Changes

Snapshot Selection Enhancement

Layer / File(s) Summary
Selection state and handler
app/client/components/snapshots-table.tsx
Adds lastSelectedId state and handleSnapshotSelection; select-all toggle now sets/clears the anchor and handleSnapshotSelection computes contiguous ranges from snapshots or toggles a single id.
Checkbox wiring & row click propagation
app/client/components/snapshots-table.tsx
Checkbox cell stops propagation and delegates clicks to handleSnapshotSelection; the Schedule link click handler now explicitly stops propagation with a typed React mouse event.
Selection reset paths
app/client/components/snapshots-table.tsx
Clears lastSelectedId along with selectedIds on successful bulk delete, successful re-tag, select-all clearing, and the X clear-selection button.
Minor UI formatting and dialog text wrapping
app/client/components/snapshots-table.tsx
Non-semantic JSX wrapping/line-break changes in the Duration cell and the bulk-delete/re-tag dialog descriptions.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Add range selection functionality to repository page' clearly and specifically summarizes the main change: adding Shift-click range selection for snapshots. It is concise, directly related to the changeset, and matches the primary objective documented in the PR description.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Rajdave69

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/client/components/snapshots-table.tsx`:
- Around line 105-135: handleSnapshotSelection currently ignores a shift-click
when lastSelectedId is stale (lastIndex === -1), causing the click to be lost;
modify handleSnapshotSelection so that when isShiftClick is true but either
lastIndex or currentIndex is -1 you fall back to the single-toggle behavior:
compute newSelected from selectedIds, toggle snapshotId presence, call
setSelectedIds(newSelected), and then always call setLastSelectedId(snapshotId);
reference handleSnapshotSelection, lastSelectedId, snapshots, selectedIds,
setSelectedIds, and setLastSelectedId when making the change.
- Around line 203-215: The Checkbox is receiving both onClick and
onCheckedChange so shift-click triggers range selection in onClick then a toggle
in onCheckedChange that removes the clicked snapshot; to fix, remove the
onCheckedChange prop from the Checkbox and move all selection logic
(single-toggle and shift-range behavior) into the onClick handler used now (keep
using handleSnapshotSelection(snapshot.short_id, e) from the click path and
update that function if needed to accept e and decide between range vs toggle),
ensuring aria-label stays unchanged and controlled checked prop (isSelected)
remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 83494167-8661-4b43-be9b-ebcfa896af93

📥 Commits

Reviewing files that changed from the base of the PR and between 82e027d and 13d2c85.

📒 Files selected for processing (1)
  • app/client/components/snapshots-table.tsx

Comment thread app/client/components/snapshots-table.tsx
Comment thread app/client/components/snapshots-table.tsx
@Rajdave69

Copy link
Copy Markdown
Contributor Author

@coderabbitai autofix

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

⚠️ Branch updated during autofix.

The branch was updated while autofix was in progress. Please try again.

@Rajdave69

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
app/client/components/snapshots-table.tsx (1)

105-144: Stale-anchor fallback looks correct; consider deduping the two identical toggle blocks.

The explicit else branch at 122-131 cleanly resolves the prior silent-no-op when lastSelectedId points at a snapshot that was filtered out or deleted, and the unconditional setLastSelectedId(snapshotId) at 143 keeps the anchor fresh in every path. One tidy-up opportunity: lines 122-131 and 134-141 are byte-identical toggle logic, so a small early-return restructure removes the duplication without changing behavior.

♻️ Optional dedup
 const handleSnapshotSelection = (snapshotId: string, event?: React.MouseEvent | React.KeyboardEvent) => {
 	const isShiftClick = event && "shiftKey" in event && event.shiftKey;

 	if (isShiftClick && lastSelectedId) {
-		// Range selection
 		const lastIndex = snapshots.findIndex((s) => s.short_id === lastSelectedId);
 		const currentIndex = snapshots.findIndex((s) => s.short_id === snapshotId);

 		if (lastIndex !== -1 && currentIndex !== -1) {
 			const start = Math.min(lastIndex, currentIndex);
 			const end = Math.max(lastIndex, currentIndex);
-			const rangeIds = new Set(snapshots.slice(start, end + 1).map((s) => s.short_id));
-
-			// Add selected range to existing selection
 			const newSelected = new Set(selectedIds);
-			rangeIds.forEach((id) => newSelected.add(id));
+			for (let i = start; i <= end; i++) newSelected.add(snapshots[i].short_id);
 			setSelectedIds(newSelected);
-		} else {
-			// Fallback to single-toggle when range selection fails due to stale lastSelectedId
-			const newSelected = new Set(selectedIds);
-			if (newSelected.has(snapshotId)) {
-				newSelected.delete(snapshotId);
-			} else {
-				newSelected.add(snapshotId);
-			}
-			setSelectedIds(newSelected);
+			setLastSelectedId(snapshotId);
+			return;
 		}
-	} else {
-		// Single selection toggle
-		const newSelected = new Set(selectedIds);
-		if (newSelected.has(snapshotId)) {
-			newSelected.delete(snapshotId);
-		} else {
-			newSelected.add(snapshotId);
-		}
-		setSelectedIds(newSelected);
 	}

+	// Single-toggle (default, and fallback when shift-range can't resolve the anchor).
+	const newSelected = new Set(selectedIds);
+	if (newSelected.has(snapshotId)) newSelected.delete(snapshotId);
+	else newSelected.add(snapshotId);
+	setSelectedIds(newSelected);
 	setLastSelectedId(snapshotId);
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/client/components/snapshots-table.tsx` around lines 105 - 144, The
duplicate toggle logic in handleSnapshotSelection can be removed by
restructuring to handle the range-selection case first and early-return;
specifically, inside handleSnapshotSelection use the isShiftClick &&
lastSelectedId branch to compute lastIndex/currentIndex and, if both are valid,
perform the range add-to-selectedIds (using snapshots, selectedIds, and
setSelectedIds) and then setLastSelectedId(snapshotId) and return, otherwise
fall through to a single shared toggle block that computes newSelected from
selectedIds, toggles snapshotId, calls setSelectedIds(newSelected) and then
setLastSelectedId(snapshotId); this preserves behavior while eliminating the
duplicated toggle code in the fallback and single-selection paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@app/client/components/snapshots-table.tsx`:
- Around line 105-144: The duplicate toggle logic in handleSnapshotSelection can
be removed by restructuring to handle the range-selection case first and
early-return; specifically, inside handleSnapshotSelection use the isShiftClick
&& lastSelectedId branch to compute lastIndex/currentIndex and, if both are
valid, perform the range add-to-selectedIds (using snapshots, selectedIds, and
setSelectedIds) and then setLastSelectedId(snapshotId) and return, otherwise
fall through to a single shared toggle block that computes newSelected from
selectedIds, toggles snapshotId, calls setSelectedIds(newSelected) and then
setLastSelectedId(snapshotId); this preserves behavior while eliminating the
duplicated toggle code in the fallback and single-selection paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 29279969-0859-4d0f-aa2b-cdf0b3c48348

📥 Commits

Reviewing files that changed from the base of the PR and between 13d2c85 and 4ae9a1f.

📒 Files selected for processing (1)
  • app/client/components/snapshots-table.tsx

@Rajdave69

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Rajdave69

Copy link
Copy Markdown
Contributor Author

@nicotsx Haven't gotten the chance to visually test it (looks like its harder to run on windows now compared to the last time I contributed), but it should be visually fine.

@nicotsx nicotsx left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM however I think the behavior is not complete.

Initial selection:
When nothing is selected yet and I shift click row 7, it should select all rows from 1 to 7.

Deselection:
When a range is selected (eg 1 to 7) if I shift click on 5, the range should change to 1-5. Currently it doesn't allow me to unselect

@Rajdave69 Rajdave69 marked this pull request as draft May 7, 2026 23:39
@Rajdave69

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Rajdave69 Rajdave69 requested a review from nicotsx June 3, 2026 22:40
@Rajdave69

Rajdave69 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

@nicotsx sorry for the delay, was pretty busy. Should be implemented now.

@Rajdave69 Rajdave69 marked this pull request as ready for review June 3, 2026 22:41
@nicotsx

nicotsx commented Jun 5, 2026

Copy link
Copy Markdown
Owner

Thanks for the update @Rajdave69

@nicotsx nicotsx merged commit e6a5d04 into nicotsx:main Jun 10, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants