Skip to content

feat: new selected list component for importing from git#7813

Open
prateek-bruno wants to merge 4 commits intousebruno:mainfrom
prateek-bruno:fix-import-collection
Open

feat: new selected list component for importing from git#7813
prateek-bruno wants to merge 4 commits intousebruno:mainfrom
prateek-bruno:fix-import-collection

Conversation

@prateek-bruno
Copy link
Copy Markdown

@prateek-bruno prateek-bruno commented Apr 21, 2026

Description

After:

Screen.Recording.2026-04-21.at.6.54.27.PM.mov

Before:

Screen.Recording.2026-04-21.at.6.53.15.PM.mov

Create a new component for selection list, use it for imports from collections. Used in git import, bulk import paths.

Will be used in github import later.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • New Features

    • Added a reusable selectable list with "Select All", per-item checkboxes, empty-state messaging, and configurable visible rows/spacing.
  • Style

    • Introduced visual and layout styling for the selection toolbar, list viewport, items, and empty state for a consistent UI.
  • Refactor

    • Replaced inline selection UIs with the new reusable component across sidebars.
  • Tests

    • Added end-to-end tests verifying viewport visibility and scrolling behavior in bulk import.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

Walkthrough

Adds a reusable SelectionList React component with its StyledWrapper, replaces two sidebar inline checkbox lists to use it, and introduces a Playwright test validating selection-list viewport visibility and scrolling.

Changes

Cohort / File(s) Summary
SelectionList component
packages/bruno-app/src/components/SelectionList/StyledWrapper.js, packages/bruno-app/src/components/SelectionList/index.js
Added StyledWrapper (styled-components) and SelectionList component. Implements toolbar with "Select All", per-item checkboxes, dynamic scrollable list height (computed from visibleRows, rowHeight, rowGap, listPadding), item rendering via getItemId/renderItemLabel, and empty-state handling.
Sidebar integrations
packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js, packages/bruno-app/src/components/Sidebar/CloneGitRespository/index.js
Replaced inline checkbox-list UIs with SelectionList. Wired select-all and per-item toggle callbacks to existing handlers; removed local all-selected booleans in bulk import component; tiny whitespace tweak.
Tests
tests/import/bulk-import/003-selection-list-viewport.spec.ts
Added Playwright spec that imports 10 collections, inspects which .selection-item rows are fully visible in the .selection-list viewport, asserts counts and specific visible items before and after scrolling.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • bijin-bruno
  • naman-bruno

Poem

Checkboxes line up, tidy and bright,
A styled wrapper keeps their spacing right.
Sidebars now sing a unified song,
Tests scroll the list to prove it along. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title references a 'selected list component' and 'importing from git', but the PR creates a reusable SelectionList component used across multiple import paths (git, bulk, and future GitHub imports). The title is partially related but understates the component's broader scope.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/bruno-app/src/components/SelectionList/index.js (1)

4-17: Add stable test IDs for the reusable checkboxes.

This component owns the new import-selection controls, so Playwright tests need stable selectors; make the prefix configurable because some screens render multiple lists.

Suggested fix
 const SelectionList = ({
   title,
   items,
   selectedItems,
   onSelectAll,
   onItemToggle,
   getItemId,
   renderItemLabel,
   visibleRows = 8,
   rowHeight = 30,
   rowGap = 2,
   listPadding = 8,
-  emptyMessage = 'No items found'
+  emptyMessage = 'No items found',
+  testIdPrefix = 'selection-list'
 }) => {
           <input
+            data-testid={`${testIdPrefix}-select-all`}
             type="checkbox"
             checked={allSelected}
             onChange={onSelectAll}
           />
                 <input
+                  data-testid={`${testIdPrefix}-item-${itemId}`}
                   type="checkbox"
                   checked={isSelected}
                   onChange={() => onItemToggle(itemId)}
                 />

As per coding guidelines, “Add data-testid to testable elements for Playwright.”

Also applies to: 29-34, 49-53

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-app/src/components/SelectionList/index.js` around lines 4 -
17, The SelectionList component should accept a configurable test id prefix
(e.g., prop name testIdPrefix) and then apply stable data-testid attributes to
the reusable checkbox elements: the master select-all checkbox (use something
like `${testIdPrefix}-select-all-checkbox`) and each item checkbox and label
(use `${testIdPrefix}-item-checkbox-${getItemId(item)}` and
`${testIdPrefix}-item-label-${getItemId(item)}`). Update the component props
list to include testIdPrefix (default to a sensible string), and add the
corresponding data-testid attributes on the elements used in
renderItemLabel/onItemToggle and the select-all control so Playwright can target
them reliably.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-app/src/components/SelectionList/index.js`:
- Line 18: The select-all boolean allSelected is currently based on array
lengths and can be true when selectedItems contains stale IDs; change its logic
in SelectionList to derive from actual item IDs by building a set of visible IDs
from items (e.g., items.map(i => i.id)) and then checking that every visible ID
is present in the selectedItems set (convert selectedItems to a Set for O(1)
lookups); ensure items.length === 0 yields false and account for missing id
fields defensively.

In `@packages/bruno-app/src/components/SelectionList/StyledWrapper.js`:
- Around line 44-56: The list currently inherits ul defaults and vertical
padding on .selection-item so getListHeight (used in max-height) undercounts
visible rows; make the list self-contained by resetting ul defaults on
.selection-list (e.g., list-style: none; margin: 0; padding: 0) and ensure each
row's height matches props.$rowHeight by removing vertical padding from
.selection-item and using either height: `${props.$rowHeight}px` or box-sizing
with explicit vertical padding accounted for in getListHeight; update references
in StyledWrapper to getListHeight, .selection-list, .selection-item,
props.$rowHeight and props.$listPadding accordingly.

In `@packages/bruno-app/src/components/Sidebar/CloneGitRespository/index.js`:
- Around line 346-355: The scanned collections are not being preselected because
selectedCollectionPaths stays empty after scan; update the place where scan
results are stored (where collectionPaths is assigned/updated) to also set
selectedCollectionPaths to the scanned collectionPaths so the SelectionList
(used with selectedCollectionPaths, getItemId, renderItemLabel) shows items
checked and enables the Open action immediately; ensure this update uses the
same state setter for selectedCollectionPaths as used by
handleSelectAllCollections/handleCollectionSelect so selection remains fully
controlled.

---

Nitpick comments:
In `@packages/bruno-app/src/components/SelectionList/index.js`:
- Around line 4-17: The SelectionList component should accept a configurable
test id prefix (e.g., prop name testIdPrefix) and then apply stable data-testid
attributes to the reusable checkbox elements: the master select-all checkbox
(use something like `${testIdPrefix}-select-all-checkbox`) and each item
checkbox and label (use `${testIdPrefix}-item-checkbox-${getItemId(item)}` and
`${testIdPrefix}-item-label-${getItemId(item)}`). Update the component props
list to include testIdPrefix (default to a sensible string), and add the
corresponding data-testid attributes on the elements used in
renderItemLabel/onItemToggle and the select-all control so Playwright can target
them reliably.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a6abb1d5-4487-42ca-96f9-5d6fe47b3fbe

📥 Commits

Reviewing files that changed from the base of the PR and between 9e92e6f and 99f95c8.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/SelectionList/StyledWrapper.js
  • packages/bruno-app/src/components/SelectionList/index.js
  • packages/bruno-app/src/components/Sidebar/BulkImportCollectionLocation/index.js
  • packages/bruno-app/src/components/Sidebar/CloneGitRespository/index.js

Comment thread packages/bruno-app/src/components/SelectionList/index.js
Comment thread packages/bruno-app/src/components/SelectionList/StyledWrapper.js
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/import/bulk-import/003-selection-list-viewport.spec.ts (1)

10-10: Use stable test IDs for the SelectionList DOM hooks.

This spec is coupled to styling classes (.selection-list, .selection-item). Please expose/use data-testid hooks on SelectionList and its rows so style refactors don’t break the e2e test.

As per coding guidelines, Add data-testid to testable elements for Playwright.

Also applies to: 64-64

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/import/bulk-import/003-selection-list-viewport.spec.ts` at line 10,
Test is fragile due to querying styling classes; update the SelectionList
component to expose stable data-testid attributes (e.g.,
data-testid="selection-list" on the root and data-testid="selection-item" on
each row) and change the spec to query those attributes instead of classes
(replace node.querySelectorAll('.selection-item') with
node.querySelectorAll('[data-testid="selection-item"]') and use
'[data-testid="selection-list"]' for the root). Ensure the component adds those
attributes in the render output for SelectionList and its row renderer so style
refactors won't break tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/import/bulk-import/003-selection-list-viewport.spec.ts`:
- Around line 36-42: The generated collection names and substring assertions are
not sort-safe; update the test data generation in
003-selection-list-viewport.spec.ts so names are zero-padded (e.g., Viewport
Collection 01..10) when creating files (the loop that builds
`filePath`/`fileContent`) and likewise in the later loop (lines ~67-81) so
sorting is stable, then change assertions against the
SelectionList/BulkImportCollectionLocation to assert the exact padded string (or
use a regex with word boundaries) instead of using toContain('Viewport
Collection 1') so "1" won't match "10"; reference `BulkImportCollectionLocation`
and `SelectionList` to locate where assertions need updating.
- Around line 77-82: The test's retry wrapper uses toPass() without an explicit
timeout; update the assertion block that calls toPass() (wrapping
getFullyVisibleRowNames(collectionList) and the expects) to pass a timeout
option of { timeout: 5000 } to toPass(), so the call becomes toPass({ timeout:
5000 }) and matches the codebase pattern for explicit retry timeouts.

---

Nitpick comments:
In `@tests/import/bulk-import/003-selection-list-viewport.spec.ts`:
- Line 10: Test is fragile due to querying styling classes; update the
SelectionList component to expose stable data-testid attributes (e.g.,
data-testid="selection-list" on the root and data-testid="selection-item" on
each row) and change the spec to query those attributes instead of classes
(replace node.querySelectorAll('.selection-item') with
node.querySelectorAll('[data-testid="selection-item"]') and use
'[data-testid="selection-list"]' for the root). Ensure the component adds those
attributes in the render output for SelectionList and its row renderer so style
refactors won't break tests.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 660960a4-1789-4ed9-84d8-9ae8711c3b0a

📥 Commits

Reviewing files that changed from the base of the PR and between 278d5cf and 3720a61.

📒 Files selected for processing (1)
  • tests/import/bulk-import/003-selection-list-viewport.spec.ts

Comment thread tests/import/bulk-import/003-selection-list-viewport.spec.ts Outdated
Comment thread tests/import/bulk-import/003-selection-list-viewport.spec.ts Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/import/bulk-import/003-selection-list-viewport.spec.ts (1)

24-86: LGTM — viewport spec reads cleanly. 🐰

Padded names, explicit toPass timeout, and test.afterEach cleanup are all in place. Nice follow-through on the earlier review rounds.

One tiny thought (take it or leave it): the bulk-import modal is left open when the test body ends, relying on closeAllCollections to clean up. If you ever hit flakes on subsequent tests added to this describe, consider dismissing the dialog explicitly (e.g., bulkImportModal.getByRole('button', { name: /cancel/i }).click()) before afterEach.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/import/bulk-import/003-selection-list-viewport.spec.ts` around lines 24
- 86, The test leaves the Bulk Import dialog open which may cause flakes;
explicitly dismiss the dialog before the test ends by clicking its cancel/close
button using the bulkImportModal handle (e.g., locate
bulkImportModal.getByRole('button', { name: /cancel|close|dismiss/i }) and click
it) so the modal is closed in-test instead of relying solely on
test.afterEach/closeAllCollections to clean up.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/import/bulk-import/003-selection-list-viewport.spec.ts`:
- Around line 24-86: The test leaves the Bulk Import dialog open which may cause
flakes; explicitly dismiss the dialog before the test ends by clicking its
cancel/close button using the bulkImportModal handle (e.g., locate
bulkImportModal.getByRole('button', { name: /cancel|close|dismiss/i }) and click
it) so the modal is closed in-test instead of relying solely on
test.afterEach/closeAllCollections to clean up.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b8729b99-6bd7-413f-a2ac-5e1cd21ce499

📥 Commits

Reviewing files that changed from the base of the PR and between 3720a61 and 1942ae1.

📒 Files selected for processing (1)
  • tests/import/bulk-import/003-selection-list-viewport.spec.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant